Injects a delay dependent on the last time we received a response or
if a fixed delay has been specified

@param transDelayMS             Fixed transaction delay (milliseconds)
@param lastTransactionTimestamp Timestamp of last transaction
429885
void waitBetweenFrames(int transDelayMS, long lastTransactionTimestamp) {

        // If a fixed delay has been set
        if (transDelayMS > 0) {
            ModbusUtil.sleep(transDelayMS);
        }
        else {
            // Make use we have a gap of 3.5 characters between adjacent requests
            // We have to do the calculations here because it is possible that the caller may have changed
            // the connection characteristics if they provided the connection instance
            int delay = getInterFrameDelay() / 1000;

            // How long since the last message we received
            long gapSinceLastMessage = (System.nanoTime() - lastTransactionTimestamp) / NS_IN_A_MS;
            if (delay > gapSinceLastMessage) {
                long sleepTime = delay - gapSinceLastMessage;

                ModbusUtil.sleep(sleepTime);

                if (logger.isDebugEnabled()) {
                    logger.debug("Waited between frames for {} ms", sleepTime);
                }
            }
        }
    }
293878
@Override
   public DelayedData getDelayed(String genericTag) {
      DelayedData d = delayedData.get(genericTag);
      return d == null ? dd : d;
   }
666309
@Override
	public void setTransactionTimeout(int seconds) throws TransactionManagementException {
		logger.entering(CLASSNAME, "setTransactionTimeout", seconds);
		logger.fine("do nothing");
		logger.exiting(CLASSNAME, "setTransactionTimeout");
	}
569042
private void registerSynchronization(TransactionImpl odmgTrans, Transaction transaction)
    {
        // todo only need for development
        if (odmgTrans == null || transaction == null)
        {
            log.error("One of the given parameters was null --> cannot do synchronization!" +
                    " omdg transaction was null: " + (odmgTrans == null) +
                    ", external transaction was null: " + (transaction == null));
            return;
        }

        int status = -1; // default status.
        try
        {
            status = transaction.getStatus();
            if (status != Status.STATUS_ACTIVE)
            {
                throw new OJBRuntimeException(
                        "Transaction synchronization failed - wrong status of external container tx: " +
                        getStatusString(status));
            }
        }
        catch (SystemException e)
        {
            throw new OJBRuntimeException("Can't read status of external tx", e);
        }

        try
        {
            //Sequence of the following method calls is significant
            // 1. register the synchronization with the ODMG notion of a transaction.
            transaction.registerSynchronization((J2EETransactionImpl) odmgTrans);
            // 2. mark the ODMG transaction as being in a JTA Transaction
            // Associate external transaction with the odmg transaction.
            txRepository.set(new TxBuffer(odmgTrans, transaction));
        }
        catch (Exception e)
        {
            log.error("Cannot associate PersistenceBroker with running Transaction", e);
            throw new OJBRuntimeException(
                    "Transaction synchronization failed - wrong status of external container tx", e);
        }
    }
714709
@Override
    public void commitPreparedTransaction(String xid) throws TransactionException, PersistenceException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "commitPreparedTransaction", xid);

        if (_manager != null)
        {
            try
            {
                PersistentTranId pid = new PersistentTranId(xid);
                _manager.commit(pid, false);
            } catch (ArrayIndexOutOfBoundsException e)
            {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    SibTr.debug(this, tc, "Invalid XID string", xid);
                throw new XidInvalidException(nls.getString("INVALID_XID_STRING_SIMS1010"));
            } catch (StringIndexOutOfBoundsException e)
            {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    SibTr.debug(this, tc, "Invalid XID string", xid);
                throw new XidInvalidException(nls.getString("INVALID_XID_STRING_SIMS1010"));
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "commitPreparedTransaction");
        return;
    }
531756
protected TwoPhaseCommitSinkFunction<IN, TXN, CONTEXT> setTransactionTimeout(long transactionTimeout) {
		checkArgument(transactionTimeout >= 0, "transactionTimeout must not be negative");
		this.transactionTimeout = transactionTimeout;
		return this;
	}
435760
public void setOriginatingTransactionId(byte[] t) {
        if (t != null && t.length != 4)
            throw new IllegalArgumentException("TransactionId leng must be 4 bytes, found: " + t.length);
        this.originatingTransactionId = t;

    }
1323985
@Override
    public void batchPrecommit(TransactionCommon currentTran)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "batchPrecommit", currentTran);
        try
        {
            persistCompletedPrefix(currentTran);
        } catch (SIResourceException e)
        {
            //FFDC
            FFDCFilter.processException(
                                        e,
                                        "com.ibm.ws.sib.processor.gd.GuaranteedTargetStream.batchPrecommit",
                                        "1:1911:1.110",
                                        this);

            SibTr.exception(tc, e);

            //TODO don't know what to do here - rethrow?!
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "batchPrecommit");
    }
785290
@Override
    public void commitChanges(SynchronizationBarrier barrier) throws JMSException
    {
    	checkNotClosed();
    	checkTransactionLock();
    	
    	if (!committables.isEmpty())
        {
    		long start = System.currentTimeMillis();
    		
    		Iterator<Committable> allCommitables = committables.iterator();
        	while (allCommitables.hasNext())
        	{
        		Committable committable = allCommitables.next();
        		committable.commitChanges(barrier);
        	}
        	
        	long end = System.currentTimeMillis();
        	notifyCommitTime(end-start);
        	
        	pendingChanges = false;
        }
    }
360239
public void setTransactionID(byte[] tranID) throws StunException {
		if (tranID == null || (tranID.length != TRANSACTION_ID_LENGTH && tranID.length != RFC3489_TRANSACTION_ID_LENGTH))
			throw new StunException(StunException.ILLEGAL_ARGUMENT, "Invalid transaction id length");

		int tranIDLength = tranID.length;
		this.transactionID = new byte[tranIDLength];
		System.arraycopy(tranID, 0, this.transactionID, 0, tranIDLength);
	}
236490
private void commitDeletes(DBTransaction dbTran, long timestamp) {
        Map<String, Set<ByteBuffer>> rowDeleteMap = CassandraTransaction.getRowDeletionMap(dbTran);
        if (rowDeleteMap.size() == 0) {
            return;
        }
        
        // Iterate through all ColumnFamilies
        for (String colFamName : rowDeleteMap.keySet()) {
            // Delete each row in this key set.
            Set<ByteBuffer> rowKeySet = rowDeleteMap.get(colFamName);
            for (ByteBuffer rowKey : rowKeySet) {
                removeRow(timestamp, rowKey, new ColumnPath(colFamName));
            }
        }
    }
913872
@Override
	public void updateTimestamp(final String columnLabel, final Timestamp x) throws SQLException {
		wrapped.updateTimestamp(columnLabel, x);
	}
14357
private void executeUpdatesSynchronous(DBTransaction transaction) {
        BatchStatement batchState = new BatchStatement(Type.UNLOGGED);
        batchState.addAll(getMutations(transaction));
        executeBatch(batchState);
    }
994552
public void processTimeout(TimeoutEvent timeoutEvent) {
				
		final SIPTransaction t;
		if (timeoutEvent.isServerTransaction()) {
			t = (SIPTransaction) timeoutEvent.getServerTransaction();
		}
		else {
			t = (SIPTransaction) timeoutEvent.getClientTransaction();
		}
		
		if (tracer.isInfoEnabled()) {
			tracer.info("Transaction "
						+ t.getTransactionId()
						+ " timer expired");			
		}
		
		TransactionWrapper tw = getTransactionWrapper(t);
		if (tw == null) {
			if (tracer.isInfoEnabled()) {
				tracer.info("Received timeout event for tx "+t.getTransactionId()+" with null app data, dropping...");
			}
			return;
		}
		
		final TimeoutEventWrapper tew;
		if (timeoutEvent.isServerTransaction()) {
			tew = new TimeoutEventWrapper(providerWrapper,(ServerTransaction)tw, timeoutEvent.getTimeout());
		}
		else {
			tew = new TimeoutEventWrapper(providerWrapper,(ClientTransaction)tw, timeoutEvent.getTimeout());
		}

        final Dialog d = t.getDialog();
		final DialogWrapper dw = getDialogWrapper(d);
		final FireableEventType eventType = eventIdCache.getTransactionTimeoutEventId(
				eventLookupFacility, dw != null);
		if (!eventIDFilter.filterEvent(eventType)) {
			Wrapper activity = tw.isActivity() ? tw : dw;			
			try {
				fireEvent(activity.getActivityHandle(), eventType, tew, activity.getEventFiringAddress(),DEFAULT_EVENT_FLAGS);
			}
			catch (UnrecognizedActivityHandleException e) {
				tracer.warning("Failed to fire event "+eventType+", the activity "+activity+" does not exists in the SLEE");			
			}
			catch (Throwable e) {
				tracer.severe("Failed to fire event",e);
			}
		}
		else {
			if (tracer.isFineEnabled()) {
				tracer.fine("Event "+eventType+" filtered.");
			}
		}
        if (d != null && dw != null && (d.getState() == null || d.getState() == DialogState.TERMINATED)) {
            // Issue 98: sip stack won't invoke processDialogTerminate when dialog creating tx times out
            processDialogTerminated(dw);
        }
	}
1113626
public int getTransactionTimeout() throws XAException
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "getTransactionTimeout");
      
      int timeout = 0;
            
      try
      {
         CommsByteBuffer request = getCommsByteBuffer();
         request.putInt(getTransactionId());
         
         CommsByteBuffer reply = jfapExchange(request, 
                                              JFapChannelConstants.SEG_XA_GETTXTIMEOUT, 
                                              JFapChannelConstants.PRIORITY_MEDIUM, 
                                              true);
      
         try
         {
            reply.checkXACommandCompletionStatus(JFapChannelConstants.SEG_XA_GETTXTIMEOUT_R, getConversation());
                              
            timeout = reply.getInt();
         }
         finally
         {
            if (reply != null) reply.release();
         }
      }
      catch (XAException xa)
      {
         // No FFDC Code needed
         // Simply re-throw...
         throw xa;
      }
      catch (Exception e)
      {
         FFDCFilter.processException(e, CLASS_NAME + ".getTransactionTimeout",
                                     CommsConstants.SIXARESOURCEPROXY_GETTXTIMEOUT_01, this);
         
         if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "Caught a comms problem:", e);
         throw new XAException(XAException.XAER_RMFAIL);
      }
         
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "getTransactionTimeout", ""+timeout);
      return timeout;
   }
612210
public FluoConfiguration setTransactionRollbackTime(long time, TimeUnit tu) {
    return setPositiveLong(TRANSACTION_ROLLBACK_TIME_PROP, tu.toMillis(time));
  }
854315
public boolean matchCompleteTransactionTask(long txnId, long timestamp) {
        if (!m_compTasks.isEmpty()) {
            long lowestTxnId = m_compTasks.firstKey();
            if (txnId == lowestTxnId) {
                Pair<CompleteTransactionTask, Boolean> pair = m_compTasks.get(lowestTxnId);
                return timestamp == pair.getFirst().getTimestamp();
            }
        }
        return false;
    }