rpuch commented on code in PR #3009:
URL: https://github.com/apache/ignite-3/pull/3009#discussion_r1446961103
##########
modules/network/src/main/java/org/apache/ignite/internal/network/netty/ConnectionManager.java:
##########
@@ -388,20 +432,38 @@ public void stop() {
return;
}
- Stream<CompletableFuture<Void>> stream = Stream.concat(Stream.concat(
+ assert stopping.get();
+
+ Stream<CompletableFuture<Void>> stopFutures = Stream.concat(
+ Stream.concat(
clients.values().stream().map(NettyClient::stop),
Stream.of(server.stop())
),
channels.values().stream().map(NettySender::closeAsync)
);
+ stopFutures = Stream.concat(stopFutures,
Stream.of(disposeDescriptors()));
- CompletableFuture<Void> stopFut =
CompletableFuture.allOf(stream.toArray(CompletableFuture<?>[]::new));
+ CompletableFuture<Void> finalStopFuture =
allOf(stopFutures.toArray(CompletableFuture<?>[]::new));
try {
- stopFut.join();
+ finalStopFuture.join();
} catch (Exception e) {
LOG.warn("Failed to stop connection manager [reason={}]",
e.getMessage());
}
+
+ IgniteUtils.shutdownAndAwaitTermination(connectionMaintenanceExecutor,
10, TimeUnit.SECONDS);
+ }
+
+ private CompletableFuture<Void> disposeDescriptors() {
+ Exception exceptionToFailSendFutures = new NodeStoppingException();
+
+ Collection<RecoveryDescriptor> descriptors =
descriptorProvider.getAllRecoveryDescriptors();
+ List<CompletableFuture<Void>> disposeFutures = new
ArrayList<>(descriptors.size());
Review Comment:
Yes it can, but the resulting code would be a bit more complex because it
would involve indices, which are not there in the current code. The alternative
with the array would require a coiuple allocations less, but this code is not
on the hot path. I think it's better to make the code just a bit simpler than
save those couple of allocations.
--
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]