* 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.util.ArrayList;
import java.util.List;
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.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder;
public class OpenflowpluginMeterTestCommandProvider implements CommandProvider {
private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginMeterTestCommandProvider.class);
- private DataBroker dataBroker;
+ private final DataBroker dataBroker;
private final BundleContext ctx;
private Meter testMeter;
private Meter testMeter1;
private final String originalMeterName = "Foo";
private final String updatedMeterName = "Bar";
private final MeterEventListener meterEventListener = new MeterEventListener();
- private NotificationService notificationService;
+ private final NotificationService notificationService;
private Registration listener1Reg;
- public OpenflowpluginMeterTestCommandProvider(BundleContext ctx) {
+ public OpenflowpluginMeterTestCommandProvider(DataBroker dataBroker, NotificationService notificationService,
+ BundleContext ctx) {
+ this.dataBroker = dataBroker;
+ this.notificationService = notificationService;
this.ctx = ctx;
}
- public void onSessionInitiated(ProviderContext session) {
- dataBroker = session.getSALService(DataBroker.class);
+ public void init() {
ctx.registerService(CommandProvider.class.getName(), this, null);
- notificationService = session.getSALService(NotificationService.class);
// For switch events
listener1Reg = notificationService.registerNotificationListener(meterEventListener);
@Override
public void onMeterAdded(MeterAdded notification) {
- LOG.info("Meter to be added.........................." + notification.toString());
- LOG.info("Meter Xid........................." + notification.getTransactionId().getValue());
- LOG.info("-----------------------------------------------------------------------------------");
+ LOG.info("Meter to be added {}", notification.toString());
+ LOG.info("Meter Xid {}", notification.getTransactionId().getValue());
}
@Override
public void onMeterRemoved(MeterRemoved notification) {
- LOG.info("Meter to be removed.........................." + notification.toString());
- LOG.info("Meter Xid........................." + notification.getTransactionId().getValue());
- LOG.info("-----------------------------------------------------------------------------------");
+ LOG.info("Meter to be removed {}", notification.toString());
+ LOG.info("Meter Xid {}", notification.getTransactionId().getValue());
}
@Override
public void onMeterUpdated(MeterUpdated notification) {
- LOG.info("Meter to be updated.........................." + notification.toString());
- LOG.info("Meter Xid........................." + notification.getTransactionId().getValue());
- LOG.info("-----------------------------------------------------------------------------------");
+ LOG.info("Meter to be updated {}", notification.toString());
+ LOG.info("Meter Xid {}", notification.getTransactionId().getValue());
}
}
InstanceIdentifier<Meter> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.key())
.augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(testMeter.getMeterId()));
modification.delete(LogicalDatastoreType.CONFIGURATION, path1);
- ListenableFuture<Void> commitFuture = modification.submit();
- Futures.addCallback(commitFuture, new FutureCallback<Void>() {
+ modification.commit().addCallback(new FutureCallback<Object>() {
@Override
- public void onSuccess(Void notUsed) {
+ public void onSuccess(Object notUsed) {
ci.println("Status of Group Data Loaded Transaction: success.");
}
break;
}
- ListenableFuture<Void> commitFuture = modification.submit();
- Futures.addCallback(commitFuture, new FutureCallback<Void>() {
+ modification.commit().addCallback(new FutureCallback<Object>() {
@Override
- public void onSuccess(Void notUsed) {
+ public void onSuccess(Object notUsed) {
ci.println("Status of Group Data Loaded Transaction: success.");
}
ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
InstanceIdentifier<Meter> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.key())
.augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(meter.getMeterId()));
- modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
- modification.merge(LogicalDatastoreType.CONFIGURATION, path1, meter, true);
- ListenableFuture<Void> commitFuture = modification.submit();
- Futures.addCallback(commitFuture, new FutureCallback<Void>() {
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode),
+ testNode);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path1, meter);
+ modification.commit().addCallback(new FutureCallback<Object>() {
@Override
- public void onSuccess(Void notUsed) {
+ public void onSuccess(Object notUsed) {
ci.println("Status of Group Data Loaded Transaction: success.");
}
ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
InstanceIdentifier<Meter> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.key())
.augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(meter.getMeterId()));
- modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
- modification.merge(LogicalDatastoreType.CONFIGURATION, path1, meter, true);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode),
+ testNode);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path1, meter);
InstanceIdentifier<Meter> path2 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.key())
.augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(meter1.getMeterId()));
- modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
- modification.merge(LogicalDatastoreType.CONFIGURATION, path2, meter1, true);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode),
+ testNode);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path2, meter1);
- ListenableFuture<Void> commitFuture = modification.submit();
- Futures.addCallback(commitFuture, new FutureCallback<Void>() {
+ modification.commit().addCallback(new FutureCallback<Object>() {
@Override
- public void onSuccess(Void notUsed) {
+ public void onSuccess(Object notUsed) {
ci.println("Status of Group Data Loaded Transaction: success.");
}