Define APIs to determine how to install/remove an intent
It's a part of ONOS-1654.
- IntentInstaller handles installation/removal of an intent
- IIntentRuntime supports register/unregister IntentInstaller
Change-Id: I7dae171b445eac6254131a9f4144f0447a2321f2
diff --git a/src/main/java/net/onrc/onos/api/intent/IIntentRuntimeService.java b/src/main/java/net/onrc/onos/api/intent/IIntentRuntimeService.java
index 6750595..0e5c36e 100644
--- a/src/main/java/net/onrc/onos/api/intent/IIntentRuntimeService.java
+++ b/src/main/java/net/onrc/onos/api/intent/IIntentRuntimeService.java
@@ -84,6 +84,35 @@
public <T extends Intent> void removeResolver(Class<T> type);
/**
+ * Adds an IntentInstaller associated with a given intent type.
+ *
+ * If there is an Intent instance of the specified Intent type in the runtime,
+ * the specified IntentInstaller doesn't replace the existing installer.
+ * Otherwise, the existing installer is replaced with the specified installer.
+ *
+ * @param type the class instance of the intent type.
+ * @param installer the installer of the given intent type.
+ * @param <T> the type of the intent.
+ * @return false when there is an Intent instance of the specified intent type
+ * in the runtime. Otherwise, true.
+ */
+ public <T extends Intent> boolean addInstaller(Class<T> type, IntentInstaller<T> installer);
+
+ /**
+ * Removes the IntentInstaller associated with a given intent type.
+ *
+ * If there is an Intent instance of the specified Intent type in the runtime,
+ * the specified IntentInstaller is not removed. Otherwise, the existing
+ * IntentInstaller is removed from the runtime.
+ *
+ * @param type the class instance of the intent type.
+ * @param <T> the type of the intent.
+ * @return false when there is an Intent instance of the specified intent type
+ * in the runtime. Otherwise, true.
+ */
+ public <T extends Intent> boolean removeInstaller(Class<T> type);
+
+ /**
* Gets IFlow objects managed by the specified intent.
*
* @param intentId ID of the target Intent.
diff --git a/src/main/java/net/onrc/onos/api/intent/IntentInstaller.java b/src/main/java/net/onrc/onos/api/intent/IntentInstaller.java
new file mode 100644
index 0000000..3b8085a
--- /dev/null
+++ b/src/main/java/net/onrc/onos/api/intent/IntentInstaller.java
@@ -0,0 +1,24 @@
+package net.onrc.onos.api.intent;
+
+/**
+ * An interface to handle installation and removal of a specific type of intent.
+ *
+ * @param <T> the type of intent this installer handles.
+ */
+public interface IntentInstaller<T extends Intent> {
+ /**
+ * Installs the given intent.
+ *
+ * @param intent the intent to be installed.
+ * @return true if the installation succeeds. Otherwise, false.
+ */
+ public boolean install(T intent);
+
+ /**
+ * Removes the given intent.
+ *
+ * @param intent the intent to be removed.
+ * @return true if the removal succeeds. Otherwise, false.
+ */
+ public boolean remove(T intent);
+}
diff --git a/src/main/java/net/onrc/onos/core/newintent/IntentRuntimeModule.java b/src/main/java/net/onrc/onos/core/newintent/IntentRuntimeModule.java
index 8da30e8..2521e56 100644
--- a/src/main/java/net/onrc/onos/core/newintent/IntentRuntimeModule.java
+++ b/src/main/java/net/onrc/onos/core/newintent/IntentRuntimeModule.java
@@ -9,6 +9,7 @@
import net.onrc.onos.api.intent.IIntentRuntimeService;
import net.onrc.onos.api.intent.Intent;
import net.onrc.onos.api.intent.IntentId;
+import net.onrc.onos.api.intent.IntentInstaller;
import net.onrc.onos.api.intent.IntentResolver;
/**
@@ -75,6 +76,18 @@
}
@Override
+ public <T extends Intent> boolean addInstaller(Class<T> type, IntentInstaller<T> installer) {
+ // TODO: implement this method
+ return false;
+ }
+
+ @Override
+ public <T extends Intent> boolean removeInstaller(Class<T> type) {
+ // TODO: impelment this method
+ return false;
+ }
+
+ @Override
public Collection<IFlow> getFlows(String intentId) {
// TODO Auto-generated method stub
return null;