Brian O'Connor

ONOS-5271 pendingDevices is used to track installation progress,

thus it is mutable.

This reverts commit 4b3e2f67.

Change-Id: I624fafd95c61766b3952263612a2a44f85d022a8
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
16 package org.onosproject.net.flow.impl; 16 package org.onosproject.net.flow.impl;
17 17
18 import com.google.common.collect.ArrayListMultimap; 18 import com.google.common.collect.ArrayListMultimap;
19 -import com.google.common.collect.ImmutableSet;
20 import com.google.common.collect.Iterables; 19 import com.google.common.collect.Iterables;
21 import com.google.common.collect.Lists; 20 import com.google.common.collect.Lists;
22 import com.google.common.collect.Maps; 21 import com.google.common.collect.Maps;
...@@ -580,22 +579,22 @@ public class FlowRuleManager ...@@ -580,22 +579,22 @@ public class FlowRuleManager
580 private class FlowOperationsProcessor implements Runnable { 579 private class FlowOperationsProcessor implements Runnable {
581 // Immutable 580 // Immutable
582 private final FlowRuleOperations fops; 581 private final FlowRuleOperations fops;
583 - private final ImmutableSet<DeviceId> pendingDevices;
584 582
585 // Mutable 583 // Mutable
586 private final List<Set<FlowRuleOperation>> stages; 584 private final List<Set<FlowRuleOperation>> stages;
585 + private final Set<DeviceId> pendingDevices;
587 private boolean hasFailed = false; 586 private boolean hasFailed = false;
588 587
589 FlowOperationsProcessor(FlowRuleOperations ops) { 588 FlowOperationsProcessor(FlowRuleOperations ops) {
590 this.stages = Lists.newArrayList(ops.stages()); 589 this.stages = Lists.newArrayList(ops.stages());
591 this.fops = ops; 590 this.fops = ops;
592 - this.pendingDevices = ImmutableSet.of(); 591 + this.pendingDevices = new HashSet<>();
593 } 592 }
594 593
595 - FlowOperationsProcessor(FlowOperationsProcessor src, boolean hasFailed, Set<DeviceId> pendingDevices) { 594 + FlowOperationsProcessor(FlowOperationsProcessor src, boolean hasFailed) {
596 this.fops = src.fops; 595 this.fops = src.fops;
597 this.stages = Lists.newArrayList(src.stages); 596 this.stages = Lists.newArrayList(src.stages);
598 - this.pendingDevices = ImmutableSet.copyOf(pendingDevices); 597 + this.pendingDevices = new HashSet<>(src.pendingDevices);
599 this.hasFailed = hasFailed; 598 this.hasFailed = hasFailed;
600 } 599 }
601 600
...@@ -615,33 +614,28 @@ public class FlowRuleManager ...@@ -615,33 +614,28 @@ public class FlowRuleManager
615 perDeviceBatches.put(op.rule().deviceId(), 614 perDeviceBatches.put(op.rule().deviceId(),
616 new FlowRuleBatchEntry(mapOperationType(op.type()), op.rule())); 615 new FlowRuleBatchEntry(mapOperationType(op.type()), op.rule()));
617 } 616 }
618 - ImmutableSet<DeviceId> newPendingDevices = ImmutableSet.<DeviceId>builder() 617 + pendingDevices.addAll(perDeviceBatches.keySet());
619 - .addAll(pendingDevices)
620 - .addAll(perDeviceBatches.keySet())
621 - .build();
622 618
623 for (DeviceId deviceId : perDeviceBatches.keySet()) { 619 for (DeviceId deviceId : perDeviceBatches.keySet()) {
624 long id = idGenerator.getNewId(); 620 long id = idGenerator.getNewId();
625 final FlowRuleBatchOperation b = new FlowRuleBatchOperation(perDeviceBatches.get(deviceId), 621 final FlowRuleBatchOperation b = new FlowRuleBatchOperation(perDeviceBatches.get(deviceId),
626 deviceId, id); 622 deviceId, id);
627 - pendingFlowOperations.put(id, new FlowOperationsProcessor(this, hasFailed, newPendingDevices)); 623 + pendingFlowOperations.put(id, this);
628 deviceInstallers.execute(() -> store.storeBatch(b)); 624 deviceInstallers.execute(() -> store.storeBatch(b));
629 } 625 }
630 } 626 }
631 627
632 synchronized void satisfy(DeviceId devId) { 628 synchronized void satisfy(DeviceId devId) {
633 - Set<DeviceId> newPendingDevices = new HashSet<>(pendingDevices); 629 + pendingDevices.remove(devId);
634 - newPendingDevices.remove(devId); 630 + if (pendingDevices.isEmpty()) {
635 - if (newPendingDevices.isEmpty()) { 631 + operationsService.execute(new FlowOperationsProcessor(this, hasFailed));
636 - operationsService.execute(new FlowOperationsProcessor(this, hasFailed, newPendingDevices));
637 } 632 }
638 } 633 }
639 634
640 synchronized void fail(DeviceId devId, Set<? extends FlowRule> failures) { 635 synchronized void fail(DeviceId devId, Set<? extends FlowRule> failures) {
641 - Set<DeviceId> newPendingDevices = new HashSet<>(pendingDevices); 636 + pendingDevices.remove(devId);
642 - newPendingDevices.remove(devId); 637 + if (pendingDevices.isEmpty()) {
643 - if (newPendingDevices.isEmpty()) { 638 + operationsService.execute(new FlowOperationsProcessor(this, true));
644 - operationsService.execute(new FlowOperationsProcessor(this, true, newPendingDevices));
645 } 639 }
646 640
647 FlowRuleOperations.Builder failedOpsBuilder = FlowRuleOperations.builder(); 641 FlowRuleOperations.Builder failedOpsBuilder = FlowRuleOperations.builder();
......