Search in sources :

Example 1 with DOMRpcAvailabilityListener

use of org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener in project controller by opendaylight.

the class AbstractInvokableServiceMetadata method retrievedDOMRpcService.

private void retrievedDOMRpcService(final Object service) {
    log.debug("{}: retrievedDOMRpcService {}", logName(), service);
    final DOMRpcService domRpcService = (DOMRpcService) service;
    setDependencyDesc("Available DOM RPC for binding RPC: " + rpcInterface);
    rpcListenerReg = domRpcService.registerRpcListener(new DOMRpcAvailabilityListener() {

        @Override
        public void onRpcAvailable(final Collection<DOMRpcIdentifier> rpcs) {
            onRpcsAvailable(rpcs);
        }

        @Override
        public void onRpcUnavailable(final Collection<DOMRpcIdentifier> rpcs) {
        }
    });
}
Also used : DOMRpcAvailabilityListener(org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener) DOMRpcService(org.opendaylight.mdsal.dom.api.DOMRpcService) Collection(java.util.Collection)

Example 2 with DOMRpcAvailabilityListener

use of org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener in project mdsal by opendaylight.

the class ForwardingDOMRpcServiceTest method basicTest.

@Test
public void basicTest() throws Exception {
    final DOMRpcAvailabilityListener domRpcAvailabilityListener = mock(DOMRpcAvailabilityListener.class);
    final QName id = QName.create("urn:foo", "foo");
    doReturn(null).when(domRpcService).invokeRpc(id, null);
    this.invokeRpc(id, null);
    verify(domRpcService).invokeRpc(id, null);
    doReturn(null).when(domRpcService).registerRpcListener(domRpcAvailabilityListener);
    this.registerRpcListener(domRpcAvailabilityListener);
    verify(domRpcService).registerRpcListener(domRpcAvailabilityListener);
}
Also used : DOMRpcAvailabilityListener(org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener) QName(org.opendaylight.yangtools.yang.common.QName) Test(org.junit.Test)

Example 3 with DOMRpcAvailabilityListener

use of org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener in project mdsal by opendaylight.

the class DOMRpcRouterTest method testRpcListener.

@Test
public void testRpcListener() {
    try (DOMRpcRouter rpcRouter = new DOMRpcRouter()) {
        assertEquals(List.of(), rpcRouter.listeners());
        final DOMRpcAvailabilityListener listener = mock(DOMRpcAvailabilityListener.class);
        doCallRealMethod().when(listener).acceptsImplementation(any());
        doNothing().when(listener).onRpcAvailable(any());
        doNothing().when(listener).onRpcUnavailable(any());
        final Registration reg = rpcRouter.getRpcService().registerRpcListener(listener);
        assertNotNull(reg);
        assertEquals(List.of(reg), rpcRouter.listeners());
        final Registration implReg = rpcRouter.getRpcProviderService().registerRpcImplementation(getTestRpcImplementation(), DOMRpcIdentifier.create(Rpcs.FOO, null));
        verify(listener, timeout(1000)).onRpcAvailable(any());
        implReg.close();
        verify(listener, timeout(1000)).onRpcUnavailable(any());
        reg.close();
        assertEquals(List.of(), rpcRouter.listeners());
    }
}
Also used : DOMRpcAvailabilityListener(org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener) ListenerRegistration(org.opendaylight.yangtools.concepts.ListenerRegistration) ObjectRegistration(org.opendaylight.yangtools.concepts.ObjectRegistration) Registration(org.opendaylight.yangtools.concepts.Registration) Test(org.junit.Test)

Aggregations

DOMRpcAvailabilityListener (org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener)3 Test (org.junit.Test)2 Collection (java.util.Collection)1 DOMRpcService (org.opendaylight.mdsal.dom.api.DOMRpcService)1 ListenerRegistration (org.opendaylight.yangtools.concepts.ListenerRegistration)1 ObjectRegistration (org.opendaylight.yangtools.concepts.ObjectRegistration)1 Registration (org.opendaylight.yangtools.concepts.Registration)1 QName (org.opendaylight.yangtools.yang.common.QName)1