import javax.annotation.Nonnull;
import org.opendaylight.protocol.concepts.KeyMapping;
import org.opendaylight.protocol.pcep.SpeakerIdMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.config.rev171025.pcep.config.SessionConfig;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
private final SpeakerIdMapping speakerIds;
private final InstanceIdentifier<Topology> topology;
- public PCEPTopologyConfiguration(
- @Nonnull final InetSocketAddress address,
- @Nonnull final KeyMapping keys,
- @Nonnull final SpeakerIdMapping speakerIds,
- @Nonnull final TopologyId topologyId,
- final short rpcTimeout) {
- this.address = checkNotNull(address);
- this.keys = checkNotNull(keys);
- this.speakerIds = checkNotNull(speakerIds);
- this.topologyId = checkNotNull(topologyId);
- this.rpcTimeout = rpcTimeout;
+ public PCEPTopologyConfiguration(@Nonnull final SessionConfig config, @Nonnull final Topology topology) {
+ checkNotNull(topology);
+ this.address = PCEPTopologyProviderUtil
+ .getInetSocketAddress(checkNotNull(config.getListenAddress()), checkNotNull(config.getListenPort()));
+ this.keys = checkNotNull(PCEPTopologyProviderUtil.contructKeys(topology));
+ this.speakerIds = checkNotNull(PCEPTopologyProviderUtil.contructSpeakersId(topology));
+ this.topologyId = checkNotNull(topology.getTopologyId());
+ this.rpcTimeout = config.getRpcTimeout();
this.topology = InstanceIdentifier.builder(NetworkTopology.class)
.child(Topology.class, new TopologyKey(this.topologyId)).build();
}
import static org.opendaylight.bgpcep.pcep.topology.provider.config.PCEPTopologyProviderUtil.filterPcepTopologies;
import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
-import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
-import org.opendaylight.protocol.concepts.KeyMapping;
-import org.opendaylight.protocol.pcep.SpeakerIdMapping;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.config.rev171025.pcep.config.SessionConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.config.rev171025.PcepTopologyTypeConfig;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
return;
}
final TopologyId topologyId = topology.getTopologyId();
+ LOG.info("Updating Topology {}", topologyId);
final PCEPTopologyProviderBean previous = this.pcepTopologyServices.remove(topology.getTopologyId());
closeTopology(previous, topologyId);
createTopologyProvider(topology);
LOG.warn("Topology Provider {} already exist. New instance won't be created", topologyId);
return;
}
+ LOG.info("Creating Topology {}", topologyId);
+ LOG.trace("Topology {}.", topology);
- final PcepTopologyTypeConfig pcepTopo = topology.getAugmentation(PcepTopologyTypeConfig.class);
-
- final SessionConfig config = pcepTopo.getSessionConfig();
-
+ final SessionConfig config = topology.getAugmentation(PcepTopologyTypeConfig.class).getSessionConfig();
final InstructionScheduler instructionScheduler = this.instructionSchedulerFactory
- .createInstructionScheduler(topologyId.getValue());
-
- final InetSocketAddress inetAddress = PCEPTopologyProviderUtil
- .getInetSocketAddress(config.getListenAddress(), config.getListenPort());
+ .createInstructionScheduler(topologyId.getValue());
- final KeyMapping keys = PCEPTopologyProviderUtil.contructKeys(topology);
- final SpeakerIdMapping speakerIds = PCEPTopologyProviderUtil.contructSpeakersId(topology);
- final PCEPTopologyConfiguration dependencies = new PCEPTopologyConfiguration(
- inetAddress, keys, speakerIds, topology.getTopologyId(),
- config.getRpcTimeout());
+ final PCEPTopologyConfiguration dependencies = new PCEPTopologyConfiguration(config, topology);
final PCEPTopologyProviderBean pcepTopologyProviderBean = (PCEPTopologyProviderBean) this.container
.getComponentInstance(PCEPTopologyProviderBean.class.getSimpleName());
pcepTopologyProviderBean.start(dependencies, instructionScheduler);
}
- private synchronized void removeTopologyProvider(final Topology topo) {
- if (!filterPcepTopologies(topo.getTopologyTypes())) {
+ private synchronized void removeTopologyProvider(final Topology topology) {
+ if (!filterPcepTopologies(topology.getTopologyTypes())) {
return;
}
- final TopologyId topologyId = topo.getTopologyId();
- final PCEPTopologyProviderBean topology = this.pcepTopologyServices.remove(topologyId);
- closeTopology(topology, topologyId);
+ final TopologyId topologyId = topology.getTopologyId();
+ closeTopology(this.pcepTopologyServices.remove(topologyId), topologyId);
}
@Override
@SuppressWarnings("checkstyle:IllegalCatch")
static void closeTopology(@Nullable final PCEPTopologyProviderBean topology, @Nonnull final TopologyId topologyId) {
- if (topology != null) {
- try {
- topology.closeServiceInstance().get(TIMEOUT_NS, TimeUnit.NANOSECONDS);
- topology.close();
- } catch (final Exception e) {
- LOG.error("Topology {} instance failed to close service instance", topologyId, e);
- }
+ if (topology == null) {
+ return;
+ }
+ LOG.info("Removing Topology {}", topologyId);
+ try {
+ topology.closeServiceInstance().get(TIMEOUT_NS, TimeUnit.NANOSECONDS);
+ topology.close();
+ } catch (final Exception e) {
+ LOG.error("Topology {} instance failed to close service instance", topologyId, e);
}
}
import java.lang.reflect.ParameterizedType;
import java.net.InetSocketAddress;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.opendaylight.bgpcep.pcep.topology.provider.config.PCEPTopologyConfiguration;
import org.opendaylight.bgpcep.pcep.topology.provider.config.PCEPTopologyProviderDependencies;
import org.opendaylight.bgpcep.pcep.topology.spi.stats.TopologySessionStatsRegistry;
-import org.opendaylight.bgpcep.programming.spi.InstructionScheduler;
import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest;
-import org.opendaylight.protocol.concepts.KeyMapping;
import org.opendaylight.protocol.pcep.PCEPSessionListener;
-import org.opendaylight.protocol.pcep.SpeakerIdMapping;
import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiator;
import org.opendaylight.protocol.pcep.impl.PCEPSessionImpl;
import org.opendaylight.protocol.util.InetSocketAddressUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.config.rev171025.pcep.config.SessionConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.EroBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject;
@Mock
private PCEPTopologyProviderDependencies topologyDependencies;
@Mock
- private InstructionScheduler scheduler;
+ private SessionConfig sessionConfig;
+ @Mock
+ private Topology topology;
@Mock
private Promise<PCEPSessionImpl> promise;
private DefaultPCEPSessionNegotiator neg;
@SuppressWarnings("unchecked") final T listenerFactory = (T) ((Class) ((ParameterizedType) this.getClass()
.getGenericSuperclass()).getActualTypeArguments()[0]).newInstance();
+ doReturn(new IpAddress(new Ipv4Address(this.testAddress))).when(this.sessionConfig).getListenAddress();
+ doReturn(new PortNumber(4189)).when(this.sessionConfig).getListenPort();
+ doReturn(RPC_TIMEOUT).when(this.sessionConfig).getRpcTimeout();
+ doReturn(TEST_TOPOLOGY_ID).when(this.topology).getTopologyId();
+ doReturn(Collections.emptyList()).when(this.topology).getNode();
- final PCEPTopologyConfiguration configDep = new PCEPTopologyConfiguration(ra, KeyMapping.getKeyMapping(),
- SpeakerIdMapping.getSpeakerIdMap(), TEST_TOPOLOGY_ID, RPC_TIMEOUT);
+ final PCEPTopologyConfiguration configDep = new PCEPTopologyConfiguration(this.sessionConfig, this.topology);
this.manager = new ServerSessionManager(this.topologyDependencies, listenerFactory, configDep);
startSessionManager();
this.neg = new DefaultPCEPSessionNegotiator(this.promise, this.clientListener,