private void doOnSealExclusive(Batch batch, long elapsedTimeMillis) { batchFillingTimeCounter.add((int) Math.max(elapsedTimeMillis, 0)); if (elapsedTimeMillis > 0) { // If elapsedTimeMillis is 0 or negative, it's likely because System.currentTimeMillis() is not monotonic, so not // accounting this time for determining batch sending timeout. lastBatchFillTimeMillis = elapsedTimeMillis; } addBatchToEmitQueue(batch); wakeUpEmittingThread(); if (!isTerminated()) { long nextBatchNumber = ConcurrentAwaitableCounter.nextCount(batch.batchNumber); byte[] newBuffer = acquireBuffer(); if (!concurrentBatch.compareAndSet(batch, new Batch(this, newBuffer, nextBatchNumber))) { buffersToReuse.add(newBuffer); // If compareAndSet failed, the service should be closed concurrently, i. e. we expect isTerminated() = true. // If we don't see this, there should be some bug in HttpPostEmitter. Preconditions.checkState(isTerminated()); } } }
private void doOnSealExclusive(Batch batch, long elapsedTimeMillis) { batchFillingTimeCounter.add((int) Math.max(elapsedTimeMillis, 0)); if (elapsedTimeMillis > 0) { // If elapsedTimeMillis is 0 or negative, it's likely because System.currentTimeMillis() is not monotonic, so not // accounting this time for determining batch sending timeout. lastFillTimeMillis = elapsedTimeMillis; } addBatchToEmitQueue(batch); wakeUpEmittingThread(); if (!isTerminated()) { long nextBatchNumber = ConcurrentAwaitableCounter.nextCount(batch.batchNumber); byte[] newBuffer = acquireBuffer(); if (!concurrentBatch.compareAndSet(batch, new Batch(this, newBuffer, nextBatchNumber))) { buffersToReuse.add(newBuffer); // If compareAndSet failed, the service should be closed concurrently, i. e. we expect isTerminated() = true. // If we don't see this, there should be some bug in HttpPostEmitter. Preconditions.checkState(isTerminated()); } } }