@SuppressWarnings("unchecked") private void initInternal(final ProcessorContext context) { this.context = (InternalProcessorContext) context; final String topic = ProcessorStateManager.storeChangelogTopic(context.applicationId(), underlying.name()); serdes = new StateSerdes<>(topic, keySerde == null ? (Serde<K>) context.keySerde() : keySerde, valueSerde == null ? (Serde<V>) context.valueSerde() : valueSerde); bytesSerdes = new StateSerdes<>(topic, Serdes.Bytes(), Serdes.ByteArray()); name = context.taskId() + "-" + underlying.name(); cache = this.context.getCache(); cache.addDirtyEntryFlushListener(name, new ThreadCache.DirtyEntryFlushListener() { @Override public void apply(final List<ThreadCache.DirtyEntry> entries) { for (final ThreadCache.DirtyEntry entry : entries) { final byte[] binaryWindowKey = cacheFunction.key(entry.key()).get(); final long timestamp = WindowKeySchema.extractStoreTimestamp(binaryWindowKey); final Windowed<K> windowedKey = WindowKeySchema.fromStoreKey(binaryWindowKey, windowSize, serdes); final Bytes key = Bytes.wrap(WindowKeySchema.extractStoreKeyBytes(binaryWindowKey)); maybeForward(entry, key, windowedKey, (InternalProcessorContext) context); underlying.put(key, entry.newValue(), timestamp); } } }); }
@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())); }