static void addTags(ProcessorContext processorContext, SpanCustomizer result) { result.tag(KafkaStreamsTags.KAFKA_STREAMS_APPLICATION_ID_TAG, processorContext.applicationId()); result.tag(KafkaStreamsTags.KAFKA_STREAMS_TASK_ID_TAG, processorContext.taskId().toString()); }
@Override public DeserializationHandlerResponse handle( final ProcessorContext context, final ConsumerRecord<byte[], byte[]> record, final Exception exception ) { log.warn( "Exception caught during Deserialization, " + "taskId: {}, topic: {}, partition: {}, offset: {}", context.taskId(), record.topic(), record.partition(), record.offset(), exception ); StreamsErrorCollector.recordError(context.applicationId(), record.topic()); return DeserializationHandlerResponse.CONTINUE; }
@Override public String applicationId() { return delegate.applicationId(); }
private StoreChangeLogger(final String storeName, final ProcessorContext context, final int partition, final StateSerdes<K, V> serialization) { this.topic = ProcessorStateManager.storeChangelogTopic(context.applicationId(), storeName); this.context = context; this.partition = partition; this.serialization = serialization; this.collector = ((RecordCollector.Supplier) context).recordCollector(); }
@Override public void init(final ProcessorContext context) { // Hold onto the context so that we can forward results. this.context = context; final String appId = context.applicationId(); final UUID queryId = UuidUtils.extractUuidFromStringEnd(appId); // Get a reference to the state store that keeps track of what can be joined with. final KeyValueStore<String, VisibilityBindingSet> stateStore = (KeyValueStore<String, VisibilityBindingSet>) context.getStateStore( stateStoreName ); joinStateStore = new KeyValueJoinStateStore( stateStore, queryId.toString(), joinVars, allVars ); }
@Override public void init(final ProcessorContext context, final StateStore root) { context.register(root, (RecordBatchingStateRestoreCallback) this::restoreBatch); if (loggingEnabled) { collector = ((RecordCollector.Supplier) context).recordCollector(); changelogTopic = ProcessorStateManager.storeChangelogTopic(context.applicationId(), storeName); } open = true; }
@Override public void init(final ProcessorContext context, final StateStore root) { initInternal(context); underlying.init(context, root); keySchema.init(context.applicationId()); }
public void init(final ProcessorContext context, final StateStore root) { topic = ProcessorStateManager.storeChangelogTopic(context.applicationId(), root.name()); initInternal((InternalProcessorContext) context); bytesStore.init(context, root); }
private StoreChangeFlushingLogger(String storeName, ProcessorContext context, int partition, StateSerdes<K, V> serialization) { this.topic = ProcessorStateManager.storeChangelogTopic(context.applicationId(), storeName); this.context = context; this.partition = partition; this.serialization = serialization; this.collector = ((RecordCollector.Supplier) context).recordCollector(); // Twitter Added this.taskId = context.taskId(); this.keySerializer = serialization.keySerializer(); this.valueSerializer = serialization.valueSerializer(); }
@Override @SuppressWarnings("unchecked") public void init(final ProcessorContext context, final StateStore root) { this.context = context; // construct the serde serdes = new StateSerdes<>(ProcessorStateManager.storeChangelogTopic(context.applicationId(), bytesStore.name()), keySerde == null ? (Serde<K>) context.keySerde() : keySerde, valueSerde == null ? (Serde<V>) context.valueSerde() : valueSerde); bytesStore.init(context, root); }
@Override @SuppressWarnings("unchecked") public void init(final ProcessorContext context, final StateStore root) { final String storeName = bytesStore.name(); topic = ProcessorStateManager.storeChangelogTopic(context.applicationId(), storeName); serdes = new StateSerdes<>( topic, keySerde == null ? (Serde<K>) context.keySerde() : keySerde, aggSerde == null ? (Serde<AGG>) context.valueSerde() : aggSerde); bytesStore.init(context, root); }
public void init(final ProcessorContext context, final StateStore root) { final String storeName = bytesStore.name(); topic = ProcessorStateManager.storeChangelogTopic(context.applicationId(), storeName); bytesStore.init(context, root); serdes = new StateSerdes<>(topic, new AggregateKeySerde<>(), new KryoSerDe<>()); }
@Override public void init(final ProcessorContext context, final StateStore root) { this.context = context; bytesStore.init(context, root); final String topic = ProcessorStateManager.storeChangelogTopic(context.applicationId(), bytesStore.name()); changeLogger = new StoreChangeLogger<>( name(), context, new StateSerdes<>(topic, Serdes.Bytes(), Serdes.ByteArray())); }
@Override @SuppressWarnings("unchecked") public void init(final ProcessorContext context, final StateStore root) { final String storeName = bytesStore.name(); topic = ProcessorStateManager.storeChangelogTopic(context.applicationId(), storeName); final Serde<MatchedEvent<K, V>> valueSerDes = new MatchedEventSerde<>( keySerde == null ? (Serde<K>) context.keySerde() : keySerde, valueSerde == null ? (Serde<V>) context.valueSerde() : valueSerde); this.serdes = new StateSerdes<>(topic, new KryoSerDe<Matched>(), valueSerDes); bytesStore.init(context, root); }
@Override public void init(final ProcessorContext context, final StateStore root) { bytesStore.init(context, root); final String topic = ProcessorStateManager.storeChangelogTopic( context.applicationId(), bytesStore.name()); changeLogger = new StoreChangeLogger<>( name(), context, new StateSerdes<>(topic, Serdes.Bytes(), Serdes.ByteArray())); }
public void init(final ProcessorContext context, final StateStore root) { final String storeName = bytesStore.name(); topic = ProcessorStateManager.storeChangelogTopic(context.applicationId(), storeName); bytesStore.init(context, root); Serde<K> kSerde = keySerde == null ? (Serde<K>) context.keySerde() : keySerde; Serde<NFAStates<K, V>> serdes = new NFAStateValueSerde<>( new ComputationStageSerde<>(stages, kSerde, valueSerde == null ? (Serde<V>) context.valueSerde() : valueSerde)); this.serdes = new StateSerdes<>(topic, new RunnedKeySerde<>(kSerde), serdes); }
@Override public void init(final ProcessorContext context, final StateStore root) { inner.init(context, root); final String topic = ProcessorStateManager.storeChangelogTopic(context.applicationId(), inner.name()); this.changeLogger = new StoreChangeLogger<>(inner.name(), context, new StateSerdes<>(topic, Serdes.Bytes(), Serdes.ByteArray())); // if the inner store is an LRU cache, add the eviction listener to log removed record if (inner instanceof MemoryLRUCache) { ((MemoryLRUCache<Bytes, byte[]>) inner).whenEldestRemoved(new MemoryLRUCache.EldestEntryRemovalListener<Bytes, byte[]>() { @Override public void apply(final Bytes key, final byte[] value) { // pass null to indicate removal changeLogger.logChange(key, null); } }); } }
@Override @SuppressWarnings("unchecked") public void init(final ProcessorContext context, final StateStore root) { inner.init(context, root); // construct the serde final StateSerdes<K, V> serdes = new StateSerdes<>( ProcessorStateManager.storeChangelogTopic(context.applicationId(), inner.name()), keySerde == null ? (Serde<K>) context.keySerde() : keySerde, valueSerde == null ? (Serde<V>) context.valueSerde() : valueSerde); this.changeLogger = new StoreChangeLogger<>(inner.name(), context, serdes); // if the inner store is an LRU cache, add the eviction listener to log removed record if (inner instanceof MemoryLRUCache) { ((MemoryLRUCache<K, V>) inner).whenEldestRemoved(new MemoryNavigableLRUCache.EldestEntryRemovalListener<K, V>() { @Override public void apply(final K key, final V value) { removed(key); } }); } }
@SuppressWarnings("unchecked") private void initInternal(final ProcessorContext context) { this.context = (InternalProcessorContext) context; this.serdes = new StateSerdes<>(ProcessorStateManager.storeChangelogTopic(context.applicationId(), underlying.name()), keySerde == null ? (Serde<K>) context.keySerde() : keySerde, valueSerde == null ? (Serde<V>) context.valueSerde() : valueSerde); this.cache = this.context.getCache(); this.cacheName = ThreadCache.nameSpaceFromTaskIdAndStore(context.taskId().toString(), underlying.name()); cache.addDirtyEntryFlushListener(cacheName, new ThreadCache.DirtyEntryFlushListener() { @Override public void apply(final List<ThreadCache.DirtyEntry> entries) { for (final ThreadCache.DirtyEntry entry : entries) { putAndMaybeForward(entry, (InternalProcessorContext) context); } } }); }
@Override @SuppressWarnings("unchecked") public void init(final ProcessorContext context, final StateStore root) { // construct the serde this.serdes = new StateSerdes<>( ProcessorStateManager.storeChangelogTopic(context.applicationId(), name), keySerde == null ? (Serde<K>) context.keySerde() : keySerde, valueSerde == null ? (Serde<V>) context.valueSerde() : valueSerde); if (root != null) { // register the store context.register(root, (key, value) -> { // this is a delete if (value == null) { delete(serdes.keyFrom(key)); } else { put(serdes.keyFrom(key), serdes.valueFrom(value)); } }); } this.open = true; }