Re-organize intent related packages
- Delete classes under intent package except for ApplicaitonIntent,
PacketConnectivityIntent, and OpticalConnectivityIntent
- Move PacketConnectivityIntent and OpticalConnectivityIntent under
net.onrc.onos.api.newintent package
- Adapt BatchOperation related changes for Intent and IntentId class
This is for ONOS-1887.
Change-Id: I4d25a0f8cbba806e9dd6e00333b6c7157c854658
diff --git a/src/main/java/net/onrc/onos/api/intent/IIntentRuntimeService.java b/src/main/java/net/onrc/onos/api/intent/IIntentRuntimeService.java
deleted file mode 100644
index a3b1705..0000000
--- a/src/main/java/net/onrc/onos/api/intent/IIntentRuntimeService.java
+++ /dev/null
@@ -1,161 +0,0 @@
-package net.onrc.onos.api.intent;
-
-import java.util.Collection;
-import java.util.EventListener;
-
-import net.onrc.onos.api.flowmanager.ConflictDetectionPolicy;
-import net.onrc.onos.api.flowmanager.Flow;
-import net.onrc.onos.api.flowmanager.FlowId;
-
-/**
- * An interface class for the Intent-Runtime Service. The role of the
- * Intent-Runtime Service is to manage a set of IFlow objects based on the
- * specified Intent objects.
- * <p>
- * It compiles accepted Intents to IFlow objects by allocating resources and
- * calculating paths based on the constrains described in the Intents, and
- * executes installation/uninstallation of the IFlow objects using FlowManager
- * Service.
- */
-public interface IIntentRuntimeService {
- /**
- * Installs the specified intent synchronously.
- *
- * <p>
- * This method blocks until the installation succeeds or fails.
- * </p>
- *
- * @param intent the intent to be installed.
- * @return true if the intent is successfully installed. Otherwise, false.
- */
- public boolean install(Intent intent);
-
- /**
- * Removes the specified intent synchronously.
- *
- * <p>
- * This method blocks until the removal succeeds or fails.
- * </p>
- *
- * @param id the ID of the intent to be uninstalled.
- * @return true if the intent is successfully uninstalled. Otherwise, false.
- */
- public boolean remove(IntentId id);
-
- /**
- * Gets specific intent.
- *
- * @param id ID of the intent should be retrieved
- * @return Intent if it exists, null otherwise.
- */
- Intent getIntent(IntentId id);
-
- /**
- * Gets all intents.
- *
- * @return collection of intents.
- */
- Collection<Intent> getIntents();
-
- /**
- * Executes batch operation of intents.
- *
- * @param ops BatchOperations to be executed.
- * @return true if succeeded, false otherwise.
- */
- boolean executeBatch(IntentBatchOperation ops);
-
- /**
- * Adds an IntentResolver associated with a given intent type.
- *
- * @param type the class instance of the intent type.
- * @param resolver the resolver of the given intent type.
- * @param <T> the type of the intent.
- */
- public <T extends Intent> void addResolver(Class<T> type, IntentResolver<T> resolver);
-
- /**
- * Removes the IntentResolver associated with the intent type.
- *
- * @param type the class instance of the intent type.
- * @param <T> the type of the intent.
- */
- public <T extends Intent> void removeResolver(Class<T> type);
-
- /**
- * Adds an IntentInstaller associated with a given intent type.
- *
- * <p>
- * 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.
- * </p>
- *
- * @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.
- *
- * <p>
- * 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.
- * </p>
- *
- * @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.
- * @return Collection of IFlow objects if exists, null otherwise.
- */
- Collection<Flow> getFlows(String intentId);
-
- /**
- * Gets Intent object which manages the specified IFlow object.
- *
- * @param flowId ID of the target IFlow object.
- * @return Intent which manages the specified IFlow object, null otherwise.
- */
- Intent getIntentByFlow(FlowId flowId);
-
- /**
- * Sets a conflict detection policy.
- *
- * @param policy ConflictDetectionPolicy object to be set.
- */
- void setConflictDetectionPolicy(ConflictDetectionPolicy policy);
-
- /**
- * Gets the conflict detection policy.
- *
- * @return ConflictDetectionPolicy object being applied currently.
- */
- ConflictDetectionPolicy getConflictDetectionPolicy();
-
- /**
- * Adds event listener to this service.
- *
- * @param listener EventListener to be added.
- */
- void addEventListener(EventListener listener);
-
- /**
- * Removes event listener from this service.
- *
- * @param listener EventListener to be removed.
- */
- void removeEventListener(EventListener listener);
-}
diff --git a/src/main/java/net/onrc/onos/api/intent/Intent.java b/src/main/java/net/onrc/onos/api/intent/Intent.java
deleted file mode 100644
index 586605c..0000000
--- a/src/main/java/net/onrc/onos/api/intent/Intent.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package net.onrc.onos.api.intent;
-
-import com.google.common.base.Objects;
-import net.onrc.onos.api.batchoperation.BatchOperationTarget;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * The base class of an intent type.
- *
- * <p>
- * This class is sub-classed to provide other intent types like shortest path
- * connectivity and bandwidth constrained shortest path connectivity.
- * </p>
- *
- * <p>
- * The reasoning behind "intent" is that the applications can provide some
- * abstract representation of how traffic should flow be handled by the
- * networking, allowing the network OS to compile, reserve and optimize the
- * data-plane to satisfy those constraints.
- * </p>
- *
- * <p>
- * It is assumed that any kinds of intents are immutable.
- * Developers that will define a new intent type should ensure its immutability.
- * </p>
- */
-public abstract class Intent implements BatchOperationTarget {
- private final IntentId id;
-
- /**
- * Constructs an intent, which is activated permanently until it is removed explicitly.
- *
- * @param id ID for this intent object.
- */
- protected Intent(IntentId id) {
- this.id = checkNotNull(id);
- }
-
- /**
- * Returns ID for this Intent object.
- *
- * @return ID for this Intent object.
- */
- public IntentId getId() {
- return id;
- }
-
- @Override
- public int hashCode() {
- return id.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
-
- if (!(obj instanceof Intent)) {
- return false;
- }
-
- Intent that = (Intent) obj;
- return Objects.equal(this.id, that.id);
- }
-
- @Override
- public String toString() {
- return Objects.toStringHelper(this)
- .add("id", id)
- .toString();
- }
-}
diff --git a/src/main/java/net/onrc/onos/api/intent/IntentId.java b/src/main/java/net/onrc/onos/api/intent/IntentId.java
deleted file mode 100644
index 5de5a12..0000000
--- a/src/main/java/net/onrc/onos/api/intent/IntentId.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package net.onrc.onos.api.intent;
-
-import net.onrc.onos.api.batchoperation.BatchOperationTarget;
-
-/**
- * The class representing intent's ID.
- *
- * <p>
- * This class is immutable.
- * </p>
- */
-public final class IntentId implements BatchOperationTarget {
- private final long id;
-
- /**
- * Constructs the ID corresponding to a given long value.
- *
- * <p>
- * In the future, this constructor will not be exposed to avoid misuses.
- * </p>
- *
- * @param id the underlay value of this ID.
- */
- public IntentId(long id) {
- this.id = id;
- }
-
- @Override
- public int hashCode() {
- return (int) (id ^ (id >>> 32));
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
-
- if (!(obj instanceof IntentId)) {
- return false;
- }
-
- IntentId that = (IntentId) obj;
- return this.id == that.id;
- }
-
- @Override
- public String toString() {
- return "0x" + Long.toHexString(id);
- }
-}
diff --git a/src/main/java/net/onrc/onos/api/intent/IntentInstaller.java b/src/main/java/net/onrc/onos/api/intent/IntentInstaller.java
deleted file mode 100644
index 3b8085a..0000000
--- a/src/main/java/net/onrc/onos/api/intent/IntentInstaller.java
+++ /dev/null
@@ -1,24 +0,0 @@
-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/api/intent/IntentResolutionException.java b/src/main/java/net/onrc/onos/api/intent/IntentResolutionException.java
deleted file mode 100644
index 5b90f27..0000000
--- a/src/main/java/net/onrc/onos/api/intent/IntentResolutionException.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package net.onrc.onos.api.intent;
-
-/**
- * The base class of an exception thrown during intent resolution.
- */
-public class IntentResolutionException extends Exception {
-}
diff --git a/src/main/java/net/onrc/onos/api/intent/IntentResolver.java b/src/main/java/net/onrc/onos/api/intent/IntentResolver.java
deleted file mode 100644
index a27cc57..0000000
--- a/src/main/java/net/onrc/onos/api/intent/IntentResolver.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package net.onrc.onos.api.intent;
-
-import java.util.List;
-
-/**
- * An interface to translate an intent to lower level intents.
- *
- * <p>
- * IntentResolvers are registered to {@link IIntentRuntimeService} to handle translations of intents
- * (we call it intent resolution).
- * </p>
- *
- * @param <T> the type of intent this resolver translates
- */
-public interface IntentResolver<T extends Intent> {
- /**
- * Returns lower level intents, into which the given intent is translated.
- *
- * This method is invoked by the Intent Framework when the framework find an unresolved intent.
- *
- * @param intent the intent to be translated.
- * @return lower level intents, into which the given intent is translated.
- * @throws IntentResolutionException if this method can't resolve the intent.
- */
- public List<Intent> resolve(T intent) throws IntentResolutionException;
-}
diff --git a/src/main/java/net/onrc/onos/api/newintent/Intent.java b/src/main/java/net/onrc/onos/api/newintent/Intent.java
index 009725c..671ad30 100644
--- a/src/main/java/net/onrc/onos/api/newintent/Intent.java
+++ b/src/main/java/net/onrc/onos/api/newintent/Intent.java
@@ -1,11 +1,13 @@
package net.onrc.onos.api.newintent;
+import net.onrc.onos.api.batchoperation.BatchOperationTarget;
+
/**
* Abstraction of an application level intent.
*
* Make sure that an Intent should be immutable when a new type is defined.
*/
-public interface Intent {
+public interface Intent extends BatchOperationTarget {
/**
* Returns the intent identifier.
*
diff --git a/src/main/java/net/onrc/onos/api/intent/IntentBatchOperation.java b/src/main/java/net/onrc/onos/api/newintent/IntentBatchOperation.java
similarity index 96%
rename from src/main/java/net/onrc/onos/api/intent/IntentBatchOperation.java
rename to src/main/java/net/onrc/onos/api/newintent/IntentBatchOperation.java
index b5ca1aa..0e34deb 100644
--- a/src/main/java/net/onrc/onos/api/intent/IntentBatchOperation.java
+++ b/src/main/java/net/onrc/onos/api/newintent/IntentBatchOperation.java
@@ -1,4 +1,4 @@
-package net.onrc.onos.api.intent;
+package net.onrc.onos.api.newintent;
import net.onrc.onos.api.batchoperation.BatchOperation;
import net.onrc.onos.api.batchoperation.BatchOperationEntry;
diff --git a/src/main/java/net/onrc/onos/api/newintent/IntentId.java b/src/main/java/net/onrc/onos/api/newintent/IntentId.java
index 6d10b35..b7cdb01 100644
--- a/src/main/java/net/onrc/onos/api/newintent/IntentId.java
+++ b/src/main/java/net/onrc/onos/api/newintent/IntentId.java
@@ -1,11 +1,13 @@
package net.onrc.onos.api.newintent;
+import net.onrc.onos.api.batchoperation.BatchOperationTarget;
+
/**
* Intent identifier suitable as an external key.
*
* This class is immutable.
*/
-public final class IntentId {
+public final class IntentId implements BatchOperationTarget {
private static final int DEC = 10;
private static final int HEX = 16;
diff --git a/src/main/java/net/onrc/onos/api/intent/IntentIdGenerator.java b/src/main/java/net/onrc/onos/api/newintent/IntentIdGenerator.java
similarity index 93%
rename from src/main/java/net/onrc/onos/api/intent/IntentIdGenerator.java
rename to src/main/java/net/onrc/onos/api/newintent/IntentIdGenerator.java
index 7bfd906..ec75c7b 100644
--- a/src/main/java/net/onrc/onos/api/intent/IntentIdGenerator.java
+++ b/src/main/java/net/onrc/onos/api/newintent/IntentIdGenerator.java
@@ -1,4 +1,4 @@
-package net.onrc.onos.api.intent;
+package net.onrc.onos.api.newintent;
/**
* This interface is for generator of IntentId.
diff --git a/src/main/java/net/onrc/onos/api/newintent/IntentState.java b/src/main/java/net/onrc/onos/api/newintent/IntentState.java
index f272320..65310ee 100644
--- a/src/main/java/net/onrc/onos/api/newintent/IntentState.java
+++ b/src/main/java/net/onrc/onos/api/newintent/IntentState.java
@@ -36,7 +36,7 @@
/**
* The intent is being withdrawn.
*
- * When {@link net.onrc.onos.api.newintent.IntentService#withdraw(Intent)} is called,
+ * When {@link IntentService#withdraw(Intent)} is called,
* the intent takes this state first.
*/
WITHDRAWING,
diff --git a/src/main/java/net/onrc/onos/api/intent/OpticalConnectivityIntent.java b/src/main/java/net/onrc/onos/api/newintent/OpticalConnectivityIntent.java
similarity index 87%
rename from src/main/java/net/onrc/onos/api/intent/OpticalConnectivityIntent.java
rename to src/main/java/net/onrc/onos/api/newintent/OpticalConnectivityIntent.java
index 256fa44..174d8c0 100644
--- a/src/main/java/net/onrc/onos/api/intent/OpticalConnectivityIntent.java
+++ b/src/main/java/net/onrc/onos/api/newintent/OpticalConnectivityIntent.java
@@ -1,7 +1,8 @@
-package net.onrc.onos.api.intent;
+package net.onrc.onos.api.newintent;
import net.onrc.onos.core.util.SwitchPort;
+// TODO: consider if this intent should be sub-class of ConnectivityIntent
/**
* An optical layer Intent for a connectivity from a transponder port to another
* transponder port.
@@ -10,7 +11,7 @@
* ports and assign lambda automatically. The lambda can be specified using
* OpticalPathFlow class.
*/
-public class OpticalConnectivityIntent extends Intent {
+public class OpticalConnectivityIntent extends AbstractIntent {
protected SwitchPort srcSwitchPort;
protected SwitchPort dstSwitchPort;
diff --git a/src/main/java/net/onrc/onos/api/intent/PacketConnectivityIntent.java b/src/main/java/net/onrc/onos/api/newintent/PacketConnectivityIntent.java
similarity index 96%
rename from src/main/java/net/onrc/onos/api/intent/PacketConnectivityIntent.java
rename to src/main/java/net/onrc/onos/api/newintent/PacketConnectivityIntent.java
index 77a2a13..e03166c 100644
--- a/src/main/java/net/onrc/onos/api/intent/PacketConnectivityIntent.java
+++ b/src/main/java/net/onrc/onos/api/newintent/PacketConnectivityIntent.java
@@ -1,4 +1,4 @@
-package net.onrc.onos.api.intent;
+package net.onrc.onos.api.newintent;
import net.onrc.onos.core.matchaction.match.PacketMatch;
import net.onrc.onos.core.util.SwitchPort;
@@ -8,6 +8,7 @@
import java.util.HashSet;
import java.util.Set;
+// TODO: consider if this intent should be sub-class of Connectivity intent
/**
* A packet layer Intent for a connectivity from a set of ports to a set of
* ports.
@@ -16,7 +17,7 @@
* NOTE: Should this class support modifier methods? Should this object a
* read-only object?
*/
-public class PacketConnectivityIntent extends Intent {
+public class PacketConnectivityIntent extends AbstractIntent {
protected Set<SwitchPort> srcSwitchPorts;
protected PacketMatch match;
protected Set<SwitchPort> dstSwitchPorts;
diff --git a/src/main/java/net/onrc/onos/core/newintent/IntentRuntimeModule.java b/src/main/java/net/onrc/onos/core/newintent/IntentRuntimeModule.java
deleted file mode 100644
index cabc1a7..0000000
--- a/src/main/java/net/onrc/onos/core/newintent/IntentRuntimeModule.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package net.onrc.onos.core.newintent;
-
-import java.util.Collection;
-import java.util.EventListener;
-
-import net.onrc.onos.api.flowmanager.ConflictDetectionPolicy;
-import net.onrc.onos.api.flowmanager.Flow;
-import net.onrc.onos.api.flowmanager.FlowId;
-import net.onrc.onos.api.intent.IIntentRuntimeService;
-import net.onrc.onos.api.intent.Intent;
-import net.onrc.onos.api.intent.IntentBatchOperation;
-import net.onrc.onos.api.intent.IntentId;
-import net.onrc.onos.api.intent.IntentInstaller;
-import net.onrc.onos.api.intent.IntentResolver;
-
-/**
- * Implementation of Intent-Runtime Service.
- * <p>
- * TODO: Make all methods thread-safe. <br>
- * TODO: Design methods to support the ReactiveForwarding and the SDN-IP.
- */
-public class IntentRuntimeModule implements IIntentRuntimeService {
- @Override
- public boolean install(Intent intent) {
- // TODO: implement this method
- return false;
- }
-
- @Override
- public boolean remove(IntentId id) {
- // TODO: implement this method
- return false;
- }
-
- @Override
- public Intent getIntent(IntentId id) {
- // TODO Auto-generated method stub
- // - retrieves intents from global distributed maps
- return null;
- }
-
- @Override
- public Collection<Intent> getIntents() {
- // TODO Auto-generated method stub
- // - retrieves intents from global distributed maps
- return null;
- }
-
- @Override
- public boolean executeBatch(IntentBatchOperation ops) {
- // TODO Auto-generated method stub
- // - gets flow operations using compile() method for each Intent object.
- // - allocates resources
- // - combines and executes flow operations using FlowManager Service.
- // - updates global distributed maps
- return false;
- }
-
- @Override
- public <T extends Intent> void addResolver(Class<T> type, IntentResolver<T> resolver) {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- @Override
- public <T extends Intent> void removeResolver(Class<T> type) {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- @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<Flow> getFlows(String intentId) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Intent getIntentByFlow(FlowId flowId) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void setConflictDetectionPolicy(ConflictDetectionPolicy policy) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public ConflictDetectionPolicy getConflictDetectionPolicy() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void addEventListener(EventListener listener) {
- // TODO Auto-generated method stub
- // - listener for addition/removal of intents,
- // and states changes of intents
- }
-
- @Override
- public void removeEventListener(EventListener listener) {
- // TODO Auto-generated method stub
-
- }
-}
diff --git a/src/main/java/net/onrc/onos/core/newintent/MultiPointToSinglePointIntent.java b/src/main/java/net/onrc/onos/core/newintent/MultiPointToSinglePointIntent.java
deleted file mode 100644
index e411dd9..0000000
--- a/src/main/java/net/onrc/onos/core/newintent/MultiPointToSinglePointIntent.java
+++ /dev/null
@@ -1,120 +0,0 @@
-package net.onrc.onos.core.newintent;
-
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableList;
-import net.onrc.onos.api.intent.Intent;
-import net.onrc.onos.api.intent.IntentId;
-import net.onrc.onos.core.matchaction.action.Action;
-import net.onrc.onos.core.matchaction.match.Match;
-import net.onrc.onos.core.util.SwitchPort;
-
-import java.util.List;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * The class represents multiple sources, single destination tree like connectivity.
- *
- * <p>
- * This class is intended to be used for the SDN-IP application.
- * </p>
- */
-public class MultiPointToSinglePointIntent extends Intent {
- private final ImmutableList<SwitchPort> ingressPorts;
- private final SwitchPort egressPort;
- private final Match match;
- private final ImmutableList<Action> modifications;
-
- /**
- * Constructs an intent representing multiple sources, single destination
- * tree like connectivity.
- *
- * @param id the ID of the intent.
- * @param ingressPorts the ingress ports.
- * @param egressPort the egress port.
- * @param match the filter condition of the incoming traffic which can go through.
- * @param modifications the modification actions to the outgoing traffic.
- */
- public MultiPointToSinglePointIntent(IntentId id,
- List<SwitchPort> ingressPorts,
- SwitchPort egressPort,
- Match match,
- List<Action> modifications) {
- super(id);
-
- this.ingressPorts = ImmutableList.copyOf(checkNotNull(ingressPorts));
- this.egressPort = checkNotNull(egressPort);
- this.match = checkNotNull(match);
- this.modifications = ImmutableList.copyOf(checkNotNull(modifications));
- }
-
- /**
- * Returns the ingress ports.
- *
- * @return the ingress ports.
- */
- public ImmutableList<SwitchPort> getIngressPorts() {
- return ingressPorts;
- }
-
- /**
- * Returns the egress port.
- *
- * @return the egress port.
- */
- public SwitchPort getEgressPort() {
- return egressPort;
- }
-
- /**
- * Returns the filter condition of the incoming traffic which can go through.
- *
- * @return the filter condition of the incoming traffic which can go through.
- */
- public Match getMatch() {
- return match;
- }
-
- /**
- * Returns the modification actions to the outgoing traffic.
- *
- * @return the modification actions to the outgoing traffic.
- */
- public ImmutableList<Action> getModifications() {
- return modifications;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(getId(), ingressPorts, egressPort, match, modifications);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
-
- if (!(obj instanceof MultiPointToSinglePointIntent)) {
- return false;
- }
-
- MultiPointToSinglePointIntent that = (MultiPointToSinglePointIntent) obj;
- return Objects.equal(this.getId(), that.getId())
- && Objects.equal(this.ingressPorts, that.ingressPorts)
- && Objects.equal(this.egressPort, that.egressPort)
- && Objects.equal(this.match, that.match)
- && Objects.equal(this.modifications, that.modifications);
- }
-
- @Override
- public String toString() {
- return Objects.toStringHelper(this)
- .add("id", getId())
- .add("ingressPorts", ingressPorts)
- .add("egressPort", egressPort)
- .add("match", match)
- .add("modifications", modifications)
- .toString();
- }
-}
diff --git a/src/main/java/net/onrc/onos/core/newintent/PointToPointIntent.java b/src/main/java/net/onrc/onos/core/newintent/PointToPointIntent.java
deleted file mode 100644
index 95e6be8..0000000
--- a/src/main/java/net/onrc/onos/core/newintent/PointToPointIntent.java
+++ /dev/null
@@ -1,151 +0,0 @@
-package net.onrc.onos.core.newintent;
-
-import com.google.common.base.Objects;
-import net.onrc.onos.api.intent.Intent;
-import net.onrc.onos.api.intent.IntentId;
-import net.onrc.onos.core.matchaction.match.Match;
-import net.onrc.onos.core.util.Pair;
-import net.onrc.onos.core.util.SwitchPort;
-
-import java.util.concurrent.TimeUnit;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * This class represents point-to-point connectivity.
- */
-public class PointToPointIntent extends Intent {
- private final SwitchPort ingressPort;
- private final SwitchPort egressPort;
- private final Match match;
- private final long idleTimeout;
- private final TimeUnit unit;
-
- /**
- * Constructs an intent representing ingress port to egress port
- * connectivity with a given match condition.
- *
- * @param id ID of this Intent object.
- * @param ingressPort the ingress port where a path is originated.
- * @param egressPort the egress port where a path is terminated.
- * @param match the match condition of a path established by this intent.
- */
- public PointToPointIntent(IntentId id,
- SwitchPort ingressPort, SwitchPort egressPort,
- Match match) {
- this(id, ingressPort, egressPort, match, 0, TimeUnit.SECONDS);
- }
-
- /**
- * Constructs an intent representing ingress port to egress port
- * connectivity with a given match condition
- * and idle timeout.
- *
- * @param id ID of this Intent object.
- * @param ingressPort the ingress port where a path is originated.
- * @param egressPort the egress port where a path is terminated.
- * @param match the match condition of a path established by this intent.
- * @param idleTimeout the maximum time to be idle.
- * @param unit the unit of the idleTimeout argument.
- */
- public PointToPointIntent(IntentId id,
- SwitchPort ingressPort, SwitchPort egressPort,
- Match match, long idleTimeout, TimeUnit unit) {
- super(id);
-
- checkArgument(idleTimeout >= 0, "idleTimeout should not be negative");
-
- this.ingressPort = checkNotNull(ingressPort);
- this.egressPort = checkNotNull(egressPort);
- this.match = checkNotNull(match);
- this.idleTimeout = idleTimeout;
- this.unit = checkNotNull(unit);
- }
-
- /**
- * Returns the ingress port.
- *
- * @return the ingress port.
- */
- public SwitchPort getIngressPort() {
- return ingressPort;
- }
-
- /**
- * Returns the egress port.
- *
- * @return the egress port.
- */
- public SwitchPort getEgressPort() {
- return egressPort;
- }
-
- /**
- * Returns the match condition.
- *
- * @return the match condition.
- */
- public Match getMatch() {
- return match;
- }
-
- /**
- * Returns the idle timeout.
- *
- * @return the idle timeout.
- */
- public Pair<Long, TimeUnit> getIdleTimeout() {
- return new Pair<>(idleTimeout, unit);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(getId(), ingressPort, egressPort, match, idleTimeout, unit);
- }
-
- /**
- * Compares the specified object with this intent for equality.
- *
- * <p>
- * Note: Comparison of idleTimeout value is done in micro-second precision.
- * Then the value less than a micro second is truncated. In addition, the comparison
- * is done between long values. It causes overflow if the idleTimeout is large.
- * </p>
- *
- * @param obj the object to be compared with this intent for equality.
- * @return true if the specified object is equal to this intent.
- */
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
-
- if (!(obj instanceof PointToPointIntent)) {
- return false;
- }
-
- PointToPointIntent that = (PointToPointIntent) obj;
- long thisIdleTimeoutInMicro = this.unit.toMicros(this.idleTimeout);
- long thatIdleTimeoutInMicro = that.unit.toMicros(that.idleTimeout);
-
- return Objects.equal(this.getId(), that.getId())
- && Objects.equal(this.ingressPort, that.ingressPort)
- && Objects.equal(this.egressPort, that.egressPort)
- && Objects.equal(this.match, that.match)
- && Objects.equal(thisIdleTimeoutInMicro, thatIdleTimeoutInMicro);
- }
-
- @Override
- public String toString() {
- return Objects.toStringHelper(this)
- .add("id", getId())
- .add("ingressPort", ingressPort)
- .add("egressPort", egressPort)
- .add("match", match)
- .add("idleTimeout", idleTimeout)
- .add("unit", unit)
- .toString();
- }
-}
diff --git a/src/test/java/net/onrc/onos/api/intent/IntentIdTest.java b/src/test/java/net/onrc/onos/api/intent/IntentIdTest.java
deleted file mode 100644
index fb563c3..0000000
--- a/src/test/java/net/onrc/onos/api/intent/IntentIdTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package net.onrc.onos.api.intent;
-
-import org.junit.Test;
-
-import static net.onrc.onos.core.util.ImmutableClassChecker.assertThatClassIsImmutable;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.not;
-import static org.junit.Assert.assertThat;
-
-/**
- * This class tests the immutability, equality, and non-equality of {@link IntentId}.
- */
-public class IntentIdTest {
- /**
- * Tests the immutability of {@link IntentId}.
- */
- @Test
- public void intentIdFollowsGuidelineForImmutableObject() {
- assertThatClassIsImmutable(IntentId.class);
- }
-
- /**
- * Tests equality of {@link IntentId}.
- */
- @Test
- public void testEquality() {
- IntentId id1 = new IntentId(1L);
- IntentId id2 = new IntentId(1L);
-
- assertThat(id1, is(id2));
- }
-
- /**
- * Tests non-equality of {@link IntentId}.
- */
- @Test
- public void testNonEquality() {
- IntentId id1 = new IntentId(1L);
- IntentId id2 = new IntentId(2L);
-
- assertThat(id1, is(not(id2)));
- }
-}
diff --git a/src/test/java/net/onrc/onos/api/newintent/IntentIdTest.java b/src/test/java/net/onrc/onos/api/newintent/IntentIdTest.java
index 01b65c0..785453d 100644
--- a/src/test/java/net/onrc/onos/api/newintent/IntentIdTest.java
+++ b/src/test/java/net/onrc/onos/api/newintent/IntentIdTest.java
@@ -10,11 +10,11 @@
/**
* This class tests the immutability, equality, and non-equality of
- * {@link net.onrc.onos.api.intent.IntentId}.
+ * {@link IntentId}.
*/
public class IntentIdTest {
/**
- * Tests the immutability of {@link net.onrc.onos.api.intent.IntentId}.
+ * Tests the immutability of {@link IntentId}.
*/
@Test
public void intentIdFollowsGuidelineForImmutableObject() {
@@ -22,7 +22,7 @@
}
/**
- * Tests equality of {@link net.onrc.onos.api.intent.IntentId}.
+ * Tests equality of {@link IntentId}.
*/
@Test
public void testEquality() {
@@ -33,7 +33,7 @@
}
/**
- * Tests non-equality of {@link net.onrc.onos.api.intent.IntentId}.
+ * Tests non-equality of {@link IntentId}.
*/
@Test
public void testNonEquality() {
diff --git a/src/test/java/net/onrc/onos/core/newintent/PointToPointIntentTest.java b/src/test/java/net/onrc/onos/core/newintent/PointToPointIntentTest.java
deleted file mode 100644
index ea57863..0000000
--- a/src/test/java/net/onrc/onos/core/newintent/PointToPointIntentTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package net.onrc.onos.core.newintent;
-
-import net.onrc.onos.api.intent.IntentId;
-import net.onrc.onos.core.matchaction.match.PacketMatch;
-import net.onrc.onos.core.util.SwitchPort;
-import org.junit.Test;
-
-import java.util.concurrent.TimeUnit;
-
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-public class PointToPointIntentTest {
- private final IntentId id = new IntentId(0);
- private final SwitchPort port1 = new SwitchPort(0L, 0L);
- private final SwitchPort port2 = new SwitchPort(1L, 1L);
- private final PacketMatch match = new PacketMatch();
-
- @Test
- public void testEqualityWhenIdleTimeoutIsZero() {
- PointToPointIntent intent1 = new PointToPointIntent(id, port1, port2, match,
- 0, TimeUnit.DAYS);
- PointToPointIntent intent2 = new PointToPointIntent(id, port1, port2, match,
- 0, TimeUnit.SECONDS);
-
- assertThat(intent1, is(intent2));
- }
-
- @Test
- public void testEqualityWhenIdleTimeoutIsOneSecond() {
- PointToPointIntent intent1 = new PointToPointIntent(id, port1, port2, match,
- 1, TimeUnit.SECONDS);
- PointToPointIntent intent2 = new PointToPointIntent(id, port1, port2, match,
- 1000, TimeUnit.MILLISECONDS);
-
- assertThat(intent1, is(intent2));
- }
-
- @Test
- public void testEqualityWhenIdleTimeoutIsTruncated() {
- PointToPointIntent intent1 = new PointToPointIntent(id, port1, port2, match,
- 1, TimeUnit.MICROSECONDS);
- PointToPointIntent intent2 = new PointToPointIntent(id, port1, port2, match,
- 1001, TimeUnit.NANOSECONDS);
-
- assertThat(intent1, is(intent2));
- }
-}