diff options
author | Ashlee Young <ashlee@wildernessvoice.com> | 2015-11-12 12:46:25 -0800 |
---|---|---|
committer | Ashlee Young <ashlee@wildernessvoice.com> | 2015-11-12 12:46:25 -0800 |
commit | 03974824abae35128f53f5a4af9a4ed8f573601a (patch) | |
tree | 4f5da69f32b7ee0dfb75e827b82212bd6c82fafe /framework/src/onos/core | |
parent | baac58c7c50e6f89eb0520e3f5b0e83a69839bd3 (diff) |
Updating onos src up to commit id fdb426e7ca9232692b0b6c335c79fc9c5a4e341f
Change-Id: I78f29f15b39f965b61154d5f8d576ed1a9481b9b
Signed-off-by: Ashlee Young <ashlee@wildernessvoice.com>
Diffstat (limited to 'framework/src/onos/core')
-rw-r--r-- | framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/flow/impl/NewDistributedFlowRuleStore.java | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/flow/impl/NewDistributedFlowRuleStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/flow/impl/NewDistributedFlowRuleStore.java index 8cd63e7d..1695e5ff 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/flow/impl/NewDistributedFlowRuleStore.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/flow/impl/NewDistributedFlowRuleStore.java @@ -59,6 +59,7 @@ import org.onosproject.net.flow.FlowRuleStore; import org.onosproject.net.flow.FlowRuleStoreDelegate; import org.onosproject.net.flow.StoredFlowEntry; import org.onosproject.net.flow.TableStatisticsEntry; +import org.onosproject.persistence.PersistenceService; import org.onosproject.store.AbstractStore; import org.onosproject.store.cluster.messaging.ClusterCommunicationService; import org.onosproject.store.cluster.messaging.ClusterMessage; @@ -74,6 +75,7 @@ import org.onosproject.store.serializers.custom.DistributedStoreSerializers; import org.onosproject.store.service.EventuallyConsistentMap; import org.onosproject.store.service.EventuallyConsistentMapEvent; import org.onosproject.store.service.EventuallyConsistentMapListener; +import org.onosproject.store.service.Serializer; import org.onosproject.store.service.StorageService; import org.onosproject.store.service.WallClockTimestamp; import org.osgi.service.component.ComponentContext; @@ -113,6 +115,7 @@ public class NewDistributedFlowRuleStore private static final int MESSAGE_HANDLER_THREAD_POOL_SIZE = 8; private static final boolean DEFAULT_BACKUP_ENABLED = true; + private static final boolean DEFAULT_PERSISTENCE_ENABLED = false; private static final int DEFAULT_BACKUP_PERIOD_MILLIS = 2000; private static final long FLOW_RULE_STORE_TIMEOUT_MILLIS = 5000; // number of devices whose flow entries will be backed up in one communication round @@ -129,6 +132,9 @@ public class NewDistributedFlowRuleStore @Property(name = "backupPeriod", intValue = DEFAULT_BACKUP_PERIOD_MILLIS, label = "Delay in ms between successive backup runs") private int backupPeriod = DEFAULT_BACKUP_PERIOD_MILLIS; + @Property(name = "persistenceEnabled", boolValue = false, + label = "Indicates whether or not changes in the flow table should be persisted to disk.") + private boolean persistenceEnabled = DEFAULT_PERSISTENCE_ENABLED; private InternalFlowTable flowTable = new InternalFlowTable(); @@ -153,6 +159,9 @@ public class NewDistributedFlowRuleStore @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected MastershipService mastershipService; + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) + protected PersistenceService persistenceService; + private Map<Long, NodeId> pendingResponses = Maps.newConcurrentMap(); private ExecutorService messageHandlingExecutor; @@ -716,7 +725,25 @@ public class NewDistributedFlowRuleStore * @return Map representing Flow Table of given device. */ private Map<FlowId, Set<StoredFlowEntry>> getFlowTable(DeviceId deviceId) { - return flowEntries.computeIfAbsent(deviceId, id -> Maps.newConcurrentMap()); + if (persistenceEnabled) { + return flowEntries.computeIfAbsent(deviceId, id -> persistenceService + .<FlowId, Set<StoredFlowEntry>>persistentMapBuilder() + .withName("FlowTable:" + deviceId.toString()) + .withSerializer(new Serializer() { + @Override + public <T> byte[] encode(T object) { + return SERIALIZER.encode(object); + } + + @Override + public <T> T decode(byte[] bytes) { + return SERIALIZER.decode(bytes); + } + }) + .build()); + } else { + return flowEntries.computeIfAbsent(deviceId, id -> Maps.newConcurrentMap()); + } } private Set<StoredFlowEntry> getFlowEntriesInternal(DeviceId deviceId, FlowId flowId) { |