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());
}
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();
}
};
}
Aggregations