import org.opendaylight.netconf.topology.util.messages.CustomIdentifyMessage;
import org.opendaylight.netconf.topology.util.messages.CustomIdentifyMessageReply;
import org.opendaylight.netconf.topology.util.messages.NormalizedNodeMessage;
+import org.opendaylight.netconf.util.NetconfTopologyPathCreator;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
return;
}
- final String path = member.address() + PATH + topologyId;
+ final NetconfTopologyPathCreator pathCreator = new NetconfTopologyPathCreator(member.address().toString(), topologyId);
+ final String path = pathCreator.build();
LOG.debug("Actor at :{} is resolving topology actor for path {}", clusterExtension.selfAddress(), path);
// first send basic identify message in case our messages have not been loaded through osgi yet to prevent crashing akka.
if (member.address().equals(clusterExtension.selfAddress())) {
return;
}
-
- final String path = member.address() + PATH + topologyId;
+ final NetconfTopologyPathCreator pathCreator = new NetconfTopologyPathCreator(member.address().toString(), topologyId);
+ final String path = pathCreator.build();
LOG.debug("Actor at :{} is resolving topology actor for path {}", clusterExtension.selfAddress(), path);
clusterExtension.system().actorSelection(path).tell(new Identify(member.address()), TypedActor.context().self());
} else if (message instanceof ActorIdentity) {
LOG.debug("Received ActorIdentity message", message);
- final String path = ((ActorIdentity) message).correlationId() + PATH + topologyId;
+ final NetconfTopologyPathCreator pathCreator = new NetconfTopologyPathCreator(((ActorIdentity) message).correlationId().toString(), topologyId);
+ final String path = pathCreator.build();
if (((ActorIdentity) message).getRef() == null) {
LOG.debug("ActorIdentity has null actor ref, retrying..", message);
final ActorRef self = TypedActor.context().self();
import org.opendaylight.netconf.topology.util.BaseTopologyManager;
import org.opendaylight.netconf.topology.util.messages.AnnounceMasterMountPoint;
import org.opendaylight.netconf.topology.util.messages.AnnounceMasterMountPointDown;
+import org.opendaylight.netconf.util.NetconfTopologyPathCreator;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus.ConnectionStatus;
this.topologyDispatcher = (ClusteredNetconfTopology) topologyDispatcher;
this.roleChangeStrategy = roleChangeStrategy;
- final Future<ActorRef> topologyRefFuture = actorSystem.actorSelection("/user/" + topologyId).resolveOne(FiniteDuration.create(10L, TimeUnit.SECONDS));
+ final NetconfTopologyPathCreator pathCreator = new NetconfTopologyPathCreator(topologyId);
+ final Future<ActorRef> topologyRefFuture = actorSystem.actorSelection(pathCreator.build()).resolveOne(FiniteDuration.create(10L, TimeUnit.SECONDS));
topologyRefFuture.onComplete(new OnComplete<ActorRef>() {
@Override
public void onComplete(Throwable throwable, ActorRef actorRef) throws Throwable {
}
}, actorSystem.dispatcher());
- final Future<ActorRef> nodeRefFuture = actorSystem.actorSelection("/user/" + topologyId + "/" + nodeId).resolveOne(FiniteDuration.create(10L, TimeUnit.SECONDS));
+ final Future<ActorRef> nodeRefFuture = actorSystem.actorSelection(pathCreator.withSuffix(nodeId).build()).resolveOne(FiniteDuration.create(10L, TimeUnit.SECONDS));
nodeRefFuture.onComplete(new OnComplete<ActorRef>() {
@Override
public void onComplete(Throwable throwable, ActorRef actorRef) throws Throwable {
import org.opendaylight.netconf.topology.pipeline.messages.AnnounceClusteredDeviceSourcesResolverUp;
import org.opendaylight.netconf.topology.pipeline.messages.AnnounceMasterOnSameNodeUp;
import org.opendaylight.netconf.topology.pipeline.messages.AnnounceMasterSourceProviderUp;
+import org.opendaylight.netconf.util.NetconfTopologyPathCreator;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
Cluster cluster = Cluster.get(actorSystem);
for(Member node : cluster.state().getMembers()) {
if(!node.address().equals(cluster.selfAddress())) {
- final String path = node.address() + "/user/" + topologyId + "/" + nodeId + "/masterSourceProvider";
+ final NetconfTopologyPathCreator pathCreator = new NetconfTopologyPathCreator(node.address().toString(), topologyId);
+ final String path = pathCreator.withSuffix(nodeId).withSuffix(NetconfTopologyPathCreator.MASTER_SOURCE_PROVIDER).build();
actorSystem.actorSelection(path).tell(new AnnounceClusteredDeviceSourcesResolverUp(), TypedActor.context().self());
}
}
import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceRpc;
import org.opendaylight.netconf.sal.connect.netconf.schema.mapping.NetconfMessageTransformer;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
+import org.opendaylight.netconf.util.NetconfTopologyPathCreator;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
public MasterSourceProviderImpl create() throws Exception {
return new MasterSourceProviderImpl(schemaRepo, sourceIds, actorSystem, topologyId, nodeId);
}
- }), "masterSourceProvider");
+ }), NetconfTopologyPathCreator.MASTER_SOURCE_PROVIDER);
}
@Override
public ClusteredDeviceSourcesResolverImpl create() throws Exception {
return new ClusteredDeviceSourcesResolverImpl(topologyId, nodeId, actorSystem, schemaRegistry, sourceRegistrations);
}
- }), "clusteredDeviceSourcesResolver");
-
+ }), NetconfTopologyPathCreator.CLUSTERED_DEVICE_SOURCES_RESOLVER);
final FutureCallback<SchemaContext> schemaContextFuture = new FutureCallback<SchemaContext>() {
@Override
import org.opendaylight.netconf.topology.pipeline.messages.AnnounceClusteredDeviceSourcesResolverUp;
import org.opendaylight.netconf.topology.pipeline.messages.AnnounceMasterOnSameNodeUp;
import org.opendaylight.netconf.topology.pipeline.messages.AnnounceMasterSourceProviderUp;
+import org.opendaylight.netconf.util.NetconfTopologyPathCreator;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.slf4j.Logger;
cluster.join(cluster.selfAddress());
LOG.debug("Notifying members master schema source provider is up.");
for(Member node : cluster.state().getMembers()) {
- final String path = node.address() + "/user/" + topologyId + "/" + nodeId + "/clusteredDeviceSourcesResolver";
+ final NetconfTopologyPathCreator pathCreator = new NetconfTopologyPathCreator(node.address().toString(),topologyId);
+ final String path = pathCreator.withSuffix(nodeId).withSuffix(NetconfTopologyPathCreator.CLUSTERED_DEVICE_SOURCES_RESOLVER).build();
if(node.address().equals(cluster.selfAddress())) {
actorSystem.actorSelection(path).tell(new AnnounceMasterOnSameNodeUp(), TypedActor.context().self());
actorSystem.actorSelection(path).tell(PoisonPill.getInstance(), TypedActor.context().self());
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
import org.opendaylight.netconf.topology.util.messages.AnnounceMasterMountPoint;
import org.opendaylight.netconf.topology.util.messages.AnnounceMasterMountPointDown;
+import org.opendaylight.netconf.util.NetconfTopologyPathCreator;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final ActorRef deviceDataBrokerRef = TypedActor.get(actorSystem).getActorRefFor(deviceDataBroker);
for (final Member member : members) {
if (!member.address().equals(cluster.selfAddress())) {
- final String path = member.address() + "/user/" + topologyId + "/" + id.getName();
+ final NetconfTopologyPathCreator pathCreator = new NetconfTopologyPathCreator(member.address().toString(),topologyId);
+ final String path = pathCreator.withSuffix(id.getName()).build();
actorSystem.actorSelection(path).tell(new AnnounceMasterMountPoint(), deviceDataBrokerRef);
}
}
if (member.address().equals(Cluster.get(actorSystem).selfAddress())) {
continue;
}
- actorSystem.actorSelection(member.address() + "/user/" + topologyId + "/" + id.getName()).tell(new AnnounceMasterMountPointDown(), null);
+ final NetconfTopologyPathCreator pathCreator = new NetconfTopologyPathCreator(member.address().toString(), topologyId);
+ final String path = pathCreator.withSuffix(id.getName()).build();
+ actorSystem.actorSelection(path).tell(new AnnounceMasterMountPointDown(), null);
}
TypedActor.get(actorSystem).stop(deviceDataBroker);
deviceDataBroker = null;
--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * 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.netconf.util;
+
+public class NetconfTopologyPathCreator {
+
+ public static final String CLUSTERED_DEVICE_SOURCES_RESOLVER = "clusteredDeviceSourcesResolver";
+ public static final String MASTER_SOURCE_PROVIDER
+ = "masterSourceProvider";
+
+ private static final String USER = "/user/";
+
+ private String mainPath;
+
+ public NetconfTopologyPathCreator(final String topologyId) {
+ mainPath = createMainPath("", topologyId);
+ }
+
+ public NetconfTopologyPathCreator(final String memberAddress, final String topologyId) {
+ mainPath = createMainPath(memberAddress, topologyId);
+ }
+
+ private String createMainPath(final String memberAddress, final String topologyId) {
+ return memberAddress + USER + topologyId;
+ }
+
+ public NetconfTopologyPathCreator withSuffix(final String suffix) {
+ mainPath += "/"+suffix;
+ return this;
+ }
+
+ public String build(){
+ return mainPath;
+ }
+
+}