Committed by
Gerrit Code Review
Simplify maps used in flow store's InternalFlowTable
Change-Id: I66c0c2a0c71b212e5c791280267792f74fb51bf5
Showing
1 changed file
with
4 additions
and
12 deletions
... | @@ -30,7 +30,6 @@ import org.apache.felix.scr.annotations.Reference; | ... | @@ -30,7 +30,6 @@ import org.apache.felix.scr.annotations.Reference; |
30 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 30 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
31 | import org.apache.felix.scr.annotations.Service; | 31 | import org.apache.felix.scr.annotations.Service; |
32 | import org.onlab.util.KryoNamespace; | 32 | import org.onlab.util.KryoNamespace; |
33 | -import org.onlab.util.NewConcurrentHashMap; | ||
34 | import org.onlab.util.Tools; | 33 | import org.onlab.util.Tools; |
35 | import org.onosproject.cfg.ComponentConfigService; | 34 | import org.onosproject.cfg.ComponentConfigService; |
36 | import org.onosproject.cluster.ClusterService; | 35 | import org.onosproject.cluster.ClusterService; |
... | @@ -76,8 +75,6 @@ import java.util.HashSet; | ... | @@ -76,8 +75,6 @@ import java.util.HashSet; |
76 | import java.util.List; | 75 | import java.util.List; |
77 | import java.util.Map; | 76 | import java.util.Map; |
78 | import java.util.Set; | 77 | import java.util.Set; |
79 | -import java.util.concurrent.ConcurrentHashMap; | ||
80 | -import java.util.concurrent.ConcurrentMap; | ||
81 | import java.util.concurrent.ExecutorService; | 78 | import java.util.concurrent.ExecutorService; |
82 | import java.util.concurrent.Executors; | 79 | import java.util.concurrent.Executors; |
83 | import java.util.concurrent.ScheduledExecutorService; | 80 | import java.util.concurrent.ScheduledExecutorService; |
... | @@ -86,7 +83,6 @@ import java.util.concurrent.TimeUnit; | ... | @@ -86,7 +83,6 @@ import java.util.concurrent.TimeUnit; |
86 | import java.util.concurrent.atomic.AtomicInteger; | 83 | import java.util.concurrent.atomic.AtomicInteger; |
87 | import java.util.stream.Collectors; | 84 | import java.util.stream.Collectors; |
88 | 85 | ||
89 | -import static org.apache.commons.lang3.concurrent.ConcurrentUtils.createIfAbsentUnchecked; | ||
90 | import static com.google.common.base.Strings.isNullOrEmpty; | 86 | import static com.google.common.base.Strings.isNullOrEmpty; |
91 | import static org.onlab.util.Tools.get; | 87 | import static org.onlab.util.Tools.get; |
92 | import static org.onlab.util.Tools.groupedThreads; | 88 | import static org.onlab.util.Tools.groupedThreads; |
... | @@ -595,17 +591,13 @@ public class NewDistributedFlowRuleStore | ... | @@ -595,17 +591,13 @@ public class NewDistributedFlowRuleStore |
595 | 591 | ||
596 | private class InternalFlowTable implements ReplicaInfoEventListener { | 592 | private class InternalFlowTable implements ReplicaInfoEventListener { |
597 | 593 | ||
598 | - private final ConcurrentMap<DeviceId, ConcurrentMap<FlowId, Set<StoredFlowEntry>>> | 594 | + private final Map<DeviceId, Map<FlowId, Set<StoredFlowEntry>>> |
599 | - flowEntries = new ConcurrentHashMap<>(); | 595 | + flowEntries = Maps.newConcurrentMap(); |
600 | 596 | ||
601 | private final Map<DeviceId, Long> lastBackupTimes = Maps.newConcurrentMap(); | 597 | private final Map<DeviceId, Long> lastBackupTimes = Maps.newConcurrentMap(); |
602 | private final Map<DeviceId, Long> lastUpdateTimes = Maps.newConcurrentMap(); | 598 | private final Map<DeviceId, Long> lastUpdateTimes = Maps.newConcurrentMap(); |
603 | private final Map<DeviceId, NodeId> lastBackupNodes = Maps.newConcurrentMap(); | 599 | private final Map<DeviceId, NodeId> lastBackupNodes = Maps.newConcurrentMap(); |
604 | 600 | ||
605 | - private NewConcurrentHashMap<FlowId, Set<StoredFlowEntry>> lazyEmptyFlowTable() { | ||
606 | - return NewConcurrentHashMap.<FlowId, Set<StoredFlowEntry>>ifNeeded(); | ||
607 | - } | ||
608 | - | ||
609 | @Override | 601 | @Override |
610 | public void event(ReplicaInfoEvent event) { | 602 | public void event(ReplicaInfoEvent event) { |
611 | if (!backupEnabled) { | 603 | if (!backupEnabled) { |
... | @@ -682,8 +674,8 @@ public class NewDistributedFlowRuleStore | ... | @@ -682,8 +674,8 @@ public class NewDistributedFlowRuleStore |
682 | * @param deviceId identifier of the device | 674 | * @param deviceId identifier of the device |
683 | * @return Map representing Flow Table of given device. | 675 | * @return Map representing Flow Table of given device. |
684 | */ | 676 | */ |
685 | - private ConcurrentMap<FlowId, Set<StoredFlowEntry>> getFlowTable(DeviceId deviceId) { | 677 | + private Map<FlowId, Set<StoredFlowEntry>> getFlowTable(DeviceId deviceId) { |
686 | - return createIfAbsentUnchecked(flowEntries, deviceId, lazyEmptyFlowTable()); | 678 | + return flowEntries.computeIfAbsent(deviceId, id -> Maps.newConcurrentMap()); |
687 | } | 679 | } |
688 | 680 | ||
689 | private Set<StoredFlowEntry> getFlowEntriesInternal(DeviceId deviceId, FlowId flowId) { | 681 | private Set<StoredFlowEntry> getFlowEntriesInternal(DeviceId deviceId, FlowId flowId) { | ... | ... |
-
Please register or login to post a comment