Fixed YANG - GetAsyncReply
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / connection / SwitchConnectionProviderImpl.java
index 1ce61d19a693e968f263bc7fd44918d89eca48b9..3a540449e4f65e657850318dadcb66ce12e151c1 100644 (file)
@@ -57,12 +57,27 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider {
     }
 
     @Override
-    public Future<Boolean> shutdown() {
+    public Future<List<Boolean>> shutdown() {
         LOG.debug("shutdown summoned");
-        for (ServerFacade server : serverLot) {
-            server.shutdown();
+        ListenableFuture<List<Boolean>> result = SettableFuture.create();
+        try {
+            List<ListenableFuture<Boolean>> shutdownChain = new ArrayList<>();
+            for (ServerFacade server : serverLot) {
+                ListenableFuture<Boolean> shutdownFuture = server.shutdown();
+                shutdownChain.add(shutdownFuture);
+            }
+            
+            if (!shutdownChain.isEmpty()) {
+                result = Futures.allAsList(shutdownChain);
+            } else {
+                throw new IllegalStateException("no servers configured");
+            }
+        } catch (Exception e) {
+            SettableFuture<List<Boolean>> exFuture = SettableFuture.create();
+            exFuture.setException(e);
+            result = exFuture;
         }
-        return null;
+        return result;
     }
 
     @Override