fix for a failed sub batch

Change-Id: Ie686efd41a6815f913e06d1167f2282334a98ecb
diff --git a/core/net/src/main/java/org/onlab/onos/net/flow/impl/FlowRuleManager.java b/core/net/src/main/java/org/onlab/onos/net/flow/impl/FlowRuleManager.java
index fa8e947..ad48ae7 100644
--- a/core/net/src/main/java/org/onlab/onos/net/flow/impl/FlowRuleManager.java
+++ b/core/net/src/main/java/org/onlab/onos/net/flow/impl/FlowRuleManager.java
@@ -401,7 +401,7 @@
             CompletedBatchOperation completed;
             for (Future<CompletedBatchOperation> future : futures) {
                 completed = future.get();
-                success = validateBatchOperation(failed, completed, future);
+                success = validateBatchOperation(failed, completed);
             }
 
             return finalizeBatchOperation(success, failed);
@@ -426,14 +426,13 @@
                 long now = System.nanoTime();
                 long thisTimeout = end - now;
                 completed = future.get(thisTimeout, TimeUnit.NANOSECONDS);
-                success = validateBatchOperation(failed, completed, future);
+                success = validateBatchOperation(failed, completed);
             }
             return finalizeBatchOperation(success, failed);
         }
 
         private boolean validateBatchOperation(List<FlowEntry> failed,
-                CompletedBatchOperation completed,
-                Future<CompletedBatchOperation> future) {
+                CompletedBatchOperation completed) {
 
             if (isCancelled()) {
                 throw new CancellationException();
diff --git a/providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/OpenFlowRuleProvider.java b/providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/OpenFlowRuleProvider.java
index a815f69..f52255a 100644
--- a/providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/OpenFlowRuleProvider.java
+++ b/providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/OpenFlowRuleProvider.java
@@ -62,6 +62,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.CancellationException;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutionException;
@@ -166,7 +167,14 @@
             FlowRule flowRule = fbe.getTarget();
             OpenFlowSwitch sw = controller.getSwitch(Dpid.dpid(flowRule.deviceId().uri()));
             if (sw == null) {
-                log.warn("WTF {}", flowRule.deviceId());
+                /*
+                 * if a switch we are supposed to install to is gone then
+                 * cancel (ie. rollback) the work that has been done so far
+                 * and return the associated future.
+                 */
+                InstallationFuture failed = new InstallationFuture(sws, fmXids);
+                failed.cancel(true);
+                return failed;
             }
             sws.add(new Dpid(sw.getId()));
             FlowModBuilder builder = new FlowModBuilder(flowRule, sw.factory());
@@ -377,7 +385,7 @@
 
 
         public void satisfyRequirement(Dpid dpid) {
-            log.warn("Satisfaction from switch {}", dpid);
+            log.debug("Satisfaction from switch {}", dpid);
             removeRequirement(dpid);
         }
 
@@ -432,7 +440,6 @@
                 throws InterruptedException, ExecutionException,
                 TimeoutException {
             if (countDownLatch.await(timeout, unit)) {
-
                 this.state = BatchState.FINISHED;
                 return new CompletedBatchOperation(ok.get(), offendingFlowMods);
             }