wcarlson5 commented on a change in pull request #11479:
URL: https://github.com/apache/kafka/pull/11479#discussion_r766186102



##########
File path: 
streams/src/main/java/org/apache/kafka/streams/processor/internals/TopologyMetadata.java
##########
@@ -108,6 +124,44 @@ private void unlock() {
         version.topologyLock.unlock();
     }
 
+    public Collection<String> sourceTopicsForTopology(final String name) {
+        return builders.get(name).sourceTopicCollection();
+    }
+
+    public boolean needsUpdate(final String threadName) {
+        return threadVersions.get(threadName) < topologyVersion();
+    }
+
+    public void registerThread(final String threadName) {
+        threadVersions.put(threadName, 0L);
+    }
+
+    public void unregisterThread(final String threadName) {
+        threadVersions.remove(threadName);
+    }
+
+    public void maybeNotifyTopologyVersionWaiters(final String threadName) {
+        try {
+            lock();
+            final Iterator<TopologyVersionWaiters> iterator = 
version.activeTopologyWaiters.listIterator();
+            TopologyVersionWaiters topologyVersionWaiters;
+            threadVersions.put(threadName, topologyVersion());
+            while (iterator.hasNext()) {
+                topologyVersionWaiters = iterator.next();
+                final long topologyVersionWaitersVersion = 
topologyVersionWaiters.topologyVersion;
+                if (topologyVersionWaitersVersion <= 
threadVersions.get(threadName)) {
+                    if (threadVersions.values().stream().allMatch(t -> t >= 
topologyVersionWaitersVersion)) {
+                        topologyVersionWaiters.future.complete(null);
+                        iterator.remove();
+                        log.info("Thread {} is now on topology version {}", 
threadName, topologyVersionWaiters.topologyVersion);

Review comment:
       Those are good points. I updated the log and method name in a follow up. 
I thought about extracting the version update to the caller but I would rather 
have the coupled so I don't have to worry about them getting out of sync.
   
   https://github.com/apache/kafka/pull/11589




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to