rpuch commented on code in PR #3009:
URL: https://github.com/apache/ignite-3/pull/3009#discussion_r1446973414


##########
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());
+        for (RecoveryDescriptor descriptor : descriptors) {
+            disposeFutures.add(blockAndDisposeDescriptor(descriptor, 
exceptionToFailSendFutures));

Review Comment:
   `blockAndDisposeDescriptor()` (if called from a non-Netty thread) never 
blocks. `close()` is async and just causes a Netty task to be added to the 
corresponding Netty thread; the `while` loop will make at most 2 iterations. So 
it seems there's no point in parallelizing this.



-- 
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]

Reply via email to