/** * Update the fraction of processing threads that should remain active. It is * the responsibility of out-of-core oracle to update the number of active * threads. * * @param fraction the fraction of processing threads to remain active. This * number is in range [0, 1] */ public void updateActiveThreadsFraction(double fraction) { checkState(fraction >= 0 && fraction <= 1); int numActiveThreads = (int) (numProcessingThreads * fraction); if (LOG.isInfoEnabled()) { LOG.info("updateActiveThreadsFraction: updating the number of active " + "threads to " + numActiveThreads); } activeThreadsPermit.setMaxPermits(numActiveThreads); }
activeThreadsPermit.setMaxPermits(activeThreadsPermit.availablePermits() * numComputeThreads / numProcessingThreads); numProcessingThreads = numComputeThreads;
/** * Process a resume signal came from a given worker * * @param clientId id of the worker that sent the signal * @param credit the credit value sent along with the resume signal * @param requestId timestamp (request id) of the resume signal */ public void processResumeSignal(int clientId, short credit, long requestId) { int timestamp = (int) (requestId & 0xFFFF); if (LOG.isDebugEnabled()) { LOG.debug("processResumeSignal: resume signal from " + clientId + " with timestamp=" + timestamp); } MutablePair<AdjustableSemaphore, Integer> pair = (MutablePair<AdjustableSemaphore, Integer>) perWorkerOpenRequestMap.get(clientId); synchronized (pair) { if (compareTimestamps(timestamp, pair.getRight()) > 0) { pair.setRight(timestamp); pair.getLeft().setMaxPermits(credit); } else if (LOG.isDebugEnabled()) { LOG.debug("processResumeSignal: received out-of-order messages. " + "Received timestamp=" + timestamp + " and current timestamp=" + pair.getRight()); } } trySendCachedRequests(clientId); } }
if (compareTimestamps(timestamp, pair.getRight()) > 0) { pair.setRight(timestamp); openRequestPermit.setMaxPermits(credit); } else if (LOG.isDebugEnabled()) { LOG.debug("messageAckReceived: received out-of-order messages." +