Source:
<code>private void createTaskStores(ContainerModel containerModel, JobContext jobContext, ContainerContext containerContext, Map<String, StorageEngineFactory<Object, Object>> storageEngineFactories, Map<String, SystemStream> changelogSystemStreams, Map<String, Serde<Object>> serdes, Map<TaskName, TaskInstanceMetrics> taskInstanceMetrics, Map<TaskName, TaskInstanceCollector> taskInstanceCollectors, StorageEngineFactory.StoreMode storeMode) { for (Map.Entry<TaskName, TaskModel> task : containerModel.getTasks().entrySet()) { TaskName taskName = task.getKey(); TaskModel taskModel = task.getValue(); for (String storeName : storageEngineFactories.keySet()) { if (this.taskStores.get(taskName) == null) { this.taskStores.put(taskName, new HashMap<>()); } if (this.taskStores.get(taskName).containsKey(storeName) && this.taskStores.get(taskName) .get(storeName) .getStoreProperties() .isPersistedToDisk()) { StorageEngine storageEngine = <START> createStore(storeName, taskName, taskModel, jobContext, containerContext, storageEngineFactories, <END> changelogSystemStreams, serdes, taskInstanceMetrics, taskInstanceCollectors, storeMode); this.taskStores.get(taskName).put(storeName, storageEngine); LOG.info("Re-created store for task because it a persistent store", storeName, taskName); } else if (!this.taskStores.get(taskName).containsKey(storeName)) { StorageEngine storageEngine = createStore(storeName, taskName, taskModel, jobContext, containerContext, storageEngineFactories, changelogSystemStreams, serdes, taskInstanceMetrics, taskInstanceCollectors, storeMode); this.taskStores.get(taskName).put(storeName, storageEngine); LOG.info("Created store for task {}", storeName, taskName); } else { LOG.info("Not re-creating store for task because it a non-persistent store", storeName, taskName); } } } }</code><technical_language>Currently,createTaskStores is currently invoked - construction another start.. Instead, prefer explicit method - recreatePersistentStoresInRWMode() instead of complexity hidden in createStores</technical_language>

Target:
private Map<TaskName, Map<String, StorageEngine>> createTaskStores(ContainerModel containerModel, JobContext jobContext, ContainerContext containerContext, Map<String, StorageEngineFactory<Object, Object>> storageEngineFactories, Map<String, SystemStream> changelogSystemStreams, Map<String, Serde<Object>> serdes, Map<TaskName, TaskInstanceMetrics> taskInstanceMetrics, Map<TaskName, TaskInstanceCollector> taskInstanceCollectors, StorageEngineFactory.StoreMode storeMode) { Map<TaskName, Map<String, StorageEngine>> taskStores = new HashMap<>(); for (Map.Entry<TaskName, TaskModel> task : containerModel.getTasks().entrySet()) { TaskName taskName = task.getKey(); TaskModel taskModel = task.getValue(); if (!taskStores.containsKey(taskName)) { taskStores.put(taskName, new HashMap<>()); } for (String storeName : storageEngineFactories.keySet()) { StorageEngine storageEngine = createStore(storeName, taskName, taskModel, jobContext, containerContext, storageEngineFactories, changelogSystemStreams, serdes, taskInstanceMetrics, taskInstanceCollectors, storeMode); taskStores.get(taskName).put(storeName, storageEngine); LOG.info("Created store for task {}", storeName, taskName); } } return taskStores; }