*/
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;
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;
}
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) {
}
- 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) {