org.apache.kafka.streams.processor.PunctuationType Java Examples
The following examples show how to use
org.apache.kafka.streams.processor.PunctuationType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StockPerformanceMetricsTransformer.java From kafka-streams-in-action with Apache License 2.0 | 6 votes |
@Override @SuppressWarnings("unchecked") public void init(final ProcessorContext processorContext) { keyValueStore = (KeyValueStore) processorContext.getStateStore(stocksStateStore); this.processorContext = processorContext; this.processorContext.schedule(5000, PunctuationType.WALL_CLOCK_TIME, this::doPunctuate); final String tagKey = "task-id"; final String tagValue = processorContext.taskId().toString(); final String nodeName = "StockPerformanceProcessor_"+count.getAndIncrement(); metricsSensor = processorContext.metrics().addLatencyAndThroughputSensor("transformer-node", nodeName, "stock-performance-calculation", Sensor.RecordingLevel.DEBUG, tagKey, tagValue); }
Example #2
Source File: ReferentialTransformer.java From SkaETL with Apache License 2.0 | 5 votes |
@Override public void init(ProcessorContext context) { super.init(context); referentialStateStore = (KeyValueStore<String, Referential>) context.getStateStore(REFERENTIAL); context.schedule(5 * 60 * 1000, PunctuationType.WALL_CLOCK_TIME, (timestamp) -> flush()); }
Example #3
Source File: StockPerformanceProcessor.java From kafka-streams-in-action with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public void init(ProcessorContext processorContext) { super.init(processorContext); keyValueStore = (KeyValueStore) context().getStateStore(stateStoreName); StockPerformancePunctuator punctuator = new StockPerformancePunctuator(differentialThreshold, context(), keyValueStore); context().schedule(10000, PunctuationType.WALL_CLOCK_TIME, punctuator); }
Example #4
Source File: StockPerformanceCancellingProcessor.java From kafka-streams-in-action with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public void init(ProcessorContext processorContext) { super.init(processorContext); keyValueStore = (KeyValueStore) context().getStateStore(stateStoreName); StockPerformancePunctuator punctuator = new StockPerformancePunctuator(differentialThreshold, context(), keyValueStore); cancellable = context().schedule(10000, PunctuationType.WALL_CLOCK_TIME, punctuator); }
Example #5
Source File: StockPerformanceTransformer.java From kafka-streams-in-action with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public void init(ProcessorContext processorContext) { keyValueStore = (KeyValueStore) processorContext.getStateStore(stateStoreName); StockPerformancePunctuator punctuator = new StockPerformancePunctuator(differentialThreshold, processorContext, keyValueStore); processorContext.schedule(15000, PunctuationType.STREAM_TIME, punctuator); }
Example #6
Source File: StockPerformanceMultipleValuesTransformer.java From kafka-streams-in-action with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public void init(ProcessorContext processorContext) { this.processorContext = processorContext; keyValueStore = (KeyValueStore) this.processorContext.getStateStore(stateStoreName); this.processorContext.schedule(15000, PunctuationType.STREAM_TIME, this::punctuate); }
Example #7
Source File: StockProcessor.java From Kafka-Streams-Real-time-Stream-Processing with The Unlicense | 5 votes |
@Override public void init(ProcessorContext processorContext) { this.stateStore = (KeyValueStore<String, TickerStack>) processorContext.getStateStore(STATE_STORE_NAME); processorContext.schedule( Duration.ofSeconds(AppConfigs.secondsDelay), PunctuationType.WALL_CLOCK_TIME, new StockPunctuator(processorContext, stateStore) ); }
Example #8
Source File: MetricDataTransformer.java From adaptive-alerting with Apache License 2.0 | 4 votes |
@Override @SuppressWarnings("unchecked") public void init(ProcessorContext context) { this.context = context; this.metricDataKeyValueStore = (KeyValueStore<String, MetricData>) context.getStateStore(stateStoreName); /* * Requests to model-service to fetch detectors for metrics are throttled * This is done by buffering them in kafka KV store and periodically clearing that buffer * */ //TODO decide PUNCTUATION time this.context.schedule(200, PunctuationType.WALL_CLOCK_TIME, (timestamp) -> { if (metricDataKeyValueStore.approximateNumEntries() >= detectorMapper.optimalBatchSize()) { KeyValueIterator<String, MetricData> iter = this.metricDataKeyValueStore.all(); Map<String, MetricData> cacheMissedMetrics = new HashMap<>(); while (iter.hasNext()) { KeyValue<String, MetricData> entry = iter.next(); cacheMissedMetrics.put(entry.key, entry.value); metricDataKeyValueStore.delete(entry.key); } iter.close(); List<Map<String, String>> cacheMissedMetricTags = cacheMissedMetrics.values().stream().map(value -> value.getMetricDefinition().getTags().getKv()).collect(Collectors.toList()); if (detectorMapper.isSuccessfulDetectorMappingLookup(cacheMissedMetricTags)) { cacheMissedMetrics.forEach((originalKey, metricData) -> { List<Detector> detectors = detectorMapper.getDetectorsFromCache(metricData.getMetricDefinition()); if (!detectors.isEmpty()) { context.forward(removeSalt(originalKey), new MapperResult(metricData, detectors)); } }); } } else { log.trace("ES lookup skipped, as batch size is not optimum"); } // commit the current processing progress context.commit(); }); }