Search in sources :

Example 1 with ClusteredDOMDataChangeListener

use of org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataChangeListener in project controller by opendaylight.

the class BindingDOMDataBrokerAdapterTest method testClusteredDataChangeListernerRegisteration.

@Test
public void testClusteredDataChangeListernerRegisteration() {
    final BindingToNormalizedNodeCodec codec = new BindingToNormalizedNodeCodec(this.classLoadingStrategy, this.codecRegistry);
    try (BindingDOMDataBrokerAdapter bindingDOMDataBrokerAdapter = new BindingDOMDataBrokerAdapter(this.dataBroker, codec)) {
        Mockito.when(this.codecRegistry.toYangInstanceIdentifier(TOP_PATH)).thenReturn(this.yangInstanceIdentifier);
        final ArgumentCaptor<ClusteredDOMDataChangeListener> clusteredDOMListener = ArgumentCaptor.forClass(ClusteredDOMDataChangeListener.class);
        final ArgumentCaptor<LogicalDatastoreType> logicalDatastoreType = ArgumentCaptor.forClass(LogicalDatastoreType.class);
        final ArgumentCaptor<AsyncDataBroker.DataChangeScope> dataChangeScope = ArgumentCaptor.forClass(AsyncDataBroker.DataChangeScope.class);
        final ArgumentCaptor<YangInstanceIdentifier> yangIidCapture = ArgumentCaptor.forClass(YangInstanceIdentifier.class);
        final TestListener listener = new TestListener();
        bindingDOMDataBrokerAdapter.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, TOP_PATH, listener, AsyncDataBroker.DataChangeScope.BASE);
        Mockito.verify(this.dataBroker).registerDataChangeListener(logicalDatastoreType.capture(), yangIidCapture.capture(), clusteredDOMListener.capture(), dataChangeScope.capture());
    }
}
Also used : AsyncDataBroker(org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker) BindingToNormalizedNodeCodec(org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec) BindingDOMDataBrokerAdapter(org.opendaylight.controller.md.sal.binding.impl.BindingDOMDataBrokerAdapter) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) ClusteredDOMDataChangeListener(org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataChangeListener) Test(org.junit.Test)

Example 2 with ClusteredDOMDataChangeListener

use of org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataChangeListener in project controller by opendaylight.

the class DataChangeListenerRegistrationProxy method doRegistration.

private void doRegistration(final ActorRef shard, final YangInstanceIdentifier path, final DataChangeScope scope) {
    Future<Object> future = actorContext.executeOperationAsync(shard, new RegisterChangeListener(path, dataChangeListenerActor, scope, listener instanceof ClusteredDOMDataChangeListener), 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 DataChangeListener {} at path {}", listener, path.toString(), failure);
            } else {
                RegisterDataTreeNotificationListenerReply reply = (RegisterDataTreeNotificationListenerReply) result;
                setListenerRegistrationActor(actorContext.actorSelection(reply.getListenerRegistrationPath()));
            }
        }
    }, actorContext.getClientDispatcher());
}
Also used : RegisterDataTreeNotificationListenerReply(org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeNotificationListenerReply) RegisterChangeListener(org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListener) ClusteredDOMDataChangeListener(org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataChangeListener)

Aggregations

ClusteredDOMDataChangeListener (org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataChangeListener)2 Test (org.junit.Test)1 RegisterChangeListener (org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListener)1 RegisterDataTreeNotificationListenerReply (org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeNotificationListenerReply)1 BindingDOMDataBrokerAdapter (org.opendaylight.controller.md.sal.binding.impl.BindingDOMDataBrokerAdapter)1 BindingToNormalizedNodeCodec (org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec)1 AsyncDataBroker (org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker)1 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)1 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)1