@Override public boolean persistent() { return innerState.persistent(); }
@Override public boolean persistent() { return innerState.persistent(); }
@Override public void checkpoint(final Map<TopicPartition, Long> checkpointableOffsets) { this.checkpointableOffsets.putAll(changelogReader.restoredOffsets()); for (final StateStore store : stores.values()) { final String storeName = store.name(); // only checkpoint the offset to the offsets file if // it is persistent AND changelog enabled if (store.persistent() && storeToChangelogTopic.containsKey(storeName)) { final String changelogTopic = storeToChangelogTopic.get(storeName); final TopicPartition topicPartition = new TopicPartition(changelogTopic, getPartition(storeName)); if (checkpointableOffsets.containsKey(topicPartition)) { // store the last offset + 1 (the log position after restoration) this.checkpointableOffsets.put(topicPartition, checkpointableOffsets.get(topicPartition) + 1); } else if (standbyRestoredOffsets.containsKey(topicPartition)) { this.checkpointableOffsets.put(topicPartition, standbyRestoredOffsets.get(topicPartition)); } } } // write the checkpoint file before closing if (checkpoint == null) { checkpoint = new OffsetCheckpoint(new File(baseDir, CHECKPOINT_FILE_NAME)); } log.trace("Writing checkpoint: {}", this.checkpointableOffsets); try { checkpoint.write(this.checkpointableOffsets); } catch (final IOException e) { log.warn("Failed to write offset checkpoint file to {}: {}", checkpoint, e); } }
checkpointableOffsets.get(storePartition), offsetLimit(storePartition), store.persistent(), storeName);
public GlobalStateManagerImpl(final LogContext logContext, final ProcessorTopology topology, final Consumer<byte[], byte[]> globalConsumer, final StateDirectory stateDirectory, final StateRestoreListener stateRestoreListener, final StreamsConfig config) { super(stateDirectory.globalStateDir(), StreamsConfig.EXACTLY_ONCE.equals(config.getString(StreamsConfig.PROCESSING_GUARANTEE_CONFIG))); // Find non persistent store's topics final Map<String, String> storeToChangelogTopic = topology.storeToChangelogTopic(); for (final StateStore store : topology.globalStateStores()) { if (!store.persistent()) { globalNonPersistentStoresTopics.add(storeToChangelogTopic.get(store.name())); } } this.log = logContext.logger(GlobalStateManagerImpl.class); this.topology = topology; this.globalConsumer = globalConsumer; this.stateDirectory = stateDirectory; this.stateRestoreListener = stateRestoreListener; this.retries = config.getInt(StreamsConfig.RETRIES_CONFIG); this.retryBackoffMs = config.getLong(StreamsConfig.RETRY_BACKOFF_MS_CONFIG); this.pollTime = Duration.ofMillis(config.getLong(StreamsConfig.POLL_MS_CONFIG)); }