import java.util.concurrent.ExecutionException;
import org.opendaylight.bgpcep.pcep.topology.provider.config.PCEPTopologyConfiguration;
import org.opendaylight.bgpcep.pcep.topology.provider.config.PCEPTopologyProviderDependencies;
+import org.opendaylight.bgpcep.programming.spi.InstructionScheduler;
import org.opendaylight.bgpcep.topology.DefaultTopologyReference;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
private final ServerSessionManager manager;
private final PCEPTopologyProviderDependencies dependenciesProvider;
private final PCEPTopologyConfiguration configDependencies;
+ private final InstructionScheduler scheduler;
private RoutedRpcRegistration<NetworkTopologyPcepProgrammingService> network;
private RoutedRpcRegistration<NetworkTopologyPcepService> element;
private Channel channel;
private PCEPTopologyProvider(
final PCEPTopologyConfiguration configDependencies,
final PCEPTopologyProviderDependencies dependenciesProvider,
- final ServerSessionManager manager) {
+ final ServerSessionManager manager, final InstructionScheduler scheduler) {
super(configDependencies.getTopology());
this.dependenciesProvider = requireNonNull(dependenciesProvider);
this.configDependencies = configDependencies;
this.manager = requireNonNull(manager);
+ this.scheduler = requireNonNull(scheduler);
}
public static PCEPTopologyProvider create(final PCEPTopologyProviderDependencies dependenciesProvider,
- final PCEPTopologyConfiguration configDependencies) {
+ final InstructionScheduler scheduler, final PCEPTopologyConfiguration configDependencies) {
final List<PCEPCapability> capabilities = dependenciesProvider.getPCEPDispatcher()
.getPCEPSessionNegotiatorFactory().getPCEPSessionProposalFactory().getCapabilities();
final Optional<PCEPCapability> statefulCapability = capabilities
final ServerSessionManager manager = new ServerSessionManager(dependenciesProvider, listenerFactory,
configDependencies);
- return new PCEPTopologyProvider(configDependencies, dependenciesProvider, manager);
+ return new PCEPTopologyProvider(configDependencies, dependenciesProvider, manager, scheduler);
}
public void instantiateServiceInstance() throws ExecutionException, InterruptedException {
this.network = requireNonNull(rpcRegistry
.addRoutedRpcImplementation(NetworkTopologyPcepProgrammingService.class,
- new TopologyProgramming(configDependencies.getSchedulerDependency(), this.manager)));
+ new TopologyProgramming(this.scheduler, this.manager)));
this.network.registerPath(NetworkTopologyContext.class, this.configDependencies.getTopology());
this.manager.instantiateServiceInstance().get();
import java.net.InetSocketAddress;
import javax.annotation.Nonnull;
-import org.opendaylight.bgpcep.programming.spi.InstructionScheduler;
import org.opendaylight.protocol.concepts.KeyMapping;
import org.opendaylight.protocol.pcep.SpeakerIdMapping;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
public final class PCEPTopologyConfiguration {
private final InetSocketAddress address;
private final KeyMapping keys;
- private final InstructionScheduler scheduler;
private final TopologyId topologyId;
private final short rpcTimeout;
private final SpeakerIdMapping speakerIds;
@Nonnull final InetSocketAddress address,
@Nonnull final KeyMapping keys,
@Nonnull final SpeakerIdMapping speakerIds,
- @Nonnull final InstructionScheduler scheduler,
@Nonnull final TopologyId topologyId,
final short rpcTimeout) {
this.address = checkNotNull(address);
this.keys = checkNotNull(keys);
this.speakerIds = checkNotNull(speakerIds);
- this.scheduler = checkNotNull(scheduler);
this.topologyId = checkNotNull(topologyId);
this.rpcTimeout = rpcTimeout;
this.topology = InstanceIdentifier.builder(NetworkTopology.class)
return this.topology;
}
- @Nonnull
- public InstructionScheduler getSchedulerDependency() {
- return this.scheduler;
- }
-
public short getRpcTimeout() {
return this.rpcTimeout;
}
final SessionConfig config = pcepTopo.getSessionConfig();
final InstructionScheduler instructionScheduler = this.instructionSchedulerFactory
- .createInstructionScheduler(topologyId.getValue());
+ .createInstructionScheduler(topologyId.getValue());
final InetSocketAddress inetAddress = PCEPTopologyProviderUtil
.getInetSocketAddress(config.getListenAddress(), config.getListenPort());
final KeyMapping keys = PCEPTopologyProviderUtil.contructKeys(topology);
final SpeakerIdMapping speakerIds = PCEPTopologyProviderUtil.contructSpeakersId(topology);
final PCEPTopologyConfiguration dependencies = new PCEPTopologyConfiguration(
- inetAddress, keys, speakerIds, instructionScheduler, topology.getTopologyId(),
+ inetAddress, keys, speakerIds, topology.getTopologyId(),
config.getRpcTimeout());
final PCEPTopologyProviderBean pcepTopologyProviderBean = (PCEPTopologyProviderBean) this.container
.getComponentInstance(PCEPTopologyProviderBean.class.getSimpleName());
this.pcepTopologyServices.put(topologyId, pcepTopologyProviderBean);
- pcepTopologyProviderBean.start(dependencies);
+ pcepTopologyProviderBean.start(dependencies, instructionScheduler);
}
private synchronized void removeTopologyProvider(final Topology topo) {
import org.opendaylight.bgpcep.pcep.topology.provider.PCEPTopologyProvider;
import org.opendaylight.bgpcep.pcep.topology.provider.TopologySessionListenerFactory;
import org.opendaylight.bgpcep.pcep.topology.spi.stats.TopologySessionStatsRegistry;
+import org.opendaylight.bgpcep.programming.spi.InstructionScheduler;
import org.opendaylight.bgpcep.topology.DefaultTopologyReference;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
}
@SuppressWarnings("checkstyle:IllegalCatch")
- synchronized void start(final PCEPTopologyConfiguration configDependencies) {
+ synchronized void start(final PCEPTopologyConfiguration configDependencies,
+ final InstructionScheduler instructionScheduler) {
Preconditions.checkState(this.pcepTopoProviderCSS == null,
"Previous instance %s was not closed.", this);
try {
- this.pcepTopoProviderCSS = new PCEPTopologyProviderBeanCSS(configDependencies, this);
+ this.pcepTopoProviderCSS = new PCEPTopologyProviderBeanCSS(configDependencies,
+ instructionScheduler, this);
} catch (final Exception e) {
LOG.debug("Failed to create PCEPTopologyProvider {}", configDependencies.getTopologyId().getValue(), e);
}
private static class PCEPTopologyProviderBeanCSS implements ClusterSingletonService, AutoCloseable {
private final ServiceGroupIdentifier sgi;
private final PCEPTopologyProvider pcepTopoProvider;
+ private final InstructionScheduler scheduler;
private ServiceRegistration<?> serviceRegistration;
private ClusterSingletonServiceRegistration cssRegistration;
@GuardedBy("this")
private boolean serviceInstantiated;
PCEPTopologyProviderBeanCSS(final PCEPTopologyConfiguration configDependencies,
- final PCEPTopologyProviderBean bean) {
- this.sgi = configDependencies.getSchedulerDependency().getIdentifier();
- this.pcepTopoProvider = PCEPTopologyProvider.create(bean, configDependencies);
+ final InstructionScheduler instructionScheduler, final PCEPTopologyProviderBean bean) {
+ this.scheduler = instructionScheduler;
+ this.sgi = this.scheduler.getIdentifier();
+ this.pcepTopoProvider = PCEPTopologyProvider.create(bean, this.scheduler, configDependencies);
final Dictionary<String, String> properties = new Hashtable<>();
properties.put(PCEPTopologyProvider.class.getName(), configDependencies.getTopologyId().getValue());
this.serviceRegistration.unregister();
this.serviceRegistration = null;
}
+ this.scheduler.close();
}
}
}
.getGenericSuperclass()).getActualTypeArguments()[0]).newInstance();
final PCEPTopologyConfiguration configDep = new PCEPTopologyConfiguration(ra, KeyMapping.getKeyMapping(),
- SpeakerIdMapping.getSpeakerIdMap(), this.scheduler, TEST_TOPOLOGY_ID, RPC_TIMEOUT);
+ SpeakerIdMapping.getSpeakerIdMap(), TEST_TOPOLOGY_ID, RPC_TIMEOUT);
this.manager = new ServerSessionManager(this.topologyDependencies, listenerFactory, configDep);
startSessionManager();
this.neg = new DefaultPCEPSessionNegotiator(this.promise, this.clientListener,
@Override
public InstructionScheduler createInstructionScheduler(final String instructionId) {
- LOG.debug("Creating Instruction Scheduler {}.", instructionId);
+ LOG.info("Creating Instruction Scheduler {}.", instructionId);
final ProgrammingServiceImpl programmingInst = new ProgrammingServiceImpl(this.dataProvider, this.notifs,
this.exec, this.rpcProviderRegistry, this.cssp, this.timer, instructionId);
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public final class ProgrammingServiceImpl implements AutoCloseable, ClusterSingletonService, InstructionScheduler,
+public final class ProgrammingServiceImpl implements ClusterSingletonService, InstructionScheduler,
ProgrammingService {
private static final Logger LOG = LoggerFactory.getLogger(ProgrammingServiceImpl.class);
this.qid = KeyedInstanceIdentifier.builder(InstructionsQueue.class,
new InstructionsQueueKey(this.instructionId)).build();
this.sgi = ServiceGroupIdentifier.create(this.instructionId + "-service-group");
- LOG.debug("Creating Programming Service {}.", this.sgi.getValue());
+ LOG.info("Creating Programming Service {}.", this.sgi.getValue());
this.csspReg = cssp.registerClusterSingletonService(this);
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.SubmitInstructionInput;
import org.opendaylight.yangtools.concepts.Identifiable;
-public interface InstructionScheduler extends Identifiable<ServiceGroupIdentifier> {
+public interface InstructionScheduler extends Identifiable<ServiceGroupIdentifier>, AutoCloseable {
/**
* Schedule a new instruction for execution. This method tries to enqueue an instruction. It will return a Future
* which represents the scheduling progress. When the future becomes successful, the requestor is expected to start