Update MRI projects for Aluminium
[openflowplugin.git] / test-provider / src / main / java / org / opendaylight / openflowplugin / test / OpenflowpluginTestCommandProvider.java
index da2077be716913984b37ff80a381bef35cc64b98..d4de894d6671aa2ebe73860441deaea40273896e 100644 (file)
@@ -5,12 +5,9 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.openflowplugin.test;
 
 import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
 import java.math.BigInteger;
 import java.util.ArrayList;
@@ -20,11 +17,10 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 import org.eclipse.osgi.framework.console.CommandInterpreter;
 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.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.NotificationService;
+import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp;
 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;
@@ -182,7 +178,7 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestCommandProvider.class);
 
-    private DataBroker dataBroker;
+    private final DataBroker dataBroker;
     private final BundleContext ctx;
     private static final String ORIGINAL_FLOW_NAME = "Foo";
     private static final String UPDATED_FLOW_NAME = "Bar";
@@ -191,18 +187,19 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
     private static final String SRC_MAC_ADDRESS = "00:00:00:00:23:ae";
     private final SalFlowListener flowEventListener = new FlowEventListenerLoggingImpl();
     private final NodeErrorListener nodeErrorListener = new NodeErrorListenerLoggingImpl();
-    private NotificationService notificationService;
+    private final NotificationService notificationService;
 
-    public OpenflowpluginTestCommandProvider(final BundleContext ctx) {
+    public OpenflowpluginTestCommandProvider(final DataBroker dataBroker, final NotificationService notificationService,
+            final BundleContext ctx) {
+        this.dataBroker = dataBroker;
+        this.notificationService = notificationService;
         this.ctx = ctx;
     }
 
-    public void onSessionInitiated(final ProviderContext session) {
-        notificationService = session.getSALService(NotificationService.class);
+    public void init() {
         // For switch events
         notificationService.registerNotificationListener(flowEventListener);
         notificationService.registerNotificationListener(nodeErrorListener);
-        dataBroker = session.getSALService(DataBroker.class);
         ctx.registerService(CommandProvider.class.getName(), this, null);
         createTestFlow(createTestNode(null), null, null);
     }
@@ -1664,8 +1661,6 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         final List<Action> actionList = new ArrayList<>();
         final ActionBuilder ab = new ActionBuilder();
 
-        final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-        setFieldBuilder.setInPort(new NodeConnectorId(nodeId + ":2"));
         ab.withKey(new ActionKey(0));
         actionList.add(ab.build());
 
@@ -2209,7 +2204,7 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         setFieldBuilder1.setLayer4Match(tcpmatch1.build());
         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
         ab1.withKey(new ActionKey(1));
-        actionList.add(ab.build());
+        actionList.add(ab1.build());
 
         final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
@@ -3151,16 +3146,15 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
                 .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf.getTableId()))
                 .child(Flow.class, tf.key());
         modification.delete(LogicalDatastoreType.CONFIGURATION, path1);
-        final ListenableFuture<Void> commitFuture = modification.submit();
-        Futures.addCallback(commitFuture, new FutureCallback<Void>() {
+        modification.commit().addCallback(new FutureCallback<Object>() {
             @Override
-            public void onSuccess(final Void notUsed) {
+            public void onSuccess(final Object notUsed) {
                 ci.println("Status of Group Data Loaded Transaction: success.");
             }
 
             @Override
             public void onFailure(final Throwable throwable) {
-                LOG.error(throwable.getMessage(), throwable);
+                LOG.error("Status of Group Data Loaded Transaction : failure.", throwable);
                 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
             }
         }, MoreExecutors.directExecutor());
@@ -3188,19 +3182,18 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         final InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class)
                 .child(Node.class, nodeBuilder.key()).augmentation(FlowCapableNode.class)
                 .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.key());
-        modification.merge(LogicalDatastoreType.CONFIGURATION,
-                nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
-        modification.merge(LogicalDatastoreType.CONFIGURATION, path1, flow.build(), true);
-        final ListenableFuture<Void> commitFuture = modification.submit();
-        Futures.addCallback(commitFuture, new FutureCallback<Void>() {
+        modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION,
+                nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
+        modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path1, flow.build());
+        modification.commit().addCallback(new FutureCallback<Object>() {
             @Override
-            public void onSuccess(final Void notUsed) {
+            public void onSuccess(final Object notUsed) {
                 ci.println("Status of Group Data Loaded Transaction: success.");
             }
 
             @Override
             public void onFailure(final Throwable throwable) {
-                LOG.error(throwable.getMessage(), throwable);
+                LOG.error("Status of Group Data Loaded Transaction : failure.", throwable);
                 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
             }
         }, MoreExecutors.directExecutor());