Search in sources :

Example 1 with NodeUpdatedBuilder

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());
    }
}
Also used : NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) NodeUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdatedBuilder) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)

Example 2 with NodeUpdatedBuilder

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));
}
Also used : NodeUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdatedBuilder) Test(org.junit.Test)

Example 3 with NodeUpdatedBuilder

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));
}
Also used : NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) NodeUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdatedBuilder) NodeRemovedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemovedBuilder) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) Test(org.junit.Test)

Example 4 with NodeUpdatedBuilder

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());
}
Also used : NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) NodeUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdatedBuilder) Test(org.junit.Test)

Example 5 with NodeUpdatedBuilder

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;
}
Also used : NodeUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdatedBuilder) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)

Aggregations

NodeUpdatedBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdatedBuilder)7 Test (org.junit.Test)4 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)4 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)2 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)2 FlowCapableNodeUpdatedBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdatedBuilder)1 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)1 NodeRemovedBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemovedBuilder)1 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)1