X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fmessagebus-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmessagebus%2Fapp%2Fimpl%2FEventSourceTopic.java;h=6c9e17b5bfbecba357171006e50811aba8a5551b;hb=3859df9beca8f13f1ff2b2744ed3470a1715bec3;hp=fc4dad6eaf7b8b4962ce902fe51e875167362635;hpb=c2983daa13f85d139797eb3ca17f81c25e6997b7;p=controller.git diff --git a/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopic.java b/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopic.java index fc4dad6eaf..6c9e17b5bf 100644 --- a/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopic.java +++ b/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopic.java @@ -5,32 +5,32 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.messagebus.app.impl; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import java.util.Collection; import java.util.List; +import java.util.Optional; import java.util.UUID; import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.ExecutionException; import java.util.regex.Pattern; -import javax.annotation.Nonnull; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataTreeChangeListener; +import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.NotificationPattern; import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.TopicId; import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.DisJoinTopicInput; import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.DisJoinTopicInputBuilder; +import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.DisJoinTopicOutput; import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.EventSourceService; import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.JoinTopicInput; import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.JoinTopicInputBuilder; @@ -64,8 +64,8 @@ public final class EventSourceTopic implements DataTreeChangeListener, Aut private EventSourceTopic(final NotificationPattern notificationPattern, final String nodeIdRegexPattern, final EventSourceService sourceService) { - this.notificationPattern = Preconditions.checkNotNull(notificationPattern); - this.sourceService = Preconditions.checkNotNull(sourceService); + this.notificationPattern = requireNonNull(notificationPattern); + this.sourceService = requireNonNull(sourceService); this.nodeIdPattern = Pattern.compile(nodeIdRegexPattern); this.topicId = new TopicId(getUUIDIdent()); this.listenerRegistration = null; @@ -77,7 +77,7 @@ public final class EventSourceTopic implements DataTreeChangeListener, Aut } @Override - public void onDataTreeChanged(Collection> changes) { + public void onDataTreeChanged(final Collection> changes) { for (DataTreeModification change: changes) { final DataObjectModification rootNode = change.getRootNode(); switch (rootNode.getModificationType()) { @@ -116,20 +116,20 @@ public final class EventSourceTopic implements DataTreeChangeListener, Aut LOG.debug("Notify existing nodes"); final Pattern nodeRegex = this.nodeIdPattern; - final ReadOnlyTransaction tx = eventSourceTopology.getDataBroker().newReadOnlyTransaction(); + final ReadTransaction tx = eventSourceTopology.getDataBroker().newReadOnlyTransaction(); final ListenableFuture> future = tx.read(LogicalDatastoreType.OPERATIONAL, EventSourceTopology.EVENT_SOURCE_TOPOLOGY_PATH); Futures.addCallback(future, new FutureCallback>() { @Override - public void onSuccess(@Nonnull final Optional data) { + public void onSuccess(final Optional data) { if (data.isPresent()) { final List nodes = data.get().getNode(); if (nodes != null) { for (final Node node : nodes) { if (nodeRegex.matcher(node.getNodeId().getValue()).matches()) { notifyNode(EventSourceTopology.EVENT_SOURCE_TOPOLOGY_PATH.child(Node.class, - node.getKey())); + node.key())); } } } @@ -170,11 +170,9 @@ public final class EventSourceTopic implements DataTreeChangeListener, Aut } private void registerListner(final EventSourceTopology eventSourceTopology) { - this.listenerRegistration = - eventSourceTopology.getDataBroker().registerDataTreeChangeListener(new DataTreeIdentifier<>( - LogicalDatastoreType.OPERATIONAL, - EventSourceTopology.EVENT_SOURCE_TOPOLOGY_PATH.child(Node.class)), - this); + this.listenerRegistration = eventSourceTopology.getDataBroker().registerDataTreeChangeListener( + DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, + EventSourceTopology.EVENT_SOURCE_TOPOLOGY_PATH.child(Node.class)), this); } @Override @@ -184,7 +182,7 @@ public final class EventSourceTopic implements DataTreeChangeListener, Aut } for (final InstanceIdentifier eventSourceNodeId : joinedEventSources) { try { - final RpcResult result = sourceService + final RpcResult result = sourceService .disJoinTopic(getDisJoinTopicInputArgument(eventSourceNodeId)).get(); if (result.isSuccessful() == false) { for (final RpcError err : result.getErrors()) {