Switch to MD-SAL APIs
[openflowplugin.git] / applications / forwardingrules-manager / src / main / java / org / opendaylight / openflowplugin / applications / frm / impl / GroupForwarder.java
index 5a08be041baac7c520850dfd7c0d7b43e4deeb3f..e2ec86f67badea0399505d99ee6d994fe6f07b82 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright (c) 2014, 2017 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -10,16 +10,17 @@ package org.opendaylight.openflowplugin.applications.frm.impl;
 import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getActiveBundle;
 import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getNodeIdFromNodeIdentifier;
 
+import com.google.common.util.concurrent.FluentFuture;
 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.util.concurrent.Future;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.infrautils.utils.concurrent.JdkFutures;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
+import org.opendaylight.mdsal.binding.api.WriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.applications.frm.ForwardingRulesManager;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
@@ -52,10 +53,10 @@ import org.slf4j.LoggerFactory;
 
 /**
  * GroupForwarder It implements
- * {@link org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener}
+ * {@link org.opendaylight.mdsal.binding.api.DataTreeChangeListener}
  * for WildCardedPath to {@link Group} and ForwardingRulesCommiter interface for
  * methods: add, update and remove {@link Group} processing for
- * {@link org.opendaylight.controller.md.sal.binding.api.DataTreeModification}.
+ * {@link org.opendaylight.mdsal.binding.api.DataTreeModification}.
  */
 public class GroupForwarder extends AbstractListeningCommiter<Group> {
 
@@ -71,7 +72,7 @@ public class GroupForwarder extends AbstractListeningCommiter<Group> {
     @SuppressWarnings("IllegalCatch")
     @Override
     public void registerListener() {
-        final DataTreeIdentifier<Group> treeId = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION,
+        final DataTreeIdentifier<Group> treeId = DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
                 getWildCardPath());
 
         try {
@@ -215,14 +216,14 @@ public class GroupForwarder extends AbstractListeningCommiter<Group> {
         writeTransaction.put(LogicalDatastoreType.CONFIGURATION, getStaleGroupInstanceIdentifier(staleGroup, nodeIdent),
                 staleGroup, false);
 
-        ListenableFuture<Void> submitFuture = writeTransaction.submit();
+        FluentFuture<?> submitFuture = writeTransaction.commit();
         handleStaleGroupResultFuture(submitFuture);
     }
 
-    private void handleStaleGroupResultFuture(ListenableFuture<Void> submitFuture) {
-        Futures.addCallback(submitFuture, new FutureCallback<Void>() {
+    private void handleStaleGroupResultFuture(FluentFuture<?> submitFuture) {
+        submitFuture.addCallback(new FutureCallback<Object>() {
             @Override
-            public void onSuccess(Void result) {
+            public void onSuccess(Object result) {
                 LOG.debug("Stale Group creation success");
             }
 
@@ -256,7 +257,7 @@ public class GroupForwarder extends AbstractListeningCommiter<Group> {
                 LOG.debug("Group add with id {} finished without error for node {}", groupId, nodeId);
             } else {
                 LOG.debug("Group add with id {} failed for node {} with error {}", groupId, nodeId,
-                        result.getErrors().toString());
+                        result.getErrors());
             }
         }
 
@@ -275,6 +276,7 @@ public class GroupForwarder extends AbstractListeningCommiter<Group> {
             this.nodeId = nodeId;
         }
 
+        @Override
         public void onSuccess(RpcResult<UpdateGroupOutput> result) {
             if (result.isSuccessful()) {
                 provider.getDevicesGroupRegistry().storeGroup(nodeId, groupId);
@@ -287,7 +289,7 @@ public class GroupForwarder extends AbstractListeningCommiter<Group> {
 
         @Override
         public void onFailure(Throwable throwable) {
-            LOG.error("Service call for updating group {} failed for node {} with error {}", groupId, nodeId,
+            LOG.error("Service call for updating group {} failed for node {} with", groupId, nodeId,
                     throwable);
         }
     }