protected TcpTransport( final Configuration configuration, final Executor bossPool, final Executor workerPool, final ThroughputCounter throughputCounter, final ConnectionCounter connectionCounter, final LocalMetricRegistry localRegistry) { super(configuration, throughputCounter, localRegistry, bossPool, workerPool, connectionCounter); final boolean nulDelimiter = configuration.getBoolean(CK_USE_NULL_DELIMITER); this.delimiter = nulDelimiter ? nulDelimiter() : lineDelimiter(); this.tcpKeepalive = configuration.getBoolean(CK_TCP_KEEPALIVE); this.maxFrameLength = configuration.getInt(CK_MAX_MESSAGE_SIZE, Config.DEFAULT_MAX_FRAME_LENGTH); }
@Override public void doLaunch(final MessageInput input) throws MisfireException { reporter = Graylog2Reporter.forRegistry(metricRegistry) .useSource(configuration.getString(CK_SOURCE)) .convertDurationsTo(TimeUnit.valueOf(configuration.getString(CK_DURATION_UNIT))) .convertRatesTo(TimeUnit.valueOf(configuration.getString(CK_RATE_UNIT))) .build(new RawGelfWriter(input)); scheduledFuture = scheduler.schedule( new Runnable() { @Override public void run() { if (isThrottled()) { // do not block, but simply skip this iteration log.debug("Skipping metric report this iteration because we are throttled."); } reporter.report(); } }, configuration.getInt(CK_REPORT_INTERVAL), TimeUnit.valueOf(configuration.getString(CK_REPORT_UNIT))); }