From c9b64dcabdbee48995894ef9d4e55af20dbd85f1 Mon Sep 17 00:00:00 2001 From: Brian O'Connor Date: Tue, 13 Sep 2016 23:01:07 +0000 Subject: [PATCH] ONOS-5271 pendingDevices is used to track installation progress, thus it is mutable. This reverts commit e38b866af5ad7ec3938ad662a46798f535a9fad8. Change-Id: Ie71a4cf2d795e2fd781e96fc1274cfcbfc659cb5 --- .../net/flow/impl/FlowRuleManager.java | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleManager.java b/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleManager.java index f1de6fadee..9e0db6a397 100644 --- a/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleManager.java +++ b/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleManager.java @@ -16,7 +16,6 @@ package org.onosproject.net.flow.impl; import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -601,22 +600,22 @@ public class FlowRuleManager private class FlowOperationsProcessor implements Runnable { // Immutable private final FlowRuleOperations fops; - private final ImmutableSet pendingDevices; // Mutable private final List> stages; + private final Set pendingDevices; private boolean hasFailed = false; FlowOperationsProcessor(FlowRuleOperations ops) { this.stages = Lists.newArrayList(ops.stages()); this.fops = ops; - this.pendingDevices = ImmutableSet.of(); + this.pendingDevices = new HashSet<>(); } - FlowOperationsProcessor(FlowOperationsProcessor src, boolean hasFailed, Set pendingDevices) { + FlowOperationsProcessor(FlowOperationsProcessor src, boolean hasFailed) { this.fops = src.fops; this.stages = Lists.newArrayList(src.stages); - this.pendingDevices = ImmutableSet.copyOf(pendingDevices); + this.pendingDevices = new HashSet<>(src.pendingDevices); this.hasFailed = hasFailed; } @@ -636,33 +635,28 @@ public class FlowRuleManager perDeviceBatches.put(op.rule().deviceId(), new FlowRuleBatchEntry(mapOperationType(op.type()), op.rule())); } - ImmutableSet newPendingDevices = ImmutableSet.builder() - .addAll(pendingDevices) - .addAll(perDeviceBatches.keySet()) - .build(); + pendingDevices.addAll(perDeviceBatches.keySet()); for (DeviceId deviceId : perDeviceBatches.keySet()) { long id = idGenerator.getNewId(); final FlowRuleBatchOperation b = new FlowRuleBatchOperation(perDeviceBatches.get(deviceId), deviceId, id); - pendingFlowOperations.put(id, new FlowOperationsProcessor(this, hasFailed, newPendingDevices)); + pendingFlowOperations.put(id, this); deviceInstallers.execute(() -> store.storeBatch(b)); } } synchronized void satisfy(DeviceId devId) { - Set newPendingDevices = new HashSet<>(pendingDevices); - newPendingDevices.remove(devId); - if (newPendingDevices.isEmpty()) { - operationsService.execute(new FlowOperationsProcessor(this, hasFailed, newPendingDevices)); + pendingDevices.remove(devId); + if (pendingDevices.isEmpty()) { + operationsService.execute(new FlowOperationsProcessor(this, hasFailed)); } } synchronized void fail(DeviceId devId, Set failures) { - Set newPendingDevices = new HashSet<>(pendingDevices); - newPendingDevices.remove(devId); - if (newPendingDevices.isEmpty()) { - operationsService.execute(new FlowOperationsProcessor(this, true, newPendingDevices)); + pendingDevices.remove(devId); + if (pendingDevices.isEmpty()) { + operationsService.execute(new FlowOperationsProcessor(this, true)); } FlowRuleOperations.Builder failedOpsBuilder = FlowRuleOperations.builder();