/* (non-Javadoc)
@see com.ibm.ws.sib.processor.runtime.SIMPQueuedMessageControllable#getPreviousSequenceId()
188321
public long getPreviousSequenceId()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "getPreviousSequenceId");
    long previousSequenceID=0;
    try
    {
      SIMPMessage msg = getSIMPMessage();
      if(msg!=null)
      {
        previousSequenceID = msg.getMessage().getGuaranteedValueStartTick()-1;
      }
    }
    catch (SIResourceException e)
    {
      // No FFDC code needed
      SibTr.exception(tc, e);
    } 
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "getPreviousSequenceId", Long.valueOf(previousSequenceID));
    return previousSequenceID;
  }
242350
private static byte[] getQueueRowPrefix(byte[] queueIdWithinFlow) {
    byte[] bytes = new byte[queueIdWithinFlow.length + 1];
    Hashing.md5().hashBytes(queueIdWithinFlow).writeBytesTo(bytes, 0, 1);
    System.arraycopy(queueIdWithinFlow, 0, bytes, 1, queueIdWithinFlow.length);

    return bytes;
  }
1175545
public long getExpectedSequenceNumber()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.entry(tc, "getExpectedSequenceNumber");
      
    long expectedSeqNumber = aoBrowserSession.getExpectedSequenceNumber();
    
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.exit(tc, "getExpectedSequenceNumber", new Long(expectedSeqNumber));
    return expectedSeqNumber;
  }
390308
public int getPrevOpcode(int offset) {
        if (offset < 0) {
            throw new IllegalArgumentException("offset (" + offset + ") must be nonnegative");
        }
        if (offset >= prevOpcode.length || offset > sizePrevOpcodeBuffer) {
            return Const.NOP;
        }
        int pos = currentPosInPrevOpcodeBuffer - offset;
        if (pos < 0) {
            pos += prevOpcode.length;
        }
        return prevOpcode[pos];
    }
426650
public long getSequenceID()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "getSequenceID");
    long sequenceID=0;
    sequenceID = msgItem.getMessage().getGuaranteedValueValueTick();

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "getSequenceID", new Long(sequenceID));
    return sequenceID;
  }
690441
public Queue<PoolGroupSchedulable> getPreemptQueue() {
    if (preemptQueue == null) {
      preemptQueue = createPoolGroupQueue(ScheduleComparator.FAIR_PREEMPT);
    }
    return preemptQueue;
  }
554177
public String eatId() {
		if (!matchId())
			throw new BadSyntaxException();
		String s = tok.sval;
		nextToken();
		return s;
	}
491561
public String getQueueName(boolean bDefaultIfNone)
    {
        String strName = null;
        Record recQueueName = ((ReferenceField)this.getField(MessageProcessInfo.QUEUE_NAME_ID)).getReference();
        if ((recQueueName != null) && (recQueueName.getEditMode() == DBConstants.EDIT_CURRENT))
            strName = recQueueName.getField(QueueName.CODE).toString();
        if ((strName == null) || (strName.length() == 0))
            if (bDefaultIfNone)
        {
            int iMessageInfoType = MessageInfoType.REQUEST_ID;
            Record recMessageInfo = ((ReferenceField)this.getField(MessageProcessInfo.MESSAGE_INFO_ID)).getReference();
            if ((recMessageInfo != null) && (recMessageInfo.getEditMode() == DBConstants.EDIT_CURRENT))
                iMessageInfoType = (int)recMessageInfo.getField(MessageInfo.MESSAGE_INFO_TYPE_ID).getValue();
            if (iMessageInfoType == MessageInfoType.REQUEST_ID)
                strName = MessageConstants.TRX_SEND_QUEUE;
            else
                strName = MessageConstants.TRX_RECEIVE_QUEUE;
        }
        return strName;
    }
152345
public String getId()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
    {
      SibTr.entry(tc, "getId");
      SibTr.exit(tc, "getId", new Long(getSequenceID()));
    }
    return ""+getSequenceID();
  }
1072977
public long get()
  {
    long now = CurrentTime.currentTime() / 1000;
    
    long oldSequence;
    long newSequence;
    
    do {
      oldSequence = _sequence.get();
      
      long oldTime = oldSequence >>> _timeOffset;
    
      if (oldTime != now) {
        newSequence = ((now << _timeOffset)
                      + (randomLong() & _sequenceRandomMask));
      }
      else {
        // relatively prime increment will use the whole sequence space
        newSequence = oldSequence + _sequenceIncrement;
      }
    } while (! _sequence.compareAndSet(oldSequence, newSequence));
      
    long id = ((now << _timeOffset)
               | _node
               | (newSequence & _sequenceMask));
      
    return id;
  }
16909
String getNextAlgorithmObjectId() {
		if (idsToAlgorithms.size() == Integer.MAX_VALUE) {
			throw new IllegalArgumentException(
					"Maximum number of algorithm objects reached");
		}
		while (true) {
			String candidate = "ALGORITHM_" + currentAlgorithmId++;
			if (isUniqueAlgorithmObjectId(candidate)) {
				return candidate;
			}
		}
	}
676454
public long getNextUniqueId() {
        // get the current time, usually the salt value is zero
        // in testing it is used to simulate clock skew
        long currentTime = m_clock.get() + m_timestampTestingSalt;
        long currentTimePlusOffset = currentTime + m_backwardsTimeAdjustmentOffset;
        if (currentTime == lastUsedTime) {
            // increment the counter for this millisecond
            counterValue++;

            // handle the case where we've run out of counter values
            // for this particular millisecond (feels unlikely)
            if (counterValue > COUNTER_MAX_VALUE) {
                // spin until the next millisecond
                while (currentTime == lastUsedTime)
                    currentTime = m_clock.get();
                // reset the counter and lastUsedTime for the new millisecond
                lastUsedTime = currentTime;
                counterValue = 0;
            }
        }
        else {
            // reset the counter and lastUsedTime for the new millisecond
            if (currentTime < lastUsedTime && currentTimePlusOffset < lastUsedTime) {
                /*
                 * Time moved backwards, if was less than three seconds, spin to let it catch up
                 * otherwise calculate an offset to add to the system clock in order to use it to
                 * continue moving forward
                 */
                double diffSeconds = (lastUsedTime - currentTime) / 1000.0;
                // if the diff is less than some specified amount of time, wait a bit
                StringBuilder msg = new StringBuilder(256);
                if ((lastUsedTime - currentTime) < BACKWARD_TIME_FORGIVENESS_WINDOW_MS) {
                    msg.append("UniqueIdGenerator time moved backwards from: %d to %d, a difference of %.2f seconds.");
                    msg.append("\nThis node will delay any stored procedures sent to it.");
                    msg.append("\nThis node will resume full operation in  %.2f seconds.");
                    log.rateLimitedLog(60, Level.INFO, null, msg.toString(), lastUsedTime, currentTime, diffSeconds, diffSeconds );

                    long count = BACKWARD_TIME_FORGIVENESS_WINDOW_MS;
                    // note, the loop should stop once lastUsedTime is PASSED, not current
                    while ((currentTime <= lastUsedTime) && (count-- > 0)) {
                        try {
                            m_clock.sleep(1);
                        } catch (InterruptedException e) {}
                        currentTime = m_clock.get();
                    }
                    // if the loop above ended because it ran too much, time is pretty darn wonky.
                    // Going to let it crash in this instance
                    if (count < 0) {
                        VoltDB.crashLocalVoltDB("VoltDB was unable to recover after the system time was externally negatively adusted. " +
                                "It is possible that there is a serious system time or NTP error. ", false, null);
                    }
                }
                // Calculate an offset that will keep time moving forward at the rate of the system clock
                // but at the current time, not the time the system clock shifted back too.
                else {
                    m_backwardsTimeAdjustmentOffset = lastUsedTime - currentTime + 1;
                    //Since we calculated a new offset, recalculate the current time + the offset
                    currentTimePlusOffset = currentTime + m_backwardsTimeAdjustmentOffset;
                    //Should satisfy this constraint now
                    assert(currentTimePlusOffset > lastUsedTime);
                    double offsetSeconds = m_backwardsTimeAdjustmentOffset / 1000.0D;

                    msg.append("UniqueIdGenerator time moved backwards from: %d to %d, a difference of %.2f seconds.");
                    msg.append("\nContinuing operation by adding an offset of %.2f to system time. ");
                    msg.append("This means the time and unique IDs provided by VoltProcedure ");
                    msg.append(" (getUniqueId, getTransactionId, getTransactionTime) ");
                    msg.append("will not correctly reflect wall clock time as reported by the system clock.");
                    msg.append(" For severe shifts you could see duplicate ");
                    msg.append("IDs or time moving backwards when the server is");
                    msg.append(" restarted causing the offset to be discarded.");

                    log.rateLimitedLog(60, Level.ERROR, null, msg.toString(), lastUsedTime, currentTime, diffSeconds, offsetSeconds);
                }
            } else if (currentTime > lastUsedTime && m_backwardsTimeAdjustmentOffset != 0) {
                //Actual wall clock time is correct, blast away the offset
                //and switch to current time
                m_backwardsTimeAdjustmentOffset = 0;
                currentTimePlusOffset = currentTime;
                log.error("Host clock seems to have adjusted again to make the offset unecessary");
                System.err.println("Host clock seems to have adjusted again to make the offset unecessary");
            }
            currentTime = currentTimePlusOffset;
            lastUsedTime = currentTime;
            counterValue = 0;
        }

        lastUniqueId = makeIdFromComponents(currentTime, counterValue, partitionId);

        return lastUniqueId;
    }
916660
public HelpTopicNode getPreviousSibling() {
        int i = getIndex() - 1;
        return i < 0 ? null : parent.children.get(i);
    }
298452
public synchronized long nextId() {
        long timestamp = timeGen();
        if (timestamp < lastTimestamp) {
            throw new RuntimeException(
                    String.format("Clock moved backwards.  Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
        }
        //如果是同一时间生成的，则进行毫秒内序列
        if (lastTimestamp == timestamp) {
            sequence = (sequence + 1) & sequenceMask;
            //毫秒内序列溢出
            if (sequence == 0) {
                //阻塞到下一个毫秒,获得新的时间戳
                timestamp = tilNextMillis(lastTimestamp);
            }
        }
        //时间戳改变，毫秒内序列重置
        else {
            sequence = 0L;
        }
        //上次生成ID的时间截
        lastTimestamp = timestamp;
        //移位并通过或运算拼到一起组成64位的ID
        return ((timestamp - twepoch) << timestampLeftShift)
                | (dataCenterId << dataCenterIdShift)
                | (workerId << workerIdShift)
                | sequence;
    }
670810
@Override
    public long getId()
                    throws SISessionUnavailableException, SISessionDroppedException,
                    SIErrorException
    {
        if (TraceComponent.isAnyTracingEnabled() && CoreSPIConsumerSession.tc.isEntryEnabled())
            SibTr.entry(CoreSPIConsumerSession.tc, "getId", this);

        _localConsumerPoint.checkNotClosed();

        if (TraceComponent.isAnyTracingEnabled() && CoreSPIConsumerSession.tc.isEntryEnabled())
            SibTr.exit(CoreSPIConsumerSession.tc, "getId", new Long(_consumerId));
        return _consumerId;
    }
340838
public int getEventInstanceId() {
    if (Event_Type.featOkTst && ((Event_Type)jcasType).casFeat_eventInstanceId == null)
      jcasType.jcas.throwFeatMissing("eventInstanceId", "de.unihd.dbs.uima.types.heideltime.Event");
    return jcasType.ll_cas.ll_getIntValue(addr, ((Event_Type)jcasType).casFeatCode_eventInstanceId);}
1001187
public SIMPRemoteQueuePointControllable getRemoteQueuePointControlByMEUuid(String id) throws SIMPInvalidRuntimeIDException, SIMPControllableNotFoundException, SIMPException
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(
        tc,
        "getRemoteQueuePointControlByMEUuid",
        new Object[] { id });
    
    assertMessageHandlerNotCorrupt();
    
//  ids are assumed to be SIBUuid8 format
    SIBUuid8 uuid = null;
    try
    {
      uuid = new SIBUuid8(id);
    }
    catch(NumberFormatException e)
    {
      FFDCFilter.processException(
        e,
        "com.ibm.ws.sib.processor.impl.Queue.getRemoteQueuePointControlByMEUuid",
        "1:172:1.30",
        this);
    
      SIMPInvalidRuntimeIDException finalE =
        new SIMPInvalidRuntimeIDException(
          nls.getFormattedMessage(
            "INTERNAL_MESSAGING_ERROR_CWSIP0003",
            new Object[] {"Queue.getRemoteQueuePointControlByMEUuid",
                "1:180:1.30",
                          e,
                          id},
            null), e);

      SibTr.exception(tc, finalE);
      SibTr.error(tc,"INTERNAL_MESSAGING_ERROR_CWSIP0003",
      new Object[] {"Queue.getRemoteQueuePointControlByMEUuid",
          "1:188:1.30",
                    e,
                    id}); 
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "getRemoteQueuePointControlByMEUuid", finalE);
      throw finalE;            
    }
    
    // TODO : shouldnt provide null here... should provide the consumerSetId
    SIMPRemoteQueuePointControllable remote = baseDest.getRemoteQueuePointControl(uuid, false);
    if(remote == null)
    {
      SIMPControllableNotFoundException finalE =
        new SIMPControllableNotFoundException(
          nls.getFormattedMessage(
            "INTERNAL_MESSAGING_ERROR_CWSIP0003",
            new Object[] {"Queue.getRemoteQueuePointControlByMEUuid",
                          "1:204:1.30",
                          id},
            null));     

      SibTr.exception(tc, finalE);
      SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0003",
      new Object[] {"Queue.getRemoteQueuePointControlByMEUuid",
                    "1:211:1.30",
                    id});
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "getRemoteQueuePointControlByMEUuid", finalE);
      throw finalE; 
    }
    
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "getRemoteQueuePointControlByMEUuid", remote);
    
    return remote;
  }