Search in sources :

Example 1 with IdleStreamWatcher

use of org.zalando.nakadi.service.subscription.IdleStreamWatcher in project nakadi by zalando.

the class StreamingState method onEnter.

@Override
public void onEnter() {
    final String kafkaFlushedBytesMetricName = MetricUtils.metricNameForHiLAStream(this.getContext().getParameters().getConsumingClient().getClientId(), this.getContext().getSubscription().getId());
    bytesSentMeterPerSubscription = this.getContext().getMetricRegistry().meter(kafkaFlushedBytesMetricName);
    lastKpiEventSent = System.currentTimeMillis();
    kpiDataPerEventType = this.getContext().getSubscription().getEventTypes().stream().collect(Collectors.toMap(et -> et, et -> new StreamKpiData()));
    idleStreamWatcher = new IdleStreamWatcher(getParameters().commitTimeoutMillis * 2);
    this.eventConsumer = getContext().getTimelineService().createEventConsumer(null);
    recreateTopologySubscription();
    addTask(this::recheckTopology);
    addTask(this::pollDataFromKafka);
    scheduleTask(this::checkBatchTimeouts, getParameters().batchTimeoutMillis, TimeUnit.MILLISECONDS);
    scheduleTask(() -> {
        final String debugMessage = "Stream timeout reached";
        this.sendMetadata(debugMessage);
        this.shutdownGracefully(debugMessage);
    }, getParameters().streamTimeoutMillis, TimeUnit.MILLISECONDS);
    this.lastCommitMillis = System.currentTimeMillis();
    scheduleTask(this::checkCommitTimeout, getParameters().commitTimeoutMillis, TimeUnit.MILLISECONDS);
    cursorResetSubscription = getZk().subscribeForCursorsReset(() -> addTask(this::resetSubscriptionCursorsCallback));
}
Also used : IdleStreamWatcher(org.zalando.nakadi.service.subscription.IdleStreamWatcher) StreamKpiData(org.zalando.nakadi.metrics.StreamKpiData)

Aggregations

StreamKpiData (org.zalando.nakadi.metrics.StreamKpiData)1 IdleStreamWatcher (org.zalando.nakadi.service.subscription.IdleStreamWatcher)1