Apply the naming convention to BatchOperationEntry
Resolve ONOS-889
Change-Id: I2001fabba138b9ff5be9a5943d3f020b4c38d195
diff --git a/core/api/src/main/java/org/onosproject/net/flow/BatchOperationEntry.java b/core/api/src/main/java/org/onosproject/net/flow/BatchOperationEntry.java
index fc24775..7e0d5b5 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/BatchOperationEntry.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/BatchOperationEntry.java
@@ -48,7 +48,17 @@
*
* @return the target object of this operation
*/
+ @Deprecated
public U getTarget() {
+ return target();
+ }
+
+ /**
+ * Gets the target object of this operation.
+ *
+ * @return the target object of this operation
+ */
+ public U target() {
return target;
}
@@ -57,7 +67,17 @@
*
* @return the operator of this operation
*/
+ @Deprecated
public T getOperator() {
+ return operator();
+ }
+
+ /**
+ * Gets the operator of this operation.
+ *
+ * @return the operator of this operation
+ */
+ public T operator() {
return operator;
}
diff --git a/core/api/src/main/java/org/onosproject/net/flow/FlowRuleBatchRequest.java b/core/api/src/main/java/org/onosproject/net/flow/FlowRuleBatchRequest.java
index a0be81c..35db171 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/FlowRuleBatchRequest.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/FlowRuleBatchRequest.java
@@ -44,7 +44,7 @@
@Override
public FlowRule apply(FlowRuleBatchEntry input) {
- return input.getTarget();
+ return input.target();
}
}).toList();
}
@@ -55,7 +55,7 @@
@Override
public FlowRule apply(FlowRuleBatchEntry input) {
- return input.getTarget();
+ return input.target();
}
}).toList();
}
diff --git a/core/api/src/test/java/org/onosproject/net/flow/BatchOperationTest.java b/core/api/src/test/java/org/onosproject/net/flow/BatchOperationTest.java
index 1395b8c..b4ca8fe 100644
--- a/core/api/src/test/java/org/onosproject/net/flow/BatchOperationTest.java
+++ b/core/api/src/test/java/org/onosproject/net/flow/BatchOperationTest.java
@@ -147,7 +147,7 @@
public void testEntryConstruction() {
final TestEntry entry = new TestEntry(TestType.OP3, new TestTarget(3));
- assertThat(entry.getOperator(), is(TestType.OP3));
- assertThat(entry.getTarget().id, is(3));
+ assertThat(entry.operator(), is(TestType.OP3));
+ assertThat(entry.target().id, is(3));
}
}
diff --git a/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleManager.java b/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleManager.java
index 44f6473..6d6cd9a 100644
--- a/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleManager.java
+++ b/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleManager.java
@@ -186,7 +186,7 @@
ArrayListMultimap.create();
List<Future<CompletedBatchOperation>> futures = Lists.newArrayList();
for (FlowRuleBatchEntry fbe : batch.getOperations()) {
- final FlowRule f = fbe.getTarget();
+ final FlowRule f = fbe.target();
perDeviceBatches.put(f.deviceId(), fbe);
}
@@ -400,7 +400,7 @@
FlowRuleBatchOperation batchOperation = request.asBatchOperation();
FlowRuleProvider flowRuleProvider =
- getProvider(batchOperation.getOperations().get(0).getTarget().deviceId());
+ getProvider(batchOperation.getOperations().get(0).target().deviceId());
final Future<CompletedBatchOperation> result =
flowRuleProvider.executeBatch(batchOperation);
futureService.submit(new Runnable() {
@@ -416,7 +416,7 @@
Set<FlowRule> failures = new HashSet<>(batchOperation.size());
for (FlowRuleBatchEntry op : batchOperation.getOperations()) {
- failures.add(op.getTarget());
+ failures.add(op.target());
}
res = new CompletedBatchOperation(false, failures);
store.batchOperationComplete(FlowRuleBatchEvent.completed(request, res));
@@ -565,12 +565,12 @@
log.debug("cleaning up batch");
// TODO convert these into a batch?
for (FlowRuleBatchEntry fbe : batches.values()) {
- if (fbe.getOperator() == FlowRuleOperation.ADD ||
- fbe.getOperator() == FlowRuleOperation.MODIFY) {
- store.deleteFlowRule(fbe.getTarget());
- } else if (fbe.getOperator() == FlowRuleOperation.REMOVE) {
- store.removeFlowRule(new DefaultFlowEntry(fbe.getTarget()));
- store.storeFlowRule(fbe.getTarget());
+ if (fbe.operator() == FlowRuleOperation.ADD ||
+ fbe.operator() == FlowRuleOperation.MODIFY) {
+ store.deleteFlowRule(fbe.target());
+ } else if (fbe.operator() == FlowRuleOperation.REMOVE) {
+ store.removeFlowRule(new DefaultFlowEntry(fbe.target()));
+ store.storeFlowRule(fbe.target());
}
}
}
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/MockFlowRuleService.java b/core/net/src/test/java/org/onosproject/net/intent/impl/MockFlowRuleService.java
index 1da849e..e956575 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/MockFlowRuleService.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/MockFlowRuleService.java
@@ -56,8 +56,8 @@
@Override
public Future<CompletedBatchOperation> applyBatch(FlowRuleBatchOperation batch) {
for (FlowRuleBatchEntry fbe : batch.getOperations()) {
- FlowRule fr = fbe.getTarget();
- switch (fbe.getOperator()) {
+ FlowRule fr = fbe.target();
+ switch (fbe.operator()) {
case ADD:
flows.add(fr);
break;
diff --git a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/DistributedFlowRuleStore.java b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/DistributedFlowRuleStore.java
index b8d3841..09aa401 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/DistributedFlowRuleStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/DistributedFlowRuleStore.java
@@ -363,7 +363,7 @@
Collections.<FlowRule>emptySet()));
}
- DeviceId deviceId = operation.getOperations().get(0).getTarget().deviceId();
+ DeviceId deviceId = operation.getOperations().get(0).target().deviceId();
ReplicaInfo replicaInfo = replicaInfoManager.getReplicaInfoFor(deviceId);
@@ -407,8 +407,8 @@
flowEntriesLock.writeLock().lock();
try {
for (FlowRuleBatchEntry batchEntry : operation.getOperations()) {
- FlowRule flowRule = batchEntry.getTarget();
- FlowRuleOperation op = batchEntry.getOperator();
+ FlowRule flowRule = batchEntry.target();
+ FlowRuleOperation op = batchEntry.operator();
if (did == null) {
did = flowRule.deviceId();
}
@@ -640,13 +640,13 @@
FlowRuleBatchOperation operation = SERIALIZER.decode(message.payload());
log.debug("received batch request {}", operation);
- final DeviceId deviceId = operation.getOperations().get(0).getTarget().deviceId();
+ final DeviceId deviceId = operation.getOperations().get(0).target().deviceId();
ReplicaInfo replicaInfo = replicaInfoManager.getReplicaInfoFor(deviceId);
if (!local.equals(replicaInfo.master().orNull())) {
Set<FlowRule> failures = new HashSet<>(operation.size());
for (FlowRuleBatchEntry op : operation.getOperations()) {
- failures.add(op.getTarget());
+ failures.add(op.target());
}
CompletedBatchOperation allFailed = new CompletedBatchOperation(false, failures);
// This node is no longer the master, respond as all failed.
@@ -675,7 +675,7 @@
// create everything failed response
Set<FlowRule> failures = new HashSet<>(operation.size());
for (FlowRuleBatchEntry op : operation.getOperations()) {
- failures.add(op.getTarget());
+ failures.add(op.target());
}
result = new CompletedBatchOperation(false, failures);
}
@@ -754,7 +754,7 @@
final SMap<FlowId, ImmutableList<StoredFlowEntry>> backupFlowTable = smaps.get(deviceId);
// Following should be rewritten using async APIs
for (FlowRuleBatchEntry bEntry : toAdd) {
- final FlowRule entry = bEntry.getTarget();
+ final FlowRule entry = bEntry.target();
final FlowId id = entry.id();
ImmutableList<StoredFlowEntry> original = backupFlowTable.get(id);
List<StoredFlowEntry> list = new ArrayList<>();
@@ -762,7 +762,7 @@
list.addAll(original);
}
- list.remove(bEntry.getTarget());
+ list.remove(bEntry.target());
list.add((StoredFlowEntry) entry);
ImmutableList<StoredFlowEntry> newValue = ImmutableList.copyOf(list);
@@ -777,7 +777,7 @@
}
}
for (FlowRuleBatchEntry bEntry : toRemove) {
- final FlowRule entry = bEntry.getTarget();
+ final FlowRule entry = bEntry.target();
final FlowId id = entry.id();
ImmutableList<StoredFlowEntry> original = backupFlowTable.get(id);
List<StoredFlowEntry> list = new ArrayList<>();
@@ -785,7 +785,7 @@
list.addAll(original);
}
- list.remove(bEntry.getTarget());
+ list.remove(bEntry.target());
ImmutableList<StoredFlowEntry> newValue = ImmutableList.copyOf(list);
boolean success;
diff --git a/core/store/trivial/src/main/java/org/onosproject/store/trivial/impl/SimpleFlowRuleStore.java b/core/store/trivial/src/main/java/org/onosproject/store/trivial/impl/SimpleFlowRuleStore.java
index e0980f2..9cfb258 100644
--- a/core/store/trivial/src/main/java/org/onosproject/store/trivial/impl/SimpleFlowRuleStore.java
+++ b/core/store/trivial/src/main/java/org/onosproject/store/trivial/impl/SimpleFlowRuleStore.java
@@ -266,13 +266,13 @@
List<FlowRuleBatchEntry> toAdd = new ArrayList<>();
List<FlowRuleBatchEntry> toRemove = new ArrayList<>();
for (FlowRuleBatchEntry entry : batchOperation.getOperations()) {
- final FlowRule flowRule = entry.getTarget();
- if (entry.getOperator().equals(FlowRuleOperation.ADD)) {
+ final FlowRule flowRule = entry.target();
+ if (entry.operator().equals(FlowRuleOperation.ADD)) {
if (!getFlowEntries(flowRule.deviceId(), flowRule.id()).contains(flowRule)) {
storeFlowRule(flowRule);
toAdd.add(entry);
}
- } else if (entry.getOperator().equals(FlowRuleOperation.REMOVE)) {
+ } else if (entry.operator().equals(FlowRuleOperation.REMOVE)) {
if (getFlowEntries(flowRule.deviceId(), flowRule.id()).contains(flowRule)) {
deleteFlowRule(flowRule);
toRemove.add(entry);
diff --git a/providers/null/flow/src/main/java/org/onosproject/provider/nil/flow/impl/NullFlowRuleProvider.java b/providers/null/flow/src/main/java/org/onosproject/provider/nil/flow/impl/NullFlowRuleProvider.java
index b021ab0..e882c76 100644
--- a/providers/null/flow/src/main/java/org/onosproject/provider/nil/flow/impl/NullFlowRuleProvider.java
+++ b/providers/null/flow/src/main/java/org/onosproject/provider/nil/flow/impl/NullFlowRuleProvider.java
@@ -110,16 +110,16 @@
public Future<CompletedBatchOperation> executeBatch(
BatchOperation<FlowRuleBatchEntry> batch) {
for (FlowRuleBatchEntry fbe : batch.getOperations()) {
- switch (fbe.getOperator()) {
+ switch (fbe.operator()) {
case ADD:
- applyFlowRule(fbe.getTarget());
+ applyFlowRule(fbe.target());
break;
case REMOVE:
- removeFlowRule(fbe.getTarget());
+ removeFlowRule(fbe.target());
break;
case MODIFY:
- removeFlowRule(fbe.getTarget());
- applyFlowRule(fbe.getTarget());
+ removeFlowRule(fbe.target());
+ applyFlowRule(fbe.target());
break;
default:
log.error("Unknown flow operation: {}", fbe);
diff --git a/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OpenFlowRuleProvider.java b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OpenFlowRuleProvider.java
index 18aca8a..32dfefd 100644
--- a/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OpenFlowRuleProvider.java
+++ b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OpenFlowRuleProvider.java
@@ -201,7 +201,7 @@
*/
Map<OFFlowMod, OpenFlowSwitch> mods = Maps.newIdentityHashMap();
for (FlowRuleBatchEntry fbe : batch.getOperations()) {
- FlowRule flowRule = fbe.getTarget();
+ FlowRule flowRule = fbe.target();
final Dpid dpid = Dpid.dpid(flowRule.deviceId().uri());
OpenFlowSwitch sw = controller.getSwitch(dpid);
if (sw == null) {
@@ -220,7 +220,7 @@
FlowModBuilder.builder(flowRule, sw.factory(),
Optional.of(flowModXid));
OFFlowMod mod = null;
- switch (fbe.getOperator()) {
+ switch (fbe.operator()) {
case ADD:
mod = builder.buildFlowAdd();
break;
@@ -231,7 +231,7 @@
mod = builder.buildFlowMod();
break;
default:
- log.error("Unsupported batch operation {}", fbe.getOperator());
+ log.error("Unsupported batch operation {}", fbe.operator());
}
if (mod != null) {
mods.put(mod, sw);
@@ -406,7 +406,7 @@
FlowEntry fe = null;
FlowRuleBatchEntry fbe = fms.get(msg.getXid());
failedId = fbe.id();
- FlowRule offending = fbe.getTarget();
+ FlowRule offending = fbe.target();
//TODO handle specific error msgs
switch (msg.getErrType()) {
case BAD_ACTION:
@@ -482,11 +482,11 @@
this.state = BatchState.CANCELLED;
cleanUp();
for (FlowRuleBatchEntry fbe : fms.values()) {
- if (fbe.getOperator() == FlowRuleOperation.ADD ||
- fbe.getOperator() == FlowRuleOperation.MODIFY) {
- removeFlowRule(fbe.getTarget());
- } else if (fbe.getOperator() == FlowRuleOperation.REMOVE) {
- applyRule(fbe.getTarget());
+ if (fbe.operator() == FlowRuleOperation.ADD ||
+ fbe.operator() == FlowRuleOperation.MODIFY) {
+ removeFlowRule(fbe.target());
+ } else if (fbe.operator() == FlowRuleOperation.REMOVE) {
+ applyRule(fbe.target());
}
}
@@ -554,7 +554,7 @@
.add("pending devices", sws)
.add("devices in batch",
fms.values().stream()
- .map((fbe) -> fbe.getTarget().deviceId())
+ .map((fbe) -> fbe.target().deviceId())
.distinct().collect(Collectors.toList()))
.add("failedId", failedId)
.add("latchCount", countDownLatch.getCount())