<name>global-timer</name>
</timer>
</module>
+
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep:topology:provider">prefix:pcep-topology-stateful02</type>
+ <name>global</name>
+ </module>
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep:topology:provider">prefix:pcep-topology-stateful07</type>
+ <name>global</name>
+ </module>
+
<module>
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep:topology:provider">prefix:pcep-topology-provider</type>
<name>pcep-topology</name>
<type xmlns:pgmspi="urn:opendaylight:params:xml:ns:yang:controller:programming:spi">pgmspi:instruction-scheduler</type>
<name>global-instruction-scheduler</name>
</scheduler>
+ <stateful-plugin>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep:topology:provider">prefix:pcep-topology-stateful</type>
+ <name>stateful07</name>
+ </stateful-plugin>
<topology-id>pcep-topology</topology-id>
</module>
</modules>
<provider>/config/modules/module[name='pcep-topology-provider']/instance[name='pcep-topology']</provider>
</instance>
</service>
+ <service>
+ <type xmlns:pcep="urn:opendaylight:params:xml:ns:yang:controller:pcep:topology:provider">pcep:pcep-topology-stateful</type>
+ <instance>
+ <name>stateful02</name>
+ <provider>/config/modules/module[name='pcep-topology-stateful02']/instance[name='global']</provider>
+ </instance>
+ <instance>
+ <name>stateful07</name>
+ <provider>/config/modules/module[name='pcep-topology-stateful07']/instance[name='global']</provider>
+ </instance>
+ </service>
</services>
</data>
"is not set.", listenAddressJmxAttribute);
JmxAttributeValidationException.checkNotNull(getListenPort(),
"is not set.", listenPortJmxAttribute);
+ JmxAttributeValidationException.checkNotNull(getStatefulPlugin(),
+ "is not set.", statefulPluginJmxAttribute);
}
private InetAddress listenAddress() {
final InetSocketAddress address = new InetSocketAddress(listenAddress(), getListenPort().getValue());
try {
return PCEPTopologyProvider.create(getDispatcherDependency(), address,
- getSchedulerDependency(), getDataProviderDependency(), getRpcRegistryDependency(), topology);
+ getSchedulerDependency(), getDataProviderDependency(), getRpcRegistryDependency(), topology, getStatefulPluginDependency());
} catch (InterruptedException | ExecutionException e) {
LOG.error("Failed to instantiate topology provider at {}", address, e);
throw new RuntimeException("Failed to instantiate provider", e);
--- /dev/null
+/*
+ * Copyright (c) 2014 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
+ */
+/**
+ * Generated file
+
+ * Generated from: yang module name: config-pcep-topology-provider yang module local name: pcep-topology-stateful02
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Mon Jan 27 11:08:05 CET 2014
+ *
+ * Do not modify this file unless it is present under src/main directory
+ */
+package org.opendaylight.controller.config.yang.pcep.topology.provider;
+
+import org.opendaylight.bgpcep.pcep.topology.provider.Stateful02TopologySessionListenerFactory;
+
+/**
+ *
+ */
+public final class Stateful02TopologySessionListenerModule extends org.opendaylight.controller.config.yang.pcep.topology.provider.AbstractStateful02TopologySessionListenerModule
+{
+
+ public Stateful02TopologySessionListenerModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ public Stateful02TopologySessionListenerModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+ final Stateful02TopologySessionListenerModule oldModule, final java.lang.AutoCloseable oldInstance) {
+
+ super(identifier, dependencyResolver, oldModule, oldInstance);
+ }
+
+ @Override
+ protected void customValidation(){
+ // Add custom validation for module attributes here.
+ }
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+ return new AutoCloseableStateful02TopologySessionListenerFactory();
+ }
+
+ private static final class AutoCloseableStateful02TopologySessionListenerFactory extends Stateful02TopologySessionListenerFactory implements AutoCloseable {
+ @Override
+ public void close() {
+ // Nothing to do
+ }
+ }
+}
--- /dev/null
+/*
+ *
+ * Copyright (c) 2014 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
+ */
+/**
+* Generated file
+
+* Generated from: yang module name: config-pcep-topology-provider yang module local name: pcep-topology-stateful02
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Mon Jan 27 11:08:05 CET 2014
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.pcep.topology.provider;
+
+/**
+*
+*/
+public class Stateful02TopologySessionListenerModuleFactory extends org.opendaylight.controller.config.yang.pcep.topology.provider.AbstractStateful02TopologySessionListenerModuleFactory
+{
+
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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
+ */
+/**
+ * Generated file
+
+ * Generated from: yang module name: config-pcep-topology-provider yang module local name: pcep-topology-stateful07
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Mon Jan 27 11:08:05 CET 2014
+ *
+ * Do not modify this file unless it is present under src/main directory
+ */
+package org.opendaylight.controller.config.yang.pcep.topology.provider;
+
+import org.opendaylight.bgpcep.pcep.topology.provider.Stateful07TopologySessionListenerFactory;
+
+/**
+ *
+ */
+public final class Stateful07TopologySessionListenerModule extends org.opendaylight.controller.config.yang.pcep.topology.provider.AbstractStateful07TopologySessionListenerModule
+{
+
+ public Stateful07TopologySessionListenerModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ public Stateful07TopologySessionListenerModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+ final Stateful07TopologySessionListenerModule oldModule, final java.lang.AutoCloseable oldInstance) {
+
+ super(identifier, dependencyResolver, oldModule, oldInstance);
+ }
+
+ @Override
+ protected void customValidation(){
+ // Add custom validation for module attributes here.
+ }
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+ return new AutoCloseableStateful07TopologySessionListenerFactory();
+ }
+
+ private static final class AutoCloseableStateful07TopologySessionListenerFactory extends Stateful07TopologySessionListenerFactory implements AutoCloseable {
+ @Override
+ public void close() {
+ // Nothing to do
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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
+ */
+/**
+* Generated file
+
+* Generated from: yang module name: config-pcep-topology-provider yang module local name: pcep-topology-stateful07
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Mon Jan 27 11:08:05 CET 2014
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.pcep.topology.provider;
+
+/**
+*
+*/
+public class Stateful07TopologySessionListenerModuleFactory extends org.opendaylight.controller.config.yang.pcep.topology.provider.AbstractStateful07TopologySessionListenerModuleFactory
+{
+
+
+}
"Initial revision";
}
+ identity pcep-topology-stateful {
+ description
+ "Service representing a stateful draft support module";
+
+ base "config:service-type";
+ config:java-class "org.opendaylight.bgpcep.pcep.topology.provider.TopologySessionListenerFactory";
+ }
+
+ identity pcep-topology-stateful02 {
+ base config:module-type;
+ config:provided-service pcep-topology-stateful;
+ config:java-name-prefix Stateful02TopologySessionListener;
+ }
+
+ augment "/config:modules/config:module/config:configuration" {
+ case pcep-topology-stateful02 {
+ when "/config:modules/config:module/config:type = 'pcep-topology-stateful02'";
+ }
+ }
+
+ identity pcep-topology-stateful07 {
+ base config:module-type;
+ config:provided-service pcep-topology-stateful;
+ config:java-name-prefix Stateful07TopologySessionListener;
+ }
+
+ augment "/config:modules/config:module/config:configuration" {
+ case pcep-topology-stateful07 {
+ when "/config:modules/config:module/config:type = 'pcep-topology-stateful07'";
+ }
+ }
+
identity pcep-topology-reference {
description
"Service representing a PCEP-enabled topology.";
+ // FIXME: should be a topology-reference, really
//base "topo:topology-reference";
base "config:service-type";
config:java-class "org.opendaylight.bgpcep.topology.TopologyReference";
}
}
+ container stateful-plugin {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity pcep-topology-stateful;
+ }
+ }
+ }
+
leaf topology-id {
type nt:topology-id;
mandatory true;
public static PCEPTopologyProvider create(final PCEPDispatcher dispatcher, final InetSocketAddress address,
final InstructionScheduler scheduler, final DataProviderService dataService, final RpcProviderRegistry rpcRegistry,
- final InstanceIdentifier<Topology> topology)
+ final InstanceIdentifier<Topology> topology, final TopologySessionListenerFactory listenerFactory)
throws InterruptedException, ExecutionException {
- final ServerSessionManager manager = new ServerSessionManager(dataService, topology);
+ final ServerSessionManager manager = new ServerSessionManager(dataService, topology, listenerFactory);
final ChannelFuture f = dispatcher.createServer(address, manager);
f.get();
private final Map<NodeId, TopologySessionListener> nodes = new HashMap<>();
private final Map<NodeId, TopologyNodeState> state = new HashMap<>();
+ private final TopologySessionListenerFactory listenerFactory;
private final InstanceIdentifier<Topology> topology;
private final DataProviderService dataProvider;
- public ServerSessionManager(final DataProviderService dataProvider, final InstanceIdentifier<Topology> topology) {
+ public ServerSessionManager(final DataProviderService dataProvider, final InstanceIdentifier<Topology> topology, final TopologySessionListenerFactory listenerFactory) {
this.dataProvider = Preconditions.checkNotNull(dataProvider);
this.topology = Preconditions.checkNotNull(topology);
+ this.listenerFactory = Preconditions.checkNotNull(listenerFactory);
// Make sure the topology does not exist
final Object c = dataProvider.readOperationalData(topology);
@Override
public PCEPSessionListener getSessionListener() {
- return new Stateful07TopologySessionListener(this);
+ return listenerFactory.createTopologySessionListener(this);
}
@Override
import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
import org.opendaylight.protocol.pcep.PCEPSession;
-import org.opendaylight.protocol.pcep.PCEPSessionListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated._00.rev140113.PcinitiateBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated._00.rev140113.pcinitiate.message.PcinitiateMessageBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated._00.rev140113.pcinitiate.message.pcinitiate.message.RequestsBuilder;
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.ListenableFuture;
-public class Stateful02TopologySessionListener extends AbstractTopologySessionListener<PlspId, PlspId> implements PCEPSessionListener {
- private static final Logger LOG = LoggerFactory.getLogger(Stateful07TopologySessionListener.class);
+public class Stateful02TopologySessionListener extends AbstractTopologySessionListener<PlspId, PlspId> {
+ private static final Logger LOG = LoggerFactory.getLogger(Stateful02TopologySessionListener.class);
/**
* @param serverSessionManager
--- /dev/null
+/*
+ * Copyright (c) 2014 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.bgpcep.pcep.topology.provider;
+
+public class Stateful02TopologySessionListenerFactory implements TopologySessionListenerFactory {
+ @Override
+ public final TopologySessionListener createTopologySessionListener(final ServerSessionManager manager) {
+ return new Stateful02TopologySessionListener(manager);
+ }
+}
import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
import org.opendaylight.protocol.pcep.PCEPSession;
-import org.opendaylight.protocol.pcep.PCEPSessionListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.PcinitiateBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.pcinitiate.message.PcinitiateMessageBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.pcinitiate.message.pcinitiate.message.RequestsBuilder;
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.ListenableFuture;
-final class Stateful07TopologySessionListener extends AbstractTopologySessionListener<SrpIdNumber, PlspId> implements PCEPSessionListener {
+final class Stateful07TopologySessionListener extends AbstractTopologySessionListener<SrpIdNumber, PlspId> {
private static final Logger LOG = LoggerFactory.getLogger(Stateful07TopologySessionListener.class);
/**
--- /dev/null
+/*
+ * Copyright (c) 2014 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.bgpcep.pcep.topology.provider;
+
+public class Stateful07TopologySessionListenerFactory implements TopologySessionListenerFactory {
+ @Override
+ public final TopologySessionListener createTopologySessionListener(final ServerSessionManager manager) {
+ return new Stateful07TopologySessionListener(manager);
+ }
+}
*/
package org.opendaylight.bgpcep.pcep.topology.provider;
-interface TopologySessionListener extends AutoCloseable, TopologySessionRPCs {
+import org.opendaylight.protocol.pcep.PCEPSessionListener;
+
+interface TopologySessionListener extends AutoCloseable, PCEPSessionListener, TopologySessionRPCs {
@Override
public void close();
}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2014 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.bgpcep.pcep.topology.provider;
+
+public interface TopologySessionListenerFactory {
+ TopologySessionListener createTopologySessionListener(ServerSessionManager manager);
+}
@Override
public RpcResult<TransactionStatus> get(final long timeout, final TimeUnit unit) throws InterruptedException,
- ExecutionException, TimeoutException {
+ ExecutionException, TimeoutException {
return null;
}
}).when(this.mockedTransaction).commit();
}).when(this.mockedTransaction).putOperationalData(Matchers.any(InstanceIdentifier.class), Matchers.any(DataObject.class));
this.manager = new ServerSessionManager(this.providerService, InstanceIdentifier.builder(NetworkTopology.class).child(
- Topology.class, new TopologyKey(new TopologyId("testtopo"))).toInstance());
+ Topology.class, new TopologyKey(new TopologyId("testtopo"))).toInstance(), new Stateful07TopologySessionListenerFactory());
final DefaultPCEPSessionNegotiator neg = new DefaultPCEPSessionNegotiator(new HashedWheelTimer(), mock(Promise.class), this.clientListener, this.manager.getSessionListener(), (short) 1, 5, this.localPrefs);
this.session = neg.createSession(new HashedWheelTimer(), this.clientListener, this.localPrefs, this.localPrefs);