X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fbinding%2Fimpl%2FAbstractForwardedDataBroker.java;h=da9cb2ee9a15f3cbc0e17db2438f3850b77d517a;hp=7e63e54f4b5c5358e33c632c76d669b602a2bf63;hb=03c13bd8a8bb89a729d739eb2fcd501a4dfa5439;hpb=8293635baf4ff10b01ab2bf2b6336d67714e94f0 diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedDataBroker.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedDataBroker.java index 7e63e54f4b..da9cb2ee9a 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedDataBroker.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedDataBroker.java @@ -7,7 +7,7 @@ */ package org.opendaylight.controller.md.sal.binding.impl; -import com.google.common.base.Objects; +import com.google.common.base.MoreObjects; import com.google.common.base.Optional; import java.util.Collections; import java.util.HashMap; @@ -15,13 +15,15 @@ import java.util.HashSet; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import org.opendaylight.controller.md.sal.binding.api.ClusteredDataChangeListener; import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataChangeListener; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener; -import org.opendaylight.controller.sal.core.api.model.SchemaService; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; import org.opendaylight.yangtools.concepts.Delegator; import org.opendaylight.yangtools.concepts.ListenerRegistration; @@ -42,7 +44,7 @@ public abstract class AbstractForwardedDataBroker implements Delegator registerDataChangeListener(final LogicalDatastoreType store, - final InstanceIdentifier path, final DataChangeListener listener, final DataChangeScope triggeringScope) { - final DOMDataChangeListener domDataChangeListener = new TranslatingDataChangeInvoker(store, path, listener, + final InstanceIdentifier path, final DataChangeListener listener, + final DataChangeScope triggeringScope) { + final DOMDataChangeListener domDataChangeListener; + + if (listener instanceof ClusteredDataChangeListener) { + domDataChangeListener = new TranslatingClusteredDataChangeInvoker(store, path, listener, triggeringScope); + } else { + domDataChangeListener = new TranslatingDataChangeInvoker(store, path, listener, triggeringScope); + } final YangInstanceIdentifier domPath = codec.toYangInstanceIdentifierBlocking(path); - final ListenerRegistration domRegistration = domDataBroker.registerDataChangeListener(store, - domPath, domDataChangeListener, triggeringScope); + final ListenerRegistration domRegistration = + domDataBroker.registerDataChangeListener(store, domPath, domDataChangeListener, triggeringScope); return new ListenerRegistrationImpl(listener, domRegistration); } @@ -77,7 +86,8 @@ public abstract class AbstractForwardedDataBroker implements Delegator> entry : normalized.entrySet()) { try { - final Optional, DataObject>> potential = getCodec().toBinding(entry); + final Optional, DataObject>> potential = + getCodec().toBinding(entry); if (potential.isPresent()) { final Entry, DataObject> binding = potential.get(); newMap.put(binding.getKey(), binding.getValue()); @@ -94,11 +104,13 @@ public abstract class AbstractForwardedDataBroker implements Delegator> hashSet = new HashSet<>(); for (final YangInstanceIdentifier normalizedPath : normalized) { try { - final Optional> potential = getCodec().toBinding(normalizedPath); + final Optional> potential = + getCodec().toBinding(normalizedPath); if (potential.isPresent()) { final InstanceIdentifier binding = potential.get(); hashSet.add(binding); - } else if (normalizedPath.getLastPathArgument() instanceof YangInstanceIdentifier.AugmentationIdentifier) { + } else if (normalizedPath.getLastPathArgument() + instanceof YangInstanceIdentifier.AugmentationIdentifier) { hashSet.add(path); } } catch (final DeserializationException e) { @@ -112,7 +124,8 @@ public abstract class AbstractForwardedDataBroker implements Delegator) getCodec().deserializeFunction(path).apply(Optional.> of(data)); + return (Optional) getCodec().deserializeFunction(path) + .apply(Optional.>of(data)); } private class TranslatingDataChangeInvoker implements DOMDataChangeListener { @@ -121,7 +134,7 @@ public abstract class AbstractForwardedDataBroker implements Delegator path; private final DataChangeScope triggeringScope; - public TranslatingDataChangeInvoker(final LogicalDatastoreType store, final InstanceIdentifier path, + TranslatingDataChangeInvoker(final LogicalDatastoreType store, final InstanceIdentifier path, final DataChangeListener bindingDataChangeListener, final DataChangeScope triggeringScope) { this.store = store; this.path = path; @@ -140,6 +153,18 @@ public abstract class AbstractForwardedDataBroker implements Delegator path, + final DataChangeListener bindingDataChangeListener, final DataChangeScope triggeringScope) { + super(store, path, bindingDataChangeListener, triggeringScope); + } + } + private class TranslatedDataChangeEvent implements AsyncDataChangeEvent, DataObject> { private final AsyncDataChangeEvent> domEvent; private final InstanceIdentifier path; @@ -151,7 +176,7 @@ public abstract class AbstractForwardedDataBroker implements Delegator originalDataCache; private Optional updatedDataCache; - public TranslatedDataChangeEvent( + TranslatedDataChangeEvent( final AsyncDataChangeEvent> change, final InstanceIdentifier path) { this.domEvent = change; @@ -218,7 +243,7 @@ public abstract class AbstractForwardedDataBroker implements Delegator { private final ListenerRegistration registration; - public ListenerRegistrationImpl(final DataChangeListener listener, + ListenerRegistrationImpl(final DataChangeListener listener, final ListenerRegistration registration) { super(listener); this.registration = registration; @@ -245,5 +270,4 @@ public abstract class AbstractForwardedDataBroker implements Delegator