X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=test-provider%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Ftest%2FOpenflowPluginBulkTransactionProvider.java;h=c761ae54980454f0ffc62cfcffa22c0c32c88795;hb=b4f4b4b702e2ccd8a7c62fd2a5c184c5b1cbe665;hp=7db89be8b0792e391a06a82da2ff1277bd872098;hpb=c0f1975113c7f6f0cc22bc60d7b6d20991a1373b;p=openflowplugin.git diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkTransactionProvider.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkTransactionProvider.java index 7db89be8b0..c761ae5498 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkTransactionProvider.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkTransactionProvider.java @@ -20,7 +20,6 @@ import org.eclipse.osgi.framework.console.CommandProvider; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; import org.opendaylight.controller.sal.binding.api.NotificationService; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel; @@ -117,20 +116,21 @@ import org.slf4j.LoggerFactory; public class OpenflowPluginBulkTransactionProvider implements CommandProvider { private static final Logger LOG = LoggerFactory.getLogger(OpenflowPluginBulkTransactionProvider.class); - private DataBroker dataBroker; + private final DataBroker dataBroker; private final BundleContext ctx; private final String originalFlowName = "Foo"; private final NodeErrorListener nodeErrorListener = new NodeErrorListenerLoggingImpl(); - private NotificationService notificationService; + private final NotificationService notificationService; - public OpenflowPluginBulkTransactionProvider(BundleContext ctx) { + public OpenflowPluginBulkTransactionProvider(DataBroker dataBroker, NotificationService notificationService, + BundleContext ctx) { + this.dataBroker = dataBroker; + this.notificationService = notificationService; this.ctx = ctx; } - public void onSessionInitiated(ProviderContext session) { - notificationService = session.getSALService(NotificationService.class); + public void init() { notificationService.registerNotificationListener(nodeErrorListener); - dataBroker = session.getSALService(DataBroker.class); ctx.registerService(CommandProvider.class.getName(), this, null); createTestFlow(createTestNode(null), null, null); } @@ -141,7 +141,7 @@ public class OpenflowPluginBulkTransactionProvider implements CommandProvider { } NodeBuilder builder = new NodeBuilder(); builder.setId(new NodeId(nodeId)); - builder.setKey(new NodeKey(builder.getId())); + builder.withKey(new NodeKey(builder.getId())); return builder; } @@ -413,7 +413,7 @@ public class OpenflowPluginBulkTransactionProvider implements CommandProvider { flow.setOutPort(outputPort); FlowKey key = new FlowKey(new FlowId(Long.toString(id))); - flow.setKey(key); + flow.withKey(key); flow.setPriority(2); flow.setFlowName(originalFlowName + "X" + flowType); return flow; @@ -489,7 +489,7 @@ public class OpenflowPluginBulkTransactionProvider implements CommandProvider { } private InstanceIdentifier nodeBuilderToInstanceId(NodeBuilder node) { - return InstanceIdentifier.create(Nodes.class).child(Node.class, node.getKey()); + return InstanceIdentifier.create(Nodes.class).child(Node.class, node.key()); } public void _modifyFlows(CommandInterpreter ci) { @@ -625,28 +625,28 @@ public class OpenflowPluginBulkTransactionProvider implements CommandProvider { throw new IllegalArgumentException("Invalid flowtype: " + flowtype); } - InstanceIdentifier path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.getKey()) + InstanceIdentifier path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.key()) .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf.getTableId())) - .child(Flow.class, tf.getKey()); + .child(Flow.class, tf.key()); modification.delete(LogicalDatastoreType.OPERATIONAL, path1); modification.delete(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(tn)); modification.delete(LogicalDatastoreType.CONFIGURATION, path1); - InstanceIdentifier path2 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.getKey()) + InstanceIdentifier path2 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.key()) .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf1.getTableId())) - .child(Flow.class, tf1.getKey()); + .child(Flow.class, tf1.key()); modification.delete(LogicalDatastoreType.OPERATIONAL, path2); modification.delete(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(tn)); modification.delete(LogicalDatastoreType.CONFIGURATION, path2); - InstanceIdentifier path3 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.getKey()) + InstanceIdentifier path3 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.key()) .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf2.getTableId())) - .child(Flow.class, tf2.getKey()); + .child(Flow.class, tf2.key()); modification.delete(LogicalDatastoreType.OPERATIONAL, path3); modification.delete(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(tn)); modification.delete(LogicalDatastoreType.CONFIGURATION, path3); - InstanceIdentifier path4 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.getKey()) + InstanceIdentifier path4 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.key()) .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf3.getTableId())) - .child(Flow.class, tf3.getKey()); + .child(Flow.class, tf3.key()); modification.delete(LogicalDatastoreType.OPERATIONAL, path4); modification.delete(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(tn)); modification.delete(LogicalDatastoreType.CONFIGURATION, path4); @@ -659,7 +659,7 @@ public class OpenflowPluginBulkTransactionProvider implements CommandProvider { @Override public void onFailure(Throwable throwable) { - LOG.error(throwable.getMessage(), throwable); + LOG.error("Status of Group Data Loaded Transaction : failure. Reason : {}", throwable); ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable)); } }, MoreExecutors.directExecutor()); @@ -670,8 +670,8 @@ public class OpenflowPluginBulkTransactionProvider implements CommandProvider { FlowBuilder flow3, NodeBuilder nodeBuilder) { ReadWriteTransaction modification = dataBroker.newReadWriteTransaction(); InstanceIdentifier path1 = InstanceIdentifier.create(Nodes.class) - .child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class) - .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.getKey()); + .child(Node.class, nodeBuilder.key()).augmentation(FlowCapableNode.class) + .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.key()); modification.merge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true); modification.merge(LogicalDatastoreType.OPERATIONAL, path1, flow.build(), true); @@ -679,8 +679,8 @@ public class OpenflowPluginBulkTransactionProvider implements CommandProvider { nodeBuilder.build(), true); modification.merge(LogicalDatastoreType.CONFIGURATION, path1, flow.build(), true); InstanceIdentifier path2 = InstanceIdentifier.create(Nodes.class) - .child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class) - .child(Table.class, new TableKey(flow1.getTableId())).child(Flow.class, flow1.getKey()); + .child(Node.class, nodeBuilder.key()).augmentation(FlowCapableNode.class) + .child(Table.class, new TableKey(flow1.getTableId())).child(Flow.class, flow1.key()); modification.merge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true); modification.merge(LogicalDatastoreType.OPERATIONAL, path2, flow1.build(), true); @@ -689,8 +689,8 @@ public class OpenflowPluginBulkTransactionProvider implements CommandProvider { modification.merge(LogicalDatastoreType.CONFIGURATION, path2, flow1.build(), true); InstanceIdentifier path3 = InstanceIdentifier.create(Nodes.class) - .child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class) - .child(Table.class, new TableKey(flow2.getTableId())).child(Flow.class, flow2.getKey()); + .child(Node.class, nodeBuilder.key()).augmentation(FlowCapableNode.class) + .child(Table.class, new TableKey(flow2.getTableId())).child(Flow.class, flow2.key()); modification.merge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true); modification.merge(LogicalDatastoreType.OPERATIONAL, path3, flow2.build(), true); @@ -699,8 +699,8 @@ public class OpenflowPluginBulkTransactionProvider implements CommandProvider { modification.merge(LogicalDatastoreType.CONFIGURATION, path3, flow2.build(), true); InstanceIdentifier path4 = InstanceIdentifier.create(Nodes.class) - .child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class) - .child(Table.class, new TableKey(flow3.getTableId())).child(Flow.class, flow3.getKey()); + .child(Node.class, nodeBuilder.key()).augmentation(FlowCapableNode.class) + .child(Table.class, new TableKey(flow3.getTableId())).child(Flow.class, flow3.key()); modification.merge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true); modification.merge(LogicalDatastoreType.OPERATIONAL, path4, flow3.build(), true); @@ -716,7 +716,7 @@ public class OpenflowPluginBulkTransactionProvider implements CommandProvider { @Override public void onFailure(Throwable throwable) { - LOG.error(throwable.getMessage(), throwable); + LOG.error("Status of Group Data Loaded Transaction : failure. Reason : {}", throwable); ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable)); } }, MoreExecutors.directExecutor()); @@ -739,7 +739,7 @@ public class OpenflowPluginBulkTransactionProvider implements CommandProvider { // Wrap our Apply Action in an Instruction InstructionBuilder ib = new InstructionBuilder(); ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build()); - ib.setKey(new InstructionKey(0)); + ib.withKey(new InstructionKey(0)); ib.setOrder(0); // Put our Instruction in a list of Instructions @@ -841,7 +841,7 @@ public class OpenflowPluginBulkTransactionProvider implements CommandProvider { output.setOutputNodeConnector(value); ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build()); ab.setOrder(0); - ab.setKey(new ActionKey(0)); + ab.withKey(new ActionKey(0)); List actionList = new ArrayList<>(); actionList.add(ab.build()); @@ -853,7 +853,7 @@ public class OpenflowPluginBulkTransactionProvider implements CommandProvider { InstructionBuilder ib = new InstructionBuilder(); ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build()); ib.setOrder(0); - ib.setKey(new InstructionKey(0)); + ib.withKey(new InstructionKey(0)); // Put our Instruction in a list of Instructions InstructionsBuilder isb = new InstructionsBuilder();