@Override
	public SIPTransaction findTransaction(String transactionId, boolean isServer) {
		if(sipCache.inLocalMode() || replicationStrategy != ReplicationStrategy.EarlyDialog) {
			return super.findTransaction(transactionId,isServer);
		}
		final String txId = transactionId.toLowerCase();
		SIPTransaction sipTransaction = super.findTransaction(txId, isServer);
		if(sipTransaction == null && transactionFactory != null) {
			if(getStackLogger().isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
				getStackLogger().logDebug("local transaction " + txId + " server = " + isServer + " is null, checking in the distributed cache");
			}
			if(getStackLogger().isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
				getStackLogger().logDebug("sipStack " + this + " checking if the transaction " + txId + " server = " + isServer + " is present in the distributed cache");
			}	
			if(isServer) {
				// fetch the corresponding server transaction from the cache instance
				try {
					sipTransaction = sipCache.getServerTransaction(txId);
					if(sipTransaction != null) {
						if(getStackLogger().isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
							getStackLogger().logDebug("sipStack " + this + " transaction " + txId + " server = " + isServer + " is present in the distributed cache");
						}	
						SIPServerTransaction retval = serverTransactionTable.putIfAbsent(txId, (SIPServerTransaction) sipTransaction);
						if(retval != null) {
							sipTransaction = retval;
						}
					} else {
						if(getStackLogger().isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
							getStackLogger().logDebug("sipStack " + this + " transaction " + txId + " server = " + isServer + " is not present in the distributed cache");
						}	
					}
				} catch (SipCacheException e) {
					getStackLogger().logError("sipStack " + this + " problem getting transaction " + txId + " server = " + isServer + " from the distributed cache", e);
				}
			} else {
				// fetch the corresponding client transaction from the cache instance
				try {
					sipTransaction = sipCache.getClientTransaction(txId);
					if(sipTransaction != null) {
						if(getStackLogger().isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
							getStackLogger().logDebug("sipStack " + this + " transaction " + txId + " server = " + isServer + " is present in the distributed cache");
						}	
						SIPClientTransaction retval = clientTransactionTable.putIfAbsent(txId, (SIPClientTransaction) sipTransaction);
						if(retval != null) {
							sipTransaction = retval;							
						} else {
							// start the transaction timer only when the transaction has been added to the stack
							// to avoid leaks on retransmissions
							((MobicentsHASIPClientTransaction)sipTransaction).startTransactionTimerOnFailover();
						}
					} else {
						if(getStackLogger().isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
							getStackLogger().logDebug("sipStack " + this + " transaction " + txId + " server = " + isServer + " is not present in the distributed cache");
						}	
					}
				} catch (SipCacheException e) {
					getStackLogger().logError("sipStack " + this + " problem getting transaction " + txId + " server = " + isServer + " from the distributed cache", e);
				}
			}
		}
		return sipTransaction;
	}
@Override
	public SIPTransaction findTransaction(String transactionId, boolean isServer) {
		if(sipCache.inLocalMode() || replicationStrategy != ReplicationStrategy.EarlyDialog) {
			return super.findTransaction(transactionId,isServer);
		}
		final String txId = transactionId.toLowerCase();
		SIPTransaction sipTransaction = super.findTransaction(txId, isServer);
		if(sipTransaction == null && transactionFactory != null) {
			if(getStackLogger().isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
				getStackLogger().logDebug("local transaction " + txId + " server = " + isServer + " is null, checking in the distributed cache");
			}
			if(getStackLogger().isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
				getStackLogger().logDebug("sipStack " + this + " checking if the transaction " + txId + " server = " + isServer + " is present in the distributed cache");
			}	
			if(isServer) {
				
				try {
					sipTransaction = sipCache.getServerTransaction(txId);
					if(sipTransaction != null) {
						if(getStackLogger().isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
							getStackLogger().logDebug("sipStack " + this + " transaction " + txId + " server = " + isServer + " is present in the distributed cache");
						}	
						SIPServerTransaction retval = serverTransactionTable.putIfAbsent(txId, (SIPServerTransaction) sipTransaction);
						if(retval != null) {
							sipTransaction = retval;
						}
					} else {
						if(getStackLogger().isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
							getStackLogger().logDebug("sipStack " + this + " transaction " + txId + " server = " + isServer + " is not present in the distributed cache");
						}	
					}
				} catch (SipCacheException e) {
					getStackLogger().logError("sipStack " + this + " problem getting transaction " + txId + " server = " + isServer + " from the distributed cache", e);
				}
			} else {
				
				try {
					sipTransaction = sipCache.getClientTransaction(txId);
					if(sipTransaction != null) {
						if(getStackLogger().isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
							getStackLogger().logDebug("sipStack " + this + " transaction " + txId + " server = " + isServer + " is present in the distributed cache");
						}	
						SIPClientTransaction retval = clientTransactionTable.putIfAbsent(txId, (SIPClientTransaction) sipTransaction);
						if(retval != null) {
							sipTransaction = retval;							
						} else {
							
							
							((MobicentsHASIPClientTransaction)sipTransaction).startTransactionTimerOnFailover();
						}
					} else {
						if(getStackLogger().isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
							getStackLogger().logDebug("sipStack " + this + " transaction " + txId + " server = " + isServer + " is not present in the distributed cache");
						}	
					}
				} catch (SipCacheException e) {
					getStackLogger().logError("sipStack " + this + " problem getting transaction " + txId + " server = " + isServer + " from the distributed cache", e);
				}
			}
		}
		return sipTransaction;
	}
@ Override public SIPTransaction findTransaction ( String transactionId , boolean isServer ) { if ( sipCache . inLocalMode ( ) || replicationStrategy != ReplicationStrategy . EarlyDialog ) { return super . findTransaction ( transactionId , isServer ) ; } final String txId = transactionId . toLowerCase ( ) ; SIPTransaction sipTransaction = super . findTransaction ( txId , isServer ) ; if ( sipTransaction == null && transactionFactory != null ) { if ( getStackLogger ( ) . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { getStackLogger ( ) . logDebug ( "local transaction " + txId + " server = " + isServer + " is null, checking in the distributed cache" ) ; } if ( getStackLogger ( ) . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { getStackLogger ( ) . logDebug ( "sipStack " + this + " checking if the transaction " + txId + " server = " + isServer + " is present in the distributed cache" ) ; } if ( isServer ) { // fetch the corresponding server transaction from the cache instance try { sipTransaction = sipCache . getServerTransaction ( txId ) ; if ( sipTransaction != null ) { if ( getStackLogger ( ) . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { getStackLogger ( ) . logDebug ( "sipStack " + this + " transaction " + txId + " server = " + isServer + " is present in the distributed cache" ) ; } SIPServerTransaction retval = serverTransactionTable . putIfAbsent ( txId , ( SIPServerTransaction ) sipTransaction ) ; if ( retval != null ) { sipTransaction = retval ; } } else { if ( getStackLogger ( ) . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { getStackLogger ( ) . logDebug ( "sipStack " + this + " transaction " + txId + " server = " + isServer + " is not present in the distributed cache" ) ; } } } catch ( SipCacheException e ) { getStackLogger ( ) . logError ( "sipStack " + this + " problem getting transaction " + txId + " server = " + isServer + " from the distributed cache" , e ) ; } } else { // fetch the corresponding client transaction from the cache instance try { sipTransaction = sipCache . getClientTransaction ( txId ) ; if ( sipTransaction != null ) { if ( getStackLogger ( ) . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { getStackLogger ( ) . logDebug ( "sipStack " + this + " transaction " + txId + " server = " + isServer + " is present in the distributed cache" ) ; } SIPClientTransaction retval = clientTransactionTable . putIfAbsent ( txId , ( SIPClientTransaction ) sipTransaction ) ; if ( retval != null ) { sipTransaction = retval ; } else { // start the transaction timer only when the transaction has been added to the stack // to avoid leaks on retransmissions ( ( MobicentsHASIPClientTransaction ) sipTransaction ) . startTransactionTimerOnFailover ( ) ; } } else { if ( getStackLogger ( ) . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { getStackLogger ( ) . logDebug ( "sipStack " + this + " transaction " + txId + " server = " + isServer + " is not present in the distributed cache" ) ; } } } catch ( SipCacheException e ) { getStackLogger ( ) . logError ( "sipStack " + this + " problem getting transaction " + txId + " server = " + isServer + " from the distributed cache" , e ) ; } } } return sipTransaction ; }
/*
(non-Javadoc)
@see gov.nist.javax.sip.stack.SIPTransactionStack#findTransaction(java.lang.String, boolean)
/ * ( non - Javadoc )