From 5c3766c9a42eee5db5a45846c6d19a933e9d54fe Mon Sep 17 00:00:00 2001 From: Madan Jampani Date: Tue, 2 Jun 2015 15:54:41 -0700 Subject: [PATCH] Simplify maps used in flow store's InternalFlowTable Change-Id: I66c0c2a0c71b212e5c791280267792f74fb51bf5 --- .../flow/impl/NewDistributedFlowRuleStore.java | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/NewDistributedFlowRuleStore.java b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/NewDistributedFlowRuleStore.java index 249cdf8903..a95eee1adf 100644 --- a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/NewDistributedFlowRuleStore.java +++ b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/NewDistributedFlowRuleStore.java @@ -30,7 +30,6 @@ import org.apache.felix.scr.annotations.Reference; import org.apache.felix.scr.annotations.ReferenceCardinality; import org.apache.felix.scr.annotations.Service; import org.onlab.util.KryoNamespace; -import org.onlab.util.NewConcurrentHashMap; import org.onlab.util.Tools; import org.onosproject.cfg.ComponentConfigService; import org.onosproject.cluster.ClusterService; @@ -76,8 +75,6 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -86,7 +83,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; -import static org.apache.commons.lang3.concurrent.ConcurrentUtils.createIfAbsentUnchecked; import static com.google.common.base.Strings.isNullOrEmpty; import static org.onlab.util.Tools.get; import static org.onlab.util.Tools.groupedThreads; @@ -595,17 +591,13 @@ public class NewDistributedFlowRuleStore private class InternalFlowTable implements ReplicaInfoEventListener { - private final ConcurrentMap>> - flowEntries = new ConcurrentHashMap<>(); + private final Map>> + flowEntries = Maps.newConcurrentMap(); private final Map lastBackupTimes = Maps.newConcurrentMap(); private final Map lastUpdateTimes = Maps.newConcurrentMap(); private final Map lastBackupNodes = Maps.newConcurrentMap(); - private NewConcurrentHashMap> lazyEmptyFlowTable() { - return NewConcurrentHashMap.>ifNeeded(); - } - @Override public void event(ReplicaInfoEvent event) { if (!backupEnabled) { @@ -682,8 +674,8 @@ public class NewDistributedFlowRuleStore * @param deviceId identifier of the device * @return Map representing Flow Table of given device. */ - private ConcurrentMap> getFlowTable(DeviceId deviceId) { - return createIfAbsentUnchecked(flowEntries, deviceId, lazyEmptyFlowTable()); + private Map> getFlowTable(DeviceId deviceId) { + return flowEntries.computeIfAbsent(deviceId, id -> Maps.newConcurrentMap()); } private Set getFlowEntriesInternal(DeviceId deviceId, FlowId flowId) {