@Override public void deactivateThrottling() { int count = throttleRequestCount.decrementAndGet(); assert count >= 0 : "invalid post-decrement throttleRequestCount=" + count; if (count == 0) { throttle.deactivate(); } }
@Override public void activateThrottling() { int count = throttleRequestCount.incrementAndGet(); assert count >= 1 : "invalid post-increment throttleRequestCount=" + count; if (count == 1) { throttle.activate(); } }
@Override public boolean index(Index index) { final boolean created; try (ReleasableLock lock = readLock.acquire()) { ensureOpen(); if (index.origin() == Operation.Origin.RECOVERY) { // Don't throttle recovery operations created = innerIndex(index); } else { try (Releasable r = throttle.acquireThrottle()) { created = innerIndex(index); } } } catch (OutOfMemoryError | IllegalStateException | IOException t) { maybeFailEngine("index", t); throw new IndexFailedEngineException(shardId, index.type(), index.id(), t); } return created; }
public long getIndexThrottleTimeInMillis() { return throttle.getThrottleTimeInMillis(); }