Update onos.api.batchoperation package.
This task is a part of ONOS-1692.
- Removed UpdateOperation class and related methods.
- Updated AddOperation and RemoveOperation classes to use generic type parameter.
- Added unit tests.
Change-Id: Ifbc34f15dd06f430f4dc8cd658c7932d03cb0515
diff --git a/src/main/java/net/onrc/onos/api/batchoperation/AddOperation.java b/src/main/java/net/onrc/onos/api/batchoperation/AddOperation.java
index 7e8b97a..f8fb8d0 100644
--- a/src/main/java/net/onrc/onos/api/batchoperation/AddOperation.java
+++ b/src/main/java/net/onrc/onos/api/batchoperation/AddOperation.java
@@ -3,15 +3,16 @@
/**
* An add-operation entry of a batch operation.
*/
-public class AddOperation implements BatchOperationEntry {
- private final IBatchOperationTarget target;
+public class AddOperation<T extends IBatchOperationTarget>
+ implements BatchOperationEntry<T> {
+ private final T target;
/**
* Creates a add-operation with specified target.
*
- * @param target The target object to be assigned to this add-operation.
+ * @param target the target object to be assigned to this add-operation
*/
- public AddOperation(IBatchOperationTarget target) {
+ public AddOperation(T target) {
this.target = target;
}
@@ -23,9 +24,9 @@
/**
* Gets the target object which assigned to this add-operation.
*
- * @return The target object which assigned to this add-operation.
+ * @return the target object which assigned to this add-operation
*/
- public IBatchOperationTarget getTarget() {
+ public T getTarget() {
return target;
}
}
diff --git a/src/main/java/net/onrc/onos/api/batchoperation/BatchOperation.java b/src/main/java/net/onrc/onos/api/batchoperation/BatchOperation.java
index 9fc20c0..cb8ddd8 100644
--- a/src/main/java/net/onrc/onos/api/batchoperation/BatchOperation.java
+++ b/src/main/java/net/onrc/onos/api/batchoperation/BatchOperation.java
@@ -12,13 +12,13 @@
* MatchAction.
*/
public class BatchOperation<T extends IBatchOperationTarget> {
- private List<BatchOperationEntry> ops;
+ private List<BatchOperationEntry<T>> ops;
/**
* Constructor.
*/
public BatchOperation() {
- ops = new LinkedList<BatchOperationEntry>();
+ ops = new LinkedList<>();
}
/**
@@ -31,7 +31,7 @@
/**
* Returns the number of operations in this object.
*
- * @return the number of operations in this object.
+ * @return the number of operations in this object
*/
public int size() {
return ops.size();
@@ -40,50 +40,38 @@
/**
* Returns an iterator over the operations in this object.
*
- * @return an iterator over the operations in this object.
+ * @return an iterator over the operations in this object
*/
- public Iterator<BatchOperationEntry> iterator() {
+ public Iterator<BatchOperationEntry<T>> iterator() {
return ops.iterator();
}
/**
* Returns the operations in this object.
*
- * @return the operations in this object.
+ * @return the operations in this object
*/
- public List<BatchOperationEntry> getOperations() {
+ public List<BatchOperationEntry<T>> getOperations() {
return Collections.unmodifiableList(ops);
}
/**
* Adds an add-operation.
*
- * @param target IBatchOperationTarget object to be added.
- * @return true if succeeded, false otherwise.
+ * @param target IBatchOperationTarget object to be added
+ * @return true if succeeded, false otherwise
*/
public boolean addAddOperation(T target) {
- return ops.add(new AddOperation(target));
+ return ops.add(new AddOperation<T>(target));
}
/**
* Adds a remove-operation.
*
- * @param id ID of the target to be removed.
- * @return true if succeeded, false otherwise.
+ * @param id ID of the target to be removed
+ * @return true if succeeded, false otherwise
*/
public boolean addRemoveOperation(BatchOperationTargetId id) {
- return ops.add(new RemoveOperation(id));
- }
-
- /**
- * Adds an update-operation.
- * <p>
- * The existing entry having the same ID with the new target is overwritten.
- *
- * @param target The new target to be used for the update.
- * @return true if succeeded, false otherwise.
- */
- public boolean addUpdateOperation(T target) {
- return ops.add(new UpdateOperation(target));
+ return ops.add(new RemoveOperation<T>(id));
}
}
diff --git a/src/main/java/net/onrc/onos/api/batchoperation/BatchOperationEntry.java b/src/main/java/net/onrc/onos/api/batchoperation/BatchOperationEntry.java
index fce31d1..7274d5f 100644
--- a/src/main/java/net/onrc/onos/api/batchoperation/BatchOperationEntry.java
+++ b/src/main/java/net/onrc/onos/api/batchoperation/BatchOperationEntry.java
@@ -6,11 +6,11 @@
* This is the interface to AddOperation, UpdateOperation and RemoveOperation
* classes which are the entry maintained by BatchOperation.
*/
-public interface BatchOperationEntry {
+public interface BatchOperationEntry<T extends IBatchOperationTarget> {
/**
* Gets the BatchOperator of this operation.
*
- * @return The BatchOperator of this operation.
+ * @return the BatchOperator of this operation
*/
public BatchOperator getOperator();
}
diff --git a/src/main/java/net/onrc/onos/api/batchoperation/BatchOperationTargetId.java b/src/main/java/net/onrc/onos/api/batchoperation/BatchOperationTargetId.java
index dfa3da9..d2d0ad1 100644
--- a/src/main/java/net/onrc/onos/api/batchoperation/BatchOperationTargetId.java
+++ b/src/main/java/net/onrc/onos/api/batchoperation/BatchOperationTargetId.java
@@ -10,7 +10,7 @@
/**
* Returns a string representation of the target object's ID.
*
- * @return a string representation of the target object's ID.
+ * @return a string representation of the target object's ID
*/
@Override
public abstract String toString();
diff --git a/src/main/java/net/onrc/onos/api/batchoperation/BatchOperator.java b/src/main/java/net/onrc/onos/api/batchoperation/BatchOperator.java
index 00ab908..0b9a2ce 100644
--- a/src/main/java/net/onrc/onos/api/batchoperation/BatchOperator.java
+++ b/src/main/java/net/onrc/onos/api/batchoperation/BatchOperator.java
@@ -5,22 +5,17 @@
*/
public enum BatchOperator {
/**
- * Adds new intent.
+ * Adds new target object.
*/
ADD,
/**
- * Removes existing intent specified by intent ID.
+ * Removes existing object.
*/
REMOVE,
/**
- * Overwrites existing intent using new intent.
- */
- UPDATE,
-
- /**
- * Unknown type.
+ * Unknown operator type.
*/
UNKNOWN,
}
diff --git a/src/main/java/net/onrc/onos/api/batchoperation/IBatchOperationTarget.java b/src/main/java/net/onrc/onos/api/batchoperation/IBatchOperationTarget.java
index 45e05ea..3b2d3d9 100644
--- a/src/main/java/net/onrc/onos/api/batchoperation/IBatchOperationTarget.java
+++ b/src/main/java/net/onrc/onos/api/batchoperation/IBatchOperationTarget.java
@@ -7,7 +7,7 @@
/**
* Gets ID of the object.
*
- * @return ID of the object.
+ * @return ID of the object
*/
public BatchOperationTargetId getId();
}
diff --git a/src/main/java/net/onrc/onos/api/batchoperation/RemoveOperation.java b/src/main/java/net/onrc/onos/api/batchoperation/RemoveOperation.java
index bafe926..52eec95 100644
--- a/src/main/java/net/onrc/onos/api/batchoperation/RemoveOperation.java
+++ b/src/main/java/net/onrc/onos/api/batchoperation/RemoveOperation.java
@@ -3,14 +3,14 @@
/**
* A remove-operation entry of a batch operation.
*/
-public class RemoveOperation implements BatchOperationEntry {
+public class RemoveOperation<T extends IBatchOperationTarget>
+ implements BatchOperationEntry<T> {
private final BatchOperationTargetId targetId;
/**
* Creates a remove-operation with specified target.
*
- * @param id The target object ID to be assigned to this
- * remove-operation.
+ * @param id the target object ID to be assigned to this remove-operation
*/
public RemoveOperation(BatchOperationTargetId id) {
this.targetId = id;
@@ -24,7 +24,7 @@
/**
* Gets the target ID to be removed.
*
- * @return The target ID to be removed.
+ * @return the target ID to be removed
*/
public BatchOperationTargetId getTargetId() {
return targetId;
diff --git a/src/main/java/net/onrc/onos/api/batchoperation/UpdateOperation.java b/src/main/java/net/onrc/onos/api/batchoperation/UpdateOperation.java
deleted file mode 100644
index a2f368e..0000000
--- a/src/main/java/net/onrc/onos/api/batchoperation/UpdateOperation.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package net.onrc.onos.api.batchoperation;
-
-/**
- * An update-operation entry of a batch operation.
- */
-public class UpdateOperation implements BatchOperationEntry {
- private final IBatchOperationTarget target;
-
- /**
- * Creates an update-operation with specified targets.
- *
- * @param target The new target to be used for the update.
- */
- public UpdateOperation(IBatchOperationTarget target) {
- this.target = target;
- }
-
- @Override
- public BatchOperator getOperator() {
- return BatchOperator.UPDATE;
- }
-
- /**
- * Gets the new target object to be used for the update.
- *
- * @return The new target object to be used for the update.
- */
- public IBatchOperationTarget getTarget() {
- return target;
- }
-
-}
diff --git a/src/main/java/net/onrc/onos/api/flowmanager/IFlowManagerService.java b/src/main/java/net/onrc/onos/api/flowmanager/IFlowManagerService.java
index ca4e5f7..fcfaacb 100644
--- a/src/main/java/net/onrc/onos/api/flowmanager/IFlowManagerService.java
+++ b/src/main/java/net/onrc/onos/api/flowmanager/IFlowManagerService.java
@@ -20,78 +20,67 @@
/**
* Adds IFlow object, calculates match-action plan and executes it.
*
- * @param flow IFlow object to be added.
- * @return true if succeeded, false otherwise.
+ * @param flow IFlow object to be added
+ * @return true if succeeded, false otherwise
*/
boolean addFlow(IFlow flow);
/**
* Removes IFlow object, calculates match-action plan and executes it.
*
- * @param id ID for IFlow object to be removed.
- * @return true if succeeded, false otherwise.
+ * @param id ID for IFlow object to be removed
+ * @return true if succeeded, false otherwise
*/
boolean removeFlow(FlowId id);
/**
- * Updates IFlow object, calculates match-action plan and executes it.
- * <p>
- * The IFlow object having the ID which is the same to the ID of the IFlow
- * object specified by the parameter will be updated.
- *
- * @param flow new IFlow object for the update.
- * @return true if succeeded, false otherwise.
- */
- boolean updateFlow(IFlow flow);
-
- /**
* Gets IFlow object.
*
- * @param id ID of IFlow object.
- * @return IFlow object if found, null otherwise.
+ * @param id ID of IFlow object
+ * @return IFlow object if found, null otherwise
*/
IFlow getFlow(FlowId id);
/**
* Gets All IFlow objects.
*
- * @return the collection of IFlow objects.
+ * @return the collection of IFlow objects
*/
Collection<IFlow> getFlows();
/**
* Executes batch operation of IFlow object.
*
- * @param ops FlowOperations to be executed.
- * @return true if succeeded, false otherwise.
+ * @param ops FlowOperations to be executed
+ * @return true if succeeded, false otherwise
*/
boolean executeBatch(BatchOperation<IFlow> ops);
/**
* Sets a conflict detection policy.
*
- * @param policy ConflictDetectionPolicy object to be set.
+ * @param policy ConflictDetectionPolicy object to be set
*/
void setConflictDetectionPolicy(ConflictDetectionPolicy policy);
/**
* Gets the conflict detection policy.
*
- * @return ConflictDetectionPolicy object being applied currently.
+ * @return ConflictDetectionPolicy object being applied currently
*/
ConflictDetectionPolicy getConflictDetectionPolicy();
/**
* Adds event listener to this service.
*
- * @param listener EventListener to be added.
+ * @param listener EventListener to be added
*/
void addEventListener(EventListener listener);
/**
* Removes event listener from this service.
*
- * @param listener EventListener to be removed.
+ * @param listener EventListener to be removed
*/
void removeEventListener(EventListener listener);
}
diff --git a/src/main/java/net/onrc/onos/core/flowmanager/FlowManagerModule.java b/src/main/java/net/onrc/onos/core/flowmanager/FlowManagerModule.java
index 1f5f446..8775737 100644
--- a/src/main/java/net/onrc/onos/core/flowmanager/FlowManagerModule.java
+++ b/src/main/java/net/onrc/onos/core/flowmanager/FlowManagerModule.java
@@ -40,13 +40,6 @@
}
@Override
- public boolean updateFlow(IFlow flow) {
- BatchOperation<IFlow> ops = new BatchOperation<IFlow>();
- ops.addUpdateOperation(flow);
- return executeBatch(ops);
- }
-
- @Override
public IFlow getFlow(FlowId id) {
// TODO Auto-generated method stub
return null;
diff --git a/src/main/java/net/onrc/onos/core/matchaction/IMatchActionService.java b/src/main/java/net/onrc/onos/core/matchaction/IMatchActionService.java
index 9a87da9..1ff8e28 100644
--- a/src/main/java/net/onrc/onos/core/matchaction/IMatchActionService.java
+++ b/src/main/java/net/onrc/onos/core/matchaction/IMatchActionService.java
@@ -26,15 +26,6 @@
boolean removeMatchAction(MatchActionId id);
/**
- * Replaces the existing match-action entry by specified match-action entry.
- *
- * @param matchAction MatchAction object which overwrites existing
- * match-action.
- * @return true if succeeded, false otherwise.
- */
- boolean updateMatchAction(MatchAction matchAction);
-
- /**
* Gets the set of match-action entries.
*
* @return The set of match-action entries.
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 c1fbd8e..c0dab41 100644
--- a/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java
@@ -32,15 +32,6 @@
}
@Override
- public boolean updateMatchAction(MatchAction matchAction) {
- BatchOperation<MatchAction> phase = new BatchOperation<MatchAction>();
- phase.addUpdateOperation(matchAction);
- MatchActionPlan plan = new MatchActionPlan();
- plan.addPhase(phase);
- return executePlan(plan);
- }
-
- @Override
public Collection<MatchAction> getMatchActions() {
// TODO Auto-generated method stub
return null;