Search in sources :

Example 1 with EventSourceService

use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.EventSourceService in project controller by opendaylight.

the class EventSourceTopology method register.

public void register(final EventSource eventSource) {
    final NodeKey nodeKey = eventSource.getSourceNodeKey();
    final KeyedInstanceIdentifier<Node, NodeKey> sourcePath = EVENT_SOURCE_TOPOLOGY_PATH.child(Node.class, nodeKey);
    final RoutedRpcRegistration<EventSourceService> reg = rpcRegistry.addRoutedRpcImplementation(EventSourceService.class, eventSource);
    reg.registerPath(NodeContext.class, sourcePath);
    routedRpcRegistrations.put(nodeKey, reg);
    insert(sourcePath);
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) EventSourceService(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.EventSourceService) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)

Example 2 with EventSourceService

use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.EventSourceService in project controller by opendaylight.

the class EventSourceTopology method unRegister.

public void unRegister(final EventSource eventSource) {
    final NodeKey nodeKey = eventSource.getSourceNodeKey();
    final KeyedInstanceIdentifier<Node, NodeKey> sourcePath = EVENT_SOURCE_TOPOLOGY_PATH.child(Node.class, nodeKey);
    final RoutedRpcRegistration<EventSourceService> removeRegistration = routedRpcRegistrations.remove(nodeKey);
    if (removeRegistration != null) {
        removeRegistration.close();
        remove(sourcePath);
    }
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) EventSourceService(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.EventSourceService) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)

Example 3 with EventSourceService

use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.EventSourceService in project controller by opendaylight.

the class EventSourceTopologyTest method unregisterTest.

@Test
public void unregisterTest() throws Exception {
    topicTestHelper();
    EventSource eventSourceMock = mock(EventSource.class);
    NodeId nodeId = new NodeId("nodeIdValue1");
    nodeKey = new NodeKey(nodeId);
    Map<NodeKey, BindingAwareBroker.RoutedRpcRegistration<EventSourceService>> localMap = getRoutedRpcRegistrations();
    NodeKey nodeKeyMock = mock(NodeKey.class);
    doReturn(nodeKeyMock).when(eventSourceMock).getSourceNodeKey();
    BindingAwareBroker.RoutedRpcRegistration<EventSourceService> routedRpcRegistrationMock = mock(BindingAwareBroker.RoutedRpcRegistration.class);
    localMap.put(nodeKeyMock, routedRpcRegistrationMock);
    eventSourceTopology.unRegister(eventSourceMock);
    verify(routedRpcRegistrationMock, times(1)).close();
}
Also used : BindingAwareBroker(org.opendaylight.controller.sal.binding.api.BindingAwareBroker) EventSource(org.opendaylight.controller.messagebus.spi.EventSource) EventSourceService(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.EventSourceService) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) Test(org.junit.Test)

Example 4 with EventSourceService

use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.EventSourceService in project controller by opendaylight.

the class EventSourceTopologyTest method constructorTestHelper.

private void constructorTestHelper() {
    aggregatorRpcReg = mock(RpcRegistration.class);
    EventSourceService eventSourceService = mock(EventSourceService.class);
    doReturn(aggregatorRpcReg).when(rpcProviderRegistryMock).addRpcImplementation(eq(EventAggregatorService.class), any(EventSourceTopology.class));
    doReturn(eventSourceService).when(rpcProviderRegistryMock).getRpcService(EventSourceService.class);
    WriteTransaction writeTransactionMock = mock(WriteTransaction.class);
    doReturn(writeTransactionMock).when(dataBrokerMock).newWriteOnlyTransaction();
    doNothing().when(writeTransactionMock).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(DataObject.class), eq(true));
    CheckedFuture checkedFutureMock = mock(CheckedFuture.class);
    doReturn(checkedFutureMock).when(writeTransactionMock).submit();
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) RpcRegistration(org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration) EventSourceService(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.EventSourceService) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) CheckedFuture(com.google.common.util.concurrent.CheckedFuture) EventAggregatorService(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.EventAggregatorService)

Aggregations

EventSourceService (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.EventSourceService)4 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)3 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)2 CheckedFuture (com.google.common.util.concurrent.CheckedFuture)1 Test (org.junit.Test)1 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)1 EventSource (org.opendaylight.controller.messagebus.spi.EventSource)1 BindingAwareBroker (org.opendaylight.controller.sal.binding.api.BindingAwareBroker)1 RpcRegistration (org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration)1 EventAggregatorService (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.EventAggregatorService)1 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)1 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)1 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)1 KeyedInstanceIdentifier (org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier)1