Search in sources :

Example 1 with ClusteredDOMDataTreeChangeListener

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

the class DataTreeChangeListenerProxy method doRegistration.

private void doRegistration(final ActorRef shard) {
    Future<Object> future = actorContext.executeOperationAsync(shard, new RegisterDataTreeChangeListener(registeredPath, dataChangeListenerActor, getInstance() instanceof ClusteredDOMDataTreeChangeListener), actorContext.getDatastoreContext().getShardInitializationTimeout());
    future.onComplete(new OnComplete<Object>() {

        @Override
        public void onComplete(final Throwable failure, final Object result) {
            if (failure != null) {
                LOG.error("{}: Failed to register DataTreeChangeListener {} at path {}", logContext(), getInstance(), registeredPath, failure);
            } else {
                RegisterDataTreeNotificationListenerReply reply = (RegisterDataTreeNotificationListenerReply) result;
                setListenerRegistrationActor(actorContext.actorSelection(reply.getListenerRegistrationPath()));
            }
        }
    }, actorContext.getClientDispatcher());
}
Also used : RegisterDataTreeNotificationListenerReply(org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeNotificationListenerReply) ClusteredDOMDataTreeChangeListener(org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener) RegisterDataTreeChangeListener(org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeChangeListener)

Example 2 with ClusteredDOMDataTreeChangeListener

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

the class DataTreeChangeListenerProxyTest method testSuccessfulRegistrationForClusteredListener.

@Test(timeout = 10000)
public void testSuccessfulRegistrationForClusteredListener() {
    new TestKit(getSystem()) {

        {
            ActorContext actorContext = new ActorContext(getSystem(), getRef(), mock(ClusterWrapper.class), mock(Configuration.class));
            ClusteredDOMDataTreeChangeListener mockClusteredListener = mock(ClusteredDOMDataTreeChangeListener.class);
            final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
            final DataTreeChangeListenerProxy<ClusteredDOMDataTreeChangeListener> proxy = new DataTreeChangeListenerProxy<>(actorContext, mockClusteredListener, path);
            new Thread(() -> proxy.init("shard-1")).start();
            FiniteDuration timeout = duration("5 seconds");
            FindLocalShard findLocalShard = expectMsgClass(timeout, FindLocalShard.class);
            Assert.assertEquals("getShardName", "shard-1", findLocalShard.getShardName());
            reply(new LocalShardFound(getRef()));
            RegisterDataTreeChangeListener registerMsg = expectMsgClass(timeout, RegisterDataTreeChangeListener.class);
            Assert.assertEquals("getPath", path, registerMsg.getPath());
            Assert.assertEquals("isRegisterOnAllInstances", true, registerMsg.isRegisterOnAllInstances());
            proxy.close();
        }
    };
}
Also used : LocalShardFound(org.opendaylight.controller.cluster.datastore.messages.LocalShardFound) Configuration(org.opendaylight.controller.cluster.datastore.config.Configuration) FiniteDuration(scala.concurrent.duration.FiniteDuration) FindLocalShard(org.opendaylight.controller.cluster.datastore.messages.FindLocalShard) TestKit(akka.testkit.javadsl.TestKit) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) RegisterDataTreeChangeListener(org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeChangeListener) ActorContext(org.opendaylight.controller.cluster.datastore.utils.ActorContext) ClusteredDOMDataTreeChangeListener(org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener) Test(org.junit.Test)

Aggregations

RegisterDataTreeChangeListener (org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeChangeListener)2 ClusteredDOMDataTreeChangeListener (org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener)2 TestKit (akka.testkit.javadsl.TestKit)1 Test (org.junit.Test)1 Configuration (org.opendaylight.controller.cluster.datastore.config.Configuration)1 FindLocalShard (org.opendaylight.controller.cluster.datastore.messages.FindLocalShard)1 LocalShardFound (org.opendaylight.controller.cluster.datastore.messages.LocalShardFound)1 RegisterDataTreeNotificationListenerReply (org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeNotificationListenerReply)1 ActorContext (org.opendaylight.controller.cluster.datastore.utils.ActorContext)1 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)1 FiniteDuration (scala.concurrent.duration.FiniteDuration)1