Merge "Added a signum to the SetMetaDataMask BigInt constructor"
[openflowplugin.git] / test-provider / src / main / java / org / opendaylight / openflowplugin / test / OpenflowpluginTableFeaturesTestCommandProvider.java
index c5929695ed361728727d6f3b2b9e5f733bd9ac14..0add3c3b24fcb2037b210ab07ef157524a20e1b8 100644 (file)
@@ -9,18 +9,19 @@
  */
 package org.opendaylight.openflowplugin.test;
 
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
 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.TransactionStatus;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
@@ -72,7 +73,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.osgi.framework.BundleContext;
 
 
@@ -113,7 +113,7 @@ public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandPr
     }
 
     private InstanceIdentifier<Node> nodeToInstanceId(Node node) {
-        return InstanceIdentifier.builder(Nodes.class).child(Node.class, node.getKey()).toInstance();
+        return InstanceIdentifier.create(Nodes.class).child(Node.class, node.getKey());
     }
 
     private TableBuilder createTestTable(String tableFeatureTypeArg) {
@@ -595,31 +595,30 @@ public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandPr
     }
 
 
-    private void writeTable(CommandInterpreter ci, Table table) {
+    private void writeTable(final CommandInterpreter ci, Table table) {
         ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
 
-        InstanceIdentifier<Table> path1 = InstanceIdentifier.builder(Nodes.class)
+        InstanceIdentifier<Table> path1 = InstanceIdentifier.create(Nodes.class)
                 .child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).
-                        child(Table.class, new TableKey(table.getId())).build();
-
-
-        modification.put(LogicalDatastoreType.OPERATIONAL, nodeToInstanceId(testNode), testNode);
-        modification.put(LogicalDatastoreType.OPERATIONAL, path1, table);
-        modification.put(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode);
-        modification.put(LogicalDatastoreType.CONFIGURATION, path1, table);
-        Future<RpcResult<TransactionStatus>> commitFuture = modification.commit();
-        try {
-            RpcResult<TransactionStatus> result = commitFuture.get();
-            TransactionStatus status = result.getResult();
-            ci.println("Status of Table Data Loaded Transaction: " + status);
-
-        } catch (InterruptedException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        } catch (ExecutionException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        }
+                        child(Table.class, new TableKey(table.getId()));
+
+
+        modification.merge(LogicalDatastoreType.OPERATIONAL, nodeToInstanceId(testNode), testNode, true);
+        modification.merge(LogicalDatastoreType.OPERATIONAL, path1, table, true);
+        modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
+        modification.merge(LogicalDatastoreType.CONFIGURATION, path1, table, true);
+        CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
+        Futures.addCallback(commitFuture, new FutureCallback<Void>() {
+            @Override
+            public void onSuccess(Void aVoid) {
+                ci.println("Status of Group Data Loaded Transaction: success.");
+            }
+
+            @Override
+            public void onFailure(Throwable throwable) {
+                ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
+            }
+        });
     }
 
     public void _modifyTable(CommandInterpreter ci) {