method checkRefCound

Checks that the reference count for this object is still valid.
IF the Reference count is less than 0 then a SIErrorException is
thrown.
165940
private final void checkRefCount() 
  {
    if (_refCount < 0)
    {
      SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0001",      
        new Object[] {
          "com.ibm.ws.sib.processor.proxyhandler.MESubscription",
          "1:298:1.55" }) ;
           
      throw new SIErrorException(
          nls.getFormattedMessage(
            "INTERNAL_MESSAGING_ERROR_CWSIP0001",
            new Object[] {
              "com.ibm.ws.sib.processor.proxyhandler.MESubscription",
              "1:305:1.55" },
            null));
    }
  }
815353
private int getSkipCorrectedReference(List<Integer> tokenPositions, int refNumber) {
    int correctedRef = 0;
    int i = 0;
    for (int tokenPosition : tokenPositions) {
      if (i++ >= refNumber) {
        break;
      }
      correctedRef += tokenPosition;
    }
    return correctedRef - 1;
  }
245150
@Override
    public void checkForMessages()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "checkForMessages", this);

        try
        {
            //start a new thread to run the callback
            _messageProcessor.startNewThread(new AsynchThread(this, false));
        } catch (InterruptedException e)
        {
            FFDCFilter.processException(
                                        e,
                                        "com.ibm.ws.sib.processor.impl.JSLocalConsumerPoint.checkForMessages",
                                        "1:3881:1.22.5.1",
                                        this);

            SibTr.exception(tc, e);

            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(tc, "checkForMessages", e);

        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "checkForMessages");
    }
1265979
public synchronized boolean isValid()
   {
      if (tc.isEntryEnabled()) SibTr.entry(this, tc, "isValid");
      if (tc.isEntryEnabled()) SibTr.exit(this, tc, "isValid", ""+valid);
      return valid;
   }
1259692
protected void stopIfRequired() throws SIException
    {
        final String methodName = "stopIfRequired";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, methodName, new Object[] { this });
        }

        if (TRACE.isDebugEnabled())
        {
            SibTr.debug(TRACE, methodName, "sibPacingSessionStarted: " + sibPacingSessionStarted + "\nmpcPacingSessionStarted: " + mpcPacingSessionStarted + "\nsessionStarted: "
                                           + sessionStarted);
        }

        if (!sibPacingSessionStarted || !mpcPacingSessionStarted || !sessionStarted)
        {
            _session.stop();
        }

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled())
        {
            SibTr.exit(this, TRACE, methodName);
        }
    }
1228895
static void isCorrectLength(byte[] object, int length, String name) {
    Validate.notNull(object, "%s cannot be null.", name);

    Validate.isTrue(object.length == length,
        "%s should be %d bytes, found %d bytes.", name, length, object.length);
  }
1271522
def isValid(self):
        
        if self._callback_func_ref is not None and self._callback_func_ref():
            if self._callback_self_ref is None or self._callback_self_ref():
                return True
        return False
237161
private void countAndVerifyObjects()
                    throws IOException,
                    EOFException,
                    FileManagerException,
                    ClassNotFoundException,
                    HashtableOnDiskException {
        println("countAndVerifyObjects(): Hashtable " + filename + " was not closed properly.  Validating ");
        header.set_num_objects(0);

        HashtableAction act = new HashtableAction() {
            public boolean execute(HashtableEntry e)
                            throws IOException
            {
                if ((header.num_objects() % 100) == 0) {
                    print(".");
                }
                header.incrementObjectCount();
                if (item_initialize != null) {
                    item_initialize.initialize(e.getKey(), e.getValue());
                }
                return true;
            }
        };

        walkHash(act, RETRIEVE_ALL, 0, -1);

        header.write();
        println("countAndVerifyObjects(): done");
    }
968860
@Override
    public void itemReferencesDroppedToZero()
    {
        super.itemReferencesDroppedToZero();
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "itemReferencesDroppedToZero");

        if (failedInitInRestore)
        {
            try
            {
                initialiseNonPersistent(true);
            } catch (SevereMessageStoreException e)
            {
                FFDCFilter.processException(
                                            e,
                                            "com.ibm.ws.sib.processor.impl.store.items.MessageItem.itemReferencesDroppedToZero",
                                            "1:1617:1.244.1.40",
                                            this);

                //There was a problem getting hold of the itemstream when trying to initilise
                //We wouldn't have registered any callbacks yet so we shouldn't carry on

                SibTr.exception(tc, e);

                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    SibTr.exit(this, tc, "itemReferencesDroppedToZero", e);

                throw new SIErrorException(e);
            }
        }

        if (REFERENCES_DROPPED_TO_ZERO != null)
        {
            try
            {
                REFERENCES_DROPPED_TO_ZERO.messageEventOccurred(MessageEvents.REFERENCES_DROPPED_TO_ZERO, this, null);
            } catch (SIException e)
            {
                // Exceptions after a commit are bad !
                FFDCFilter.processException(
                                            e,
                                            "com.ibm.ws.sib.processor.impl.store.items.MessageItem.itemReferencesDroppedToZero",
                                            "1:1644:1.244.1.40",
                                            this);

                SibTr.exception(tc, e);

                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    SibTr.exit(this, tc, "itemReferencesDroppedToZero", e);

                throw new SIErrorException(e);
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "itemReferencesDroppedToZero");
    }
774575
@Override
  public void validate() {
    try {
      IFD ifd = model.getFirstIFD();
      int n = 0;
      while (ifd != null) {
        validateIfd(ifd, n);
        ifd = ifd.getNextIFD();
        n++;
      }
    } catch (Exception e) {

    }
  }
684797
public final synchronized void commitDecrementReferenceCount(PersistentTransaction transaction) throws SevereMessageStoreException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "commitDecrementReferenceCount");

        if (_referenceCount < 1)
        {
            SevereMessageStoreException e = new SevereMessageStoreException("Reference count decrement cannot be committed");
            FFDCFilter.processException(e, "com.ibm.ws.sib.msgstore.cache.links.ItemLink.commitDecrementReferenceCount", "1:131:1.104.1.1");
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) SibTr.event(this, tc, "Reference count decrement cannot be committed");
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "commitDecrementReferenceCount");
            throw e;
        }
        _referenceCount--;

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "reference count dropped to: " + _referenceCount);

        if (0 == _referenceCount)
        {
            // This causes the item's itemReferencesDroppedToZero to be called after
            // completion of this transaction
            transaction.registerCallback(this);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "commitDecrementReferenceCount");
    }
246887
public boolean shouldInvalidate (Object id, int sourceOfInvalidation, int causeOfInvalidation) {
    	boolean retVal = true;
        if (preInvalidationListenerCount > 0) {
        	// In external implementation, catch any exceptions and process
        	try {
        		retVal = currentPreInvalidationListener.shouldInvalidate(id, sourceOfInvalidation, causeOfInvalidation);
        	}
        	catch (Throwable t) {
        		com.ibm.ws.ffdc.FFDCFilter.processException(t, "com.ibm.ws.cache.DCEventSource.shouldInvalidate", "120", this);
        		if (tc.isDebugEnabled()) {
            		Tr.debug(tc, "Exception thrown in shouldInvalidate method of PreInvalidationListener\n" + t.toString());
            	}
        	}
        }
        
        return retVal; //invalidate
    }
319354
public void validate() {
    synchronized (mSharedMapsLock) {
      // Compute block lock reference counts based off of lock records
      ConcurrentMap<Long, AtomicInteger> blockLockReferenceCounts = new ConcurrentHashMap<>();
      for (LockRecord record : mLockIdToRecordMap.values()) {
        blockLockReferenceCounts.putIfAbsent(record.getBlockId(), new AtomicInteger(0));
        blockLockReferenceCounts.get(record.getBlockId()).incrementAndGet();
      }

      // Check that the reference count for each block lock matches the lock record counts.
      for (Entry<Long, ClientRWLock> entry : mLocks.entrySet()) {
        long blockId = entry.getKey();
        ClientRWLock lock = entry.getValue();
        Integer recordCount = blockLockReferenceCounts.get(blockId).get();
        Integer referenceCount = lock.getReferenceCount();
        if (!Objects.equal(recordCount, referenceCount)) {
          throw new IllegalStateException("There are " + recordCount + " lock records for block"
              + " id " + blockId + ", but the reference count is " + referenceCount);
        }
      }

      // Check that if a lock id is mapped to by a session id, the lock record for that lock id
      // contains that session id.
      for (Entry<Long, Set<Long>> entry : mSessionIdToLockIdsMap.entrySet()) {
        for (Long lockId : entry.getValue()) {
          LockRecord record = mLockIdToRecordMap.get(lockId);
          if (record.getSessionId() != entry.getKey()) {
            throw new IllegalStateException("The session id map contains lock id " + lockId
                + "under session id " + entry.getKey() + ", but the record for that lock id ("
                + record + ")" + " doesn't contain that session id");
          }
        }
      }
    }
  }
222724
private void validate() {
        if (host.isEmpty()) {
            throw new IllegalArgumentException("host cannot be null");
        }
        if (catalog == null) {
            throw new IllegalArgumentException("namespace cannot be null");
        }
        if (table == null) {
            throw new IllegalArgumentException("set cannot be null");
        }
        if (portList.isEmpty()) {
            if(port>0){
                port(port);
            }else{
                throw new IllegalArgumentException("port cannot be null");
            }

        }
        if (host.size() != portList.size()) {
            throw new IllegalArgumentException("Host and ports cardinality must be the same");
        }

    }
674786
private static void checkValidObject(Path path, AbstractConfigObject reference,
            AbstractConfigObject value,
            List<ConfigException.ValidationProblem> accumulator) {
        for (Map.Entry<String, ConfigValue> entry : reference.entrySet()) {
            String key = entry.getKey();

            Path childPath;
            if (path != null)
                childPath = Path.newKey(key).prepend(path);
            else
                childPath = Path.newKey(key);

            AbstractConfigValue v = value.get(key);
            if (v == null) {
                addMissing(accumulator, entry.getValue(), childPath, value.origin());
            } else {
                checkValid(childPath, entry.getValue(), v, accumulator);
            }
        }
    }
439437
private boolean checkRateExceededErrorAndUpdateWaitTime(
      long clientCustomerId, Throwable throwable) {
    if (ReflectionUtil.isInstanceOf(throwable, "ApiException")) {
      try {
        Object[] errors = (Object[]) ReflectionUtil.invokeNoArgMethod(throwable, "getErrors");
        if (errors == null) {
          return false;
        }
        for (Object error : errors) {
          if (ReflectionUtil.isInstanceOf(error, "RateExceededError")) {
            String rateScope = (String) ReflectionUtil.invokeNoArgMethod(error, "getRateScope");
            Integer retryAfterSeconds =
                (Integer) ReflectionUtil.invokeNoArgMethod(error, "getRetryAfterSeconds");
            logger.info(
                "Encountered RateExceededError: scope={}, seconds={}.",
                rateScope,
                retryAfterSeconds);
            if (retryAfterSeconds == null) {
              logger.warn("Unexpected rate exceeed error, missing retryAfterSeconds");
            } else if (retryAfterSeconds != null) {
              long waitForMillis = getWaitUntilMillis(retryAfterSeconds.intValue());
              if ("DEVELOPER".equals(rateScope)) {
                updateTokenWaitTime(waitForMillis);
                return true;
              } else if ("ACCOUNT".equals(rateScope)) {
                updateAccountWaitTime(clientCustomerId, waitForMillis);
                return true;
              } else {
                logger.warn("Unknown RateExceededError scope: " + rateScope, throwable);
              }
            }
          }
        }
      } catch (RateLimiterReflectionException e) {
        // Failed during reflection analysis, just log and proceed.
        logger.error("Encountered error during analysis using reflection.", e);
      }
    }
    return false;
  }
717161
private void ensureFill() throws JedisConnectionException {
    if (count >= limit) {
      try {
        limit = in.read(buf);
        count = 0;
        if (limit == -1) {
          throw new JedisConnectionException("Unexpected end of stream.");
        }
      } catch (IOException e) {
        throw new JedisConnectionException(e);
      }
    }
  }