arunpandianp commented on code in PR #41549:
URL: https://github.com/apache/beam/pull/41549#discussion_r4793578348
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/streaming/harness/FanOutStreamingEngineWorkerHarness.java:
##########
@@ -331,39 +348,64 @@ private synchronized void
consumeWindmillWorkerEndpoints(WindmillEndpoints newWi
@CanIgnoreReturnValue
private CompletableFuture<Void> closeStreamsNotIn(WindmillEndpoints
newWindmillEndpoints) {
StreamingEngineBackends currentBackends = backends.get();
- Stream<CompletableFuture<Void>> closeStreamFutures =
- currentBackends.windmillStreams().entrySet().stream()
- .filter(
- connectionAndStream ->
- !newWindmillEndpoints
- .windmillEndpoints()
- .contains(connectionAndStream.getKey()))
- .map(
- entry ->
- CompletableFuture.runAsync(
- () -> closeStreamSender(entry.getKey(),
entry.getValue()),
- windmillStreamManager));
-
- Set<Endpoint> newGlobalDataEndpoints =
- new HashSet<>(newWindmillEndpoints.globalDataEndpoints().values());
- Stream<CompletableFuture<Void>> closeGlobalDataStreamFutures =
- currentBackends.globalDataStreams().values().stream()
- .filter(sender ->
!newGlobalDataEndpoints.contains(sender.endpoint()))
+ ImmutableSet<WindmillServiceAddress> activeDirectAddresses =
+ Streams.concat(
+ newWindmillEndpoints.windmillEndpoints().stream(),
+ newWindmillEndpoints.globalDataEndpoints().values().stream())
+ .map(Endpoint::directEndpoint)
+ .filter(Optional::isPresent)
+ .map(Optional::get)
+ .collect(toImmutableSet());
+
+ List<Pair<Endpoint, StreamSender>> streamsToClose = new ArrayList<>();
+ currentBackends
+ .windmillStreams()
+ .forEach(
+ (endpoint, sender) -> {
+ if
(!newWindmillEndpoints.windmillEndpoints().contains(endpoint)) {
Review Comment:
activeDirectAddresses are WindmillServiceAddresses and cannot be compared
directly against an Endpoint. Endpoint contains WindmillServiceAddress and a
backend_token. Multiple endpoints can map to a single WindmillServiceAddress.
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/streaming/harness/FanOutStreamingEngineWorkerHarness.java:
##########
@@ -331,39 +348,64 @@ private synchronized void
consumeWindmillWorkerEndpoints(WindmillEndpoints newWi
@CanIgnoreReturnValue
private CompletableFuture<Void> closeStreamsNotIn(WindmillEndpoints
newWindmillEndpoints) {
StreamingEngineBackends currentBackends = backends.get();
- Stream<CompletableFuture<Void>> closeStreamFutures =
- currentBackends.windmillStreams().entrySet().stream()
- .filter(
- connectionAndStream ->
- !newWindmillEndpoints
- .windmillEndpoints()
- .contains(connectionAndStream.getKey()))
- .map(
- entry ->
- CompletableFuture.runAsync(
- () -> closeStreamSender(entry.getKey(),
entry.getValue()),
- windmillStreamManager));
-
- Set<Endpoint> newGlobalDataEndpoints =
- new HashSet<>(newWindmillEndpoints.globalDataEndpoints().values());
- Stream<CompletableFuture<Void>> closeGlobalDataStreamFutures =
- currentBackends.globalDataStreams().values().stream()
- .filter(sender ->
!newGlobalDataEndpoints.contains(sender.endpoint()))
+ ImmutableSet<WindmillServiceAddress> activeDirectAddresses =
+ Streams.concat(
+ newWindmillEndpoints.windmillEndpoints().stream(),
+ newWindmillEndpoints.globalDataEndpoints().values().stream())
+ .map(Endpoint::directEndpoint)
+ .filter(Optional::isPresent)
+ .map(Optional::get)
+ .collect(toImmutableSet());
+
+ List<Pair<Endpoint, StreamSender>> streamsToClose = new ArrayList<>();
+ currentBackends
+ .windmillStreams()
+ .forEach(
+ (endpoint, sender) -> {
+ if
(!newWindmillEndpoints.windmillEndpoints().contains(endpoint)) {
+ streamsToClose.add(Pair.of(endpoint, sender));
+ }
+ });
+
+ ImmutableMap<String, Endpoint> newGlobalDataEndpoints =
+ newWindmillEndpoints.globalDataEndpoints();
+ currentBackends
+ .globalDataStreams()
+ .forEach(
+ (tag, sender) -> {
+ if (!sender.endpoint().equals(newGlobalDataEndpoints.get(tag))) {
Review Comment:
Same, activeDirectAddresses are WindmillServiceAddresses and cannot be
compared directly against an Endpoint. Endpoint contains WindmillServiceAddress
and a backend_token. Multiple endpoints can map to a single
WindmillServiceAddress.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]