use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdatedBuilder in project openflowplugin by opendaylight.
the class DeviceManagerImpl method sendNodeAddedNotification.
@Override
public void sendNodeAddedNotification(@Nonnull final KeyedInstanceIdentifier<Node, NodeKey> instanceIdentifier) {
if (!notificationCreateNodeSend.contains(instanceIdentifier)) {
notificationCreateNodeSend.add(instanceIdentifier);
final NodeId id = instanceIdentifier.firstKeyOf(Node.class).getId();
NodeUpdatedBuilder builder = new NodeUpdatedBuilder();
builder.setId(id);
builder.setNodeRef(new NodeRef(instanceIdentifier));
LOG.info("Publishing node added notification for {}", id);
notificationPublishService.offerNotification(builder.build());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdatedBuilder in project openflowplugin by opendaylight.
the class DeviceMastershipManagerTest method testIsDeviceMasteredOrSlaved.
@Test
public void testIsDeviceMasteredOrSlaved() {
// no context
Assert.assertFalse(deviceMastershipManager.isDeviceMastered(NODE_ID));
NodeUpdatedBuilder nodeUpdatedBuilder = new NodeUpdatedBuilder();
nodeUpdatedBuilder.setId(NODE_ID);
deviceMastershipManager.onNodeUpdated(nodeUpdatedBuilder.build());
// is master
deviceMastershipManager.getDeviceMasterships().get(NODE_ID).instantiateServiceInstance();
Assert.assertTrue(deviceMastershipManager.isDeviceMastered(NODE_ID));
// is not master
deviceMastershipManager.getDeviceMasterships().get(NODE_ID).closeServiceInstance();
Assert.assertFalse(deviceMastershipManager.isDeviceMastered(NODE_ID));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdatedBuilder in project openflowplugin by opendaylight.
the class DeviceMastershipManagerTest method testOnDeviceConnectedAndDisconnected.
@Test
public void testOnDeviceConnectedAndDisconnected() throws Exception {
// no context
Assert.assertNull(deviceMastershipManager.getDeviceMasterships().get(NODE_ID));
NodeUpdatedBuilder nodeUpdatedBuilder = new NodeUpdatedBuilder();
nodeUpdatedBuilder.setId(NODE_ID);
deviceMastershipManager.onNodeUpdated(nodeUpdatedBuilder.build());
DeviceMastership serviceInstance = deviceMastershipManager.getDeviceMasterships().get(NODE_ID);
Assert.assertNotNull(serviceInstance);
// destroy context - unregister
Assert.assertNotNull(deviceMastershipManager.getDeviceMasterships().get(NODE_ID));
NodeRemovedBuilder nodeRemovedBuilder = new NodeRemovedBuilder();
InstanceIdentifier<Node> nodeIId = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(NODE_ID));
nodeRemovedBuilder.setNodeRef(new NodeRef(nodeIId));
deviceMastershipManager.onNodeRemoved(nodeRemovedBuilder.build());
Assert.assertNull(deviceMastershipManager.getDeviceMasterships().get(NODE_ID));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdatedBuilder in project openflowplugin by opendaylight.
the class DeviceManagerImplTest method sendNodeAddedNotification.
@Test
public void sendNodeAddedNotification() throws Exception {
deviceManager.sendNodeAddedNotification(DUMMY_IDENTIFIER);
deviceManager.sendNodeAddedNotification(DUMMY_IDENTIFIER);
verify(notificationPublishService).offerNotification(new NodeUpdatedBuilder().setId(DUMMY_NODE_ID).setNodeRef(new NodeRef(DUMMY_IDENTIFIER)).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdatedBuilder in project openflowplugin by opendaylight.
the class InventoryDataServiceUtil method nodeUpdatedBuilderFromDataPathId.
public static NodeUpdatedBuilder nodeUpdatedBuilderFromDataPathId(final BigInteger datapathId) {
NodeUpdatedBuilder builder = new NodeUpdatedBuilder();
builder.setId(nodeIdFromDatapathId(datapathId));
builder.setNodeRef(nodeRefFromNodeKey(new NodeKey(builder.getId())));
return builder;
}
Aggregations