Committed by
Thomas Vachuska
Provide pendingDevices explicitly
Change-Id: I2cc29d5672d11aa176c7fa774e9d66f32b2d300f
Showing
1 changed file
with
18 additions
and
12 deletions
... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
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; | ||
19 | import com.google.common.collect.Iterables; | 20 | import com.google.common.collect.Iterables; |
20 | import com.google.common.collect.Lists; | 21 | import com.google.common.collect.Lists; |
21 | import com.google.common.collect.Maps; | 22 | import com.google.common.collect.Maps; |
... | @@ -600,22 +601,22 @@ public class FlowRuleManager | ... | @@ -600,22 +601,22 @@ public class FlowRuleManager |
600 | private class FlowOperationsProcessor implements Runnable { | 601 | private class FlowOperationsProcessor implements Runnable { |
601 | // Immutable | 602 | // Immutable |
602 | private final FlowRuleOperations fops; | 603 | private final FlowRuleOperations fops; |
604 | + private final ImmutableSet<DeviceId> pendingDevices; | ||
603 | 605 | ||
604 | // Mutable | 606 | // Mutable |
605 | private final List<Set<FlowRuleOperation>> stages; | 607 | private final List<Set<FlowRuleOperation>> stages; |
606 | - private final Set<DeviceId> pendingDevices; | ||
607 | private boolean hasFailed = false; | 608 | private boolean hasFailed = false; |
608 | 609 | ||
609 | FlowOperationsProcessor(FlowRuleOperations ops) { | 610 | FlowOperationsProcessor(FlowRuleOperations ops) { |
610 | this.stages = Lists.newArrayList(ops.stages()); | 611 | this.stages = Lists.newArrayList(ops.stages()); |
611 | this.fops = ops; | 612 | this.fops = ops; |
612 | - this.pendingDevices = new HashSet<>(); | 613 | + this.pendingDevices = ImmutableSet.of(); |
613 | } | 614 | } |
614 | 615 | ||
615 | - FlowOperationsProcessor(FlowOperationsProcessor src, boolean hasFailed) { | 616 | + FlowOperationsProcessor(FlowOperationsProcessor src, boolean hasFailed, Set<DeviceId> pendingDevices) { |
616 | this.fops = src.fops; | 617 | this.fops = src.fops; |
617 | this.stages = Lists.newArrayList(src.stages); | 618 | this.stages = Lists.newArrayList(src.stages); |
618 | - this.pendingDevices = new HashSet<>(src.pendingDevices); | 619 | + this.pendingDevices = ImmutableSet.copyOf(pendingDevices); |
619 | this.hasFailed = hasFailed; | 620 | this.hasFailed = hasFailed; |
620 | } | 621 | } |
621 | 622 | ||
... | @@ -635,28 +636,33 @@ public class FlowRuleManager | ... | @@ -635,28 +636,33 @@ public class FlowRuleManager |
635 | perDeviceBatches.put(op.rule().deviceId(), | 636 | perDeviceBatches.put(op.rule().deviceId(), |
636 | new FlowRuleBatchEntry(mapOperationType(op.type()), op.rule())); | 637 | new FlowRuleBatchEntry(mapOperationType(op.type()), op.rule())); |
637 | } | 638 | } |
638 | - pendingDevices.addAll(perDeviceBatches.keySet()); | 639 | + ImmutableSet<DeviceId> newPendingDevices = ImmutableSet.<DeviceId>builder() |
640 | + .addAll(pendingDevices) | ||
641 | + .addAll(perDeviceBatches.keySet()) | ||
642 | + .build(); | ||
639 | 643 | ||
640 | for (DeviceId deviceId : perDeviceBatches.keySet()) { | 644 | for (DeviceId deviceId : perDeviceBatches.keySet()) { |
641 | long id = idGenerator.getNewId(); | 645 | long id = idGenerator.getNewId(); |
642 | final FlowRuleBatchOperation b = new FlowRuleBatchOperation(perDeviceBatches.get(deviceId), | 646 | final FlowRuleBatchOperation b = new FlowRuleBatchOperation(perDeviceBatches.get(deviceId), |
643 | deviceId, id); | 647 | deviceId, id); |
644 | - pendingFlowOperations.put(id, this); | 648 | + pendingFlowOperations.put(id, new FlowOperationsProcessor(this, hasFailed, newPendingDevices)); |
645 | deviceInstallers.execute(() -> store.storeBatch(b)); | 649 | deviceInstallers.execute(() -> store.storeBatch(b)); |
646 | } | 650 | } |
647 | } | 651 | } |
648 | 652 | ||
649 | synchronized void satisfy(DeviceId devId) { | 653 | synchronized void satisfy(DeviceId devId) { |
650 | - pendingDevices.remove(devId); | 654 | + Set<DeviceId> newPendingDevices = new HashSet<>(pendingDevices); |
651 | - if (pendingDevices.isEmpty()) { | 655 | + newPendingDevices.remove(devId); |
652 | - operationsService.execute(new FlowOperationsProcessor(this, hasFailed)); | 656 | + if (newPendingDevices.isEmpty()) { |
657 | + operationsService.execute(new FlowOperationsProcessor(this, hasFailed, newPendingDevices)); | ||
653 | } | 658 | } |
654 | } | 659 | } |
655 | 660 | ||
656 | synchronized void fail(DeviceId devId, Set<? extends FlowRule> failures) { | 661 | synchronized void fail(DeviceId devId, Set<? extends FlowRule> failures) { |
657 | - pendingDevices.remove(devId); | 662 | + Set<DeviceId> newPendingDevices = new HashSet<>(pendingDevices); |
658 | - if (pendingDevices.isEmpty()) { | 663 | + newPendingDevices.remove(devId); |
659 | - operationsService.execute(new FlowOperationsProcessor(this, true)); | 664 | + if (newPendingDevices.isEmpty()) { |
665 | + operationsService.execute(new FlowOperationsProcessor(this, true, newPendingDevices)); | ||
660 | } | 666 | } |
661 | 667 | ||
662 | FlowRuleOperations.Builder failedOpsBuilder = FlowRuleOperations.builder(); | 668 | FlowRuleOperations.Builder failedOpsBuilder = FlowRuleOperations.builder(); | ... | ... |
-
Please register or login to post a comment