add persistance of intents to ramcloud
Change-Id: I9a8b5886cf57da0621dc92e341d46c53d252528a
diff --git a/src/main/java/net/onrc/onos/intent/runtime/PathCalcRuntimeModule.java b/src/main/java/net/onrc/onos/intent/runtime/PathCalcRuntimeModule.java
old mode 100644
new mode 100755
index 4c90a23..3a9c607
--- a/src/main/java/net/onrc/onos/intent/runtime/PathCalcRuntimeModule.java
+++ b/src/main/java/net/onrc/onos/intent/runtime/PathCalcRuntimeModule.java
@@ -23,6 +23,8 @@
import net.onrc.onos.ofcontroller.networkgraph.LinkEvent;
import net.onrc.onos.ofcontroller.networkgraph.PortEvent;
import net.onrc.onos.ofcontroller.networkgraph.SwitchEvent;
+import net.onrc.onos.intent.persist.PersistIntent;
+import net.onrc.onos.registry.controller.IControllerRegistryService;
/**
* @author Toshio Koide (t-koide@onlab.us)
@@ -33,8 +35,10 @@
private INetworkGraphService networkGraphService;
private IntentMap highLevelIntents;
private PathIntentMap pathIntents;
+ private IControllerRegistryService controllerRegistry;
+ private PersistIntent persistIntent;
- private IEventChannel<String, IntentOperationList> eventChannel;
+ private IEventChannel<Long, IntentOperationList> eventChannel;
private static final String EVENT_CHANNEL_NAME = "onos.pathintent";
private void reroutePaths(LinkEvent linkEvent) {
@@ -75,6 +79,7 @@
public void init(FloodlightModuleContext context) throws FloodlightModuleException {
datagridService = context.getServiceImpl(IDatagridService.class);
networkGraphService = context.getServiceImpl(INetworkGraphService.class);
+ controllerRegistry = context.getServiceImpl(IControllerRegistryService.class);
}
@Override
@@ -84,19 +89,22 @@
pathIntents = new PathIntentMap();
eventChannel = datagridService.createChannel(
EVENT_CHANNEL_NAME,
- String.class,
+ Long.class,
IntentOperationList.class);
networkGraphService.registerNetworkGraphListener(this);
+ persistIntent = new PersistIntent(controllerRegistry, networkGraphService);
+
}
@Override
public IntentOperationList executeIntentOperations(IntentOperationList list) {
highLevelIntents.executeOperations(list);
IntentOperationList pathIntentOperations = runtime.calcPathIntents(list, pathIntents);
- String key = "..."; // TODO generate key
+ long key = persistIntent.getKey();
System.out.println(pathIntentOperations);
pathIntents.executeOperations(pathIntentOperations);
eventChannel.addEntry(key, pathIntentOperations);
+ persistIntent.persistIfLeader(key, pathIntentOperations);
return pathIntentOperations;
}