@Test public void eventCountBased() throws InterruptedException, IOException HttpEmitterConfig config = new HttpEmitterConfig.Builder("http://foo.bar") .setFlushMillis(100) .setFlushCount(4)
@Test public void timeoutEmptyQueue() throws IOException, InterruptedException { float timeoutAllowanceFactor = 2.0f; final HttpEmitterConfig config = new HttpEmitterConfig.Builder("http://foo.bar") .setBatchingStrategy(BatchingStrategy.ONLY_EVENTS) .setHttpTimeoutAllowanceFactor(timeoutAllowanceFactor) .build(); final HttpPostEmitter emitter = new HttpPostEmitter(config, httpClient, objectMapper); long startMs = System.currentTimeMillis(); emitter.start(); emitter.emitAndReturnBatch(new IntEvent()); emitter.flush(); long fillTimeMs = System.currentTimeMillis() - startMs; Assert.assertThat((double) timeoutUsed.get(), Matchers.lessThan(fillTimeMs * (timeoutAllowanceFactor + 0.5))); startMs = System.currentTimeMillis(); final Batch batch = emitter.emitAndReturnBatch(new IntEvent()); Thread.sleep(1000); batch.seal(); emitter.flush(); fillTimeMs = System.currentTimeMillis() - startMs; Assert.assertThat((double) timeoutUsed.get(), Matchers.lessThan(fillTimeMs * (timeoutAllowanceFactor + 0.5))); } }
@Test public void testLargeAndSmallEventsQueueLimit() throws InterruptedException, IOException HttpEmitterConfig config = new HttpEmitterConfig.Builder("http://foo.bar") .setFlushMillis(100) .setFlushCount(4)
@Test public void testLargeEventsQueueLimit() throws IOException HttpEmitterConfig config = new HttpEmitterConfig.Builder("http://foo.bar") .setFlushMillis(100) .setFlushCount(4)
private HttpPostEmitter manualFlushEmitterWithBasicAuthenticationAndNewlineSeparating(String authentication) { HttpEmitterConfig config = new HttpEmitterConfig.Builder(TARGET_URL) .setFlushMillis(Long.MAX_VALUE) .setFlushCount(Integer.MAX_VALUE) .setBasicAuthentication(authentication) .setBatchingStrategy(BatchingStrategy.NEWLINES) .setMaxBatchSize(1024 * 1024) .build(); HttpPostEmitter emitter = new HttpPostEmitter( config, httpClient, jsonMapper ); emitter.start(); return emitter; }
private HttpPostEmitter sizeBasedEmitter(int size) { HttpEmitterConfig config = new HttpEmitterConfig.Builder(TARGET_URL) .setFlushMillis(Long.MAX_VALUE) .setFlushCount(size) .build(); HttpPostEmitter emitter = new HttpPostEmitter( config, httpClient, jsonMapper ); emitter.start(); return emitter; }
private HttpPostEmitter timeBasedEmitter(long timeInMillis) { HttpEmitterConfig config = new HttpEmitterConfig.Builder(TARGET_URL) .setFlushMillis(timeInMillis) .setFlushCount(Integer.MAX_VALUE) .build(); HttpPostEmitter emitter = new HttpPostEmitter( config, httpClient, jsonMapper ); emitter.start(); return emitter; }
private HttpPostEmitter sizeBasedEmitterWithContentEncoding(int size, ContentEncoding encoding) { HttpEmitterConfig config = new HttpEmitterConfig.Builder(TARGET_URL) .setFlushMillis(Long.MAX_VALUE) .setFlushCount(size) .setContentEncoding(encoding) .build(); HttpPostEmitter emitter = new HttpPostEmitter( config, httpClient, jsonMapper ); emitter.start(); return emitter; }
private HttpPostEmitter manualFlushEmitterWithBatchSize(int batchSize) { HttpEmitterConfig config = new HttpEmitterConfig.Builder(TARGET_URL) .setFlushMillis(Long.MAX_VALUE) .setFlushCount(Integer.MAX_VALUE) .setMaxBatchSize(batchSize) .build(); HttpPostEmitter emitter = new HttpPostEmitter( config, httpClient, jsonMapper ); emitter.start(); return emitter; }