Source:
<code>private void handleDatastreamAddOrDelete() { boolean shouldRetry = false; List<Datastream> allStreams = _datastreamCache.getAllDatastreams(true); if (allStreams.isEmpty()) { _log.warn("Received a new datastream event, but there were no datastreams"); return; } boolean needInvalidate = false; for (Datastream ds : allStreams) { if (ds.getStatus() == DatastreamStatus.INITIALIZING) { try { createTopic(ds); ds.setStatus(DatastreamStatus.READY); if (!_adapter.updateDatastream(ds)) { _log.warn(String.format("Failed to update datastream: %s after initializing, " + "This datastream will not be scheduled for producing events ", ds.getName())); shouldRetry = true; } } catch (Exception e) { _log.warn("Failed to update the destination of new datastream {}", ds, e); shouldRetry = true; } } else if (isDeletingOrExpired(ds)) { _log.info("Trying to hard delete datastream (reason={})", ds, ds.getStatus() == DatastreamStatus.DELETING ? "deleting" : "expired"); hardDeleteDatastream(ds, allStreams); needInvalidate = true; } } if (!shouldRetry && needInvalidate) { <START> _datastreamCache.invalidateAllCache(); <END> } if (shouldRetry) { _dynamicMetricsManager.createOrUpdateMeter(MODULE, "handleDatastreamAddOrDelete", NUM_RETRIES, 1); if (leaderDatastreamAddOrDeleteEventScheduled.compareAndSet(false, true)) { _log.warn("Schedule retry for handling new datastream"); _executor.schedule(() -> { _eventQueue.put(CoordinatorEvent.createHandleDatastreamAddOrDeleteEvent()); leaderDatastreamAddOrDeleteEventScheduled.set(false); }, _config.getRetryIntervalMs(), TimeUnit.MILLISECONDS); } } _eventQueue.put(CoordinatorEvent.createLeaderDoAssignmentEvent()); }</code><technical_language>I do this (plus, this work invalidateAllCache invalidate datastream names). do, is remove datastream cache "hardDeleteDatastream"</technical_language>

Target:
private void handleDatastreamAddOrDelete() { boolean shouldRetry = false; List<Datastream> allStreams = _datastreamCache.getAllDatastreams(true); if (allStreams.isEmpty()) { _log.warn("Received a new datastream event, but there were no datastreams"); return; } for (Datastream ds : allStreams) { if (ds.getStatus() == DatastreamStatus.INITIALIZING) { try { createTopic(ds); ds.setStatus(DatastreamStatus.READY); if (!_adapter.updateDatastream(ds)) { _log.warn(String.format("Failed to update datastream: %s after initializing, " + "This datastream will not be scheduled for producing events ", ds.getName())); shouldRetry = true; } } catch (Exception e) { _log.warn("Failed to update the destination of new datastream {}", ds, e); shouldRetry = true; } } else if (isDeletingOrExpired(ds)) { _log.info("Trying to hard delete datastream (reason={})", ds, ds.getStatus() == DatastreamStatus.DELETING ? "deleting" : "expired"); hardDeleteDatastream(ds, allStreams); } } if (shouldRetry) { _dynamicMetricsManager.createOrUpdateMeter(MODULE, "handleDatastreamAddOrDelete", NUM_RETRIES, 1); if (leaderDatastreamAddOrDeleteEventScheduled.compareAndSet(false, true)) { _log.warn("Schedule retry for handling new datastream"); _executor.schedule(() -> { _eventQueue.put(CoordinatorEvent.createHandleDatastreamAddOrDeleteEvent()); leaderDatastreamAddOrDeleteEventScheduled.set(false); }, _config.getRetryIntervalMs(), TimeUnit.MILLISECONDS); } } _eventQueue.put(CoordinatorEvent.createLeaderDoAssignmentEvent()); }