Improvements to Intent Framework to allow intents to be installed end to end.
Change-Id: I7256e31c745e2c36270ab7f25378a94e20664c34
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchActionComponent.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionComponent.java
index 0307d4c..3ee164f 100644
--- a/src/main/java/net/onrc/onos/core/matchaction/MatchActionComponent.java
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionComponent.java
@@ -50,7 +50,7 @@
private final BlockingQueue<MatchActionOperationsId> resolvedQueue = new ArrayBlockingQueue<>(100);
private final BlockingQueue<MatchActionOperations> installationWorkQueue = new ArrayBlockingQueue<>(100);
- private IEventChannel<String, MatchActionOperations> installSetChannel;
+ private IEventChannel<Long, MatchActionOperations> installSetChannel;
private IEventChannel<String, SwitchResultList> installSetReplyChannel;
private final IDatagridService datagrid;
@@ -88,23 +88,26 @@
matchActionOperationsIdGenerator =
new MatchActionOperationsIdGeneratorWithIdBlockAllocator(idBlockAllocator);
- installSetChannel = datagrid.createChannel("onos.matchaction.installSetChannel",
- String.class,
+ final Installer installerListener = new Installer();
+ installSetChannel = datagrid.addListener(
+ "onos.matchaction.installSetChannel",
+ installerListener,
+ Long.class,
MatchActionOperations.class);
- installSetReplyChannel = datagrid.createChannel("onos.matchaction.installSetReplyChannel",
+
+ final Coordinator coordinator = new Coordinator();
+ coordinator.start();
+ installSetReplyChannel = datagrid.addListener(
+ "onos.matchaction.installSetReplyChannel",
+ coordinator,
String.class,
SwitchResultList.class);
- final Thread coordinator = new Coordinator();
- coordinator.start();
-
// TODO Single instance for now, should be a work queue of some sort eventually
- final Thread installer = new InstallerWorker();
+ final InstallerWorker installer = new InstallerWorker();
installer.start();
- final Installer installerListener = new Installer();
- installerListener.start();
}
/**
@@ -175,7 +178,7 @@
* Default constructor.
*/
Coordinator() {
- installSetReplyChannel.addListener(this);
+ // nothing to initialize
}
@Override
@@ -228,7 +231,8 @@
pendingMatchActionOperations.put(setId, switches);
// distribute apply/undo sets to cluster
- installSetChannel.addTransientEntry(setId.toString(), matchSet);
+ log.trace("MatchAction Coordinator distributing set: {}", matchSet);
+ installSetChannel.addTransientEntry(setId.getId(), matchSet);
}
@Override
@@ -404,20 +408,12 @@
* InstallerWorker threads.
*/
class Installer
- implements IEventChannelListener<String, MatchActionOperations> {
-
- /**
- * Starts the Installer consumer. Adds a listener on the MatchActionOperations
- * channel.
- */
- private void start() {
- installSetChannel.addListener(this);
- }
-
+ implements IEventChannelListener<Long, MatchActionOperations> {
@Override
public void entryAdded(MatchActionOperations value) {
try {
+ log.trace("MatchAction Installer receiving set: {}", value);
installationWorkQueue.put(value);
} catch (InterruptedException e) {
log.warn("Error adding to installer work queue: {}",
@@ -433,6 +429,7 @@
@Override
public void entryUpdated(MatchActionOperations value) {
try {
+ log.trace("MatchAction Installer receiving set: {}", value);
installationWorkQueue.put(value);
} catch (InterruptedException e) {
log.warn("Error adding to installer work queue: {}",
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java
index 9bf1be4..8bf34a8 100644
--- a/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java
@@ -117,11 +117,13 @@
@Override
public void addEventListener(EventListener listener) {
- throw new UnsupportedOperationException("events not implemented yet");
+ // TODO
+ log.warn("Could not add MatchAction EventListener: {}", listener);
}
@Override
public void removeEventListener(EventListener listener) {
- throw new UnsupportedOperationException("events not implemented yet");
+ // TODO
+ log.warn("Could not remove MatchAction EventListener: {}", listener);
}
}
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperationsId.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperationsId.java
index a05dd90..3bf34d8 100644
--- a/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperationsId.java
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperationsId.java
@@ -55,4 +55,9 @@
public int hashCode() {
return Objects.hashCode(id);
}
+
+ @Override
+ public String toString() {
+ return "0x" + Long.toHexString(getId());
+ }
}