@@ -144,8 +144,12 @@ public InternalTopologyBuilder(final TopologyConfig topologyConfigs) {
144
144
145
145
private String applicationId = null ;
146
146
147
+ // keyed by subtopology id
147
148
private Map <Integer , Set <String >> nodeGroups = null ;
148
149
150
+ // keyed by subtopology id
151
+ private Map <Integer , Set <String >> subtopologyIdToStateStoreNames = null ;
152
+
149
153
// The name of the topology this builder belongs to, or null if this is not a NamedTopology
150
154
private final String topologyName ;
151
155
// TODO KAFKA-13336: we can remove this reference once we make the Topology/NamedTopology class into an interface and implement it
@@ -937,14 +941,15 @@ private int putNodeGroupName(final String nodeName,
937
941
* @return the full topology minus any global state
938
942
*/
939
943
public synchronized ProcessorTopology buildTopology () {
940
- final Set <String > nodeGroup = new HashSet <>();
944
+ final Set <String > allNodes = new HashSet <>();
941
945
for (final Set <String > value : nodeGroups ().values ()) {
942
- nodeGroup .addAll (value );
946
+ allNodes .addAll (value );
943
947
}
944
- nodeGroup .removeAll (globalNodeGroups ());
948
+ allNodes .removeAll (globalNodeGroups ());
945
949
946
950
initializeSubscription ();
947
- return build (nodeGroup );
951
+ initializeSubtopologyIdToStateStoreNamesMap ();
952
+ return build (allNodes );
948
953
}
949
954
950
955
/**
@@ -1500,6 +1505,34 @@ private boolean isGlobalSource(final String nodeName) {
1500
1505
return false ;
1501
1506
}
1502
1507
1508
+ public Set <String > stateStoreNamesForSubtopology (final int subtopologyId ) {
1509
+ return subtopologyIdToStateStoreNames .get (subtopologyId );
1510
+ }
1511
+
1512
+ private void initializeSubtopologyIdToStateStoreNamesMap () {
1513
+ final Map <Integer , Set <String >> storeNames = new HashMap <>();
1514
+
1515
+ for (final Map .Entry <Integer , Set <String >> nodeGroup : makeNodeGroups ().entrySet ()) {
1516
+ final Set <String > subtopologyNodes = nodeGroup .getValue ();
1517
+ final boolean isNodeGroupOfGlobalStores = nodeGroupContainsGlobalSourceNode (subtopologyNodes );
1518
+
1519
+ if (!isNodeGroupOfGlobalStores ) {
1520
+ final int subtopologyId = nodeGroup .getKey ();
1521
+ final Set <String > subtopologyStoreNames = new HashSet <>();
1522
+
1523
+ for (final String nodeName : subtopologyNodes ) {
1524
+ final AbstractNode node = nodeFactories .get (nodeName ).describe ();
1525
+ if (node instanceof Processor ) {
1526
+ subtopologyStoreNames .addAll (((Processor ) node ).stores ());
1527
+ }
1528
+ }
1529
+
1530
+ storeNames .put (subtopologyId , subtopologyStoreNames );
1531
+ }
1532
+ }
1533
+ subtopologyIdToStateStoreNames = storeNames ;
1534
+ }
1535
+
1503
1536
public TopologyDescription describe () {
1504
1537
final TopologyDescription description = new TopologyDescription (topologyName );
1505
1538
0 commit comments