@Override public ThresholdEventWriter get() { return new ThresholdEventWriter(eventWriter, maxUncommittedWriteCount, maxUncommittedPeriodInSeconds); } }
@Override public void send(final File file, final CallbackHandler handler) { // no-op handler.onSuccess(file); }
@Override public void onThrowable(final Throwable t) { activeRequests.decrementAndGet(); handler.onError(t, file); } };
httpMaxWaitTimeInMillis, httpMaxKeepAliveInMillis, httpWorkersPoolSize); EventSerializer serializer = new ObjectOutputEventSerializer(); switch (eventType) { case SMILE: final DiskSpoolEventWriter eventWriter = new DiskSpoolEventWriter(new EventHandler() syncType, syncBatchSize, new NoCompressionCodec(), serializer); final ThresholdEventWriter thresholdEventWriter = new ThresholdEventWriter(eventWriter, maxUncommittedWriteCount, maxUncommittedPeriodInSeconds); controller = new CollectorController(thresholdEventWriter);
/** * Provides an instance of a DiskSpoolEventWriter, which forwards local buffered events (in files) to the collector, * via an EventSender. * * @return instance of a DiskSpoolEventWriter */ @Override public DiskSpoolEventWriter get() { return new DiskSpoolEventWriter(new EventHandler() { @Override public void handle(final File file, final CallbackHandler handler) { eventSender.send(file, handler); } }, config.getSpoolDirectoryName(), config.isFlushEnabled(), config.getFlushIntervalInSeconds(), executor, SyncType.valueOf(config.getSyncType()), config.getSyncBatchSize(), new NoCompressionCodec(), serializer); } }
@Override public Response onCompleted(final Response response) { activeRequests.decrementAndGet(); if (response.getStatusCode() == 202) { handler.onSuccess(file); } else { handler.onError(new IOException(String.format("Received response %d: %s", response.getStatusCode(), response.getStatusText())), file); } sendTimer.update(System.nanoTime() - startTime, TimeUnit.NANOSECONDS); return response; // never read }
@Managed(description = "Promote events to final spool area") public void commit() throws IOException { eventWriter.forceCommit(); }
@Managed(description = "Flush events to remote agent") public void flush() throws IOException { eventWriter.flush(); } }
/** * Offer an event to the queue. * * @param event an event to collect * @throws IOException if a serialization exception (to disk) occurs */ public void offerEvent(final Event event) throws IOException { if (!acceptEvents.get()) { // TODO shouldn't we increment eventsLost here? return; } eventsReceived.incrementAndGet(); try { log.debug("Writing event: {}", event); eventWriter.write(event); } catch (IOException e) { log.error(String.format("Failed to write event: %s", event), e); eventsLost.incrementAndGet(); throw e; } }
public void close() { setAcceptEvents(false); try { commit(); flush(); eventWriter.close(); } catch (IOException e) { log.warn("Got I/O exception closing the eventtracker library: " + e); } }