Sho SHIMIZU
Committed by Gerrit Code Review

Apply the naming convention to BatchOperationEntry

Resolve ONOS-889

Change-Id: I2001fabba138b9ff5be9a5943d3f020b4c38d195
...@@ -48,7 +48,17 @@ public class BatchOperationEntry<T extends Enum<?>, U> { ...@@ -48,7 +48,17 @@ public class BatchOperationEntry<T extends Enum<?>, U> {
48 * 48 *
49 * @return the target object of this operation 49 * @return the target object of this operation
50 */ 50 */
51 + @Deprecated
51 public U getTarget() { 52 public U getTarget() {
53 + return target();
54 + }
55 +
56 + /**
57 + * Gets the target object of this operation.
58 + *
59 + * @return the target object of this operation
60 + */
61 + public U target() {
52 return target; 62 return target;
53 } 63 }
54 64
...@@ -57,7 +67,17 @@ public class BatchOperationEntry<T extends Enum<?>, U> { ...@@ -57,7 +67,17 @@ public class BatchOperationEntry<T extends Enum<?>, U> {
57 * 67 *
58 * @return the operator of this operation 68 * @return the operator of this operation
59 */ 69 */
70 + @Deprecated
60 public T getOperator() { 71 public T getOperator() {
72 + return operator();
73 + }
74 +
75 + /**
76 + * Gets the operator of this operation.
77 + *
78 + * @return the operator of this operation
79 + */
80 + public T operator() {
61 return operator; 81 return operator;
62 } 82 }
63 83
......
...@@ -44,7 +44,7 @@ public class FlowRuleBatchRequest { ...@@ -44,7 +44,7 @@ public class FlowRuleBatchRequest {
44 44
45 @Override 45 @Override
46 public FlowRule apply(FlowRuleBatchEntry input) { 46 public FlowRule apply(FlowRuleBatchEntry input) {
47 - return input.getTarget(); 47 + return input.target();
48 } 48 }
49 }).toList(); 49 }).toList();
50 } 50 }
...@@ -55,7 +55,7 @@ public class FlowRuleBatchRequest { ...@@ -55,7 +55,7 @@ public class FlowRuleBatchRequest {
55 55
56 @Override 56 @Override
57 public FlowRule apply(FlowRuleBatchEntry input) { 57 public FlowRule apply(FlowRuleBatchEntry input) {
58 - return input.getTarget(); 58 + return input.target();
59 } 59 }
60 }).toList(); 60 }).toList();
61 } 61 }
......
...@@ -147,7 +147,7 @@ public class BatchOperationTest { ...@@ -147,7 +147,7 @@ public class BatchOperationTest {
147 public void testEntryConstruction() { 147 public void testEntryConstruction() {
148 final TestEntry entry = new TestEntry(TestType.OP3, new TestTarget(3)); 148 final TestEntry entry = new TestEntry(TestType.OP3, new TestTarget(3));
149 149
150 - assertThat(entry.getOperator(), is(TestType.OP3)); 150 + assertThat(entry.operator(), is(TestType.OP3));
151 - assertThat(entry.getTarget().id, is(3)); 151 + assertThat(entry.target().id, is(3));
152 } 152 }
153 } 153 }
......
...@@ -186,7 +186,7 @@ public class FlowRuleManager ...@@ -186,7 +186,7 @@ public class FlowRuleManager
186 ArrayListMultimap.create(); 186 ArrayListMultimap.create();
187 List<Future<CompletedBatchOperation>> futures = Lists.newArrayList(); 187 List<Future<CompletedBatchOperation>> futures = Lists.newArrayList();
188 for (FlowRuleBatchEntry fbe : batch.getOperations()) { 188 for (FlowRuleBatchEntry fbe : batch.getOperations()) {
189 - final FlowRule f = fbe.getTarget(); 189 + final FlowRule f = fbe.target();
190 perDeviceBatches.put(f.deviceId(), fbe); 190 perDeviceBatches.put(f.deviceId(), fbe);
191 } 191 }
192 192
...@@ -400,7 +400,7 @@ public class FlowRuleManager ...@@ -400,7 +400,7 @@ public class FlowRuleManager
400 FlowRuleBatchOperation batchOperation = request.asBatchOperation(); 400 FlowRuleBatchOperation batchOperation = request.asBatchOperation();
401 401
402 FlowRuleProvider flowRuleProvider = 402 FlowRuleProvider flowRuleProvider =
403 - getProvider(batchOperation.getOperations().get(0).getTarget().deviceId()); 403 + getProvider(batchOperation.getOperations().get(0).target().deviceId());
404 final Future<CompletedBatchOperation> result = 404 final Future<CompletedBatchOperation> result =
405 flowRuleProvider.executeBatch(batchOperation); 405 flowRuleProvider.executeBatch(batchOperation);
406 futureService.submit(new Runnable() { 406 futureService.submit(new Runnable() {
...@@ -416,7 +416,7 @@ public class FlowRuleManager ...@@ -416,7 +416,7 @@ public class FlowRuleManager
416 416
417 Set<FlowRule> failures = new HashSet<>(batchOperation.size()); 417 Set<FlowRule> failures = new HashSet<>(batchOperation.size());
418 for (FlowRuleBatchEntry op : batchOperation.getOperations()) { 418 for (FlowRuleBatchEntry op : batchOperation.getOperations()) {
419 - failures.add(op.getTarget()); 419 + failures.add(op.target());
420 } 420 }
421 res = new CompletedBatchOperation(false, failures); 421 res = new CompletedBatchOperation(false, failures);
422 store.batchOperationComplete(FlowRuleBatchEvent.completed(request, res)); 422 store.batchOperationComplete(FlowRuleBatchEvent.completed(request, res));
...@@ -565,12 +565,12 @@ public class FlowRuleManager ...@@ -565,12 +565,12 @@ public class FlowRuleManager
565 log.debug("cleaning up batch"); 565 log.debug("cleaning up batch");
566 // TODO convert these into a batch? 566 // TODO convert these into a batch?
567 for (FlowRuleBatchEntry fbe : batches.values()) { 567 for (FlowRuleBatchEntry fbe : batches.values()) {
568 - if (fbe.getOperator() == FlowRuleOperation.ADD || 568 + if (fbe.operator() == FlowRuleOperation.ADD ||
569 - fbe.getOperator() == FlowRuleOperation.MODIFY) { 569 + fbe.operator() == FlowRuleOperation.MODIFY) {
570 - store.deleteFlowRule(fbe.getTarget()); 570 + store.deleteFlowRule(fbe.target());
571 - } else if (fbe.getOperator() == FlowRuleOperation.REMOVE) { 571 + } else if (fbe.operator() == FlowRuleOperation.REMOVE) {
572 - store.removeFlowRule(new DefaultFlowEntry(fbe.getTarget())); 572 + store.removeFlowRule(new DefaultFlowEntry(fbe.target()));
573 - store.storeFlowRule(fbe.getTarget()); 573 + store.storeFlowRule(fbe.target());
574 } 574 }
575 } 575 }
576 } 576 }
......
...@@ -56,8 +56,8 @@ public class MockFlowRuleService implements FlowRuleService { ...@@ -56,8 +56,8 @@ public class MockFlowRuleService implements FlowRuleService {
56 @Override 56 @Override
57 public Future<CompletedBatchOperation> applyBatch(FlowRuleBatchOperation batch) { 57 public Future<CompletedBatchOperation> applyBatch(FlowRuleBatchOperation batch) {
58 for (FlowRuleBatchEntry fbe : batch.getOperations()) { 58 for (FlowRuleBatchEntry fbe : batch.getOperations()) {
59 - FlowRule fr = fbe.getTarget(); 59 + FlowRule fr = fbe.target();
60 - switch (fbe.getOperator()) { 60 + switch (fbe.operator()) {
61 case ADD: 61 case ADD:
62 flows.add(fr); 62 flows.add(fr);
63 break; 63 break;
......
...@@ -363,7 +363,7 @@ public class DistributedFlowRuleStore ...@@ -363,7 +363,7 @@ public class DistributedFlowRuleStore
363 Collections.<FlowRule>emptySet())); 363 Collections.<FlowRule>emptySet()));
364 } 364 }
365 365
366 - DeviceId deviceId = operation.getOperations().get(0).getTarget().deviceId(); 366 + DeviceId deviceId = operation.getOperations().get(0).target().deviceId();
367 367
368 ReplicaInfo replicaInfo = replicaInfoManager.getReplicaInfoFor(deviceId); 368 ReplicaInfo replicaInfo = replicaInfoManager.getReplicaInfoFor(deviceId);
369 369
...@@ -407,8 +407,8 @@ public class DistributedFlowRuleStore ...@@ -407,8 +407,8 @@ public class DistributedFlowRuleStore
407 flowEntriesLock.writeLock().lock(); 407 flowEntriesLock.writeLock().lock();
408 try { 408 try {
409 for (FlowRuleBatchEntry batchEntry : operation.getOperations()) { 409 for (FlowRuleBatchEntry batchEntry : operation.getOperations()) {
410 - FlowRule flowRule = batchEntry.getTarget(); 410 + FlowRule flowRule = batchEntry.target();
411 - FlowRuleOperation op = batchEntry.getOperator(); 411 + FlowRuleOperation op = batchEntry.operator();
412 if (did == null) { 412 if (did == null) {
413 did = flowRule.deviceId(); 413 did = flowRule.deviceId();
414 } 414 }
...@@ -640,13 +640,13 @@ public class DistributedFlowRuleStore ...@@ -640,13 +640,13 @@ public class DistributedFlowRuleStore
640 FlowRuleBatchOperation operation = SERIALIZER.decode(message.payload()); 640 FlowRuleBatchOperation operation = SERIALIZER.decode(message.payload());
641 log.debug("received batch request {}", operation); 641 log.debug("received batch request {}", operation);
642 642
643 - final DeviceId deviceId = operation.getOperations().get(0).getTarget().deviceId(); 643 + final DeviceId deviceId = operation.getOperations().get(0).target().deviceId();
644 ReplicaInfo replicaInfo = replicaInfoManager.getReplicaInfoFor(deviceId); 644 ReplicaInfo replicaInfo = replicaInfoManager.getReplicaInfoFor(deviceId);
645 if (!local.equals(replicaInfo.master().orNull())) { 645 if (!local.equals(replicaInfo.master().orNull())) {
646 646
647 Set<FlowRule> failures = new HashSet<>(operation.size()); 647 Set<FlowRule> failures = new HashSet<>(operation.size());
648 for (FlowRuleBatchEntry op : operation.getOperations()) { 648 for (FlowRuleBatchEntry op : operation.getOperations()) {
649 - failures.add(op.getTarget()); 649 + failures.add(op.target());
650 } 650 }
651 CompletedBatchOperation allFailed = new CompletedBatchOperation(false, failures); 651 CompletedBatchOperation allFailed = new CompletedBatchOperation(false, failures);
652 // This node is no longer the master, respond as all failed. 652 // This node is no longer the master, respond as all failed.
...@@ -675,7 +675,7 @@ public class DistributedFlowRuleStore ...@@ -675,7 +675,7 @@ public class DistributedFlowRuleStore
675 // create everything failed response 675 // create everything failed response
676 Set<FlowRule> failures = new HashSet<>(operation.size()); 676 Set<FlowRule> failures = new HashSet<>(operation.size());
677 for (FlowRuleBatchEntry op : operation.getOperations()) { 677 for (FlowRuleBatchEntry op : operation.getOperations()) {
678 - failures.add(op.getTarget()); 678 + failures.add(op.target());
679 } 679 }
680 result = new CompletedBatchOperation(false, failures); 680 result = new CompletedBatchOperation(false, failures);
681 } 681 }
...@@ -754,7 +754,7 @@ public class DistributedFlowRuleStore ...@@ -754,7 +754,7 @@ public class DistributedFlowRuleStore
754 final SMap<FlowId, ImmutableList<StoredFlowEntry>> backupFlowTable = smaps.get(deviceId); 754 final SMap<FlowId, ImmutableList<StoredFlowEntry>> backupFlowTable = smaps.get(deviceId);
755 // Following should be rewritten using async APIs 755 // Following should be rewritten using async APIs
756 for (FlowRuleBatchEntry bEntry : toAdd) { 756 for (FlowRuleBatchEntry bEntry : toAdd) {
757 - final FlowRule entry = bEntry.getTarget(); 757 + final FlowRule entry = bEntry.target();
758 final FlowId id = entry.id(); 758 final FlowId id = entry.id();
759 ImmutableList<StoredFlowEntry> original = backupFlowTable.get(id); 759 ImmutableList<StoredFlowEntry> original = backupFlowTable.get(id);
760 List<StoredFlowEntry> list = new ArrayList<>(); 760 List<StoredFlowEntry> list = new ArrayList<>();
...@@ -762,7 +762,7 @@ public class DistributedFlowRuleStore ...@@ -762,7 +762,7 @@ public class DistributedFlowRuleStore
762 list.addAll(original); 762 list.addAll(original);
763 } 763 }
764 764
765 - list.remove(bEntry.getTarget()); 765 + list.remove(bEntry.target());
766 list.add((StoredFlowEntry) entry); 766 list.add((StoredFlowEntry) entry);
767 767
768 ImmutableList<StoredFlowEntry> newValue = ImmutableList.copyOf(list); 768 ImmutableList<StoredFlowEntry> newValue = ImmutableList.copyOf(list);
...@@ -777,7 +777,7 @@ public class DistributedFlowRuleStore ...@@ -777,7 +777,7 @@ public class DistributedFlowRuleStore
777 } 777 }
778 } 778 }
779 for (FlowRuleBatchEntry bEntry : toRemove) { 779 for (FlowRuleBatchEntry bEntry : toRemove) {
780 - final FlowRule entry = bEntry.getTarget(); 780 + final FlowRule entry = bEntry.target();
781 final FlowId id = entry.id(); 781 final FlowId id = entry.id();
782 ImmutableList<StoredFlowEntry> original = backupFlowTable.get(id); 782 ImmutableList<StoredFlowEntry> original = backupFlowTable.get(id);
783 List<StoredFlowEntry> list = new ArrayList<>(); 783 List<StoredFlowEntry> list = new ArrayList<>();
...@@ -785,7 +785,7 @@ public class DistributedFlowRuleStore ...@@ -785,7 +785,7 @@ public class DistributedFlowRuleStore
785 list.addAll(original); 785 list.addAll(original);
786 } 786 }
787 787
788 - list.remove(bEntry.getTarget()); 788 + list.remove(bEntry.target());
789 789
790 ImmutableList<StoredFlowEntry> newValue = ImmutableList.copyOf(list); 790 ImmutableList<StoredFlowEntry> newValue = ImmutableList.copyOf(list);
791 boolean success; 791 boolean success;
......
...@@ -266,13 +266,13 @@ public class SimpleFlowRuleStore ...@@ -266,13 +266,13 @@ public class SimpleFlowRuleStore
266 List<FlowRuleBatchEntry> toAdd = new ArrayList<>(); 266 List<FlowRuleBatchEntry> toAdd = new ArrayList<>();
267 List<FlowRuleBatchEntry> toRemove = new ArrayList<>(); 267 List<FlowRuleBatchEntry> toRemove = new ArrayList<>();
268 for (FlowRuleBatchEntry entry : batchOperation.getOperations()) { 268 for (FlowRuleBatchEntry entry : batchOperation.getOperations()) {
269 - final FlowRule flowRule = entry.getTarget(); 269 + final FlowRule flowRule = entry.target();
270 - if (entry.getOperator().equals(FlowRuleOperation.ADD)) { 270 + if (entry.operator().equals(FlowRuleOperation.ADD)) {
271 if (!getFlowEntries(flowRule.deviceId(), flowRule.id()).contains(flowRule)) { 271 if (!getFlowEntries(flowRule.deviceId(), flowRule.id()).contains(flowRule)) {
272 storeFlowRule(flowRule); 272 storeFlowRule(flowRule);
273 toAdd.add(entry); 273 toAdd.add(entry);
274 } 274 }
275 - } else if (entry.getOperator().equals(FlowRuleOperation.REMOVE)) { 275 + } else if (entry.operator().equals(FlowRuleOperation.REMOVE)) {
276 if (getFlowEntries(flowRule.deviceId(), flowRule.id()).contains(flowRule)) { 276 if (getFlowEntries(flowRule.deviceId(), flowRule.id()).contains(flowRule)) {
277 deleteFlowRule(flowRule); 277 deleteFlowRule(flowRule);
278 toRemove.add(entry); 278 toRemove.add(entry);
......
...@@ -110,16 +110,16 @@ public class NullFlowRuleProvider extends AbstractProvider implements FlowRulePr ...@@ -110,16 +110,16 @@ public class NullFlowRuleProvider extends AbstractProvider implements FlowRulePr
110 public Future<CompletedBatchOperation> executeBatch( 110 public Future<CompletedBatchOperation> executeBatch(
111 BatchOperation<FlowRuleBatchEntry> batch) { 111 BatchOperation<FlowRuleBatchEntry> batch) {
112 for (FlowRuleBatchEntry fbe : batch.getOperations()) { 112 for (FlowRuleBatchEntry fbe : batch.getOperations()) {
113 - switch (fbe.getOperator()) { 113 + switch (fbe.operator()) {
114 case ADD: 114 case ADD:
115 - applyFlowRule(fbe.getTarget()); 115 + applyFlowRule(fbe.target());
116 break; 116 break;
117 case REMOVE: 117 case REMOVE:
118 - removeFlowRule(fbe.getTarget()); 118 + removeFlowRule(fbe.target());
119 break; 119 break;
120 case MODIFY: 120 case MODIFY:
121 - removeFlowRule(fbe.getTarget()); 121 + removeFlowRule(fbe.target());
122 - applyFlowRule(fbe.getTarget()); 122 + applyFlowRule(fbe.target());
123 break; 123 break;
124 default: 124 default:
125 log.error("Unknown flow operation: {}", fbe); 125 log.error("Unknown flow operation: {}", fbe);
......
...@@ -201,7 +201,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr ...@@ -201,7 +201,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr
201 */ 201 */
202 Map<OFFlowMod, OpenFlowSwitch> mods = Maps.newIdentityHashMap(); 202 Map<OFFlowMod, OpenFlowSwitch> mods = Maps.newIdentityHashMap();
203 for (FlowRuleBatchEntry fbe : batch.getOperations()) { 203 for (FlowRuleBatchEntry fbe : batch.getOperations()) {
204 - FlowRule flowRule = fbe.getTarget(); 204 + FlowRule flowRule = fbe.target();
205 final Dpid dpid = Dpid.dpid(flowRule.deviceId().uri()); 205 final Dpid dpid = Dpid.dpid(flowRule.deviceId().uri());
206 OpenFlowSwitch sw = controller.getSwitch(dpid); 206 OpenFlowSwitch sw = controller.getSwitch(dpid);
207 if (sw == null) { 207 if (sw == null) {
...@@ -220,7 +220,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr ...@@ -220,7 +220,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr
220 FlowModBuilder.builder(flowRule, sw.factory(), 220 FlowModBuilder.builder(flowRule, sw.factory(),
221 Optional.of(flowModXid)); 221 Optional.of(flowModXid));
222 OFFlowMod mod = null; 222 OFFlowMod mod = null;
223 - switch (fbe.getOperator()) { 223 + switch (fbe.operator()) {
224 case ADD: 224 case ADD:
225 mod = builder.buildFlowAdd(); 225 mod = builder.buildFlowAdd();
226 break; 226 break;
...@@ -231,7 +231,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr ...@@ -231,7 +231,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr
231 mod = builder.buildFlowMod(); 231 mod = builder.buildFlowMod();
232 break; 232 break;
233 default: 233 default:
234 - log.error("Unsupported batch operation {}", fbe.getOperator()); 234 + log.error("Unsupported batch operation {}", fbe.operator());
235 } 235 }
236 if (mod != null) { 236 if (mod != null) {
237 mods.put(mod, sw); 237 mods.put(mod, sw);
...@@ -406,7 +406,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr ...@@ -406,7 +406,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr
406 FlowEntry fe = null; 406 FlowEntry fe = null;
407 FlowRuleBatchEntry fbe = fms.get(msg.getXid()); 407 FlowRuleBatchEntry fbe = fms.get(msg.getXid());
408 failedId = fbe.id(); 408 failedId = fbe.id();
409 - FlowRule offending = fbe.getTarget(); 409 + FlowRule offending = fbe.target();
410 //TODO handle specific error msgs 410 //TODO handle specific error msgs
411 switch (msg.getErrType()) { 411 switch (msg.getErrType()) {
412 case BAD_ACTION: 412 case BAD_ACTION:
...@@ -482,11 +482,11 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr ...@@ -482,11 +482,11 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr
482 this.state = BatchState.CANCELLED; 482 this.state = BatchState.CANCELLED;
483 cleanUp(); 483 cleanUp();
484 for (FlowRuleBatchEntry fbe : fms.values()) { 484 for (FlowRuleBatchEntry fbe : fms.values()) {
485 - if (fbe.getOperator() == FlowRuleOperation.ADD || 485 + if (fbe.operator() == FlowRuleOperation.ADD ||
486 - fbe.getOperator() == FlowRuleOperation.MODIFY) { 486 + fbe.operator() == FlowRuleOperation.MODIFY) {
487 - removeFlowRule(fbe.getTarget()); 487 + removeFlowRule(fbe.target());
488 - } else if (fbe.getOperator() == FlowRuleOperation.REMOVE) { 488 + } else if (fbe.operator() == FlowRuleOperation.REMOVE) {
489 - applyRule(fbe.getTarget()); 489 + applyRule(fbe.target());
490 } 490 }
491 491
492 } 492 }
...@@ -554,7 +554,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr ...@@ -554,7 +554,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr
554 .add("pending devices", sws) 554 .add("pending devices", sws)
555 .add("devices in batch", 555 .add("devices in batch",
556 fms.values().stream() 556 fms.values().stream()
557 - .map((fbe) -> fbe.getTarget().deviceId()) 557 + .map((fbe) -> fbe.target().deviceId())
558 .distinct().collect(Collectors.toList())) 558 .distinct().collect(Collectors.toList()))
559 .add("failedId", failedId) 559 .add("failedId", failedId)
560 .add("latchCount", countDownLatch.getCount()) 560 .add("latchCount", countDownLatch.getCount())
......