--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>commons.opendaylight</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../../opendaylight/commons/opendaylight</relativePath>
+ </parent>
+ <artifactId>features-neutron</artifactId>
+ <version>${networkconfig.neutron.version}</version>
+ <packaging>jar</packaging>
+
+ <properties>
+ <features.file>features.xml</features.file>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>networkconfig.neutron</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-server</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-servlet</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>org.eclipse.persistence.moxy</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>org.eclipse.persistence.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>networkconfig.neutron</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-net</groupId>
+ <artifactId>commons-net</artifactId>
+ </dependency>
+ <!-- test to validate features.xml -->
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>features-test</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>features-test</artifactId>
+ <version>0.7.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <filtering>true</filtering>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>filter</id>
+ <goals>
+ <goal>resources</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-artifacts</id>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>${project.build.directory}/classes/${features.file}</file>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <karaf.distro.groupId>org.opendaylight.controller</karaf.distro.groupId>
+ <karaf.distro.artifactId>opendaylight-karaf-empty</karaf.distro.artifactId>
+ <karaf.distro.version>${commons.opendaylight.version}</karaf.distro.version>
+ </systemPropertyVariables>
+ <dependenciesToScan>
+ <dependency>org.opendaylight.yangtools:features-test</dependency>
+ </dependenciesToScan>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <scm>
+ <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
+ <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
+ <tag>HEAD</tag>
+ <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
+ </scm>
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+
+<features name="odl-neutron-${networkconfig.neutron.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
+ <feature name='odl-neutron-all' version='${networkconfig.neutron.version}' description="OpenDaylight :: Neutron :: API">
+ <feature version='${networkconfig.neutron.version}'>odl-neutron-api</feature>
+ <feature version='${networkconfig.neutron.version}'>odl-neutron-northbound</feature>
+ <feature version='${networkconfig.neutron.version}'>odl-neutron-implementation</feature>
+ </feature>
+ <feature name='odl-neutron-northbound' version='${networkconfig.neutron.version}' description="OpenDaylight :: Neutron :: Northbound">
+ <feature version='${networkconfig.neutron.version}'>odl-neutron-api</feature>
+ <bundle>mvn:org.eclipse.persistence/org.eclipse.persistence.moxy/${eclipse.persistence.version}</bundle>
+ <bundle>mvn:org.eclipse.persistence/org.eclipse.persistence.core/${eclipse.persistence.version}</bundle>
+ <bundle>mvn:org.opendaylight.controller/networkconfig.neutron.northbound/${networkconfig.neutron.northbound.version}</bundle>
+ <bundle>mvn:com.sun.jersey/jersey-core/${jersey.version}</bundle>
+ <bundle>mvn:com.sun.jersey/jersey-server/${jersey.version}</bundle>
+ <bundle>mvn:com.sun.jersey/jersey-servlet/${jersey.version}</bundle>
+ <bundle>mvn:org.osgi/org.osgi.core/${osgi.core.version}</bundle>
+ </feature>
+
+ <feature name='odl-neutron-api' version='${networkconfig.neutron.version}' description="OpenDaylight :: Neutron :: API">
+ <bundle>mvn:org.opendaylight.controller/networkconfig.neutron/${networkconfig.neutron.version}</bundle>
+ <bundle>mvn:commons-net/commons-net/${commons.net.version}</bundle>
+ <bundle>mvn:org.osgi/org.osgi.core/${osgi.core.version}</bundle>
+ </feature>
+ <feature name='odl-neutron-implementation' version='${networkconfig.neutron.version}' description="OpenDaylight :: Neutron :: Implementation">
+ <feature version='${networkconfig.neutron.version}'>odl-neutron-api</feature>
+ <bundle>mvn:org.opendaylight.controller/networkconfig.neutron.implementation/${networkconfig.neutron.implementation.version}</bundle>
+ <bundle>mvn:org.osgi/org.osgi.core/${osgi.core.version}</bundle>
+ </feature>
+</features>
\ No newline at end of file
<module>netconf-connector</module>
<module>restconf</module>
<module>extras</module>
+ <module>neutron</module>
</modules>
</project>
<plugin>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>maven-paxexam-plugin</artifactId>
- <version>1.2.4</version>
<executions>
<execution>
<id>generate-config</id>
<usermanager.version>0.5.0-SNAPSHOT</usermanager.version>
<nsf.version>0.5.0-SNAPSHOT</nsf.version>
<web.version>0.5.0-SNAPSHOT</web.version>
- <xtend.dstdir>src/main/xtend-gen</xtend.dstdir>
<yang-ext.version>2013.09.07.7-SNAPSHOT</yang-ext.version>
<yang-jmx-generator.version>1.1.0-SNAPSHOT</yang-jmx-generator.version>
<yangtools.version>0.7.0-SNAPSHOT</yangtools.version>
<type>pom</type>
<scope>import</scope>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>mdsal-artifacts</artifactId>
+ <version>${mdsal.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>netconf-artifacts</artifactId>
</dependency>
<!-- md-sal -->
- <dependency>
- <groupId>org.eclipse.xtend</groupId>
- <artifactId>org.eclipse.xtend.lib</artifactId>
- <version>${xtend.version}</version>
- </dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-grizzly2</artifactId>
<artifactId>sal</artifactId>
<version>${sal.version}</version>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-api</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-broker-impl</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-config</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-util</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-broker-impl</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-api</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-impl</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-util</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-inmemory-datastore</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-compatibility</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-connector-api</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-dom-xsql</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-karaf-xsql</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-dom-xsql-config</artifactId>
- <version>${mdsal.version}</version>
- <classifier>config</classifier>
- <type>xml</type>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-api</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-spi</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-netconf-connector</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-remote</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-rest-connector</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-rest-connector-config</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>md-sal-config</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-rest-docgen</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-restconf-broker</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-test-model</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-distributed-datastore</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-clustering-commons</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-clustering-config</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-remoterpc-connector</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
-
<!-- SAL Extension bundles -->
<dependency>
<artifactId>web</artifactId>
<version>${web.version}</version>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller.md</groupId>
- <artifactId>forwardingrules-manager</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.md</groupId>
- <artifactId>inventory-manager</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.md</groupId>
- <artifactId>statistics-manager</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.md</groupId>
- <artifactId>topology-lldp-discovery</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.md</groupId>
- <artifactId>topology-manager</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.model</groupId>
- <artifactId>model-flow-base</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.model</groupId>
- <artifactId>model-flow-service</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.model</groupId>
- <artifactId>model-flow-statistics</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.model</groupId>
- <artifactId>model-inventory</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.model</groupId>
- <artifactId>model-topology</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.samples</groupId>
- <artifactId>sample-toaster</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.samples</groupId>
- <artifactId>sample-toaster-consumer</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.samples</groupId>
- <artifactId>sample-toaster-provider</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.samples</groupId>
- <artifactId>toaster-config</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>features-test</artifactId>
<type>xml</type>
<scope>runtime</scope>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller.samples</groupId>
- <artifactId>features-toaster</artifactId>
- <version>${mdsal.version}</version>
- <classifier>features</classifier>
- <type>xml</type>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>features-flow</artifactId>
- <version>${mdsal.version}</version>
- <classifier>features</classifier>
- <type>xml</type>
- <scope>runtime</scope>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller.thirdparty</groupId>
<artifactId>com.sun.jersey.jersey-servlet</artifactId>
<version>0.1.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-broker-impl</artifactId>
- <version>${mdsal.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-it</artifactId>
- <version>${mdsal.version}</version>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>features-protocol-framework</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>features-mdsal</artifactId>
- <version>${mdsal.version}</version>
- <classifier>features</classifier>
- <type>xml</type>
- <scope>runtime</scope>
- </dependency>
- <dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>features-netconf-connector</artifactId>
<version>${mdsal.version}</version>
<classifier>features</classifier>
<type>xml</type>
<scope>runtime</scope>
- </dependency>
+ </dependency>
+
<!-- JMH Benchmark dependencies -->
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
- <fileset>
- <directory>${xtend.dstdir}</directory>
- <includes>
- <include>**</include>
- </includes>
- </fileset>
<fileset>
<directory>${jmxGeneratorPath}</directory>
<includes>
<source>src/main/yang</source>
<source>${jmxGeneratorPath}</source>
<source>${salGeneratorPath}</source>
- <source>${xtend.dstdir}</source>
</sources>
</configuration>
</execution>
</lifecycleMappingMetadata>
</configuration>
</plugin>
- <plugin>
- <groupId>org.eclipse.xtend</groupId>
- <artifactId>xtend-maven-plugin</artifactId>
- <version>${xtend.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>compile</goal>
- </goals>
- <configuration>
- <outputDirectory>${xtend.dstdir}</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<sourceDirectory>${project.basedir}</sourceDirectory>
<includes>**\/*.java,**\/*.xml,**\/*.ini,**\/*.sh,**\/*.bat</includes>
- <excludes>**\/target\/,**\/bin\/,**\/target-ide\/,**\/${jmxGeneratorPath}\/,**\/${salGeneratorPath}\/,**\/xtend-gen\/,**\/protobuff\/</excludes>
+ <excludes>**\/target\/,**\/bin\/,**\/target-ide\/,**\/${jmxGeneratorPath}\/,**\/${salGeneratorPath}\/,**\/protobuff\/</excludes>
</configuration>
<dependencies>
<dependency>
createInstance();
final ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
assertBeanCount(1, FACTORY_NAME);
- final NeverReconnectStrategyFactoryModuleMXBean mxBean = transaction.newMBeanProxy(
+ final NeverReconnectStrategyFactoryModuleMXBean mxBean = transaction.newMXBeanProxy(
transaction.lookupConfigBean(FACTORY_NAME, INSTANCE_NAME), NeverReconnectStrategyFactoryModuleMXBean.class);
mxBean.setTimeout(200);
final CommitStatus status = transaction.commit();
private static ObjectName createInstance(final ConfigTransactionJMXClient transaction, final Integer timeout)
throws InstanceAlreadyExistsException {
final ObjectName nameCreated = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
- final NeverReconnectStrategyFactoryModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated,
+ final NeverReconnectStrategyFactoryModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated,
NeverReconnectStrategyFactoryModuleMXBean.class);
mxBean.setTimeout(timeout);
mxBean.setExecutor(GlobalEventExecutorUtil.create(transaction));
createInstance();
final ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
assertBeanCount(1, FACTORY_NAME);
- final ReconnectImmediatelyStrategyFactoryModuleMXBean mxBean = transaction.newMBeanProxy(
+ final ReconnectImmediatelyStrategyFactoryModuleMXBean mxBean = transaction.newMXBeanProxy(
transaction.lookupConfigBean(FACTORY_NAME, INSTANCE_NAME),
ReconnectImmediatelyStrategyFactoryModuleMXBean.class);
mxBean.setReconnectTimeout(200);
private static ObjectName createInstance(final ConfigTransactionJMXClient transaction, final Integer timeout)
throws InstanceAlreadyExistsException {
final ObjectName nameCreated = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
- final ReconnectImmediatelyStrategyFactoryModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated,
+ final ReconnectImmediatelyStrategyFactoryModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated,
ReconnectImmediatelyStrategyFactoryModuleMXBean.class);
mxBean.setReconnectTimeout(timeout);
mxBean.setReconnectExecutor(GlobalEventExecutorUtil.create(transaction));
createInstance();
final ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
assertBeanCount(1, FACTORY_NAME);
- final TimedReconnectStrategyFactoryModuleMXBean mxBean = transaction.newMBeanProxy(
+ final TimedReconnectStrategyFactoryModuleMXBean mxBean = transaction.newMXBeanProxy(
transaction.lookupConfigBean(FACTORY_NAME, INSTANCE_NAME), TimedReconnectStrategyFactoryModuleMXBean.class);
assertEquals(mxBean.getMinSleep(), new Long(100));
mxBean.setMinSleep(200L);
final Integer connectTime, final Long minSleep, final BigDecimal sleepFactor, final Long maxSleep,
final Long maxAttempts, final Long deadline) throws InstanceAlreadyExistsException {
final ObjectName nameCreated = transaction.createModule(FACTORY_NAME, instanceName);
- final TimedReconnectStrategyFactoryModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated,
+ final TimedReconnectStrategyFactoryModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated,
TimedReconnectStrategyFactoryModuleMXBean.class);
mxBean.setConnectTime(connectTime);
mxBean.setDeadline(deadline);
// test reported apsp number of threads
TestingParallelAPSPConfigMXBean parallelAPSPRuntimeProxy = configRegistryClient
- .newMBeanProxy(apspON, TestingParallelAPSPConfigMXBean.class);
+ .newMXBeanProxy(apspON, TestingParallelAPSPConfigMXBean.class);
assertEquals(
(Integer) TestingParallelAPSPImpl.MINIMAL_NUMBER_OF_THREADS,
parallelAPSPRuntimeProxy.getMaxNumberOfThreads());
import static org.junit.Assert.fail;
import javax.annotation.Nullable;
-import javax.management.DynamicMBean;
import javax.management.InstanceAlreadyExistsException;
import javax.management.InstanceNotFoundException;
+import javax.management.IntrospectionException;
import javax.management.ObjectName;
+import javax.management.ReflectionException;
import org.junit.Test;
import org.opendaylight.controller.config.api.ValidationException;
import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
private void assertExists(@Nullable final ConfigTransactionJMXClient transaction,
final String moduleName, final String instanceName)
- throws InstanceNotFoundException {
+ throws InstanceNotFoundException, IntrospectionException, ReflectionException {
if (transaction != null) {
transaction.lookupConfigBean(moduleName, instanceName);
// make a dummy call
- configRegistryClient.newMBeanProxy(
- ObjectNameUtil.createTransactionModuleON(
- transaction.getTransactionName(), moduleName,
- instanceName), DynamicMBean.class).getMBeanInfo();
+ platformMBeanServer.getMBeanInfo(ObjectNameUtil.createTransactionModuleON(
+ transaction.getTransactionName(), moduleName, instanceName));
} else {
configRegistryClient.lookupConfigBean(moduleName, instanceName);
// make a dummy call
- configRegistryClient.newMBeanProxy(
- ObjectNameUtil.createReadOnlyModuleON(moduleName,
- instanceName), DynamicMBean.class).getMBeanInfo();
+ platformMBeanServer.getMBeanInfo(ObjectNameUtil.createReadOnlyModuleON(moduleName,
+ instanceName));
}
}
ObjectName apspName = transaction.createModule(
TestingParallelAPSPModuleFactory.NAME, "apsp1");
- TestingParallelAPSPConfigMXBean apspProxy = transaction.newMBeanProxy(
+ TestingParallelAPSPConfigMXBean apspProxy = transaction.newMXBeanProxy(
apspName, TestingParallelAPSPConfigMXBean.class);
apspProxy.setThreadPool(scheduledName);
apspProxy.setSomeParam("someParam");
ObjectName apspName = transaction.createModule(
TestingParallelAPSPModuleFactory.NAME, "apsp1");
- TestingParallelAPSPConfigMXBean apspProxy = transaction.newMBeanProxy(
+ TestingParallelAPSPConfigMXBean apspProxy = transaction.newMXBeanProxy(
apspName, TestingParallelAPSPConfigMXBean.class);
apspProxy.setThreadPool(ObjectNameUtil.createReadOnlyModuleON(
TestingScheduledThreadPoolModuleFactory.NAME, scheduled1));
ObjectName fixed1name = firstCommit();
// 2, check that configuration was copied to platform
- DynamicMBean dynamicMBean = configRegistryClient.newMBeanProxy(
- ObjectNameUtil.withoutTransactionName(fixed1name),
- DynamicMBean.class);
- dynamicMBean.getMBeanInfo();
- assertEquals(numberOfThreads, dynamicMBean.getAttribute("ThreadCount"));
+ ObjectName on = ObjectNameUtil.withoutTransactionName(fixed1name);
+ platformMBeanServer.getMBeanInfo(on);
+ assertEquals(numberOfThreads, platformMBeanServer.getAttribute(on, "ThreadCount"));
// 3, shutdown fixed1 in new transaction
assertFalse(TestingFixedThreadPool.allExecutors.get(0).isShutdown());
// dynamic config should be removed from platform
try {
- dynamicMBean.getMBeanInfo();
+ platformMBeanServer.getMBeanInfo(on);
fail();
} catch (Exception e) {
- assertTrue(e.getCause() instanceof InstanceNotFoundException);
+ assertTrue(e instanceof InstanceNotFoundException);
}
}
public class ContextSetterImpl implements ContextSetter, Closeable {
private final LogbackStatusListener statusListener;
- private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ContextSetterImpl.class);
+ private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(ContextSetterImpl.class);
public ContextSetterImpl(final LogbackRuntimeRegistrator rootRuntimeBeanRegistratorWrapper) {
statusListener = new LogbackStatusListener(rootRuntimeBeanRegistratorWrapper);
Map<String, Appender<ILoggingEvent>> appendersMap = getAppenders(module, context);
for (LoggerTO logger : module.getLoggerTO()) {
- LOGGER.trace("Setting configuration for logger {}", logger.getLoggerName());
+ LOG.trace("Setting configuration for logger {}", logger.getLoggerName());
final ch.qos.logback.classic.Logger logbackLogger = context.getLogger(logger.getLoggerName());
Optional<Set<Appender<ILoggingEvent>>> appendersBefore = getAppendersBefore(loggersBefore, logbackLogger);
- LOGGER.trace("Logger {}: Appenders registered before: {}", logger.getLoggerName(),
+ LOG.trace("Logger {}: Appenders registered before: {}", logger.getLoggerName(),
appendersBefore.isPresent() ? appendersBefore.get() : "NO APPENDERS BEFORE");
logbackLogger.setLevel(Level.toLevel(logger.getLevel()));
for (String appenderName : logger.getAppenders()) {
if (appendersMap.containsKey(appenderName)) {
logbackLogger.addAppender(appendersMap.get(appenderName));
- LOGGER.trace("Logger {}: Adding new appender: {}", logger.getLoggerName(), appenderName);
+ LOG.trace("Logger {}: Adding new appender: {}", logger.getLoggerName(), appenderName);
} else {
throw new IllegalStateException("No appender " + appenderName
+ " found. This error should have been discovered by validation");
for (Appender<ILoggingEvent> appenderBefore : appendersBefore.get()) {
logbackLogger.detachAppender(appenderBefore);
appenderBefore.stop();
- LOGGER.trace("Logger {}: Removing old appender: {}", logger.getLoggerName(),
+ LOG.trace("Logger {}: Removing old appender: {}", logger.getLoggerName(),
appenderBefore.getName());
}
loggersBefore.remove(logbackLogger);
*/
package org.opendaylight.controller.config.yang.logback.config;
+import com.google.common.collect.Sets;
import java.util.Set;
-
import org.opendaylight.controller.config.api.JmxAttribute;
import org.opendaylight.controller.config.api.JmxAttributeValidationException;
-import com.google.common.collect.Sets;
-
/**
*
*/
*/
package org.opendaylight.controller.config.yang.logback.config;
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.core.status.StatusBase;
+import ch.qos.logback.core.status.StatusListener;
+import ch.qos.logback.core.status.StatusManager;
import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-
import org.slf4j.LoggerFactory;
-import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.core.status.StatusBase;
-import ch.qos.logback.core.status.StatusListener;
-import ch.qos.logback.core.status.StatusManager;
-
public class LogbackStatusListener implements StatusListener, LogbackRuntimeMXBean, Closeable {
private final List<StatusTO> receivedStatuses;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.Appender;
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Multimap;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.slf4j.LoggerFactory;
-import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.spi.ILoggingEvent;
-import ch.qos.logback.core.Appender;
-
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Multimap;
-
public class ContextSetterImplTest {
@Mock
a.setEncoderPattern("%-4relative [%thread] %-5level %logger{35} - %msg%n");
return a;
}
+
}
try {
createBeans(
- true, "target/rollingApp", "", "30MB", 1, 5, "target/%i.log", "rolling", "consoleName", "ALL", "logger1",
+ true, "target/rollingApp", "", "30MB", 1, 5, "target/%i.log", "rolling", "consoleName", "ALL", "logger1",
"DEBUG", "FixedWindowRollingPolicy", 0, "FileAppender").commit();
fail();
} catch (ValidationException e) {
*/
package org.opendaylight.controller.config.yang.logback.config;
+import static org.junit.Assert.assertEquals;
+
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.rolling.FixedWindowRollingPolicy;
import ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy;
import com.google.common.collect.Lists;
+import java.io.File;
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.JMX;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
import org.slf4j.LoggerFactory;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.JMX;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import java.io.File;
-import java.io.IOException;
-import java.lang.management.ManagementFactory;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
public class LogbackModuleWithInitialConfigurationTest extends AbstractConfigTest {
private LogbackModuleFactory factory;
*/
package org.opendaylight.controller.config.yang.logback.config;
+import static org.junit.Assert.assertEquals;
+
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.joran.spi.JoranException;
import com.google.common.collect.Lists;
+import java.io.File;
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.util.List;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.JMX;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
import org.slf4j.LoggerFactory;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.JMX;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import java.io.File;
-import java.io.IOException;
-import java.lang.management.ManagementFactory;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
public class LogbackWithXmlConfigModuleTest extends AbstractConfigTest {
private LogbackModuleFactory factory;
import com.google.common.reflect.AbstractInvocationHandler;
import com.google.common.reflect.Reflection;
import io.netty.util.concurrent.EventExecutor;
-
import java.lang.reflect.Method;
import java.util.concurrent.TimeUnit;
*/
package org.opendaylight.controller.config.yang.netty.eventexecutor;
+import static com.google.common.base.Preconditions.checkArgument;
+
import org.opendaylight.controller.config.api.DependencyResolver;
import org.osgi.framework.BundleContext;
-import static com.google.common.base.Preconditions.checkArgument;
-
public class GlobalEventExecutorModuleFactory extends org.opendaylight.controller.config.yang.netty.eventexecutor.AbstractGlobalEventExecutorModuleFactory {
public static final String SINGLETON_NAME = "singleton";
*/
package org.opendaylight.controller.config.yang.netty.eventexecutor;
+import static com.google.common.base.Preconditions.checkArgument;
+
import org.opendaylight.controller.config.api.DependencyResolver;
import org.osgi.framework.BundleContext;
-import static com.google.common.base.Preconditions.checkArgument;
-
public class ImmediateEventExecutorModuleFactory extends org.opendaylight.controller.config.yang.netty.eventexecutor.AbstractImmediateEventExecutorModuleFactory {
public static final String SINGLETON_NAME = "singleton";
package org.opendaylight.controller.config.yang.netty.eventexecutor;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.ObjectName;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.config.api.ConflictingVersionException;
import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.ObjectName;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
public class GlobalEventExecutorModuleTest extends AbstractConfigTest {
private GlobalEventExecutorModuleFactory factory;
private ObjectName createInstance(ConfigTransactionJMXClient transaction, String instanceName)
throws InstanceAlreadyExistsException {
ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName);
- transaction.newMBeanProxy(nameCreated, GlobalEventExecutorModuleMXBean.class);
+ transaction.newMXBeanProxy(nameCreated, GlobalEventExecutorModuleMXBean.class);
return nameCreated;
}
private ObjectName createInstance(ConfigTransactionJMXClient transaction, String instanceName)
throws InstanceAlreadyExistsException {
ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName);
- transaction.newMBeanProxy(nameCreated, ImmediateEventExecutorModuleMXBean.class);
+ transaction.newMXBeanProxy(nameCreated, ImmediateEventExecutorModuleMXBean.class);
return nameCreated;
}
package org.opendaylight.controller.config.yang.netty.threadgroup;
import io.netty.channel.nio.NioEventLoopGroup;
-
-import org.opendaylight.controller.config.api.JmxAttributeValidationException;
-
import java.util.concurrent.TimeUnit;
+import org.opendaylight.controller.config.api.JmxAttributeValidationException;
/**
*
*/
package org.opendaylight.controller.config.yang.netty.threadgroup;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.ObjectName;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.config.api.ConflictingVersionException;
import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.ObjectName;
-
public class NettyThreadgroupModuleTest extends AbstractConfigTest {
private NettyThreadgroupModuleFactory factory;
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<sourceDirectory>${project.basedir}</sourceDirectory>
<includes>**\/*.java,**\/*.xml,**\/*.ini,**\/*.sh,**\/*.bat,**\/*.yang</includes>
- <excludes>**\/target\/,**\/bin\/,**\/target-ide\/,**\/${jmxGeneratorPath}\/,**\/${salGeneratorPath}\/</excludes>
+ <!-- excluding logback-config, has several checkstyle warnings
+ regarding Logger/LoggerFactory, which couldn't be removed due necessity/intention
+ to use the particular implementation/library of Logger/LoggerFactory -->
+ <excludes>**\/logback-config\/,**\/target\/,**\/bin\/,**\/target-ide\/,**\/${jmxGeneratorPath}\/,**\/${salGeneratorPath}\/</excludes>
</configuration>
<dependencies>
<dependency>
<type>xml</type>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>features-neutron</artifactId>
+ <version>${networkconfig.neutron.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
<!-- Netconf connector features. When this is included, users can test the netconf connector using netconf-testtool -->
<dependency>
<groupId>org.opendaylight.controller</groupId>
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.broker.impl.DOMDataBrokerImpl;
+import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker;
import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
import org.opendaylight.controller.sal.core.spi.data.DOMStore;
import org.openjdk.jmh.annotations.BenchmarkMode;
LogicalDatastoreType.OPERATIONAL, (DOMStore)operStore,
LogicalDatastoreType.CONFIGURATION, configStore);
- domBroker = new DOMDataBrokerImpl(datastores, executor);
+ domBroker = new SerializedDOMDataBroker(datastores, executor);
schemaContext = BenchmarkModel.createTestContext();
configStore.onGlobalContextUpdated(schemaContext);
operStore.onGlobalContextUpdated(schemaContext);
import org.opendaylight.controller.md.sal.binding.impl.ForwardedBindingDataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.broker.impl.DOMDataBrokerImpl;
+import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker;
import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
import org.opendaylight.controller.sal.core.spi.data.DOMStore;
}
public DOMDataBroker createDOMDataBroker() {
- return new DOMDataBrokerImpl(getDatastores(), getCommitCoordinatorExecutor());
+ return new SerializedDOMDataBroker(getDatastores(), getCommitCoordinatorExecutor());
}
public ListeningExecutorService getCommitCoordinatorExecutor() {
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ 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
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>mdsal-artifacts</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <dependencyManagement>
+ <dependencies>
+ <!-- Core API/implementation -->
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-common-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-common-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-common-util</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-core-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-core-spi</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-broker-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-binding-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-binding-config</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-binding-util</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-connector-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-inmemory-datastore</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>md-sal-config</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- Test support -->
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-test-model</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-binding-it</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- Features -->
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>features-mdsal</artifactId>
+ <version>${project.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- FIXME: move this into netconf-artifacts -->
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-netconf-connector</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- FIXME: These below need splitting up -->
+
+ <!-- AD-SAL compatibility -->
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-compatibility</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- Base model augmentations -->
+ <dependency>
+ <groupId>org.opendaylight.controller.model</groupId>
+ <artifactId>model-inventory</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.model</groupId>
+ <artifactId>model-topology</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- Clustered implementation -->
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-clustering-commons</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-clustering-config</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-distributed-datastore</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-remoterpc-connector</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- OpenFlow stuff -->
+ <dependency>
+ <groupId>org.opendaylight.controller.md</groupId>
+ <artifactId>forwardingrules-manager</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.md</groupId>
+ <artifactId>inventory-manager</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.md</groupId>
+ <artifactId>statistics-manager</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.md</groupId>
+ <artifactId>topology-lldp-discovery</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.md</groupId>
+ <artifactId>topology-manager</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.model</groupId>
+ <artifactId>model-flow-base</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.model</groupId>
+ <artifactId>model-flow-service</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.model</groupId>
+ <artifactId>model-flow-statistics</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>features-flow</artifactId>
+ <version>${project.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- RESTCONF -->
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-remote</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-rest-connector</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-rest-connector-config</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-restconf-broker</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-rest-docgen</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- Toaster -->
+ <dependency>
+ <groupId>org.opendaylight.controller.samples</groupId>
+ <artifactId>sample-toaster</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.samples</groupId>
+ <artifactId>sample-toaster-consumer</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.samples</groupId>
+ <artifactId>sample-toaster-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.samples</groupId>
+ <artifactId>toaster-config</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.samples</groupId>
+ <artifactId>features-toaster</artifactId>
+ <version>${project.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- XSQL support -->
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-dom-xsql</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-karaf-xsql</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-dom-xsql-config</artifactId>
+ <version>${project.version}</version>
+ <classifier>config</classifier>
+ <type>xml</type>
+ </dependency>
+
+ </dependencies>
+ </dependencyManagement>
+</project>
+
<packaging>pom</packaging>
<modules>
+ <module>mdsal-artifacts</module>
+
<!-- Common APIs & Implementation -->
<module>sal-common</module>
<module>sal-common-api</module>
</lifecycleMappingMetadata>
</configuration>
</plugin>
- <plugin>
- <groupId>org.eclipse.xtend</groupId>
- <artifactId>xtend-maven-plugin</artifactId>
- <version>${xtend.version}</version>
- </plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
- <dependency>
- <groupId>org.eclipse.xtend</groupId>
- <artifactId>org.eclipse.xtend.lib</artifactId>
- </dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>org.eclipse.xtend</groupId>
- <artifactId>xtend-maven-plugin</artifactId>
- </plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
--- /dev/null
+/*
+ * Copyright (c) 2013 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.controller.sal.binding.codegen.impl;
+
+import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSet.Builder;
+import java.lang.reflect.Method;
+import java.util.Map;
+import javassist.CannotCompileException;
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.CtMethod;
+import javassist.NotFoundException;
+import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeSpecification;
+import org.opendaylight.yangtools.sal.binding.generator.util.ClassGenerator;
+import org.opendaylight.yangtools.sal.binding.generator.util.MethodGenerator;
+import org.opendaylight.yangtools.util.ClassLoaderUtils;
+import org.opendaylight.yangtools.yang.binding.BaseIdentity;
+import org.opendaylight.yangtools.yang.binding.Notification;
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
+import org.opendaylight.yangtools.yang.binding.RpcImplementation;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
+
+final class DefaultRuntimeCodeGenerator extends AbstractRuntimeCodeGenerator {
+
+ DefaultRuntimeCodeGenerator(final ClassPool pool) {
+ super(pool);
+ }
+
+ @Override
+ protected <T extends RpcService> Supplier<T> directProxySupplier(final Class<T> serviceType) {
+ return new Supplier<T>() {
+ @SuppressWarnings("unchecked")
+ @Override
+ public T get() {
+ final String proxyName = RuntimeCodeSpecification.getDirectProxyName(serviceType);
+
+ final Class<?> potentialClass = ClassLoaderUtils.tryToLoadClassWithTCCL(proxyName);
+ if (potentialClass != null) {
+ try {
+ return (T)potentialClass.newInstance();
+ } catch (InstantiationException | IllegalAccessException e) {
+ throw new IllegalStateException("Failed to instantiate class " + potentialClass.getName(), e);
+ }
+ }
+
+ final CtClass supertype = utils.asCtClass(serviceType);
+ final String directProxyName = RuntimeCodeSpecification.getDirectProxyName(serviceType);
+
+ final CtClass createdCls;
+ try {
+ createdCls = utils.createClass(directProxyName, supertype, new ClassGenerator() {
+ @Override
+ public void process(final CtClass cls) throws CannotCompileException {
+ utils.field(cls, RuntimeCodeSpecification.DELEGATE_FIELD, serviceType);
+ utils.implementsType(cls, utils.asCtClass(RpcImplementation.class));
+ utils.implementMethodsFrom(cls, supertype, new MethodGenerator() {
+ @Override
+ public void process(final CtMethod method) throws CannotCompileException {
+ final StringBuilder sb = new StringBuilder("\n");
+ sb.append("{\n");
+ sb.append(" if (").append(RuntimeCodeSpecification.DELEGATE_FIELD).append(" == null) {\n");
+ sb.append(" throw new java.lang.IllegalStateException(\"No default provider is available\");\n");
+ sb.append(" }\n");
+ sb.append(" return ($r) ").append(RuntimeCodeSpecification.DELEGATE_FIELD).append('.').append(method.getName()).append("($$);\n");
+ sb.append("}\n");
+ method.setBody(sb.toString());
+ }
+ });
+
+ // FIXME: copy this one...
+ utils.implementMethodsFrom(cls, utils.asCtClass(RpcImplementation.class), new MethodGenerator() {
+ @Override
+ public void process(final CtMethod method) throws CannotCompileException {
+ final StringBuilder sb = new StringBuilder("\n");
+ sb.append("{\n");
+ sb.append(" throw new java.lang.IllegalStateException(\"No provider is processing supplied message\");\n");
+ sb.append(" return ($r) null;\n");
+ sb.append("}\n");
+ method.setBody(sb.toString());
+ }
+ });
+ }
+ });
+ } catch (CannotCompileException e) {
+ throw new IllegalStateException("Failed to create class " + directProxyName, e);
+ }
+
+ final Class<?> c;
+ try {
+ c = createdCls.toClass(serviceType.getClassLoader(), serviceType.getProtectionDomain());
+ } catch (CannotCompileException e) {
+ throw new IllegalStateException(String.format("Failed to create class %s", createdCls), e);
+ }
+
+ try {
+ return (T) c.newInstance();
+ } catch (InstantiationException | IllegalAccessException e) {
+ throw new IllegalStateException(String.format("Failed to instantiated class %s", c), e);
+ }
+ }
+ };
+ }
+
+ @Override
+ protected <T extends RpcService> Supplier<T> routerSupplier(final Class<T> serviceType, final RpcServiceMetadata metadata) {
+ return new Supplier<T>() {
+ @SuppressWarnings("unchecked")
+ @Override
+ public T get() {
+ final CtClass supertype = utils.asCtClass(serviceType);
+ final String routerName = RuntimeCodeSpecification.getRouterName(serviceType);
+ final Class<?> potentialClass = ClassLoaderUtils.tryToLoadClassWithTCCL(routerName);
+ if (potentialClass != null) {
+ try {
+ return (T)potentialClass.newInstance();
+ } catch (InstantiationException | IllegalAccessException e) {
+ throw new IllegalStateException("Failed to instantiate class", e);
+ }
+ }
+
+ final CtClass targetCls;
+ try {
+ targetCls = utils.createClass(routerName, supertype, new ClassGenerator() {
+ @Override
+ public void process(final CtClass cls) throws CannotCompileException {
+ utils.field(cls, RuntimeCodeSpecification.DELEGATE_FIELD, serviceType);
+ //utils.field(cls, REMOTE_INVOKER_FIELD,iface);
+ utils.implementsType(cls, utils.asCtClass(RpcImplementation.class));
+
+ for (final Class<? extends BaseIdentity> ctx : metadata.getContexts()) {
+ utils.field(cls, RuntimeCodeSpecification.getRoutingTableField(ctx), Map.class);
+ }
+
+ utils.implementMethodsFrom(cls, supertype, new MethodGenerator() {
+ @Override
+ public void process(final CtMethod method) throws CannotCompileException {
+ final int ptl;
+ try {
+ ptl = method.getParameterTypes().length;
+ } catch (NotFoundException e) {
+ throw new CannotCompileException(e);
+ }
+ final StringBuilder sb = new StringBuilder();
+
+ switch (ptl) {
+ case 0:
+ sb.append("return ($r) ").append(RuntimeCodeSpecification.DELEGATE_FIELD).append('.').append(method.getName()).append("($$);");
+ break;
+ case 1:
+ final RpcMetadata rpcMeta = metadata.getRpcMethod(method.getName());
+ final String rtGetter = rpcMeta.getInputRouteGetter().getName();
+ final String stName = supertype.getName();
+
+ sb.append('\n');
+ sb.append("{\n");
+ sb.append(" if ($1 == null) {\n");
+ sb.append(" throw new IllegalArgumentException(\"RPC input must not be null and must contain a value for field ").append(rtGetter).append("\");\n");
+ sb.append(" }\n");
+ sb.append(" if ($1.").append(rtGetter).append("() == null) {\n");
+ sb.append(" throw new IllegalArgumentException(\"Field ").append(rtGetter).append(" must not be null\");\n");
+ sb.append(" }\n");
+
+ sb.append(" final org.opendaylight.yangtools.yang.binding.InstanceIdentifier identifier = $1.").append(rtGetter).append("()");
+ if (rpcMeta.isRouteEncapsulated()) {
+ sb.append(".getValue()");
+ }
+ sb.append(";\n");
+
+ sb.append(" ").append(supertype.getName()).append(" instance = (").append(stName).append(") ").append(RuntimeCodeSpecification.getRoutingTableField(rpcMeta.getContext())).append(".get(identifier);\n");
+ sb.append(" if (instance == null) {\n");
+ sb.append(" instance = ").append(RuntimeCodeSpecification.DELEGATE_FIELD).append(";\n");
+ sb.append(" }\n");
+
+ sb.append(" if (instance == null) {\n");
+ sb.append(" throw new java.lang.IllegalStateException(\"No routable provider is processing routed message for \" + String.valueOf(identifier));\n");
+ sb.append(" }\n");
+ sb.append(" return ($r) instance.").append(method.getName()).append("($$);\n");
+ sb.append('}');
+ break;
+ default:
+ throw new CannotCompileException(String.format("Unsupported parameters length %s", ptl));
+ }
+
+ method.setBody(sb.toString());
+ }
+ });
+
+ // FIXME: move this into a template class
+ utils.implementMethodsFrom(cls, utils.asCtClass(RpcImplementation.class), new MethodGenerator() {
+ @Override
+ public void process(final CtMethod method) throws CannotCompileException {
+ final StringBuilder sb = new StringBuilder("\n");
+ sb.append("{\n");
+ sb.append(" throw new java.lang.IllegalStateException(\"No provider is processing supplied message\");\n");
+ sb.append(" return ($r) null;\n");
+ sb.append("}\n");
+
+ method.setBody(sb.toString());
+ }
+ });
+ }
+ });
+ } catch (CannotCompileException e) {
+ throw new IllegalStateException("Failed to create class " + routerName, e);
+ }
+
+ final Class<?> c;
+ try {
+ c = targetCls.toClass(serviceType.getClassLoader(), serviceType.getProtectionDomain());
+ } catch (CannotCompileException e) {
+ throw new IllegalStateException(String.format("Failed to compile class %s", targetCls), e);
+ }
+
+ try {
+ return (T)c.newInstance();
+ } catch (InstantiationException | IllegalAccessException e) {
+ throw new IllegalStateException(String.format("Failed to instantiate class %s", c), e);
+ }
+ }
+ };
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected RuntimeGeneratedInvokerPrototype generateListenerInvoker(final Class<? extends NotificationListener> listenerType) {
+ final String invokerName = RuntimeCodeSpecification.getInvokerName(listenerType);
+ final CtClass targetCls;
+
+ // Builder for a set of supported types. Filled while the target class is being generated
+ final Builder<Class<? extends Notification>> b = ImmutableSet.builder();
+
+ try {
+ targetCls = utils.createClass(invokerName, getBrokerNotificationListener(), new ClassGenerator() {
+ @Override
+ public void process(final CtClass cls) throws CannotCompileException {
+ utils.field(cls, RuntimeCodeSpecification.DELEGATE_FIELD, listenerType);
+ utils.implementMethodsFrom(cls, getBrokerNotificationListener(), new MethodGenerator() {
+ @Override
+ public void process(final CtMethod method) throws CannotCompileException {
+ final StringBuilder sb = new StringBuilder("\n");
+
+ sb.append("{\n");
+
+ for (Method m : listenerType.getMethods()) {
+ if (BindingReflections.isNotificationCallback(m)) {
+ final Class<?> argType = m.getParameterTypes()[0];
+
+ // populates builder above
+ b.add((Class<? extends Notification>) argType);
+
+ sb.append(" if ($1 instanceof ").append(argType.getName()).append(") {\n");
+ sb.append(" ").append(RuntimeCodeSpecification.DELEGATE_FIELD).append('.').append(m.getName()).append("((").append(argType.getName()).append(") $1);\n");
+ sb.append(" return null;\n");
+ sb.append(" } else ");
+ }
+ }
+
+ sb.append(" return null;\n");
+ sb.append("}\n");
+ method.setBody(sb.toString());
+ }
+ });
+ }
+ });
+ } catch (CannotCompileException e) {
+ throw new IllegalStateException("Failed to create class " + invokerName, e);
+ }
+
+ final Class<?> finalClass;
+ try {
+ finalClass = targetCls.toClass(listenerType.getClassLoader(), listenerType.getProtectionDomain());
+ } catch (CannotCompileException e) {
+ throw new IllegalStateException(String.format("Failed to compile class %s", targetCls), e);
+ }
+
+ return new RuntimeGeneratedInvokerPrototype(b.build(), (Class<? extends org.opendaylight.controller.sal.binding.api.NotificationListener<?>>) finalClass);
+ }
+}
+++ /dev/null
-/*
- * Copyright (c) 2013 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.controller.sal.binding.codegen.impl
-
-import java.util.Map
-import javassist.ClassPool
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import org.opendaylight.yangtools.yang.binding.Notification
-import org.opendaylight.yangtools.yang.binding.RpcImplementation
-import org.opendaylight.yangtools.yang.binding.util.BindingReflections
-import org.opendaylight.yangtools.yang.binding.util.ClassLoaderUtils
-
-import static extension org.opendaylight.controller.sal.binding.codegen.RuntimeCodeSpecification.*
-import org.opendaylight.yangtools.yang.binding.RpcService
-
-class RuntimeCodeGenerator extends AbstractRuntimeCodeGenerator {
-
- new(ClassPool pool) {
- super(pool)
- }
-
- override directProxySupplier(Class iface) {
- return [|
- val proxyName = iface.directProxyName;
- val potentialClass = ClassLoaderUtils.tryToLoadClassWithTCCL(proxyName)
- if(potentialClass != null) {
- return potentialClass.newInstance as RpcService;
- }
- val supertype = iface.asCtClass
- val createdCls = createClass(iface.directProxyName, supertype) [
- field(DELEGATE_FIELD, iface);
- implementsType(RpcImplementation.asCtClass)
- implementMethodsFrom(supertype) [
- body = '''
- {
- if(«DELEGATE_FIELD» == null) {
- throw new java.lang.IllegalStateException("No default provider is available");
- }
- return ($r) «DELEGATE_FIELD».«it.name»($$);
- }
- '''
- ]
- implementMethodsFrom(RpcImplementation.asCtClass) [
- body = '''
- {
- throw new java.lang.IllegalStateException("No provider is processing supplied message");
- return ($r) null;
- }
- '''
- ]
- ]
- return createdCls.toClass(iface.classLoader).newInstance as RpcService
- ]
- }
-
- override routerSupplier(Class iface, RpcServiceMetadata metadata) {
- return [ |
- val supertype = iface.asCtClass
- val routerName = iface.routerName;
- val potentialClass = ClassLoaderUtils.tryToLoadClassWithTCCL(routerName)
- if(potentialClass != null) {
- return potentialClass.newInstance as RpcService;
- }
-
- val targetCls = createClass(iface.routerName, supertype) [
-
-
- field(DELEGATE_FIELD, iface)
- //field(REMOTE_INVOKER_FIELD,iface);
- implementsType(RpcImplementation.asCtClass)
-
- for (ctx : metadata.contexts) {
- field(ctx.routingTableField, Map)
- }
- implementMethodsFrom(supertype) [
- if (parameterTypes.size === 1) {
- val rpcMeta = metadata.getRpcMethod(name);
- val bodyTmp = '''
- {
- if($1 == null) {
- throw new IllegalArgumentException("RPC input must not be null and must contain a value for field «rpcMeta.inputRouteGetter.name»");
- }
- if($1.«rpcMeta.inputRouteGetter.name»() == null) {
- throw new IllegalArgumentException("Field «rpcMeta.inputRouteGetter.name» must not be null");
- }
- final «InstanceIdentifier.name» identifier = $1.«rpcMeta.inputRouteGetter.name»()«IF rpcMeta.
- routeEncapsulated».getValue()«ENDIF»;
- «supertype.name» instance = («supertype.name») «rpcMeta.context.routingTableField».get(identifier);
- if(instance == null) {
- instance = «DELEGATE_FIELD»;
- }
- if(instance == null) {
- throw new java.lang.IllegalStateException("No routable provider is processing routed message for " + String.valueOf(identifier));
- }
- return ($r) instance.«it.name»($$);
- }'''
- body = bodyTmp
- } else if (parameterTypes.size === 0) {
- body = '''return ($r) «DELEGATE_FIELD».«it.name»($$);'''
- }
- ]
- implementMethodsFrom(RpcImplementation.asCtClass) [
- body = '''
- {
- throw new java.lang.IllegalStateException("No provider is processing supplied message");
- return ($r) null;
- }
- '''
- ]
- ]
- return targetCls.toClass(iface.classLoader,iface.protectionDomain).newInstance as RpcService
- ];
- }
-
- override generateListenerInvoker(Class iface) {
- val callbacks = iface.methods.filter[BindingReflections.isNotificationCallback(it)]
-
- val supportedNotification = callbacks.map[parameterTypes.get(0) as Class<? extends Notification>].toSet;
-
- val targetCls = createClass(iface.invokerName, brokerNotificationListener) [
- field(DELEGATE_FIELD, iface)
- implementMethodsFrom(brokerNotificationListener) [
- body = '''
- {
- «FOR callback : callbacks SEPARATOR " else "»
- «val cls = callback.parameterTypes.get(0).name»
- if($1 instanceof «cls») {
- «DELEGATE_FIELD».«callback.name»((«cls») $1);
- return null;
- }
- «ENDFOR»
- return null;
- }
- '''
- ]
- ]
- val finalClass = targetCls.toClass(iface.classLoader, iface.protectionDomain)
- return new RuntimeGeneratedInvokerPrototype(supportedNotification,
- finalClass as Class<? extends org.opendaylight.controller.sal.binding.api.NotificationListener<?>>);
- }
-}
public static final ClassPool CLASS_POOL = ClassPool.getDefault();
public static final JavassistUtils JAVASSIST = JavassistUtils.forClassPool(CLASS_POOL);
- public static final org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator RPC_GENERATOR_IMPL = new org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator(
+ public static final org.opendaylight.controller.sal.binding.codegen.impl.DefaultRuntimeCodeGenerator RPC_GENERATOR_IMPL = new org.opendaylight.controller.sal.binding.codegen.impl.DefaultRuntimeCodeGenerator(
CLASS_POOL);
public static final RuntimeCodeGenerator RPC_GENERATOR = RPC_GENERATOR_IMPL;
public static final NotificationInvokerFactory INVOKER_FACTORY = RPC_GENERATOR_IMPL.getInvokerFactory();
import org.opendaylight.controller.md.sal.binding.impl.ForwardedBindingDataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.broker.impl.DOMDataBrokerImpl;
+import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker;
import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
import org.opendaylight.controller.sal.binding.test.util.MockSchemaService;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
}
public DOMDataBroker createDOMDataBroker() {
- return new DOMDataBrokerImpl(getDatastores(), getCommitCoordinatorExecutor());
+ return new SerializedDOMDataBroker(getDatastores(), getCommitCoordinatorExecutor());
}
public ListeningExecutorService getCommitCoordinatorExecutor() {
* 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.sal.binding.test;
+package org.opendaylight.controller.sal.binding.codegen.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
-
import java.util.ArrayList;
import java.util.List;
-
import javassist.ClassPool;
-
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter;
import org.opendaylight.controller.sal.binding.api.rpc.RpcRoutingTable;
-import org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator;
+import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeGenerator;
import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory;
import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory.NotificationInvoker;
import org.opendaylight.controller.sal.binding.test.mock.BarListener;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class RuntimeCodeGeneratorTest {
+public class DefaultRuntimeCodeGeneratorTest {
private RuntimeCodeGenerator codeGenerator;
private NotificationInvokerFactory invokerFactory;
@Before
public void initialize() {
- this.codeGenerator = new RuntimeCodeGenerator(ClassPool.getDefault());
+ this.codeGenerator = new DefaultRuntimeCodeGenerator(ClassPool.getDefault());
this.invokerFactory = codeGenerator.getInvokerFactory();
}
import org.opendaylight.controller.md.sal.binding.impl.ForwardedBindingDataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.broker.impl.DOMDataBrokerImpl;
+import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker;
import org.opendaylight.controller.md.sal.dom.broker.impl.compat.BackwardsCompatibleDataBroker;
import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
.put(LogicalDatastoreType.CONFIGURATION, configStore)
.build();
- newDOMDataBroker = new DOMDataBrokerImpl(newDatastores, executor);
+ newDOMDataBroker = new SerializedDOMDataBroker(newDatastores, executor);
biCompatibleBroker = new BackwardsCompatibleDataBroker(newDOMDataBroker,mockSchemaService);
shardMBean.setCommitIndex(getCommitIndex());
shardMBean.setLastApplied(getLastApplied());
- shardMBean.setDataSize(getRaftActorContext().getReplicatedLog().dataSize());
+ shardMBean.setInMemoryJournalDataSize(getRaftActorContext().getReplicatedLog().dataSize());
}
@Override
this.lastCommittedTransactionTime = lastCommittedTransactionTime;
}
- public void setDataSize(long dataSize){
+ public void setInMemoryJournalDataSize(long dataSize){
this.dataSize = dataSize;
}
@Override
- public long getDataSize(){
+ public long getInMemoryJournalDataSize(){
return dataSize;
}
void resetTransactionCounters();
- long getDataSize();
+ long getInMemoryJournalDataSize();
}
.shardJournalRecoveryLogBatchSize(props.getShardJournalRecoveryLogBatchSize().
getValue().intValue())
.shardSnapshotBatchCount(props.getShardSnapshotBatchCount().getValue().intValue())
+ .shardSnapshotDataThresholdPercentage(props.getShardSnapshotDataThresholdPercentage().getValue().intValue())
.shardHeartbeatIntervalInMillis(props.getShardHearbeatIntervalInMillis().getValue())
.shardInitializationTimeout(props.getShardInitializationTimeoutInSeconds().getValue(),
TimeUnit.SECONDS)
.shardJournalRecoveryLogBatchSize(props.getShardJournalRecoveryLogBatchSize().
getValue().intValue())
.shardSnapshotBatchCount(props.getShardSnapshotBatchCount().getValue().intValue())
+ .shardSnapshotDataThresholdPercentage(props.getShardSnapshotDataThresholdPercentage().getValue().intValue())
.shardHeartbeatIntervalInMillis(props.getShardHearbeatIntervalInMillis().getValue())
.shardInitializationTimeout(props.getShardInitializationTimeoutInSeconds().getValue(),
TimeUnit.SECONDS)
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitDeadlockException;
import org.opendaylight.controller.md.sal.common.util.jmx.AbstractMXBean;
import org.opendaylight.controller.md.sal.common.util.jmx.ThreadExecutorStatsMXBeanImpl;
-import org.opendaylight.controller.md.sal.dom.broker.impl.DOMConcurrentDataCommitCoordinator;
-import org.opendaylight.controller.md.sal.dom.broker.impl.DOMDataBrokerImpl;
-import org.opendaylight.controller.md.sal.dom.broker.impl.DOMDataCommitCoordinatorImpl;
-import org.opendaylight.controller.md.sal.dom.broker.impl.DOMDataCommitExecutor;
+import org.opendaylight.controller.md.sal.dom.broker.impl.ConcurrentDOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.broker.impl.AbstractDOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker;
import org.opendaylight.controller.md.sal.dom.broker.impl.jmx.CommitStatsMXBeanImpl;
import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreFactory;
import org.opendaylight.controller.sal.core.spi.data.DOMStore;
final List<AbstractMXBean> mBeans = Lists.newArrayList();
- DOMDataCommitExecutor commitCoordinator;
- DurationStatisticsTracker commitStatsTracker = null;
+ final DurationStatisticsTracker commitStatsTracker;
+ final AbstractDOMDataBroker broker;
- if(getAllowConcurrentCommits()) {
- DOMConcurrentDataCommitCoordinator coordinator =
- new DOMConcurrentDataCommitCoordinator(listenableFutureExecutor);
- commitStatsTracker = coordinator.getCommitStatsTracker();
- commitCoordinator = coordinator;
+ if (getAllowConcurrentCommits()) {
+ final ConcurrentDOMDataBroker cdb = new ConcurrentDOMDataBroker(datastores, listenableFutureExecutor);
+ commitStatsTracker = cdb.getCommitStatsTracker();
+ broker = cdb;
} else {
/*
* We use a single-threaded executor for commits with a bounded queue capacity. If the
ExecutorService commitExecutor = SpecialExecutors.newBoundedSingleThreadExecutor(
getMaxDataBrokerCommitQueueSize(), "WriteTxCommit");
- DOMDataCommitCoordinatorImpl coordinator = new DOMDataCommitCoordinatorImpl(
+ SerializedDOMDataBroker sdb = new SerializedDOMDataBroker(datastores,
new DeadlockDetectingListeningExecutorService(commitExecutor,
TransactionCommitDeadlockException.DEADLOCK_EXCEPTION_SUPPLIER,
listenableFutureExecutor));
-
- commitStatsTracker = coordinator.getCommitStatsTracker();
- commitCoordinator = coordinator;
+ commitStatsTracker = sdb.getCommitStatsTracker();
+ broker = sdb;
final AbstractMXBean commitExecutorStatsMXBean =
ThreadExecutorStatsMXBeanImpl.create(commitExecutor, "CommitExecutorStats",
}
}
- DOMDataBrokerImpl newDataBroker = new DOMDataBrokerImpl(datastores, commitCoordinator);
-
if(commitStatsTracker != null) {
final CommitStatsMXBeanImpl commitStatsMXBean = new CommitStatsMXBeanImpl(
commitStatsTracker, JMX_BEAN_TYPE);
mBeans.add(commitFutureStatsMXBean);
}
- newDataBroker.setCloseable(new AutoCloseable() {
+ broker.setCloseable(new AutoCloseable() {
@Override
public void close() {
for(AbstractMXBean mBean: mBeans) {
}
});
- return newDataBroker;
+ return broker;
}
}
--- /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.controller.md.sal.dom.broker.impl;
+
+import static com.google.common.base.Preconditions.checkState;
+import java.util.EnumMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.atomic.AtomicLong;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener;
+import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
+import org.opendaylight.controller.sal.core.spi.data.DOMStore;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class AbstractDOMDataBroker extends AbstractDOMForwardedTransactionFactory<DOMStore> implements DOMDataBroker, AutoCloseable {
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractDOMDataBroker.class);
+
+ private final AtomicLong txNum = new AtomicLong();
+ private final AtomicLong chainNum = new AtomicLong();
+ private volatile AutoCloseable closeable;
+
+ protected AbstractDOMDataBroker(final Map<LogicalDatastoreType, DOMStore> datastores) {
+ super(datastores);
+ }
+
+ public void setCloseable(final AutoCloseable closeable) {
+ this.closeable = closeable;
+ }
+
+ @Override
+ public void close() {
+ super.close();
+
+ if(closeable != null) {
+ try {
+ closeable.close();
+ } catch(Exception e) {
+ LOG.debug("Error closing instance", e);
+ }
+ }
+ }
+
+ @Override
+ protected Object newTransactionIdentifier() {
+ return "DOM-" + txNum.getAndIncrement();
+ }
+
+ @Override
+ public ListenerRegistration<DOMDataChangeListener> registerDataChangeListener(final LogicalDatastoreType store,
+ final YangInstanceIdentifier path, final DOMDataChangeListener listener, final DataChangeScope triggeringScope) {
+
+ DOMStore potentialStore = getTxFactories().get(store);
+ checkState(potentialStore != null, "Requested logical data store is not available.");
+ return potentialStore.registerChangeListener(path, listener, triggeringScope);
+ }
+
+ @Override
+ public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) {
+ checkNotClosed();
+
+ final Map<LogicalDatastoreType, DOMStoreTransactionChain> backingChains = new EnumMap<>(LogicalDatastoreType.class);
+ for (Entry<LogicalDatastoreType, DOMStore> entry : getTxFactories().entrySet()) {
+ backingChains.put(entry.getKey(), entry.getValue().createTransactionChain());
+ }
+
+ final long chainId = chainNum.getAndIncrement();
+ LOG.debug("Transactoin chain {} created with listener {}, backing store chains {}", chainId, listener,
+ backingChains);
+ return new DOMDataBrokerTransactionChainImpl(chainId, backingChains, this, listener);
+ }
+}
package org.opendaylight.controller.md.sal.dom.broker.impl;
import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.CheckedFuture;
import java.util.EnumMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionFactory;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
* @param <T>
* Type of {@link DOMStoreTransactionFactory} factory.
*/
-abstract class AbstractDOMForwardedTransactionFactory<T extends DOMStoreTransactionFactory> implements DOMDataCommitImplementation, AutoCloseable {
+abstract class AbstractDOMForwardedTransactionFactory<T extends DOMStoreTransactionFactory> implements AutoCloseable {
@SuppressWarnings("rawtypes")
private static final AtomicIntegerFieldUpdater<AbstractDOMForwardedTransactionFactory> UPDATER =
AtomicIntegerFieldUpdater.newUpdater(AbstractDOMForwardedTransactionFactory.class, "closed");
*/
protected abstract Object newTransactionIdentifier();
+ /**
+ * User-supplied implementation of {@link DOMDataWriteTransaction#submit()}
+ * for transaction.
+ *
+ * Callback invoked when {@link DOMDataWriteTransaction#submit()} is invoked
+ * on transaction created by this factory.
+ *
+ * @param transaction
+ * Transaction on which {@link DOMDataWriteTransaction#commit()}
+ * was invoked.
+ * @param cohorts
+ * Iteratable of cohorts for subtransactions associated with
+ * the transaction being committed.
+ * @return a CheckedFuture. if commit coordination on cohorts finished successfully,
+ * nothing is returned from the Future, On failure,
+ * the Future fails with a {@link TransactionCommitFailedException}.
+ */
+ protected abstract CheckedFuture<Void,TransactionCommitFailedException> submit(final DOMDataWriteTransaction transaction,
+ final Iterable<DOMStoreThreePhaseCommitCohort> cohorts);
+
/**
* Creates a new composite read-only transaction
*
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.controller.sal.core.spi.data.DOMStore;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
import org.opendaylight.yangtools.util.DurationStatisticsTracker;
import org.opendaylight.yangtools.util.concurrent.MappingCheckedFuture;
*
* @author Thomas Pantelis
*/
-public class DOMConcurrentDataCommitCoordinator implements DOMDataCommitExecutor {
-
+public class ConcurrentDOMDataBroker extends AbstractDOMDataBroker {
+ private static final Logger LOG = LoggerFactory.getLogger(ConcurrentDOMDataBroker.class);
private static final String CAN_COMMIT = "CAN_COMMIT";
private static final String PRE_COMMIT = "PRE_COMMIT";
private static final String COMMIT = "COMMIT";
- private static final Logger LOG = LoggerFactory.getLogger(DOMConcurrentDataCommitCoordinator.class);
-
private final DurationStatisticsTracker commitStatsTracker = DurationStatisticsTracker.createConcurrent();
/**
*/
private final ExecutorService internalFutureCallbackExecutor = new SimpleSameThreadExecutor();
- public DOMConcurrentDataCommitCoordinator(ExecutorService listenableFutureExecutor) {
+ public ConcurrentDOMDataBroker(final Map<LogicalDatastoreType, DOMStore> datastores, ExecutorService listenableFutureExecutor) {
+ super(datastores);
this.clientFutureCallbackExecutor = Preconditions.checkNotNull(listenableFutureExecutor);
}
*/
package org.opendaylight.controller.md.sal.dom.broker.impl;
-import static com.google.common.base.Preconditions.checkState;
-import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
-import java.util.EnumMap;
import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
import org.opendaylight.controller.sal.core.spi.data.DOMStore;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-public class DOMDataBrokerImpl extends AbstractDOMForwardedTransactionFactory<DOMStore> implements DOMDataBroker,
- AutoCloseable {
-
- private static final Logger LOG = LoggerFactory.getLogger(DOMDataBrokerImpl.class);
-
- private final DOMDataCommitExecutor coordinator;
- private final AtomicLong txNum = new AtomicLong();
- private final AtomicLong chainNum = new AtomicLong();
- private volatile AutoCloseable closeable;
-
- public DOMDataBrokerImpl(final Map<LogicalDatastoreType, DOMStore> datastores,
- final ListeningExecutorService executor) {
- this(datastores, new DOMDataCommitCoordinatorImpl(executor));
- }
-
- public DOMDataBrokerImpl(final Map<LogicalDatastoreType, DOMStore> datastores,
- final DOMDataCommitExecutor coordinator) {
- super(datastores);
- this.coordinator = Preconditions.checkNotNull(coordinator);
- }
-
- public void setCloseable(final AutoCloseable closeable) {
- this.closeable = closeable;
- }
-
- @Override
- public void close() {
- super.close();
-
- if(closeable != null) {
- try {
- closeable.close();
- } catch(Exception e) {
- LOG.debug("Error closing instance", e);
- }
- }
- }
-
- @Override
- protected Object newTransactionIdentifier() {
- return "DOM-" + txNum.getAndIncrement();
- }
-
- @Override
- public ListenerRegistration<DOMDataChangeListener> registerDataChangeListener(final LogicalDatastoreType store,
- final YangInstanceIdentifier path, final DOMDataChangeListener listener, final DataChangeScope triggeringScope) {
-
- DOMStore potentialStore = getTxFactories().get(store);
- checkState(potentialStore != null, "Requested logical data store is not available.");
- return potentialStore.registerChangeListener(path, listener, triggeringScope);
- }
-
- @Override
- public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) {
- checkNotClosed();
-
- final Map<LogicalDatastoreType, DOMStoreTransactionChain> backingChains = new EnumMap<>(LogicalDatastoreType.class);
- for (Entry<LogicalDatastoreType, DOMStore> entry : getTxFactories().entrySet()) {
- backingChains.put(entry.getKey(), entry.getValue().createTransactionChain());
- }
-
- final long chainId = chainNum.getAndIncrement();
- LOG.debug("Transactoin chain {} created with listener {}, backing store chains {}", chainId, listener,
- backingChains);
- return new DOMDataBrokerTransactionChainImpl(chainId, backingChains, coordinator, listener);
-
- }
-
- @Override
- public CheckedFuture<Void,TransactionCommitFailedException> submit(final DOMDataWriteTransaction transaction,
- final Iterable<DOMStoreThreePhaseCommitCohort> cohorts) {
- LOG.debug("Transaction: {} submitted with cohorts {}.", transaction.getIdentifier(), cohorts);
- return coordinator.submit(transaction, cohorts);
+/**
+ * @deprecated Compatibility wrapper around {@link SerializedDOMDataBroker}.
+ */
+@Deprecated
+public final class DOMDataBrokerImpl extends SerializedDOMDataBroker {
+ public DOMDataBrokerImpl(final Map<LogicalDatastoreType, DOMStore> datastores, final ListeningExecutorService executor) {
+ super(datastores, executor);
}
}
AtomicReferenceFieldUpdater.newUpdater(DOMDataBrokerTransactionChainImpl.class, State.class, "state");
private static final Logger LOG = LoggerFactory.getLogger(DOMDataBrokerTransactionChainImpl.class);
private final AtomicLong txNum = new AtomicLong();
- private final DOMDataCommitExecutor coordinator;
+ private final AbstractDOMDataBroker broker;
private final TransactionChainListener listener;
private final long chainId;
*/
public DOMDataBrokerTransactionChainImpl(final long chainId,
final Map<LogicalDatastoreType, DOMStoreTransactionChain> chains,
- final DOMDataCommitExecutor coordinator, final TransactionChainListener listener) {
+ final AbstractDOMDataBroker broker, final TransactionChainListener listener) {
super(chains);
this.chainId = chainId;
- this.coordinator = Preconditions.checkNotNull(coordinator);
+ this.broker = Preconditions.checkNotNull(broker);
this.listener = Preconditions.checkNotNull(listener);
}
checkNotFailed();
checkNotClosed();
- final CheckedFuture<Void, TransactionCommitFailedException> ret = coordinator.submit(transaction, cohorts);
+ final CheckedFuture<Void, TransactionCommitFailedException> ret = broker.submit(transaction, cohorts);
COUNTER_UPDATER.incrementAndGet(this);
Futures.addCallback(ret, new FutureCallback<Void>() {
+++ /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.controller.md.sal.dom.broker.impl;
-
-import com.google.common.util.concurrent.CheckedFuture;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-
-/**
- * Executor of Three Phase Commit coordination for
- * {@link DOMDataWriteTransaction} transactions.
- *
- * Implementations are responsible for executing implementation of three-phase
- * commit protocol on supplied {@link DOMStoreThreePhaseCommitCohort}s.
- *
- *
- */
-public interface DOMDataCommitExecutor {
-
- /**
- * Submits supplied transaction to be executed in context of provided
- * cohorts.
- *
- * Transaction is used only as a context, cohorts should be associated with
- * this transaction.
- *
- * @param tx
- * Transaction to be used as context for reporting
- * @param cohort
- * DOM Store cohorts representing provided transaction, its
- * subtransactions.
- * @return a CheckedFuture. if commit coordination on cohorts finished successfully,
- * nothing is returned from the Future, On failure,
- * the Future fails with a {@link TransactionCommitFailedException}.
- *
- */
- CheckedFuture<Void,TransactionCommitFailedException> submit(DOMDataWriteTransaction tx,
- Iterable<DOMStoreThreePhaseCommitCohort> cohort);
-
-}
+++ /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.controller.md.sal.dom.broker.impl;
-
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import com.google.common.util.concurrent.CheckedFuture;
-
-/**
- *
- * Implementation prototype of commit method for
- * {@link DOMForwardedWriteTransaction}.
- *
- */
-public interface DOMDataCommitImplementation {
-
- /**
- * User-supplied implementation of {@link DOMDataWriteTransaction#submit()}
- * for transaction.
- *
- * Callback invoked when {@link DOMDataWriteTransaction#submit()} is invoked
- * on transaction created by this factory.
- *
- * @param transaction
- * Transaction on which {@link DOMDataWriteTransaction#commit()}
- * was invoked.
- * @param cohorts
- * Iteration of cohorts for subtransactions associated with
- * commited transaction.
- *
- */
- CheckedFuture<Void,TransactionCommitFailedException> submit(final DOMDataWriteTransaction transaction,
- final Iterable<DOMStoreThreePhaseCommitCohort> cohorts);
-}
-
final class DOMForwardedReadWriteTransaction extends DOMForwardedWriteTransaction<DOMStoreReadWriteTransaction> implements DOMDataReadWriteTransaction {
protected DOMForwardedReadWriteTransaction(final Object identifier,
final Map<LogicalDatastoreType, DOMStoreReadWriteTransaction> backingTxs,
- final DOMDataCommitImplementation commitImpl) {
+ final AbstractDOMForwardedTransactionFactory<?> commitImpl) {
super(identifier, backingTxs, commitImpl);
}
class DOMForwardedWriteTransaction<T extends DOMStoreWriteTransaction> extends
AbstractDOMForwardedCompositeTransaction<LogicalDatastoreType, T> implements DOMDataWriteTransaction {
@SuppressWarnings("rawtypes")
- private static final AtomicReferenceFieldUpdater<DOMForwardedWriteTransaction, DOMDataCommitImplementation> IMPL_UPDATER =
- AtomicReferenceFieldUpdater.newUpdater(DOMForwardedWriteTransaction.class, DOMDataCommitImplementation.class, "commitImpl");
+ private static final AtomicReferenceFieldUpdater<DOMForwardedWriteTransaction, AbstractDOMForwardedTransactionFactory> IMPL_UPDATER =
+ AtomicReferenceFieldUpdater.newUpdater(DOMForwardedWriteTransaction.class, AbstractDOMForwardedTransactionFactory.class, "commitImpl");
@SuppressWarnings("rawtypes")
private static final AtomicReferenceFieldUpdater<DOMForwardedWriteTransaction, Future> FUTURE_UPDATER =
AtomicReferenceFieldUpdater.newUpdater(DOMForwardedWriteTransaction.class, Future.class, "commitFuture");
* the transaction is running -- which we flip atomically using
* {@link #IMPL_UPDATER}.
*/
- private volatile DOMDataCommitImplementation commitImpl;
+ private volatile AbstractDOMForwardedTransactionFactory<?> commitImpl;
/**
* Future task of transaction commit. It starts off as null, but is
private volatile Future<?> commitFuture;
protected DOMForwardedWriteTransaction(final Object identifier,
- final Map<LogicalDatastoreType, T> backingTxs, final DOMDataCommitImplementation commitImpl) {
+ final Map<LogicalDatastoreType, T> backingTxs, final AbstractDOMForwardedTransactionFactory<?> commitImpl) {
super(identifier, backingTxs);
this.commitImpl = Preconditions.checkNotNull(commitImpl, "commitImpl must not be null.");
}
@Override
public boolean cancel() {
- final DOMDataCommitImplementation impl = IMPL_UPDATER.getAndSet(this, null);
+ final AbstractDOMForwardedTransactionFactory<?> impl = IMPL_UPDATER.getAndSet(this, null);
if (impl != null) {
LOG.trace("Transaction {} cancelled before submit", getIdentifier());
FUTURE_UPDATER.lazySet(this, CANCELLED_FUTURE);
return future.cancel(false);
}
+ @Deprecated
@Override
public ListenableFuture<RpcResult<TransactionStatus>> commit() {
return AbstractDataTransaction.convertToLegacyCommitFuture(submit());
@Override
public CheckedFuture<Void, TransactionCommitFailedException> submit() {
- final DOMDataCommitImplementation impl = IMPL_UPDATER.getAndSet(this, null);
+ final AbstractDOMForwardedTransactionFactory<?> impl = IMPL_UPDATER.getAndSet(this, null);
checkRunning(impl);
final Collection<T> txns = getSubtransactions();
return ret;
}
- private void checkRunning(final DOMDataCommitImplementation impl) {
+ private void checkRunning(final AbstractDOMForwardedTransactionFactory<?> impl) {
Preconditions.checkState(impl != null, "Transaction %s is no longer running", getIdentifier());
}
}
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
+import java.util.Map;
import java.util.concurrent.RejectedExecutionException;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.controller.sal.core.spi.data.DOMStore;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
import org.opendaylight.yangtools.util.DurationStatisticsTracker;
import org.opendaylight.yangtools.util.concurrent.MappingCheckedFuture;
import org.slf4j.LoggerFactory;
/**
- *
* Implementation of blocking three phase commit coordinator, which which
* supports coordination on multiple {@link DOMStoreThreePhaseCommitCohort}.
*
- * This implementation does not support cancelation of commit,
+ * This implementation does not support cancellation of commit,
*
* In order to advance to next phase of three phase commit all subtasks of
* previous step must be finish.
*
* This executor does not have an upper bound on subtask timeout.
- *
- *
*/
-public class DOMDataCommitCoordinatorImpl implements DOMDataCommitExecutor {
-
- private static final Logger LOG = LoggerFactory.getLogger(DOMDataCommitCoordinatorImpl.class);
+public class SerializedDOMDataBroker extends AbstractDOMDataBroker {
+ private static final Logger LOG = LoggerFactory.getLogger(SerializedDOMDataBroker.class);
private final DurationStatisticsTracker commitStatsTracker = DurationStatisticsTracker.createConcurrent();
private final ListeningExecutorService executor;
*
* @param executor
*/
- public DOMDataCommitCoordinatorImpl(final ListeningExecutorService executor) {
+ public SerializedDOMDataBroker(final Map<LogicalDatastoreType, DOMStore> datastores, final ListeningExecutorService executor) {
+ super(datastores);
this.executor = Preconditions.checkNotNull(executor, "executor must not be null.");
}
}
@Override
- public CheckedFuture<Void,TransactionCommitFailedException> submit(final DOMDataWriteTransaction transaction,
+ protected CheckedFuture<Void,TransactionCommitFailedException> submit(final DOMDataWriteTransaction transaction,
final Iterable<DOMStoreThreePhaseCommitCohort> cohorts) {
Preconditions.checkArgument(transaction != null, "Transaction must not be null.");
Preconditions.checkArgument(cohorts != null, "Cohorts must not be null.");
}
private SchemaContext schemaContext;
- private DOMDataBrokerImpl domBroker;
+ private AbstractDOMDataBroker domBroker;
private static <V> V measure(final String name, final Callable<V> callable) throws Exception {
// TODO Auto-generated method stub
.put(OPERATIONAL, operStore) //
.build();
ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
- domBroker = new DOMDataBrokerImpl(stores, executor);
+ domBroker = new SerializedDOMDataBroker(stores, executor);
}
@Test
public class DOMBrokerTest {
private SchemaContext schemaContext;
- private DOMDataBrokerImpl domBroker;
+ private AbstractDOMDataBroker domBroker;
private ListeningExecutorService executor;
private ExecutorService futureExecutor;
private CommitExecutorService commitExecutor;
futureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(1, 5, "FCB");
executor = new DeadlockDetectingListeningExecutorService(commitExecutor,
TransactionCommitDeadlockException.DEADLOCK_EXCEPTION_SUPPLIER, futureExecutor);
- domBroker = new DOMDataBrokerImpl(stores, executor);
+ domBroker = new SerializedDOMDataBroker(stores, executor);
}
@After
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.util.concurrent.CheckedFuture;
+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 com.google.common.util.concurrent.SettableFuture;
+import com.google.common.util.concurrent.Uninterruptibles;
import java.util.Arrays;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.SynchronousQueue;
import org.mockito.InOrder;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
+import org.opendaylight.controller.sal.core.spi.data.DOMStore;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import com.google.common.util.concurrent.CheckedFuture;
-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.SettableFuture;
-import com.google.common.util.concurrent.Uninterruptibles;
/**
* Unit tests for DOMConcurrentDataCommitCoordinator.
private final DOMStoreThreePhaseCommitCohort mockCohort2 = mock(DOMStoreThreePhaseCommitCohort.class);
private final ThreadPoolExecutor futureExecutor =
new ThreadPoolExecutor(0, 1, 5, TimeUnit.SECONDS, new SynchronousQueue<Runnable>());
- private final DOMConcurrentDataCommitCoordinator coordinator =
- new DOMConcurrentDataCommitCoordinator(futureExecutor);
+ private ConcurrentDOMDataBroker coordinator;
@Before
public void setup() {
doReturn("tx").when(transaction).getIdentifier();
+
+ DOMStore store = new InMemoryDOMDataStore("OPER",
+ MoreExecutors.sameThreadExecutor());
+
+ coordinator = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, store), futureExecutor);
}
@After
final CountDownLatch asyncCanCommitContinue = new CountDownLatch(1);
Answer<ListenableFuture<Boolean>> asyncCanCommit = new Answer<ListenableFuture<Boolean>>() {
@Override
- public ListenableFuture<Boolean> answer(InvocationOnMock invocation) {
+ public ListenableFuture<Boolean> answer(final InvocationOnMock invocation) {
final SettableFuture<Boolean> future = SettableFuture.create();
if(doAsync) {
new Thread() {
final AtomicReference<Throwable> caughtEx = new AtomicReference<>();
Futures.addCallback(future, new FutureCallback<Void>() {
@Override
- public void onSuccess(Void result) {
+ public void onSuccess(final Void result) {
doneLatch.countDown();
}
@Override
- public void onFailure(Throwable t) {
+ public void onFailure(final Throwable t) {
caughtEx.set(t);
doneLatch.countDown();
}
assertFailure(future, null, mockCohort1, mockCohort2, mockCohort3);
}
- private void assertFailure(CheckedFuture<Void, TransactionCommitFailedException> future,
- Exception expCause, DOMStoreThreePhaseCommitCohort... mockCohorts)
+ private void assertFailure(final CheckedFuture<Void, TransactionCommitFailedException> future,
+ final Exception expCause, final DOMStoreThreePhaseCommitCohort... mockCohorts)
throws Exception {
try {
future.checkedGet(5, TimeUnit.SECONDS);
public class DOMTransactionChainTest {
private SchemaContext schemaContext;
- private DOMDataBrokerImpl domBroker;
+ private AbstractDOMDataBroker domBroker;
@Before
public void setupStore() {
.build();
ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
- domBroker = new DOMDataBrokerImpl(stores, executor);
+ domBroker = new SerializedDOMDataBroker(stores, executor);
}
@Test
import java.util.List;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
* It is call from collecting allStatistics methods as a future result for
* Operational/DS statistic store call (does not matter in the outcome).
*/
- void collectNextStatistics();
+ void collectNextStatistics(TransactionId xid);
/**
* Method returns true if collector has registered some active nodes
import org.opendaylight.yangtools.yang.common.RpcResult;
import com.google.common.base.Optional;
+import com.google.common.util.concurrent.SettableFuture;
/**
* statistics-manager
*
* @param future - result every Device RPC call
*/
- <T extends TransactionAware, D extends DataObject> void registrationRpcFutureCallBack(Future<RpcResult<T>> future, D inputObj, NodeRef ref);
+ <T extends TransactionAware, D extends DataObject> void registrationRpcFutureCallBack(
+ Future<RpcResult<T>> future, D inputObj, NodeRef ref, SettableFuture<TransactionId> resultTransId);
/**
* Method adds Notification which is marked as Multipart to the transaction cash
*
* @param NodeRef nodeRef
*/
- void getAllGroupsStat(NodeRef nodeRef);
+ Future<TransactionId> getAllGroupsStat(NodeRef nodeRef);
/**
* Method wraps OpendaylightGroupStatisticsService.getGroupDescription
*
* @param NodeRef nodeRef
*/
- void getAllGroupsConfStats(NodeRef nodeRef);
+ Future<TransactionId> getAllGroupsConfStats(NodeRef nodeRef);
/**
* Method wraps OpendaylightMeterStatisticsService.getGroupFeatures
*
* @param NodeRef nodeRef
*/
- void getAllMetersStat(NodeRef nodeRef);
+ Future<TransactionId> getAllMetersStat(NodeRef nodeRef);
/**
* Method wraps OpendaylightMeterStatisticsService.getAllMeterConfigStatistics
*
* @param NodeRef nodeRef
*/
- void getAllMeterConfigStat(NodeRef nodeRef);
+ Future<TransactionId> getAllMeterConfigStat(NodeRef nodeRef);
/**
* Method wraps OpendaylightMeterStatisticsService.getMeterFeatures
*
* @param NodeRef nodeRef
*/
- void getAllFlowsStat(NodeRef nodeRef);
+ Future<TransactionId> getAllFlowsStat(NodeRef nodeRef);
/**
* Method wraps OpendaylightFlowStatisticsService.getAggregateFlowStatisticsFromFlowTableForAllFlows
*
* @param NodeRef nodeRef
*/
- void getAllPortsStat(NodeRef nodeRef);
+ Future<TransactionId> getAllPortsStat(NodeRef nodeRef);
/**
* Method wraps OpendaylightFlowTableStatisticsService.getFlowTablesStatistics
*
* @param NodeRef nodeRef
*/
- void getAllTablesStat(NodeRef nodeRef);
+ Future<TransactionId> getAllTablesStat(NodeRef nodeRef);
/**
* Method wraps OpendaylightQueueStatisticsService.getAllQueuesStatisticsFromAllPorts
*
* @param NodeRef nodeRef
*/
- void getAllQueueStat(NodeRef nodeRef);
+ Future<TransactionId> getAllQueueStat(NodeRef nodeRef);
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
*
* @param nodeIdent
*/
- void collectNextStatistics(InstanceIdentifier<Node> nodeIdent);
+ void collectNextStatistics(InstanceIdentifier<Node> nodeIdent, TransactionId xid);
/**
* Method wraps {@link StatPermCollector}.connectedNodeRegistration to provide
return manager.isProvidedFlowNodeActive(nodeIdent);
}
- protected void notifyToCollectNextStatistics(final InstanceIdentifier<Node> nodeIdent) {
+ protected void notifyToCollectNextStatistics(final InstanceIdentifier<Node> nodeIdent, final TransactionId xid) {
Preconditions.checkNotNull(nodeIdent, "FlowCapableNode ident can not be null!");
- manager.collectNextStatistics(nodeIdent);
+ manager.collectNextStatistics(nodeIdent, xid);
}
/**
}
}
/* Notification for continue collecting statistics */
- notifyToCollectNextStatistics(nodeIdent);
+ notifyToCollectNextStatistics(nodeIdent, transId);
}
});
}
/* Delete all not presented Group Nodes */
deleteAllNotPresentNode(fNodeIdent, tx, Collections.unmodifiableList(existGroupKeys));
/* Notification for continue collecting statistics */
- notifyToCollectNextStatistics(nodeIdent);
+ notifyToCollectNextStatistics(nodeIdent, transId);
}
});
}
}
statGroupCommit(((GroupStatisticsUpdated) notif).getGroupStats(), nodeIdent, tx);
}
- if (notifGroup.isPresent()) {
- notifyToCollectNextStatistics(nodeIdent);
+ if ( ! notifGroup.isPresent()) {
+ notifyToCollectNextStatistics(nodeIdent, transId);
}
}
});
/* Delete all not presented Meter Nodes */
deleteAllNotPresentedNodes(fNodeIdent, tx, Collections.unmodifiableList(existMeterKeys));
/* Notification for continue collecting statistics */
- notifyToCollectNextStatistics(nodeIdent);
+ notifyToCollectNextStatistics(nodeIdent, transId);
}
});
}
}
statMeterCommit(((MeterStatisticsUpdated) notif).getMeterStats(), nodeIdent, tx);
}
- if (notifMeter.isPresent()) {
- notifyToCollectNextStatistics(nodeIdent);
+ if ( ! notifMeter.isPresent()) {
+ notifyToCollectNextStatistics(nodeIdent, transId);
}
}
});
/* Delete all not presented Group Nodes */
deleteAllNotPresentedNodes(nodeIdent, tx, Collections.unmodifiableMap(existQueueKeys));
/* Notification for continue collecting statistics */
- notifyToCollectNextStatistics(nodeIdent);
+ notifyToCollectNextStatistics(nodeIdent, transId);
}
});
}
statPortCommit(portStats, nodeIdent, trans);
/* Notification for continue collecting statistics - Port statistics are still same size
* and they are small - don't need to wait for whole apply operation*/
- notifyToCollectNextStatistics(nodeIdent);
+ notifyToCollectNextStatistics(nodeIdent, transId);
}
});
}
statTableCommit(tableStats, nodeIdent, trans);
/* Notification for continue collecting statistics - Tables statistics are still same size
* and they are small - don't need to wait to whole apply operation */
- notifyToCollectNextStatistics(nodeIdent);
+ notifyToCollectNextStatistics(nodeIdent, transId);
}
});
}
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import org.opendaylight.controller.md.statistics.manager.StatPermCollector;
import org.opendaylight.controller.md.statistics.manager.StatisticsManager;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
private final static Logger LOG = LoggerFactory.getLogger(StatPermCollectorImpl.class);
- private final static long STAT_COLLECT_TIME_OUT = 30000L;
+ private final static long STAT_COLLECT_TIME_OUT = 3000L;
private final ExecutorService statNetCollectorServ;
private final StatisticsManager manager;
private final Object statCollectorLock = new Object();
private final Object statNodeHolderLock = new Object();
+ private final Object transNotifyLock = new Object();
private Map<InstanceIdentifier<Node>, StatNodeInfoHolder> statNodeHolder =
Collections.<InstanceIdentifier<Node>, StatNodeInfoHolder> emptyMap();
private volatile boolean wakeMe = false;
private volatile boolean finishing = false;
+ private TransactionId actualTransactionId;
public StatPermCollectorImpl(final StatisticsManager manager, final long minReqNetInterv, final int nr,
final int maxNodeForCollectors) {
public void close() {
statNodeHolder = Collections.<InstanceIdentifier<Node>, StatNodeInfoHolder> emptyMap();
finishing = true;
- collectNextStatistics();
+ collectNextStatistics(actualTransactionId);
statNetCollectorServ.shutdown();
}
}
if (statNodeHolder.isEmpty()) {
finishing = true;
- collectNextStatistics();
+ collectNextStatistics(actualTransactionId);
statNetCollectorServ.shutdown();
}
return true;
}
@Override
- public void collectNextStatistics() {
- if (wakeMe) {
- synchronized (statCollectorLock) {
- if (wakeMe) {
- LOG.trace("STAT-COLLECTOR is notified to conntinue");
- statCollectorLock.notify();
+ public void collectNextStatistics(final TransactionId xid) {
+ if (checkTransactionId(xid)) {
+ if (wakeMe) {
+ synchronized (statCollectorLock) {
+ if (wakeMe) {
+ LOG.trace("STAT-COLLECTOR is notified to conntinue");
+ statCollectorLock.notify();
+ }
}
}
}
@Override
public void run() {
try {
+ // sleep 5 second before collecting all statistics cycles is important
+ // for loading all Nodes to Operational/DS
Thread.sleep(5000);
}
catch (final InterruptedException e1) {
} catch (final InterruptedException e) {
LOG.warn("statCollector has been interrupted waiting stat Response sleep", e);
} finally {
+ setActualTransactionId(null);
wakeMe = false;
}
}
if ( ! isProvidedFlowNodeActive(nodeEntity.getKey())) {
break;
}
- switch (statMarker) {
- case PORT_STATS:
- LOG.trace("STAT-MANAGER-collecting PORT-STATS for NodeRef {}", actualNodeRef);
- manager.getRpcMsgManager().getAllPortsStat(actualNodeRef);
- waitingForNotification();
- break;
- case QUEUE_STATS:
- LOG.trace("STAT-MANAGER-collecting QUEUE-STATS for NodeRef {}", actualNodeRef);
- manager.getRpcMsgManager().getAllQueueStat(actualNodeRef);
- waitingForNotification();
- break;
- case TABLE_STATS:
- LOG.trace("STAT-MANAGER-collecting TABLE-STATS for NodeRef {}", actualNodeRef);
- manager.getRpcMsgManager().getAllTablesStat(actualNodeRef);
- waitingForNotification();
- break;
- case GROUP_STATS:
- LOG.trace("STAT-MANAGER-collecting GROUP-STATS for NodeRef {}", actualNodeRef);
- manager.getRpcMsgManager().getAllGroupsConfStats(actualNodeRef);
- waitingForNotification();
- manager.getRpcMsgManager().getAllGroupsStat(actualNodeRef);
- waitingForNotification();
- break;
- case METER_STATS:
- LOG.trace("STAT-MANAGER-collecting METER-STATS for NodeRef {}", actualNodeRef);
- manager.getRpcMsgManager().getAllMeterConfigStat(actualNodeRef);
- waitingForNotification();
- manager.getRpcMsgManager().getAllMetersStat(actualNodeRef);
- waitingForNotification();
- break;
- case FLOW_STATS:
- LOG.trace("STAT-MANAGER-collecting FLOW-STATS-ALL_FLOWS for NodeRef {}", actualNodeRef);
- manager.getRpcMsgManager().getAllFlowsStat(actualNodeRef);
- waitingForNotification();
- LOG.trace("STAT-MANAGER-collecting FLOW-AGGREGATE-STATS for NodeRef {}", actualNodeRef);
- for (short i = 0; i < maxTables; i++) {
- final TableId tableId = new TableId(i);
- manager.getRpcMsgManager().getAggregateFlowStat(actualNodeRef, tableId);
+ try {
+ switch (statMarker) {
+ case PORT_STATS:
+ LOG.trace("STAT-MANAGER-collecting PORT-STATS for NodeRef {}", actualNodeRef);
+ setActualTransactionId(manager.getRpcMsgManager().getAllPortsStat(actualNodeRef).get());
+ waitingForNotification();
+ break;
+ case QUEUE_STATS:
+ LOG.trace("STAT-MANAGER-collecting QUEUE-STATS for NodeRef {}", actualNodeRef);
+ setActualTransactionId(manager.getRpcMsgManager().getAllQueueStat(actualNodeRef).get());
+ waitingForNotification();
+ break;
+ case TABLE_STATS:
+ LOG.trace("STAT-MANAGER-collecting TABLE-STATS for NodeRef {}", actualNodeRef);
+ setActualTransactionId(manager.getRpcMsgManager().getAllTablesStat(actualNodeRef).get());
+ waitingForNotification();
+ break;
+ case GROUP_STATS:
+ LOG.trace("STAT-MANAGER-collecting GROUP-STATS for NodeRef {}", actualNodeRef);
+ setActualTransactionId(manager.getRpcMsgManager().getAllGroupsConfStats(actualNodeRef).get());
+ waitingForNotification();
+ setActualTransactionId(manager.getRpcMsgManager().getAllGroupsStat(actualNodeRef).get());
+ waitingForNotification();
+ break;
+ case METER_STATS:
+ LOG.trace("STAT-MANAGER-collecting METER-STATS for NodeRef {}", actualNodeRef);
+ setActualTransactionId(manager.getRpcMsgManager().getAllMeterConfigStat(actualNodeRef).get());
+ waitingForNotification();
+ setActualTransactionId(manager.getRpcMsgManager().getAllMetersStat(actualNodeRef).get());
+ waitingForNotification();
+ break;
+ case FLOW_STATS:
+ LOG.trace("STAT-MANAGER-collecting FLOW-STATS-ALL_FLOWS for NodeRef {}", actualNodeRef);
+ setActualTransactionId(manager.getRpcMsgManager().getAllFlowsStat(actualNodeRef).get());
+ waitingForNotification();
+ LOG.trace("STAT-MANAGER-collecting FLOW-AGGREGATE-STATS for NodeRef {}", actualNodeRef);
+ for (short i = 0; i < maxTables; i++) {
+ final TableId tableId = new TableId(i);
+ manager.getRpcMsgManager().getAggregateFlowStat(actualNodeRef, tableId);
+ }
+ break;
+ default:
+ /* Exception for programmers in implementation cycle */
+ throw new IllegalStateException("Not implemented ASK for " + statMarker);
}
- break;
- default:
- /* Exception for programmers in implementation cycle */
- throw new IllegalStateException("Not implemented ASK for " + statMarker);
+ } catch (InterruptedException | ExecutionException ex) {
+ LOG.warn("Unexpected RPC exception by call RPC Future!", ex);
+ continue;
}
}
}
}
return true;
}
+
+ private boolean checkTransactionId(final TransactionId xid) {
+ synchronized (transNotifyLock) {
+ return actualTransactionId != null && actualTransactionId.equals(xid);
+ }
+ }
+
+ private void setActualTransactionId(final TransactionId transactionId) {
+ synchronized (transNotifyLock) {
+ actualTransactionId = transactionId;
+ }
+ }
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsService;
private final Cache<String, TransactionCacheContainer<? super TransactionAware>> txCache;
- private final long maxLifeForRequest = 50; /* 50 second */
private final int queueCapacity = 5000;
private final OpendaylightGroupStatisticsService groupStatsService;
private volatile boolean finishing = false;
public StatRpcMsgManagerImpl (final StatisticsManager manager,
- final RpcConsumerRegistry rpcRegistry, final long minReqNetMonitInt) {
+ final RpcConsumerRegistry rpcRegistry, final long maxNodeForCollector) {
Preconditions.checkArgument(manager != null, "StatisticManager can not be null!");
Preconditions.checkArgument(rpcRegistry != null, "RpcConsumerRegistry can not be null !");
groupStatsService = Preconditions.checkNotNull(
"OpendaylightQueueStatisticsService can not be null!");
statsRpcJobQueue = new LinkedBlockingQueue<>(queueCapacity);
- txCache = CacheBuilder.newBuilder().expireAfterWrite(maxLifeForRequest, TimeUnit.SECONDS)
+ /* nr. 7 is here nr. of possible statistic which are waiting for notification
+ * - check it in StatPermCollectorImpl method collectStatCrossNetwork */
+ txCache = CacheBuilder.newBuilder().expireAfterWrite((maxNodeForCollector * 7), TimeUnit.SECONDS)
.maximumSize(10000).build();
}
@Override
public <T extends TransactionAware, D extends DataObject> void registrationRpcFutureCallBack(
- final Future<RpcResult<T>> future, final D inputObj, final NodeRef nodeRef) {
+ final Future<RpcResult<T>> future, final D inputObj, final NodeRef nodeRef,
+ final SettableFuture<TransactionId> resultTransId) {
Futures.addCallback(JdkFutureAdapters.listenInPoolThread(future),
new FutureCallback<RpcResult<? extends TransactionAware>>() {
if (id == null) {
LOG.warn("No protocol support");
} else {
+ if (resultTransId != null) {
+ resultTransId.set(id);
+ }
final NodeKey nodeKey = nodeRef.getValue().firstKeyOf(Node.class, NodeKey.class);
final String cacheKey = buildCacheKey(id, nodeKey.getId());
final TransactionCacheContainer<? super TransactionAware> container =
}
@Override
- public void getAllGroupsStat(final NodeRef nodeRef) {
+ public Future<TransactionId> getAllGroupsStat(final NodeRef nodeRef) {
Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+ final SettableFuture<TransactionId> result = SettableFuture.create();
final RpcJobsQueue getAllGroupStat = new RpcJobsQueue() {
@Override
new GetAllGroupStatisticsInputBuilder();
builder.setNode(nodeRef);
registrationRpcFutureCallBack(groupStatsService
- .getAllGroupStatistics(builder.build()), null, nodeRef);
+ .getAllGroupStatistics(builder.build()), null, nodeRef, result);
return null;
}
};
addGetAllStatJob(getAllGroupStat);
+ return result;
}
@Override
- public void getAllMetersStat(final NodeRef nodeRef) {
+ public Future<TransactionId> getAllMetersStat(final NodeRef nodeRef) {
Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+ final SettableFuture<TransactionId> result = SettableFuture.create();
final RpcJobsQueue getAllMeterStat = new RpcJobsQueue() {
@Override
new GetAllMeterStatisticsInputBuilder();
builder.setNode(nodeRef);
registrationRpcFutureCallBack(meterStatsService
- .getAllMeterStatistics(builder.build()), null, nodeRef);
+ .getAllMeterStatistics(builder.build()), null, nodeRef, result);
return null;
}
};
addGetAllStatJob(getAllMeterStat);
+ return result;
}
@Override
- public void getAllFlowsStat(final NodeRef nodeRef) {
+ public Future<TransactionId> getAllFlowsStat(final NodeRef nodeRef) {
Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+ final SettableFuture<TransactionId> result = SettableFuture.create();
final RpcJobsQueue getAllFlowStat = new RpcJobsQueue() {
@Override
new GetAllFlowsStatisticsFromAllFlowTablesInputBuilder();
builder.setNode(nodeRef);
registrationRpcFutureCallBack(flowStatsService
- .getAllFlowsStatisticsFromAllFlowTables(builder.build()), null, nodeRef);
+ .getAllFlowsStatisticsFromAllFlowTables(builder.build()), null, nodeRef, result);
return null;
}
};
addGetAllStatJob(getAllFlowStat);
+ return result;
}
@Override
tbuilder.setId(tableId.getValue());
tbuilder.setKey(new TableKey(tableId.getValue()));
registrationRpcFutureCallBack(flowStatsService
- .getAggregateFlowStatisticsFromFlowTableForAllFlows(builder.build()), tbuilder.build(), nodeRef);
+ .getAggregateFlowStatisticsFromFlowTableForAllFlows(builder.build()), tbuilder.build(), nodeRef, null);
return null;
}
};
}
@Override
- public void getAllPortsStat(final NodeRef nodeRef) {
+ public Future<TransactionId> getAllPortsStat(final NodeRef nodeRef) {
Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+ final SettableFuture<TransactionId> result = SettableFuture.create();
final RpcJobsQueue getAllPortsStat = new RpcJobsQueue() {
@Override
final GetAllNodeConnectorsStatisticsInputBuilder builder =
new GetAllNodeConnectorsStatisticsInputBuilder();
builder.setNode(nodeRef);
- registrationRpcFutureCallBack(portStatsService
- .getAllNodeConnectorsStatistics(builder.build()), null, nodeRef);
+ final Future<RpcResult<GetAllNodeConnectorsStatisticsOutput>> rpc =
+ portStatsService.getAllNodeConnectorsStatistics(builder.build());
+ registrationRpcFutureCallBack(rpc, null, nodeRef, result);
return null;
}
};
addGetAllStatJob(getAllPortsStat);
+ return result;
}
@Override
- public void getAllTablesStat(final NodeRef nodeRef) {
+ public Future<TransactionId> getAllTablesStat(final NodeRef nodeRef) {
Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+ final SettableFuture<TransactionId> result = SettableFuture.create();
final RpcJobsQueue getAllTableStat = new RpcJobsQueue() {
@Override
new GetFlowTablesStatisticsInputBuilder();
builder.setNode(nodeRef);
registrationRpcFutureCallBack(flowTableStatsService
- .getFlowTablesStatistics(builder.build()), null, nodeRef);
+ .getFlowTablesStatistics(builder.build()), null, nodeRef, result);
return null;
}
};
addGetAllStatJob(getAllTableStat);
+ return result;
}
@Override
- public void getAllQueueStat(final NodeRef nodeRef) {
+ public Future<TransactionId> getAllQueueStat(final NodeRef nodeRef) {
Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+ final SettableFuture<TransactionId> result = SettableFuture.create();
final RpcJobsQueue getAllQueueStat = new RpcJobsQueue() {
@Override
new GetAllQueuesStatisticsFromAllPortsInputBuilder();
builder.setNode(nodeRef);
registrationRpcFutureCallBack(queueStatsService
- .getAllQueuesStatisticsFromAllPorts(builder.build()), null, nodeRef);
+ .getAllQueuesStatisticsFromAllPorts(builder.build()), null, nodeRef, result);
return null;
}
};
addGetAllStatJob(getAllQueueStat);
+ return result;
}
@Override
- public void getAllMeterConfigStat(final NodeRef nodeRef) {
+ public Future<TransactionId> getAllMeterConfigStat(final NodeRef nodeRef) {
Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+ final SettableFuture<TransactionId> result = SettableFuture.create();
final RpcJobsQueue qetAllMeterConfStat = new RpcJobsQueue() {
@Override
new GetAllMeterConfigStatisticsInputBuilder();
builder.setNode(nodeRef);
registrationRpcFutureCallBack(meterStatsService
- .getAllMeterConfigStatistics(builder.build()), null, nodeRef);
+ .getAllMeterConfigStatistics(builder.build()), null, nodeRef, result);
return null;
}
};
addGetAllStatJob(qetAllMeterConfStat);
+ return result;
}
@Override
/* RPC input */
final GetGroupFeaturesInputBuilder input = new GetGroupFeaturesInputBuilder();
input.setNode(nodeRef);
- registrationRpcFutureCallBack(groupStatsService.getGroupFeatures(input.build()), null, nodeRef);
+ registrationRpcFutureCallBack(groupStatsService.getGroupFeatures(input.build()), null, nodeRef, null);
return null;
}
};
/* RPC input */
final GetMeterFeaturesInputBuilder input = new GetMeterFeaturesInputBuilder();
input.setNode(nodeRef);
- registrationRpcFutureCallBack(meterStatsService.getMeterFeatures(input.build()), null, nodeRef);
+ registrationRpcFutureCallBack(meterStatsService.getMeterFeatures(input.build()), null, nodeRef, null);
return null;
}
};
}
@Override
- public void getAllGroupsConfStats(final NodeRef nodeRef) {
+ public Future<TransactionId> getAllGroupsConfStats(final NodeRef nodeRef) {
Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+ final SettableFuture<TransactionId> result = SettableFuture.create();
final RpcJobsQueue getAllGropConfStat = new RpcJobsQueue() {
@Override
new GetGroupDescriptionInputBuilder();
builder.setNode(nodeRef);
registrationRpcFutureCallBack(groupStatsService
- .getGroupDescription(builder.build()), null, nodeRef);
+ .getGroupDescription(builder.build()), null, nodeRef, result);
return null;
}
};
addGetAllStatJob(getAllGropConfStat);
+ return result;
}
public class TransactionCacheContainerImpl<T extends TransactionAware> implements TransactionCacheContainer<T> {
package org.opendaylight.controller.md.statistics.manager.impl;
-import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.ThreadFactory;
+
import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.LinkedBlockingDeque;
-import java.util.concurrent.ThreadFactory;
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
/**
* statistics-manager
private final StatisticsManagerConfig statManagerConfig;
- public StatisticsManagerImpl (final DataBroker dataBroker, StatisticsManagerConfig statManagerconfig) {
- this.statManagerConfig = Preconditions.checkNotNull(statManagerconfig);
+ public StatisticsManagerImpl (final DataBroker dataBroker, final StatisticsManagerConfig statManagerconfig) {
+ statManagerConfig = Preconditions.checkNotNull(statManagerconfig);
this.dataBroker = Preconditions.checkNotNull(dataBroker, "DataBroker can not be null!");
ThreadFactory threadFact;
threadFact = new ThreadFactoryBuilder().setNameFormat("odl-stat-rpc-oper-thread-%d").build();
public void start(final NotificationProviderService notifService,
final RpcConsumerRegistry rpcRegistry) {
Preconditions.checkArgument(rpcRegistry != null, "RpcConsumerRegistry can not be null !");
- rpcMsgManager = new StatRpcMsgManagerImpl(this, rpcRegistry, statManagerConfig.getMinRequestNetMonitorInterval());
+ rpcMsgManager = new StatRpcMsgManagerImpl(this, rpcRegistry, statManagerConfig.getMaxNodesForCollector());
statCollectors = Collections.emptyList();
nodeRegistrator = new StatNodeRegistrationImpl(this, dataBroker, notifService);
flowListeningCommiter = new StatListenCommitFlow(this, dataBroker, notifService);
}
@Override
- public void collectNextStatistics(final InstanceIdentifier<Node> nodeIdent) {
+ public void collectNextStatistics(final InstanceIdentifier<Node> nodeIdent, final TransactionId xid) {
for (final StatPermCollector collector : statCollectors) {
if (collector.isProvidedFlowNodeActive(nodeIdent)) {
- collector.collectNextStatistics();
+ collector.collectNextStatistics(xid);
}
}
}
import org.opendaylight.controller.md.sal.binding.impl.ForwardedBindingDataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.broker.impl.DOMDataBrokerImpl;
+import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker;
import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
import org.opendaylight.controller.sal.core.spi.data.DOMStore;
}
public DOMDataBroker createDOMDataBroker() {
- return new DOMDataBrokerImpl(getDatastores(), getCommitCoordinatorExecutor());
+ return new SerializedDOMDataBroker(getDatastores(), getCommitCoordinatorExecutor());
}
public ListeningExecutorService getCommitCoordinatorExecutor() {
<bundle.plugin.version>2.4.0</bundle.plugin.version>
<guava.version>14.0.1</guava.version>
<maven.clean.plugin.version>2.5</maven.clean.plugin.version>
- <xtend.version>2.4.3</xtend.version>
</properties>
<dependencies>
<dependency>
final Collection<String> capabilities) {
super(sessionListener, channel, sessionId);
this.capabilities = capabilities;
- LOG.debug("Client Session {} created", toString());
+ LOG.debug("Client Session {} created", this);
}
public Collection<String> getServerCapabilities() {
<scope>test</scope>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>maven-paxexam-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-config</id>
- <goals>
- <goal>generate-depends-file</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
</project>
import org.w3c.dom.Element;
public class JaxBSerializer {
+ private static final JAXBContext JAXB_CONTEXT;
+
+ static {
+ try {
+ JAXB_CONTEXT = JAXBContext.newInstance(NetconfState.class);
+ } catch (JAXBException e) {
+ throw new ExceptionInInitializerError(e);
+ }
+ }
public Element toXml(final NetconfState monitoringModel) {
final DOMResult res;
try {
- final JAXBContext jaxbContext = JAXBContext.newInstance(NetconfState.class);
- final Marshaller marshaller = jaxbContext.createMarshaller();
+ final Marshaller marshaller = JAXB_CONTEXT.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
package org.opendaylight.controller.netconf.util;
import com.google.common.base.Preconditions;
-
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.controller.netconf.util.xml.XmlElement;
public final class NetconfUtil {
- private static final Logger logger = LoggerFactory.getLogger(NetconfUtil.class);
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfUtil.class);
private NetconfUtil() {}
if (element.getName().equals(XmlNetconfConstants.OK)) {
return response;
}
- logger.warn("Can not load last configuration. Operation failed.");
+ LOG.warn("Can not load last configuration. Operation failed.");
throw new IllegalStateException("Can not load last configuration. Operation failed: "
+ XmlUtil.toString(response));
}
import java.util.Collections;
import java.util.Map;
-
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
public class MissingNameSpaceException extends NetconfDocumentedException {
import java.util.Collections;
import java.util.Map;
-
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
public class UnexpectedElementException extends NetconfDocumentedException {
import java.util.Collections;
import java.util.Map;
-
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
public class UnexpectedNamespaceException extends NetconfDocumentedException {
package org.opendaylight.controller.netconf.util.messages;
-import org.opendaylight.controller.netconf.api.NetconfMessage;
-
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Sets;
import java.util.Set;
-
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
+import org.opendaylight.controller.netconf.api.NetconfMessage;
import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.controller.netconf.util.exception.MissingNameSpaceException;
import org.opendaylight.controller.netconf.util.xml.XmlElement;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Sets;
-
/**
* NetconfMessage that can carry additional header with session metadata. See {@link org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader}
*/
package org.opendaylight.controller.netconf.util.messages;
import com.google.common.base.Preconditions;
-
import java.util.regex.Matcher;
import java.util.regex.Pattern;
package org.opendaylight.controller.netconf.util.messages;
-import java.nio.ByteBuffer;
-
import com.google.common.base.Charsets;
import com.google.common.base.Preconditions;
+import java.nio.ByteBuffer;
/**
* Netconf message header is used only when chunked framing mechanism is
public final class NetconfMessageUtil {
- private static final Logger logger = LoggerFactory.getLogger(NetconfMessageUtil.class);
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfMessageUtil.class);
private NetconfMessageUtil() {}
try {
return input.getTextContent().trim();
} catch (NetconfDocumentedException e) {
- logger.trace("Error fetching inpit text content becauese {}",e);
+ LOG.trace("Error fetching input text content",e);
return null;
}
}
package org.opendaylight.controller.netconf.util.messages;
import com.google.common.base.Preconditions;
-
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
-
-import org.opendaylight.controller.netconf.api.NetconfSession;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.api.NetconfMessage;
+import org.opendaylight.controller.netconf.api.NetconfSession;
import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.controller.netconf.util.xml.XmlUtil;
import org.slf4j.Logger;
import org.w3c.dom.NamedNodeMap;
public final class SendErrorExceptionUtil {
- private static final Logger logger = LoggerFactory.getLogger(SendErrorExceptionUtil.class);
+ private static final Logger LOG = LoggerFactory.getLogger(SendErrorExceptionUtil.class);
private SendErrorExceptionUtil() {}
public static void sendErrorMessage(final NetconfSession session,
final NetconfDocumentedException sendErrorException) {
- logger.trace("Sending error {}", sendErrorException.getMessage(), sendErrorException);
+ LOG.trace("Sending error {}", sendErrorException.getMessage(), sendErrorException);
final Document errorDocument = createDocument(sendErrorException);
ChannelFuture f = session.sendMessage(new NetconfMessage(errorDocument));
f.addListener(new SendErrorVerifyingListener(sendErrorException));
}
public static void sendErrorMessage(Channel channel, NetconfDocumentedException sendErrorException) {
- logger.trace("Sending error {}", sendErrorException.getMessage(), sendErrorException);
+ LOG.trace("Sending error {}", sendErrorException.getMessage(), sendErrorException);
final Document errorDocument = createDocument(sendErrorException);
ChannelFuture f = channel.writeAndFlush(new NetconfMessage(errorDocument));
f.addListener(new SendErrorVerifyingListener(sendErrorException));
public static void sendErrorMessage(NetconfSession session, NetconfDocumentedException sendErrorException,
NetconfMessage incommingMessage) {
final Document errorDocument = createDocument(sendErrorException);
- logger.trace("Sending error {}", XmlUtil.toString(errorDocument));
+ LOG.trace("Sending error {}", XmlUtil.toString(errorDocument));
tryToCopyAttributes(incommingMessage.getDocument(), errorDocument, sendErrorException);
ChannelFuture f = session.sendMessage(new NetconfMessage(errorDocument));
f.addListener(new SendErrorVerifyingListener(sendErrorException));
rpcReply.setAttributeNode((Attr) errorDocument.importNode(attr, true));
}
} catch (final Exception e) {
- logger.warn("Unable to copy incomming attributes to {}, returned rpc-error might be invalid for client",
+ LOG.warn("Unable to copy incomming attributes to {}, returned rpc-error might be invalid for client",
sendErrorException, e);
}
}
import org.slf4j.LoggerFactory;
public final class NetconfConfigUtil {
- private static final Logger logger = LoggerFactory.getLogger(NetconfConfigUtil.class);
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfConfigUtil.class);
private static final String PREFIX_PROP = "netconf.";
try {
return Long.parseLong(timeoutString);
} catch (final NumberFormatException e) {
- logger.warn("Cannot parse {} property: {}, using defaults", key, timeoutString, e);
+ LOG.warn("Cannot parse {} property: {}, using defaults", key, timeoutString, e);
return DEFAULT_TIMEOUT_MILLIS;
}
}
try {
return Optional.of(parseAddress(address, port));
} catch (final RuntimeException e) {
- logger.warn("Unable to parse {} netconf address from {}:{}, fallback to default",
+ LOG.warn("Unable to parse {} netconf address from {}:{}, fallback to default",
infixProp, address, port, e);
}
}
package org.opendaylight.controller.netconf.util.xml;
+import com.google.common.collect.ImmutableMap;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
-
import javax.xml.namespace.NamespaceContext;
-import com.google.common.collect.ImmutableMap;
-
// http://www.ibm.com/developerworks/library/x-nmspccontext/
public class HardcodedNamespaceResolver implements NamespaceContext {
private final Map<String/* prefix */, String/* namespace */> prefixesToNamespaces;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
-
import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
public final class XMLNetconfUtil {
public static final String DEFAULT_NAMESPACE_PREFIX = "";
private final Element element;
- private static final Logger logger = LoggerFactory.getLogger(XmlElement.class);
+ private static final Logger LOG = LoggerFactory.getLogger(XmlElement.class);
private XmlElement(Element element) {
this.element = element;
public void checkNamespace(String expectedNamespace) throws UnexpectedNamespaceException, MissingNameSpaceException {
if (!getNamespace().equals(expectedNamespace))
- {
+ {
throw new UnexpectedNamespaceException(String.format("Unexpected namespace %s should be %s",
getNamespace(),
expectedNamespace),
try {
sb.append(", namespace='").append(getNamespace()).append('\'');
} catch (MissingNameSpaceException e) {
- logger.trace("Missing namespace for element.");
+ LOG.trace("Missing namespace for element.");
}
}
sb.append('}');
package org.opendaylight.controller.netconf.util.xml;
+import com.google.common.base.Preconditions;
import java.io.IOException;
import java.io.InputStream;
-
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import javax.xml.validation.Schema;
import javax.xml.validation.Validator;
-
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
-import com.google.common.base.Preconditions;
-
public final class XmlNetconfValidator {
private static final Schema SCHEMA;
import com.google.common.base.Charsets;
import com.google.common.base.Optional;
-
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
-
import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.validation.SchemaFactory;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
-
import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public static Element createTextElementWithNamespacedContent(Document document, String qName, String prefix,
String namespace, String contentWithoutPrefix) {
- return createTextElementWithNamespacedContent(document, qName, prefix, namespace, contentWithoutPrefix, Optional.<String>absent());
+ return createTextElementWithNamespacedContent(document, qName, prefix, namespace, contentWithoutPrefix, Optional.<String>absent());
}
public static Element createTextElementWithNamespacedContent(Document document, String qName, String prefix,
*/
package org.opendaylight.controller.netconf.util;
-import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
+import static org.hamcrest.CoreMatchers.containsString;
+
import org.junit.Test;
import org.opendaylight.controller.netconf.util.xml.XmlUtil;
import org.w3c.dom.Document;
package org.opendaylight.controller.netconf.util.mapping;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-
public class AbstractLastNetconfOperationTest {
class LastNetconfOperationImplTest extends AbstractLastNetconfOperation {
package org.opendaylight.controller.netconf.util.mapping;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-
public class AbstractNetconfOperationTest {
class NetconfOperationImpl extends AbstractNetconfOperation {
package org.opendaylight.controller.netconf.util.mapping;
+import static org.junit.Assert.assertEquals;
+
import org.junit.Test;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.mapping.api.HandlingPriority;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import static org.junit.Assert.assertEquals;
-
public class AbstractSingletonNetconfOperationTest {
class SingletonNCOperationImpl extends AbstractSingletonNetconfOperation {
package org.opendaylight.controller.netconf.util.messages;
+import static org.junit.Assert.assertEquals;
+
import org.junit.Before;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-
public class NetconfHelloMessageAdditionalHeaderTest {
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+
import com.google.common.base.Optional;
import java.util.Set;
import org.junit.Before;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+
import com.google.common.base.Charsets;
import org.junit.Test;
package org.opendaylight.controller.netconf.util.messages;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.util.Collection;
import org.junit.Test;
import org.opendaylight.controller.netconf.api.NetconfMessage;
import org.opendaylight.controller.netconf.util.test.XmlFileLoader;
import org.w3c.dom.Document;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
public class NetconfMessageUtilTest {
@Test
public void testNetconfMessageUtil() throws Exception {
package org.opendaylight.controller.netconf.util.messages;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.util.concurrent.GenericFutureListener;
import org.opendaylight.controller.netconf.util.test.XmlFileLoader;
import org.w3c.dom.Document;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.*;
-
public class SendErrorExceptionUtilTest {
NetconfSession netconfSession;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
+
import com.google.common.base.Optional;
import io.netty.channel.local.LocalAddress;
import java.net.InetSocketAddress;
package org.opendaylight.controller.netconf.util.test;
+import com.google.common.base.Charsets;
+import com.google.common.base.Preconditions;
+import com.google.common.io.CharStreams;
+import com.google.common.io.InputSupplier;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-
import javax.xml.parsers.ParserConfigurationException;
-
import org.opendaylight.controller.netconf.api.NetconfMessage;
import org.opendaylight.controller.netconf.util.xml.XmlUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
-import com.google.common.base.Charsets;
-import com.google.common.base.Preconditions;
-import com.google.common.io.CharStreams;
-import com.google.common.io.InputSupplier;
-
public class XmlFileLoader {
public static NetconfMessage xmlFileToNetconfMessage(final String fileName) throws IOException, SAXException,
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import com.google.common.base.Optional;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import com.google.common.base.Optional;
-
public class XmlElementTest {
private final String elementAsString = "<top xmlns=\"namespace\" xmlns:a=\"attrNamespace\" a:attr1=\"value1\" attr2=\"value2\">" +
<lexical-values/>
</fidelity>
</start-exi>
-</rpc>
+</rpc>
\ No newline at end of file
<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<stop-exi xmlns="urn:ietf:params:xml:ns:netconf:exi:1.0"/>
-</rpc>
+</rpc>
\ No newline at end of file
<enunciate.version>1.26.2</enunciate.version>
</properties>
<dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>clustering.services</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>configuration</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>networkconfig.neutron</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal</artifactId>
- </dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
- <Import-Package>org.opendaylight.controller.clustering.services,
- org.opendaylight.controller.configuration,
- org.opendaylight.controller.sal.core,
- org.opendaylight.controller.sal.utils,
- org.apache.felix.dm,
- org.apache.commons.net.util,
- org.osgi.service.component,
- org.opendaylight.controller.networkconfig.neutron,
- org.slf4j,
- javax.xml.bind.annotation</Import-Package>
+ <Import-Package>*</Import-Package>
<Bundle-Activator>org.opendaylight.controller.networkconfig.neutron.implementation.Activator</Bundle-Activator>
</instructions>
<manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
package org.opendaylight.controller.networkconfig.neutron.implementation;
-import org.apache.felix.dm.Component;
-import org.opendaylight.controller.clustering.services.IClusterContainerServices;
-import org.opendaylight.controller.configuration.IConfigurationContainerAware;
-import org.opendaylight.controller.configuration.IConfigurationContainerService;
+import java.util.ArrayList;
+import java.util.List;
+
import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallCRUD;
import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallPolicyCRUD;
import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallRuleCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronFloatingIPCRUD;
import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerCRUD;
import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerHealthMonitorCRUD;
import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerListenerCRUD;
import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityGroupCRUD;
import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityRuleCRUD;
import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD;
-import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-public class Activator extends ComponentActivatorAbstractBase {
+public class Activator implements BundleActivator {
protected static final Logger logger = LoggerFactory
.getLogger(Activator.class);
+ private List<ServiceRegistration<?>> registrations = new ArrayList<ServiceRegistration<?>>();
- /**
- * Function called when the activator starts just after some
- * initializations are done by the
- * ComponentActivatorAbstractBase.
- *
- */
- @Override
- public void init() {
-
- }
-
- /**
- * Function called when the activator stops just before the
- * cleanup done by ComponentActivatorAbstractBase
- *
- */
- @Override
- public void destroy() {
-
- }
-
- /**
- * Function that is used to communicate to dependency manager the
- * list of known implementations for services inside a container
- *
- *
- * @return An array containing all the CLASS objects that will be
- * instantiated in order to get an fully working implementation
- * Object
- */
- @Override
- public Object[] getImplementations() {
- Object[] res = { NeutronFloatingIPInterface.class,
- NeutronRouterInterface.class,
- NeutronPortInterface.class,
- NeutronSubnetInterface.class,
- NeutronNetworkInterface.class,
- NeutronSecurityGroupInterface.class,
- NeutronSecurityRuleInterface.class,
- NeutronFirewallInterface.class,
- NeutronFirewallPolicyInterface.class,
- NeutronFirewallRuleInterface.class,
- NeutronLoadBalancerInterface.class,
- NeutronLoadBalancerPoolInterface.class,
- NeutronLoadBalancerListenerInterface.class,
- NeutronLoadBalancerHealthMonitorInterface.class,
- NeutronLoadBalancerPoolMemberInterface.class};
- return res;
- }
-
- /**
- * Function that is called when configuration of the dependencies
- * is required.
- *
- * @param c dependency manager Component object, used for
- * configuring the dependencies exported and imported
- * @param imp Implementation class that is being configured,
- * needed as long as the same routine can configure multiple
- * implementations
- * @param containerName The containerName being configured, this allow
- * also optional per-container different behavior if needed, usually
- * should not be the case though.
- */
@Override
- public void configureInstance(Component c, Object imp, String containerName) {
- if (imp.equals(NeutronFloatingIPInterface.class)) {
- // export the service
- c.setInterface(
- new String[] { INeutronFloatingIPCRUD.class.getName(),
- IConfigurationContainerAware.class.getName()}, null);
- Dictionary<String, String> props = new Hashtable<String, String>();
- props.put("salListenerName", "neutron");
- c.add(createContainerServiceDependency(containerName)
- .setService(IClusterContainerServices.class)
- .setCallbacks("setClusterContainerService",
- "unsetClusterContainerService").setRequired(true));
- c.add(createContainerServiceDependency(containerName).setService(
- IConfigurationContainerService.class).setCallbacks(
- "setConfigurationContainerService",
- "unsetConfigurationContainerService").setRequired(true));
- }
- if (imp.equals(NeutronRouterInterface.class)) {
- // export the service
- c.setInterface(
- new String[] { INeutronRouterCRUD.class.getName(),
- IConfigurationContainerAware.class.getName()}, null);
- Dictionary<String, String> props = new Hashtable<String, String>();
- props.put("salListenerName", "neutron");
- c.add(createContainerServiceDependency(containerName)
- .setService(IClusterContainerServices.class)
- .setCallbacks("setClusterContainerService",
- "unsetClusterContainerService").setRequired(true));
- c.add(createContainerServiceDependency(containerName).setService(
- IConfigurationContainerService.class).setCallbacks(
- "setConfigurationContainerService",
- "unsetConfigurationContainerService").setRequired(true));
+ public void start(BundleContext context) throws Exception {
+ NeutronRouterInterface neutronRouterInterface = new NeutronRouterInterface();
+ ServiceRegistration<INeutronRouterCRUD> neutronRouterInterfaceRegistration = context.registerService(INeutronRouterCRUD.class, neutronRouterInterface, null);
+ if(neutronRouterInterfaceRegistration != null) {
+ registrations.add(neutronRouterInterfaceRegistration);
}
- if (imp.equals(NeutronPortInterface.class)) {
- // export the service
- c.setInterface(
- new String[] { INeutronPortCRUD.class.getName(),
- IConfigurationContainerAware.class.getName()}, null);
- Dictionary<String, String> props = new Hashtable<String, String>();
- props.put("salListenerName", "neutron");
- c.add(createContainerServiceDependency(containerName)
- .setService(IClusterContainerServices.class)
- .setCallbacks("setClusterContainerService",
- "unsetClusterContainerService").setRequired(true));
- c.add(createContainerServiceDependency(containerName).setService(
- IConfigurationContainerService.class).setCallbacks(
- "setConfigurationContainerService",
- "unsetConfigurationContainerService").setRequired(true));
+ NeutronPortInterface neutronPortInterface = new NeutronPortInterface();
+ ServiceRegistration<INeutronPortCRUD> neutronPortInterfaceRegistration = context.registerService(INeutronPortCRUD.class, neutronPortInterface, null);
+ if(neutronPortInterfaceRegistration != null) {
+ registrations.add(neutronPortInterfaceRegistration);
}
- if (imp.equals(NeutronSubnetInterface.class)) {
- // export the service
- c.setInterface(
- new String[] { INeutronSubnetCRUD.class.getName(),
- IConfigurationContainerAware.class.getName()}, null);
- Dictionary<String, String> props = new Hashtable<String, String>();
- props.put("salListenerName", "neutron");
- c.add(createContainerServiceDependency(containerName)
- .setService(IClusterContainerServices.class)
- .setCallbacks("setClusterContainerService",
- "unsetClusterContainerService").setRequired(true));
- c.add(createContainerServiceDependency(containerName).setService(
- IConfigurationContainerService.class).setCallbacks(
- "setConfigurationContainerService",
- "unsetConfigurationContainerService").setRequired(true));
+
+ NeutronSubnetInterface neutronSubnetInterface = new NeutronSubnetInterface();
+ ServiceRegistration<INeutronSubnetCRUD> neutronSubnetInterfaceRegistration = context.registerService(INeutronSubnetCRUD.class, neutronSubnetInterface, null);
+ if(neutronSubnetInterfaceRegistration != null) {
+ registrations.add(neutronSubnetInterfaceRegistration);
}
- if (imp.equals(NeutronNetworkInterface.class)) {
- // export the service
- c.setInterface(
- new String[] { INeutronNetworkCRUD.class.getName(),
- IConfigurationContainerAware.class.getName()}, null);
- Dictionary<String, String> props = new Hashtable<String, String>();
- props.put("salListenerName", "neutron");
- c.add(createContainerServiceDependency(containerName)
- .setService(IClusterContainerServices.class)
- .setCallbacks("setClusterContainerService",
- "unsetClusterContainerService").setRequired(true));
- c.add(createContainerServiceDependency(containerName).setService(
- IConfigurationContainerService.class).setCallbacks(
- "setConfigurationContainerService",
- "unsetConfigurationContainerService").setRequired(true));
+
+ NeutronNetworkInterface neutronNetworkInterface = new NeutronNetworkInterface();
+ ServiceRegistration<INeutronNetworkCRUD> neutronNetworkInterfaceRegistration = context.registerService(INeutronNetworkCRUD.class, neutronNetworkInterface, null);
+ if(neutronNetworkInterfaceRegistration != null) {
+ registrations.add(neutronNetworkInterfaceRegistration);
}
- if (imp.equals(NeutronSecurityGroupInterface.class)) {
- // export the service
- c.setInterface(
- new String[] { INeutronSecurityGroupCRUD.class.getName(),
- IConfigurationContainerAware.class.getName()}, null);
- Dictionary<String, String> props = new Hashtable<String, String>();
- props.put("salListenerName", "neutron");
- c.add(createContainerServiceDependency(containerName)
- .setService(IClusterContainerServices.class)
- .setCallbacks("setClusterContainerService",
- "unsetClusterContainerService").setRequired(true));
- c.add(createContainerServiceDependency(containerName).setService(
- IConfigurationContainerService.class).setCallbacks(
- "setConfigurationContainerService",
- "unsetConfigurationContainerService").setRequired(true));
+
+ NeutronSecurityGroupInterface neutronSecurityGroupInterface = new NeutronSecurityGroupInterface();
+ ServiceRegistration<INeutronSecurityGroupCRUD> neutronSecurityGroupInterfaceRegistration = context.registerService(INeutronSecurityGroupCRUD.class, neutronSecurityGroupInterface, null);
+ if(neutronSecurityGroupInterfaceRegistration != null) {
+ registrations.add(neutronSecurityGroupInterfaceRegistration);
}
- if (imp.equals(NeutronSecurityRuleInterface.class)) {
- // export the service
- c.setInterface(
- new String[] { INeutronSecurityRuleCRUD.class.getName(),
- IConfigurationContainerAware.class.getName()}, null);
- Dictionary<String, String> props = new Hashtable<String, String>();
- props.put("salListenerName", "neutron");
- c.add(createContainerServiceDependency(containerName)
- .setService(IClusterContainerServices.class)
- .setCallbacks("setClusterContainerService",
- "unsetClusterContainerService").setRequired(true));
- c.add(createContainerServiceDependency(containerName).setService(
- IConfigurationContainerService.class).setCallbacks(
- "setConfigurationContainerService",
- "unsetConfigurationContainerService").setRequired(true));
+
+ NeutronSecurityRuleInterface neutronSecurityRuleInterface = new NeutronSecurityRuleInterface();
+ ServiceRegistration<INeutronSecurityRuleCRUD> neutronSecurityRuleInterfaceRegistration = context.registerService(INeutronSecurityRuleCRUD.class, neutronSecurityRuleInterface, null);
+ if(neutronSecurityRuleInterfaceRegistration != null) {
+ registrations.add(neutronSecurityRuleInterfaceRegistration);
}
- if (imp.equals(NeutronFirewallInterface.class)) {
- // export the service
- c.setInterface(
- new String[] { INeutronFirewallCRUD.class.getName(),
- IConfigurationContainerAware.class.getName()}, null);
- Dictionary<String, String> props = new Hashtable<String, String>();
- props.put("salListenerName", "neutron");
- c.add(createContainerServiceDependency(containerName)
- .setService(IClusterContainerServices.class)
- .setCallbacks("setClusterContainerService",
- "unsetClusterContainerService").setRequired(true));
- c.add(createContainerServiceDependency(containerName).setService(
- IConfigurationContainerService.class).setCallbacks(
- "setConfigurationContainerService",
- "unsetConfigurationContainerService").setRequired(true));
+
+ NeutronFirewallInterface neutronFirewallInterface = new NeutronFirewallInterface();
+ ServiceRegistration<INeutronFirewallCRUD> neutronFirewallInterfaceRegistration = context.registerService(INeutronFirewallCRUD.class, neutronFirewallInterface, null);
+ if(neutronFirewallInterfaceRegistration != null) {
+ registrations.add(neutronFirewallInterfaceRegistration);
}
- if (imp.equals(NeutronFirewallPolicyInterface.class)) {
- // export the service
- c.setInterface(
- new String[] { INeutronFirewallPolicyCRUD.class.getName(),
- IConfigurationContainerAware.class.getName()}, null);
- Dictionary<String, String> props = new Hashtable<String, String>();
- props.put("salListenerName", "neutron");
- c.add(createContainerServiceDependency(containerName)
- .setService(IClusterContainerServices.class)
- .setCallbacks("setClusterContainerService",
- "unsetClusterContainerService").setRequired(true));
- c.add(createContainerServiceDependency(containerName).setService(
- IConfigurationContainerService.class).setCallbacks(
- "setConfigurationContainerService",
- "unsetConfigurationContainerService").setRequired(true));
+
+ NeutronFirewallPolicyInterface neutronFirewallPolicyInterface = new NeutronFirewallPolicyInterface();
+ ServiceRegistration<INeutronFirewallPolicyCRUD> neutronFirewallPolicyInterfaceRegistration = context.registerService(INeutronFirewallPolicyCRUD.class, neutronFirewallPolicyInterface, null);
+ if(neutronFirewallPolicyInterfaceRegistration != null) {
+ registrations.add(neutronFirewallPolicyInterfaceRegistration);
}
- if (imp.equals(NeutronFirewallRuleInterface.class)) {
- // export the service
- c.setInterface(
- new String[] { INeutronFirewallRuleCRUD.class.getName(),
- IConfigurationContainerAware.class.getName()}, null);
- Dictionary<String, String> props = new Hashtable<String, String>();
- props.put("salListenerName", "neutron");
- c.add(createContainerServiceDependency(containerName)
- .setService(IClusterContainerServices.class)
- .setCallbacks("setClusterContainerService",
- "unsetClusterContainerService").setRequired(true));
- c.add(createContainerServiceDependency(containerName).setService(
- IConfigurationContainerService.class).setCallbacks(
- "setConfigurationContainerService",
- "unsetConfigurationContainerService").setRequired(true));
+
+ NeutronFirewallRuleInterface neutronFirewallRuleInterface = new NeutronFirewallRuleInterface();
+ ServiceRegistration<INeutronFirewallRuleCRUD> neutronFirewallRuleInterfaceRegistration = context.registerService(INeutronFirewallRuleCRUD.class, neutronFirewallRuleInterface, null);
+ if(neutronFirewallRuleInterfaceRegistration != null) {
+ registrations.add(neutronFirewallRuleInterfaceRegistration);
}
- if (imp.equals(NeutronLoadBalancerInterface.class)) {
- // export the service
- c.setInterface(
- new String[] { INeutronLoadBalancerCRUD.class.getName(),
- IConfigurationContainerAware.class.getName()}, null);
- Dictionary<String, String> props = new Hashtable<String, String>();
- props.put("salListenerName", "neutron");
- c.add(createContainerServiceDependency(containerName)
- .setService(IClusterContainerServices.class)
- .setCallbacks("setClusterContainerService",
- "unsetClusterContainerService").setRequired(true));
- c.add(createContainerServiceDependency(containerName).setService(
- IConfigurationContainerService.class).setCallbacks(
- "setConfigurationContainerService",
- "unsetConfigurationContainerService").setRequired(true));
+
+ NeutronLoadBalancerInterface neutronLoadBalancerInterface = new NeutronLoadBalancerInterface();
+ ServiceRegistration<INeutronLoadBalancerCRUD> neutronLoadBalancerInterfaceRegistration = context.registerService(INeutronLoadBalancerCRUD.class, neutronLoadBalancerInterface, null);
+ if(neutronFirewallInterfaceRegistration != null) {
+ registrations.add(neutronLoadBalancerInterfaceRegistration);
}
- if (imp.equals(NeutronLoadBalancerListenerInterface.class)) {
- // export the service
- c.setInterface(
- new String[] { INeutronLoadBalancerListenerCRUD.class.getName(),
- IConfigurationContainerAware.class.getName()}, null);
- Dictionary<String, String> props = new Hashtable<String, String>();
- props.put("salListenerName", "neutron");
- c.add(createContainerServiceDependency(containerName)
- .setService(IClusterContainerServices.class)
- .setCallbacks("setClusterContainerService",
- "unsetClusterContainerService").setRequired(true));
- c.add(createContainerServiceDependency(containerName).setService(
- IConfigurationContainerService.class).setCallbacks(
- "setConfigurationContainerService",
- "unsetConfigurationContainerService").setRequired(true));
+
+ NeutronLoadBalancerPoolInterface neutronLoadBalancerPoolInterface = new NeutronLoadBalancerPoolInterface();
+ ServiceRegistration<INeutronLoadBalancerPoolCRUD> neutronLoadBalancerPoolInterfaceRegistration = context.registerService(INeutronLoadBalancerPoolCRUD.class, neutronLoadBalancerPoolInterface, null);
+ if(neutronLoadBalancerPoolInterfaceRegistration != null) {
+ registrations.add(neutronLoadBalancerPoolInterfaceRegistration);
}
- if (imp.equals(NeutronLoadBalancerPoolInterface.class)) {
- // export the service
- c.setInterface(
- new String[] { INeutronLoadBalancerPoolCRUD.class.getName(),
- IConfigurationContainerAware.class.getName()}, null);
- Dictionary<String, String> props = new Hashtable<String, String>();
- props.put("salListenerName", "neutron");
- c.add(createContainerServiceDependency(containerName)
- .setService(IClusterContainerServices.class)
- .setCallbacks("setClusterContainerService",
- "unsetClusterContainerService").setRequired(true));
- c.add(createContainerServiceDependency(containerName).setService(
- IConfigurationContainerService.class).setCallbacks(
- "setConfigurationContainerService",
- "unsetConfigurationContainerService").setRequired(true));
+
+ NeutronLoadBalancerListenerInterface neutronLoadBalancerListenerInterface = new NeutronLoadBalancerListenerInterface();
+ ServiceRegistration<INeutronLoadBalancerListenerCRUD> neutronLoadBalancerListenerInterfaceRegistration = context.registerService(INeutronLoadBalancerListenerCRUD.class, neutronLoadBalancerListenerInterface, null);
+ if(neutronLoadBalancerListenerInterfaceRegistration != null) {
+ registrations.add(neutronLoadBalancerListenerInterfaceRegistration);
}
- if (imp.equals(NeutronLoadBalancerHealthMonitorInterface.class)) {
- // export the service
- c.setInterface(
- new String[] { INeutronLoadBalancerHealthMonitorCRUD.class.getName(),
- IConfigurationContainerAware.class.getName()}, null);
- Dictionary<String, String> props = new Hashtable<String, String>();
- props.put("salListenerName", "neutron");
- c.add(createContainerServiceDependency(containerName)
- .setService(IClusterContainerServices.class)
- .setCallbacks("setClusterContainerService",
- "unsetClusterContainerService").setRequired(true));
- c.add(createContainerServiceDependency(containerName).setService(
- IConfigurationContainerService.class).setCallbacks(
- "setConfigurationContainerService",
- "unsetConfigurationContainerService").setRequired(true));
+
+ NeutronLoadBalancerHealthMonitorInterface neutronLoadBalancerHealthMonitorInterface = new NeutronLoadBalancerHealthMonitorInterface();
+ ServiceRegistration<INeutronLoadBalancerHealthMonitorCRUD> neutronLoadBalancerHealthMonitorInterfaceRegistration = context.registerService(INeutronLoadBalancerHealthMonitorCRUD.class, neutronLoadBalancerHealthMonitorInterface, null);
+ if(neutronLoadBalancerHealthMonitorInterfaceRegistration != null) {
+ registrations.add(neutronLoadBalancerHealthMonitorInterfaceRegistration);
}
- if (imp.equals(NeutronLoadBalancerPoolMemberInterface.class)) {
- // export the service
- c.setInterface(
- new String[] { INeutronLoadBalancerPoolMemberCRUD.class.getName(),
- IConfigurationContainerAware.class.getName()}, null);
- Dictionary<String, String> props = new Hashtable<String, String>();
- props.put("salListenerName", "neutron");
- c.add(createContainerServiceDependency(containerName)
- .setService(IClusterContainerServices.class)
- .setCallbacks("setClusterContainerService",
- "unsetClusterContainerService").setRequired(true));
- c.add(createContainerServiceDependency(containerName).setService(
- IConfigurationContainerService.class).setCallbacks(
- "setConfigurationContainerService",
- "unsetConfigurationContainerService").setRequired(true));
+
+ NeutronLoadBalancerPoolMemberInterface neutronLoadBalancerPoolMemberInterface = new NeutronLoadBalancerPoolMemberInterface();
+ ServiceRegistration<INeutronLoadBalancerPoolMemberCRUD> neutronLoadBalancerPoolMemberInterfaceRegistration = context.registerService(INeutronLoadBalancerPoolMemberCRUD.class, neutronLoadBalancerPoolMemberInterface, null);
+ if(neutronLoadBalancerPoolMemberInterfaceRegistration != null) {
+ registrations.add(neutronLoadBalancerPoolMemberInterfaceRegistration);
}
+
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ for(ServiceRegistration registration : registrations) {
+ if(registration != null) {
+ registration.unregister();
+ }
+ }
+
}
-}
+}
\ No newline at end of file
package org.opendaylight.controller.networkconfig.neutron.implementation;
-import org.apache.felix.dm.Component;
-import org.opendaylight.controller.clustering.services.CacheConfigException;
-import org.opendaylight.controller.clustering.services.CacheExistException;
-import org.opendaylight.controller.clustering.services.IClusterContainerServices;
-import org.opendaylight.controller.clustering.services.IClusterServices;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-import org.opendaylight.controller.configuration.IConfigurationContainerAware;
-import org.opendaylight.controller.configuration.IConfigurationContainerService;
import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallCRUD;
import org.opendaylight.controller.networkconfig.neutron.NeutronFirewall;
-import org.opendaylight.controller.sal.utils.IObjectReader;
-import org.opendaylight.controller.sal.utils.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.ObjectInputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-public class NeutronFirewallInterface implements INeutronFirewallCRUD, IConfigurationContainerAware, IObjectReader {
+public class NeutronFirewallInterface implements INeutronFirewallCRUD {
private static final Logger logger = LoggerFactory.getLogger(NeutronFirewallInterface.class);
- private static final String FILE_NAME = "neutron.firewall.conf";
- private String containerName = null;
- private IClusterContainerServices clusterContainerService = null;
- private IConfigurationContainerService configurationService;
- private ConcurrentMap<String, NeutronFirewall> firewallDB;
-
- // methods needed for creating caches
- void setClusterContainerService(IClusterContainerServices s) {
- logger.debug("Cluster Service set");
- clusterContainerService = s;
- }
-
- void unsetClusterContainerService(IClusterContainerServices s) {
- if (clusterContainerService == s) {
- logger.debug("Cluster Service removed!");
- clusterContainerService = null;
- }
- }
-
- public void setConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service set: {}", service);
- configurationService = service;
- }
-
- public void unsetConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service removed: {}", service);
- configurationService = null;
- }
-
- private void allocateCache() {
- if (this.clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't create cache");
- return;
- }
- logger.debug("Creating Cache for Neutron Firewall");
- try {
- // neutron caches
- this.clusterContainerService.createCache("neutronFirewalls",
- EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL));
- } catch (CacheConfigException cce) {
- logger.error("Cache couldn't be created for Neutron Firewall - check cache mode");
- } catch (CacheExistException cce) {
- logger.error("Cache for Neutron Firewall already exists, destroy and recreate");
- }
- logger.debug("Cache successfully created for Neutron Firewall");
- }
-
- @SuppressWarnings ({"unchecked"})
- private void retrieveCache() {
- if (clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't retrieve cache");
- return;
- }
-
- logger.debug("Retrieving cache for Neutron Firewall");
- firewallDB = (ConcurrentMap<String, NeutronFirewall>) clusterContainerService
- .getCache("neutronFirewalls");
- if (firewallDB == null) {
- logger.error("Cache couldn't be retrieved for Neutron Firewall");
- }
- logger.debug("Cache was successfully retrieved for Neutron Firewall");
- }
-
- private void destroyCache() {
- if (clusterContainerService == null) {
- logger.error("un-initialized clusterMger, can't destroy cache");
- return;
- }
- logger.debug("Destroying Cache for HostTracker");
- clusterContainerService.destroyCache("neutronFirewalls");
- }
-
- private void startUp() {
- allocateCache();
- retrieveCache();
- loadConfiguration();
- }
-
- /**
- * Function called by the dependency manager when all the required
- * dependencies are satisfied
- */
- void init(Component c) {
- Dictionary<?, ?> props = c.getServiceProperties();
- if (props != null) {
- this.containerName = (String) props.get("containerName");
- logger.debug("Running containerName: {}", this.containerName);
- } else {
- // In the Global instance case the containerName is empty
- this.containerName = "";
- }
- startUp();
- }
-
- /**
- * Function called by the dependency manager when at least one dependency
- * become unsatisfied or when the component is shutting down because for
- * example bundle is being stopped.
- */
- void destroy() {
- destroyCache();
- }
-
- /**
- * Function called by dependency manager after "init ()" is called and after
- * the services provided by the class are registered in the service registry
- */
- void start() {
- }
-
- /**
- * Function called by the dependency manager before the services exported by
- * the component are unregistered, this will be followed by a "destroy ()"
- * calls
- */
- void stop() {
- }
+ private ConcurrentMap<String, NeutronFirewall> firewallDB = new ConcurrentHashMap<String, NeutronFirewall>();
// this method uses reflection to update an object from it's delta.
return !neutronFirewallExists(firewallUUID);
}
- private void loadConfiguration() {
- for (ConfigurationObject conf : configurationService.retrieveConfiguration(this, FILE_NAME)) {
- NeutronFirewall nn = (NeutronFirewall) conf;
- firewallDB.put(nn.getFirewallUUID(), nn);
- }
- }
-
- @Override
- public Status saveConfiguration() {
- return configurationService.persistConfiguration(new ArrayList<ConfigurationObject>(firewallDB.values()),
- FILE_NAME);
- }
-
- @Override
- public Object readObject(ObjectInputStream ois) throws FileNotFoundException, IOException, ClassNotFoundException {
- return ois.readObject();
- }
}
\ No newline at end of file
package org.opendaylight.controller.networkconfig.neutron.implementation;
-import org.apache.felix.dm.Component;
-import org.opendaylight.controller.clustering.services.CacheConfigException;
-import org.opendaylight.controller.clustering.services.CacheExistException;
-import org.opendaylight.controller.clustering.services.IClusterContainerServices;
-import org.opendaylight.controller.clustering.services.IClusterServices;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-import org.opendaylight.controller.configuration.IConfigurationContainerAware;
-import org.opendaylight.controller.configuration.IConfigurationContainerService;
import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallPolicyCRUD;
import org.opendaylight.controller.networkconfig.neutron.NeutronFirewallPolicy;
-import org.opendaylight.controller.sal.utils.IObjectReader;
-import org.opendaylight.controller.sal.utils.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.ObjectInputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-public class NeutronFirewallPolicyInterface implements INeutronFirewallPolicyCRUD, IConfigurationContainerAware, IObjectReader {
+public class NeutronFirewallPolicyInterface implements INeutronFirewallPolicyCRUD {
private static final Logger logger = LoggerFactory.getLogger(NeutronFirewallPolicyInterface.class);
- private static final String FILE_NAME ="neutron.firewallpolicy.conf";
- private String containerName = null;
- private IClusterContainerServices clusterContainerService = null;
- private IConfigurationContainerService configurationService;
- private ConcurrentMap<String, NeutronFirewallPolicy> firewallPolicyDB;
-
- // methods needed for creating caches
- void setClusterContainerService(IClusterContainerServices s) {
- logger.debug("Cluster Service set");
- clusterContainerService = s;
- }
-
- void unsetClusterContainerService(IClusterContainerServices s) {
- if (clusterContainerService == s) {
- logger.debug("Cluster Service removed!");
- clusterContainerService = null;
- }
- }
-
- public void setConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service set: {}", service);
- configurationService = service;
- }
-
- public void unsetConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service removed: {}", service);
- configurationService = null;
- }
-
- private void allocateCache() {
- if (this.clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't create cache");
- return;
- }
- logger.debug("Creating Cache for Neutron Firewall Rule");
- try {
- // neutron caches
- this.clusterContainerService.createCache("neutronFirewallPolicies",
- EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL));
- } catch (CacheConfigException cce) {
- logger.error("Cache couldn't be created for Neutron Firewall Rule - check cache mode");
- } catch (CacheExistException cce) {
- logger.error("Cache for Neutron Firewall Rule already exists, destroy and recreate");
- }
- logger.debug("Cache successfully created for Neutron Firewall Rule");
- }
-
- @SuppressWarnings({ "unchecked" })
- private void retrieveCache() {
- if (clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't retrieve cache");
- return;
- }
-
- logger.debug("Retrieving cache for Neutron Firewall Rule");
- firewallPolicyDB = (ConcurrentMap<String, NeutronFirewallPolicy>) clusterContainerService
- .getCache("neutronFirewallPolicies");
- if (firewallPolicyDB == null) {
- logger.error("Cache couldn't be retrieved for Neutron Firewall Rule");
- }
- logger.debug("Cache was successfully retrieved for Neutron Firewall Rule");
- }
-
- private void destroyCache() {
- if (clusterContainerService == null) {
- logger.error("un-initialized clusterMger, can't destroy cache");
- return;
- }
- logger.debug("Destroying Cache for HostTracker");
- clusterContainerService.destroyCache("neutronFirewallPolicies");
- }
-
- private void startUp() {
- allocateCache();
- retrieveCache();
- loadConfiguration();
- }
-
- /**
- * Function called by the dependency manager when all the required
- * dependencies are satisfied
- *
- */
- void init(Component c) {
- Dictionary<?, ?> props = c.getServiceProperties();
- if (props != null) {
- this.containerName = (String) props.get("containerName");
- logger.debug("Running containerName: {}", this.containerName);
- } else {
- // In the Global instance case the containerName is empty
- this.containerName = "";
- }
- startUp();
- }
-
- /**
- * Function called by the dependency manager when at least one dependency
- * become unsatisfied or when the component is shutting down because for
- * example bundle is being stopped.
- *
- */
- void destroy() {
- destroyCache();
- }
-
- /**
- * Function called by dependency manager after "init ()" is called and after
- * the services provided by the class are registered in the service registry
- *
- */
- void start() {
- }
-
- /**
- * Function called by the dependency manager before the services exported by
- * the component are unregistered, this will be followed by a "destroy ()"
- * calls
- *
- */
- void stop() {
- }
+ private ConcurrentMap<String, NeutronFirewallPolicy> firewallPolicyDB = new ConcurrentHashMap<String, NeutronFirewallPolicy>();
// this method uses reflection to update an object from it's delta.
return !neutronFirewallPolicyExists(firewallPolicyUUID);
}
- private void loadConfiguration() {
- for (ConfigurationObject conf : configurationService.retrieveConfiguration(this, FILE_NAME)) {
- NeutronFirewallPolicy nn = (NeutronFirewallPolicy) conf;
- firewallPolicyDB.put(nn.getFirewallPolicyUUID(), nn);
- }
- }
-
- @Override
- public Status saveConfiguration() {
- return configurationService.persistConfiguration(new ArrayList<ConfigurationObject>(firewallPolicyDB.values()),
- FILE_NAME);
- }
-
- @Override
- public Object readObject(ObjectInputStream ois) throws FileNotFoundException, IOException, ClassNotFoundException {
- return ois.readObject();
- }
-
}
\ No newline at end of file
package org.opendaylight.controller.networkconfig.neutron.implementation;
-import org.apache.felix.dm.Component;
-import org.opendaylight.controller.clustering.services.CacheConfigException;
-import org.opendaylight.controller.clustering.services.CacheExistException;
-import org.opendaylight.controller.clustering.services.IClusterContainerServices;
-import org.opendaylight.controller.clustering.services.IClusterServices;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-import org.opendaylight.controller.configuration.IConfigurationContainerAware;
-import org.opendaylight.controller.configuration.IConfigurationContainerService;
import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallRuleCRUD;
import org.opendaylight.controller.networkconfig.neutron.NeutronFirewallRule;
-import org.opendaylight.controller.sal.utils.IObjectReader;
-import org.opendaylight.controller.sal.utils.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.ObjectInputStream;
+
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-public class NeutronFirewallRuleInterface implements INeutronFirewallRuleCRUD, IConfigurationContainerAware, IObjectReader {
+public class NeutronFirewallRuleInterface implements INeutronFirewallRuleCRUD {
private static final Logger logger = LoggerFactory.getLogger(NeutronFirewallRuleInterface.class);
- private static final String FILE_NAME ="neutron.firewallrules.conf";
- private String containerName = null;
-
- private IClusterContainerServices clusterContainerService = null;
- private IConfigurationContainerService configurationService;
- private ConcurrentMap<String, NeutronFirewallRule> firewallRuleDB;
-
- // methods needed for creating caches
- void setClusterContainerService(IClusterContainerServices s) {
- logger.debug("Cluster Service set");
- clusterContainerService = s;
- }
-
- void unsetClusterContainerService(IClusterContainerServices s) {
- if (clusterContainerService == s) {
- logger.debug("Cluster Service removed!");
- clusterContainerService = null;
- }
- }
-
- public void setConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service set: {}", service);
- configurationService = service;
- }
-
- public void unsetConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service removed: {}", service);
- configurationService = null;
- }
-
- private void allocateCache() {
- if (this.clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't create cache");
- return;
- }
- logger.debug("Creating Cache for Neutron Firewall Rule");
- try {
- // neutron caches
- this.clusterContainerService.createCache("neutronFirewallRules",
- EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL));
- } catch (CacheConfigException cce) {
- logger.error("Cache couldn't be created for Neutron Firewall Rule - check cache mode");
- } catch (CacheExistException cce) {
- logger.error("Cache for Neutron Firewall Rule already exists, destroy and recreate");
- }
- logger.debug("Cache successfully created for Neutron Firewall Rule");
- }
-
- @SuppressWarnings({ "unchecked" })
- private void retrieveCache() {
- if (clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't retrieve cache");
- return;
- }
-
- logger.debug("Retrieving cache for Neutron Firewall Rule");
- firewallRuleDB = (ConcurrentMap<String, NeutronFirewallRule>) clusterContainerService
- .getCache("neutronFirewallRules");
- if (firewallRuleDB == null) {
- logger.error("Cache couldn't be retrieved for Neutron Firewall Rule");
- }
- logger.debug("Cache was successfully retrieved for Neutron Firewall Rule");
- }
-
- private void destroyCache() {
- if (clusterContainerService == null) {
- logger.error("un-initialized clusterMger, can't destroy cache");
- return;
- }
- logger.debug("Destroying Cache for HostTracker");
- clusterContainerService.destroyCache("neutronFirewallRules");
- }
-
- private void startUp() {
- allocateCache();
- retrieveCache();
- loadConfiguration();
- }
- /**
- * Function called by the dependency manager when all the required
- * dependencies are satisfied
- *
- */
- void init(Component c) {
- Dictionary<?, ?> props = c.getServiceProperties();
- if (props != null) {
- this.containerName = (String) props.get("containerName");
- logger.debug("Running containerName: {}", this.containerName);
- } else {
- // In the Global instance case the containerName is empty
- this.containerName = "";
- }
- startUp();
- }
-
- /**
- * Function called by the dependency manager when at least one dependency
- * become unsatisfied or when the component is shutting down because for
- * example bundle is being stopped.
- *
- */
- void destroy() {
- destroyCache();
- }
-
- /**
- * Function called by dependency manager after "init ()" is called and after
- * the services provided by the class are registered in the service registry
- *
- */
- void start() {
- }
-
- /**
- * Function called by the dependency manager before the services exported by
- * the component are unregistered, this will be followed by a "destroy ()"
- * calls
- *
- */
- void stop() {
- }
+ private ConcurrentMap<String, NeutronFirewallRule> firewallRuleDB = new ConcurrentHashMap<String, NeutronFirewallRule>();
// this method uses reflection to update an object from it's delta.
return !neutronFirewallRuleExists(firewallRuleUUID);
}
- private void loadConfiguration() {
- for (ConfigurationObject conf : configurationService.retrieveConfiguration(this, FILE_NAME)) {
- NeutronFirewallRule nn = (NeutronFirewallRule) conf;
- firewallRuleDB.put(nn.getFirewallRuleUUID(), nn);
- }
- }
-
- @Override
- public Status saveConfiguration() {
- return configurationService.persistConfiguration(new ArrayList<ConfigurationObject>(firewallRuleDB.values()),
- FILE_NAME);
- }
-
- @Override
- public Object readObject(ObjectInputStream ois) throws FileNotFoundException, IOException, ClassNotFoundException {
- return ois.readObject();
- }
-
}
\ No newline at end of file
package org.opendaylight.controller.networkconfig.neutron.implementation;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.ObjectInputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import org.apache.felix.dm.Component;
-import org.opendaylight.controller.clustering.services.CacheConfigException;
-import org.opendaylight.controller.clustering.services.CacheExistException;
-import org.opendaylight.controller.clustering.services.IClusterContainerServices;
-import org.opendaylight.controller.clustering.services.IClusterServices;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-import org.opendaylight.controller.configuration.IConfigurationContainerAware;
-import org.opendaylight.controller.configuration.IConfigurationContainerService;
import org.opendaylight.controller.networkconfig.neutron.INeutronFloatingIPCRUD;
import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD;
import org.opendaylight.controller.networkconfig.neutron.NeutronFloatingIP;
import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
-import org.opendaylight.controller.sal.utils.IObjectReader;
-import org.opendaylight.controller.sal.utils.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class NeutronFloatingIPInterface implements INeutronFloatingIPCRUD, IConfigurationContainerAware,
- IObjectReader {
+public class NeutronFloatingIPInterface implements INeutronFloatingIPCRUD {
private static final Logger logger = LoggerFactory.getLogger(NeutronFloatingIPInterface.class);
- private static final String FILE_NAME = "neutron.floatingip.conf";
- private String containerName = null;
- private IClusterContainerServices clusterContainerService = null;
- private IConfigurationContainerService configurationService;
- private ConcurrentMap<String, NeutronFloatingIP> floatingIPDB;
-
- // methods needed for creating caches
-
- void setClusterContainerService(IClusterContainerServices s) {
- logger.debug("Cluster Service set");
- this.clusterContainerService = s;
- }
-
- void unsetClusterContainerService(IClusterContainerServices s) {
- if (this.clusterContainerService == s) {
- logger.debug("Cluster Service removed!");
- this.clusterContainerService = null;
- }
- }
-
- public void setConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service set: {}", service);
- this.configurationService = service;
- }
-
- public void unsetConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service removed: {}", service);
- this.configurationService = null;
- }
-
- private void allocateCache() {
- if (this.clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't create cache");
- return;
- }
- logger.debug("Creating Cache for Neutron FloatingIPs");
- try {
- // neutron caches
- this.clusterContainerService.createCache("neutronFloatingIPs",
- EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL));
- } catch (CacheConfigException cce) {
- logger.error("Cache couldn't be created for Neutron - check cache mode");
- } catch (CacheExistException cce) {
- logger.error("Cache for Neutron already exists, destroy and recreate");
- }
- logger.debug("Cache successfully created for NeutronFloatingIps");
- }
-
- @SuppressWarnings({ "unchecked" })
- private void retrieveCache() {
- if (this.clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't retrieve cache");
- return;
- }
-
- logger.debug("Retrieving cache for Neutron FloatingIPs");
- floatingIPDB = (ConcurrentMap<String, NeutronFloatingIP>) this.clusterContainerService
- .getCache("neutronFloatingIPs");
- if (floatingIPDB == null) {
- logger.error("Cache couldn't be retrieved for Neutron FloatingIPs");
- }
- logger.debug("Cache was successfully retrieved for Neutron FloatingIPs");
- }
-
- private void destroyCache() {
- if (this.clusterContainerService == null) {
- logger.error("un-initialized clusterMger, can't destroy cache");
- return;
- }
- logger.debug("Destroying Cache for HostTracker");
- this.clusterContainerService.destroyCache("neutronFloatingIPs");
- }
-
- private void startUp() {
- allocateCache();
- retrieveCache();
- loadConfiguration();
- }
-
- /**
- * Function called by the dependency manager when all the required
- * dependencies are satisfied
- *
- */
- void init(Component c) {
- Dictionary<?, ?> props = c.getServiceProperties();
- if (props != null) {
- this.containerName = (String) props.get("containerName");
- logger.debug("Running containerName: {}", this.containerName);
- } else {
- // In the Global instance case the containerName is empty
- this.containerName = "";
- }
- startUp();
- }
-
- /**
- * Function called by the dependency manager when at least one dependency
- * become unsatisfied or when the component is shutting down because for
- * example bundle is being stopped.
- *
- */
- void destroy() {
- destroyCache();
- }
-
- /**
- * Function called by dependency manager after "init ()" is called and after
- * the services provided by the class are registered in the service registry
- *
- */
- void start() {
- }
-
- /**
- * Function called by the dependency manager before the services exported by
- * the component are unregistered, this will be followed by a "destroy ()"
- * calls
- *
- */
- void stop() {
- }
+ private ConcurrentMap<String, NeutronFloatingIP> floatingIPDB = new ConcurrentHashMap<String, NeutronFloatingIP>();
// this method uses reflection to update an object from it's delta.
target.setFixedIPAddress(delta.getFixedIPAddress());
return true;
}
-
- private void loadConfiguration() {
- for (ConfigurationObject conf : configurationService.retrieveConfiguration(this, FILE_NAME)) {
- NeutronFloatingIP nfIP = (NeutronFloatingIP) conf;
- floatingIPDB.put(nfIP.getID(), nfIP);
- }
- }
-
- @Override
- public Status saveConfiguration() {
- return configurationService.persistConfiguration(new ArrayList<ConfigurationObject>(floatingIPDB.values()),
- FILE_NAME);
- }
-
- @Override
- public Object readObject(ObjectInputStream ois) throws FileNotFoundException, IOException, ClassNotFoundException {
- return ois.readObject();
- }
}
package org.opendaylight.controller.networkconfig.neutron.implementation;
-import org.apache.felix.dm.Component;
-import org.opendaylight.controller.clustering.services.CacheConfigException;
-import org.opendaylight.controller.clustering.services.CacheExistException;
-import org.opendaylight.controller.clustering.services.IClusterContainerServices;
-import org.opendaylight.controller.clustering.services.IClusterServices;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-import org.opendaylight.controller.configuration.IConfigurationContainerAware;
-import org.opendaylight.controller.configuration.IConfigurationContainerService;
import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerHealthMonitorCRUD;
import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerHealthMonitor;
-import org.opendaylight.controller.sal.utils.IObjectReader;
-import org.opendaylight.controller.sal.utils.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.ObjectInputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-public class NeutronLoadBalancerHealthMonitorInterface implements INeutronLoadBalancerHealthMonitorCRUD, IConfigurationContainerAware,
- IObjectReader {
+public class NeutronLoadBalancerHealthMonitorInterface implements INeutronLoadBalancerHealthMonitorCRUD {
private static final Logger logger = LoggerFactory.getLogger(NeutronLoadBalancerHealthMonitorInterface.class);
- private static final String FILE_NAME = "neutron.loadBalancerHealthMonitor.conf";
- private String containerName = null;
+ private ConcurrentMap<String, NeutronLoadBalancerHealthMonitor> loadBalancerHealthMonitorDB = new ConcurrentHashMap<String, NeutronLoadBalancerHealthMonitor>();
- private IClusterContainerServices clusterContainerService = null;
- private IConfigurationContainerService configurationService;
- private ConcurrentMap<String, NeutronLoadBalancerHealthMonitor> loadBalancerHealthMonitorDB;
-
- // methods needed for creating caches
- void setClusterContainerService(IClusterContainerServices s) {
- logger.debug("Cluster Service set");
- clusterContainerService = s;
- }
-
- void unsetClusterContainerService(IClusterContainerServices s) {
- if (clusterContainerService == s) {
- logger.debug("Cluster Service removed!");
- clusterContainerService = null;
- }
- }
-
- public void setConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service set: {}", service);
- configurationService = service;
- }
-
- public void unsetConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service removed: {}", service);
- configurationService = null;
- }
-
- private void allocateCache() {
- if (this.clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't create cache");
- return;
- }
- logger.debug("Creating Cache for Neutron LoadBalancerHealthMonitor");
- try {
- // neutron caches
- this.clusterContainerService.createCache("neutronLoadBalancerHealthMonitors",
- EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL));
- } catch (CacheConfigException cce) {
- logger.error("Cache couldn't be created for Neutron LoadBalancerHealthMonitor - check cache mode");
- } catch (CacheExistException cce) {
- logger.error("Cache for Neutron LoadBalancerHealthMonitor already exists, destroy and recreate");
- }
- logger.debug("Cache successfully created for Neutron LoadBalancerHealthMonitor");
- }
-
- @SuppressWarnings ({"unchecked"})
- private void retrieveCache() {
- if (clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't retrieve cache");
- return;
- }
-
- logger.debug("Retrieving cache for Neutron LoadBalancerHealthMonitor");
- loadBalancerHealthMonitorDB = (ConcurrentMap<String, NeutronLoadBalancerHealthMonitor>) clusterContainerService
- .getCache("neutronLoadBalancerHealthMonitors");
- if (loadBalancerHealthMonitorDB == null) {
- logger.error("Cache couldn't be retrieved for Neutron LoadBalancerHealthMonitor");
- }
- logger.debug("Cache was successfully retrieved for Neutron LoadBalancerHealthMonitor");
- }
-
- private void destroyCache() {
- if (clusterContainerService == null) {
- logger.error("un-initialized clusterMger, can't destroy cache");
- return;
- }
- logger.debug("Destroying Cache for LoadBalancerHealthMonitor");
- clusterContainerService.destroyCache("neutronLoadBalancerHealthMonitors");
- }
-
- private void startUp() {
- allocateCache();
- retrieveCache();
- loadConfiguration();
- }
-
- /**
- * Function called by the dependency manager when all the required
- * dependencies are satisfied
- */
- void init(Component c) {
- Dictionary<?, ?> props = c.getServiceProperties();
- if (props != null) {
- this.containerName = (String) props.get("containerName");
- logger.debug("Running containerName: {}", this.containerName);
- } else {
- // In the Global instance case the containerName is empty
- this.containerName = "";
- }
- startUp();
- }
-
- /**
- * Function called by the dependency manager when at least one dependency
- * become unsatisfied or when the component is shutting down because for
- * example bundle is being stopped.
- */
- void destroy() {
- destroyCache();
- }
-
- /**
- * Function called by dependency manager after "init ()" is called and after
- * the services provided by the class are registered in the service registry
- */
- void start() {
- }
-
- /**
- * Function called by the dependency manager before the services exported by
- * the component are unregistered, this will be followed by a "destroy ()"
- * calls
- */
- void stop() {
- }
// this method uses reflection to update an object from it's delta.
public boolean neutronLoadBalancerHealthMonitorInUse(String loadBalancerHealthMonitorUUID) {
return !neutronLoadBalancerHealthMonitorExists(loadBalancerHealthMonitorUUID);
}
-
- private void loadConfiguration() {
- for (ConfigurationObject conf : configurationService.retrieveConfiguration(this, FILE_NAME)) {
- NeutronLoadBalancerHealthMonitor nn = (NeutronLoadBalancerHealthMonitor) conf;
- loadBalancerHealthMonitorDB.put(nn.getLoadBalancerHealthMonitorID(), nn);
- }
- }
-
- @Override
- public Status saveConfiguration() {
- return configurationService.persistConfiguration(new ArrayList<ConfigurationObject>(loadBalancerHealthMonitorDB.values()),
- FILE_NAME);
- }
-
- @Override
- public Object readObject(ObjectInputStream ois) throws FileNotFoundException, IOException, ClassNotFoundException {
- return ois.readObject();
- }
}
package org.opendaylight.controller.networkconfig.neutron.implementation;
-import org.apache.felix.dm.Component;
-import org.opendaylight.controller.clustering.services.CacheConfigException;
-import org.opendaylight.controller.clustering.services.CacheExistException;
-import org.opendaylight.controller.clustering.services.IClusterContainerServices;
-import org.opendaylight.controller.clustering.services.IClusterServices;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-import org.opendaylight.controller.configuration.IConfigurationContainerAware;
-import org.opendaylight.controller.configuration.IConfigurationContainerService;
import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerCRUD;
import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancer;
-import org.opendaylight.controller.sal.utils.IObjectReader;
-import org.opendaylight.controller.sal.utils.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.ObjectInputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-public class NeutronLoadBalancerInterface implements INeutronLoadBalancerCRUD, IConfigurationContainerAware,
- IObjectReader {
+public class NeutronLoadBalancerInterface implements INeutronLoadBalancerCRUD {
private static final Logger logger = LoggerFactory.getLogger(NeutronLoadBalancerInterface.class);
- private static final String FILE_NAME = "neutron.loadBalancer.conf";
- private String containerName = null;
+ private ConcurrentMap<String, NeutronLoadBalancer> loadBalancerDB = new ConcurrentHashMap<String, NeutronLoadBalancer>();
- private IClusterContainerServices clusterContainerService = null;
- private IConfigurationContainerService configurationService;
- private ConcurrentMap<String, NeutronLoadBalancer> loadBalancerDB;
-
- // methods needed for creating caches
- void setClusterContainerService(IClusterContainerServices s) {
- logger.debug("Cluster Service set");
- clusterContainerService = s;
- }
-
- void unsetClusterContainerService(IClusterContainerServices s) {
- if (clusterContainerService == s) {
- logger.debug("Cluster Service removed!");
- clusterContainerService = null;
- }
- }
-
- public void setConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service set: {}", service);
- configurationService = service;
- }
-
- public void unsetConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service removed: {}", service);
- configurationService = null;
- }
-
- private void allocateCache() {
- if (this.clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't create cache");
- return;
- }
- logger.debug("Creating Cache for Neutron LoadBalancer");
- try {
- // neutron caches
- this.clusterContainerService.createCache("neutronLoadBalancers",
- EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL));
- } catch (CacheConfigException cce) {
- logger.error("Cache couldn't be created for Neutron LoadBalancer - check cache mode");
- } catch (CacheExistException cce) {
- logger.error("Cache for Neutron LoadBalancer already exists, destroy and recreate");
- }
- logger.debug("Cache successfully created for Neutron LoadBalancer");
- }
-
- @SuppressWarnings ({"unchecked"})
- private void retrieveCache() {
- if (clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't retrieve cache");
- return;
- }
-
- logger.debug("Retrieving cache for Neutron LoadBalancer");
- loadBalancerDB = (ConcurrentMap<String, NeutronLoadBalancer>) clusterContainerService
- .getCache("neutronLoadBalancers");
- if (loadBalancerDB == null) {
- logger.error("Cache couldn't be retrieved for Neutron LoadBalancer");
- }
- logger.debug("Cache was successfully retrieved for Neutron LoadBalancer");
- }
-
- private void destroyCache() {
- if (clusterContainerService == null) {
- logger.error("un-initialized clusterMger, can't destroy cache");
- return;
- }
- logger.debug("Destroying Cache for LoadBalancer");
- clusterContainerService.destroyCache("neutronLoadBalancers");
- }
-
- private void startUp() {
- allocateCache();
- retrieveCache();
- loadConfiguration();
- }
-
- /**
- * Function called by the dependency manager when all the required
- * dependencies are satisfied
- */
- void init(Component c) {
- Dictionary<?, ?> props = c.getServiceProperties();
- if (props != null) {
- this.containerName = (String) props.get("containerName");
- logger.debug("Running containerName: {}", this.containerName);
- } else {
- // In the Global instance case the containerName is empty
- this.containerName = "";
- }
- startUp();
- }
-
- /**
- * Function called by the dependency manager when at least one dependency
- * become unsatisfied or when the component is shutting down because for
- * example bundle is being stopped.
- */
- void destroy() {
- destroyCache();
- }
-
- /**
- * Function called by dependency manager after "init ()" is called and after
- * the services provided by the class are registered in the service registry
- */
- void start() {
- }
-
- /**
- * Function called by the dependency manager before the services exported by
- * the component are unregistered, this will be followed by a "destroy ()"
- * calls
- */
- void stop() {
- }
// this method uses reflection to update an object from it's delta.
return !neutronLoadBalancerExists(loadBalancerUUID);
}
- private void loadConfiguration() {
- for (ConfigurationObject conf : configurationService.retrieveConfiguration(this, FILE_NAME)) {
- NeutronLoadBalancer nn = (NeutronLoadBalancer) conf;
- loadBalancerDB.put(nn.getLoadBalancerID(), nn);
- }
- }
-
- @Override
- public Status saveConfiguration() {
- return configurationService.persistConfiguration(new ArrayList<ConfigurationObject>(loadBalancerDB.values()),
- FILE_NAME);
- }
-
- @Override
- public Object readObject(ObjectInputStream ois) throws FileNotFoundException, IOException, ClassNotFoundException {
- return ois.readObject();
- }
}
package org.opendaylight.controller.networkconfig.neutron.implementation;
-import org.apache.felix.dm.Component;
-import org.opendaylight.controller.clustering.services.CacheConfigException;
-import org.opendaylight.controller.clustering.services.CacheExistException;
-import org.opendaylight.controller.clustering.services.IClusterContainerServices;
-import org.opendaylight.controller.clustering.services.IClusterServices;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-import org.opendaylight.controller.configuration.IConfigurationContainerAware;
-import org.opendaylight.controller.configuration.IConfigurationContainerService;
import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerListenerCRUD;
import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerListener;
-import org.opendaylight.controller.sal.utils.IObjectReader;
-import org.opendaylight.controller.sal.utils.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.ObjectInputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-public class NeutronLoadBalancerListenerInterface implements INeutronLoadBalancerListenerCRUD, IConfigurationContainerAware,
- IObjectReader {
+public class NeutronLoadBalancerListenerInterface implements INeutronLoadBalancerListenerCRUD {
private static final Logger logger = LoggerFactory.getLogger(NeutronLoadBalancerListenerInterface.class);
- private static final String FILE_NAME = "neutron.loadBalancerListener.conf";
- private String containerName = null;
+ private ConcurrentMap<String, NeutronLoadBalancerListener> loadBalancerListenerDB = new ConcurrentHashMap<String, NeutronLoadBalancerListener>();
- private IClusterContainerServices clusterContainerService = null;
- private IConfigurationContainerService configurationService;
- private ConcurrentMap<String, NeutronLoadBalancerListener> loadBalancerListenerDB;
- // methods needed for creating caches
- void setClusterContainerService(IClusterContainerServices s) {
- logger.debug("Cluster Service set");
- clusterContainerService = s;
- }
-
- void unsetClusterContainerService(IClusterContainerServices s) {
- if (clusterContainerService == s) {
- logger.debug("Cluster Service removed!");
- clusterContainerService = null;
- }
- }
-
- public void setConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service set: {}", service);
- configurationService = service;
- }
-
- public void unsetConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service removed: {}", service);
- configurationService = null;
- }
-
- private void allocateCache() {
- if (this.clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't create cache");
- return;
- }
- logger.debug("Creating Cache for Neutron LoadBalancerListener");
- try {
- // neutron caches
- this.clusterContainerService.createCache("neutronLoadBalancerListeners",
- EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL));
- } catch (CacheConfigException cce) {
- logger.error("Cache couldn't be created for Neutron LoadBalancerListener - check cache mode");
- } catch (CacheExistException cce) {
- logger.error("Cache for Neutron LoadBalancerListener already exists, destroy and recreate");
- }
- logger.debug("Cache successfully created for Neutron LoadBalancerListener");
- }
-
- @SuppressWarnings ({"unchecked"})
- private void retrieveCache() {
- if (clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't retrieve cache");
- return;
- }
-
- logger.debug("Retrieving cache for Neutron LoadBalancerListener");
- loadBalancerListenerDB = (ConcurrentMap<String, NeutronLoadBalancerListener>) clusterContainerService
- .getCache("neutronLoadBalancerListeners");
- if (loadBalancerListenerDB == null) {
- logger.error("Cache couldn't be retrieved for Neutron LoadBalancerListener");
- }
- logger.debug("Cache was successfully retrieved for Neutron LoadBalancerListener");
- }
-
- private void destroyCache() {
- if (clusterContainerService == null) {
- logger.error("un-initialized clusterMger, can't destroy cache");
- return;
- }
- logger.debug("Destroying Cache for LoadBalancerListener");
- clusterContainerService.destroyCache("neutronLoadBalancerListeners");
- }
-
- private void startUp() {
- allocateCache();
- retrieveCache();
- loadConfiguration();
- }
-
- /**
- * Function called by the dependency manager when all the required
- * dependencies are satisfied
- */
- void init(Component c) {
- Dictionary<?, ?> props = c.getServiceProperties();
- if (props != null) {
- this.containerName = (String) props.get("containerName");
- logger.debug("Running containerName: {}", this.containerName);
- } else {
- // In the Global instance case the containerName is empty
- this.containerName = "";
- }
- startUp();
- }
-
- /**
- * Function called by the dependency manager when at least one dependency
- * become unsatisfied or when the component is shutting down because for
- * example bundle is being stopped.
- */
- void destroy() {
- destroyCache();
- }
-
- /**
- * Function called by dependency manager after "init ()" is called and after
- * the services provided by the class are registered in the service registry
- */
- void start() {
- }
-
- /**
- * Function called by the dependency manager before the services exported by
- * the component are unregistered, this will be followed by a "destroy ()"
- * calls
- */
- void stop() {
- }
// this method uses reflection to update an object from it's delta.
public boolean neutronLoadBalancerListenerInUse(String loadBalancerListenerUUID) {
return !neutronLoadBalancerListenerExists(loadBalancerListenerUUID);
}
-
- private void loadConfiguration() {
- for (ConfigurationObject conf : configurationService.retrieveConfiguration(this, FILE_NAME)) {
- NeutronLoadBalancerListener nn = (NeutronLoadBalancerListener) conf;
- loadBalancerListenerDB.put(nn.getLoadBalancerListenerID(), nn);
- }
- }
-
- @Override
- public Status saveConfiguration() {
- return configurationService.persistConfiguration(new ArrayList<ConfigurationObject>(loadBalancerListenerDB.values()),
- FILE_NAME);
- }
-
- @Override
- public Object readObject(ObjectInputStream ois) throws FileNotFoundException, IOException, ClassNotFoundException {
- return ois.readObject();
- }
}
package org.opendaylight.controller.networkconfig.neutron.implementation;
-import org.apache.felix.dm.Component;
-import org.opendaylight.controller.clustering.services.CacheConfigException;
-import org.opendaylight.controller.clustering.services.CacheExistException;
-import org.opendaylight.controller.clustering.services.IClusterContainerServices;
-import org.opendaylight.controller.clustering.services.IClusterServices;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-import org.opendaylight.controller.configuration.IConfigurationContainerAware;
-import org.opendaylight.controller.configuration.IConfigurationContainerService;
import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolCRUD;
import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerPool;
-import org.opendaylight.controller.sal.utils.IObjectReader;
-import org.opendaylight.controller.sal.utils.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.ObjectInputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-public class NeutronLoadBalancerPoolInterface implements INeutronLoadBalancerPoolCRUD, IConfigurationContainerAware,
- IObjectReader {
+public class NeutronLoadBalancerPoolInterface implements INeutronLoadBalancerPoolCRUD {
private static final Logger logger = LoggerFactory.getLogger(NeutronLoadBalancerPoolInterface.class);
- private static final String FILE_NAME = "neutron.loadBalancerPool.conf";
- private String containerName = null;
+ private ConcurrentMap<String, NeutronLoadBalancerPool> loadBalancerPoolDB = new ConcurrentHashMap<String, NeutronLoadBalancerPool>();
- private IClusterContainerServices clusterContainerService = null;
- private IConfigurationContainerService configurationService;
- private ConcurrentMap<String, NeutronLoadBalancerPool> loadBalancerPoolDB;
-
- // methods needed for creating caches
- void setClusterContainerService(IClusterContainerServices s) {
- logger.debug("Cluster Service set");
- clusterContainerService = s;
- }
-
- void unsetClusterContainerService(IClusterContainerServices s) {
- if (clusterContainerService == s) {
- logger.debug("Cluster Service removed!");
- clusterContainerService = null;
- }
- }
-
- public void setConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service set: {}", service);
- configurationService = service;
- }
-
- public void unsetConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service removed: {}", service);
- configurationService = null;
- }
-
- private void allocateCache() {
- if (this.clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't create cache");
- return;
- }
- logger.debug("Creating Cache for Neutron LoadBalancerPool");
- try {
- // neutron caches
- this.clusterContainerService.createCache("neutronLoadBalancerPools",
- EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL));
- } catch (CacheConfigException cce) {
- logger.error("Cache couldn't be created for Neutron LoadBalancerPool - check cache mode");
- } catch (CacheExistException cce) {
- logger.error("Cache for Neutron LoadBalancerPool already exists, destroy and recreate");
- }
- logger.debug("Cache successfully created for Neutron LoadBalancerPool");
- }
-
- @SuppressWarnings ({"unchecked"})
- private void retrieveCache() {
- if (clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't retrieve cache");
- return;
- }
-
- logger.debug("Retrieving cache for Neutron LoadBalancerPool");
- loadBalancerPoolDB = (ConcurrentMap<String, NeutronLoadBalancerPool>) clusterContainerService
- .getCache("neutronLoadBalancerPools");
- if (loadBalancerPoolDB == null) {
- logger.error("Cache couldn't be retrieved for Neutron LoadBalancerPool");
- }
- logger.debug("Cache was successfully retrieved for Neutron LoadBalancerPool");
- }
-
- private void destroyCache() {
- if (clusterContainerService == null) {
- logger.error("un-initialized clusterMger, can't destroy cache");
- return;
- }
- logger.debug("Destroying Cache for LoadBalancerPool");
- clusterContainerService.destroyCache("neutronLoadBalancerPools");
- }
-
- private void startUp() {
- allocateCache();
- retrieveCache();
- loadConfiguration();
- }
-
- /**
- * Function called by the dependency manager when all the required
- * dependencies are satisfied
- */
- void init(Component c) {
- Dictionary<?, ?> props = c.getServiceProperties();
- if (props != null) {
- this.containerName = (String) props.get("containerName");
- logger.debug("Running containerName: {}", this.containerName);
- } else {
- // In the Global instance case the containerName is empty
- this.containerName = "";
- }
- startUp();
- }
-
- /**
- * Function called by the dependency manager when at least one dependency
- * become unsatisfied or when the component is shutting down because for
- * example bundle is being stopped.
- */
- void destroy() {
- destroyCache();
- }
-
- /**
- * Function called by dependency manager after "init ()" is called and after
- * the services provided by the class are registered in the service registry
- */
- void start() {
- }
-
- /**
- * Function called by the dependency manager before the services exported by
- * the component are unregistered, this will be followed by a "destroy ()"
- * calls
- */
- void stop() {
- }
// this method uses reflection to update an object from it's delta.
return !neutronLoadBalancerPoolExists(loadBalancerPoolUUID);
}
- private void loadConfiguration() {
- for (ConfigurationObject conf : configurationService.retrieveConfiguration(this, FILE_NAME)) {
- NeutronLoadBalancerPool nn = (NeutronLoadBalancerPool) conf;
- loadBalancerPoolDB.put(nn.getLoadBalancerPoolID(), nn);
- }
- }
-
- @Override
- public Status saveConfiguration() {
- return configurationService.persistConfiguration(new ArrayList<ConfigurationObject>(loadBalancerPoolDB.values()),
- FILE_NAME);
- }
-
- @Override
- public Object readObject(ObjectInputStream ois) throws FileNotFoundException, IOException, ClassNotFoundException {
- return ois.readObject();
- }
}
package org.opendaylight.controller.networkconfig.neutron.implementation;
-import org.apache.felix.dm.Component;
-import org.opendaylight.controller.clustering.services.CacheConfigException;
-import org.opendaylight.controller.clustering.services.CacheExistException;
-import org.opendaylight.controller.clustering.services.IClusterContainerServices;
-import org.opendaylight.controller.clustering.services.IClusterServices;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-import org.opendaylight.controller.configuration.IConfigurationContainerAware;
-import org.opendaylight.controller.configuration.IConfigurationContainerService;
import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolMemberCRUD;
import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerPoolMember;
-import org.opendaylight.controller.sal.utils.IObjectReader;
-import org.opendaylight.controller.sal.utils.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.ObjectInputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
public class NeutronLoadBalancerPoolMemberInterface
- implements INeutronLoadBalancerPoolMemberCRUD, IConfigurationContainerAware,
- IObjectReader {
+ implements INeutronLoadBalancerPoolMemberCRUD {
private static final Logger logger = LoggerFactory.getLogger(NeutronLoadBalancerPoolMemberInterface.class);
- private static final String FILE_NAME = "neutron.loadBalancerPoolMember.conf";
- private String containerName = null;
+ private ConcurrentMap<String, NeutronLoadBalancerPoolMember> loadBalancerPoolMemberDB = new ConcurrentHashMap<String, NeutronLoadBalancerPoolMember>();
- private IClusterContainerServices clusterContainerService = null;
- private IConfigurationContainerService configurationService;
- private ConcurrentMap<String, NeutronLoadBalancerPoolMember> loadBalancerPoolMemberDB;
-
- // methods needed for creating caches
- void setClusterContainerService(IClusterContainerServices s) {
- logger.debug("Cluster Service set");
- clusterContainerService = s;
- }
-
- void unsetClusterContainerService(IClusterContainerServices s) {
- if (clusterContainerService == s) {
- logger.debug("Cluster Service removed!");
- clusterContainerService = null;
- }
- }
-
- public void setConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service set: {}", service);
- configurationService = service;
- }
-
- public void unsetConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service removed: {}", service);
- configurationService = null;
- }
-
- private void allocateCache() {
- if (this.clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't create cache");
- return;
- }
- logger.debug("Creating Cache for Neutron LoadBalancerPoolMember");
- try {
- // neutron caches
- this.clusterContainerService.createCache("neutronLoadBalancerPoolMembers",
- EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL));
- } catch(CacheConfigException cce) {
- logger.error("Cache couldn't be created for Neutron LoadBalancerPoolMember - check cache mode");
- } catch(CacheExistException cce) {
- logger.error("Cache for Neutron LoadBalancerPoolMember already exists, destroy and recreate");
- }
- logger.debug("Cache successfully created for Neutron LoadBalancerPoolMember");
- }
-
- @SuppressWarnings({"unchecked"})
- private void retrieveCache() {
- if (clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't retrieve cache");
- return;
- }
-
- logger.debug("Retrieving cache for Neutron LoadBalancerPoolMember");
- loadBalancerPoolMemberDB = (ConcurrentMap<String, NeutronLoadBalancerPoolMember>) clusterContainerService
- .getCache("neutronLoadBalancerPoolMembers");
- if (loadBalancerPoolMemberDB == null) {
- logger.error("Cache couldn't be retrieved for Neutron LoadBalancerPoolMember");
- }
- logger.debug("Cache was successfully retrieved for Neutron LoadBalancerPoolMember");
- }
-
- private void destroyCache() {
- if (clusterContainerService == null) {
- logger.error("un-initialized clusterMger, can't destroy cache");
- return;
- }
- logger.debug("Destroying Cache for HostTracker");
- clusterContainerService.destroyCache("neutronLoadBalancerPoolMembers");
- }
-
- private void startUp() {
- allocateCache();
- retrieveCache();
- loadConfiguration();
- }
-
- /**
- * Function called by the dependency manager when all the required
- * dependencies are satisfied
- */
- void init(Component c) {
- Dictionary<?, ?> props = c.getServiceProperties();
- if (props != null) {
- this.containerName = (String) props.get("containerName");
- logger.debug("Running containerName: {}", this.containerName);
- } else {
- // In the Global instance case the containerName is empty
- this.containerName = "";
- }
- startUp();
- }
-
- /**
- * Function called by the dependency manager when at least one dependency
- * become unsatisfied or when the component is shutting down because for
- * example bundle is being stopped.
- */
- void destroy() {
- destroyCache();
- }
-
- /**
- * Function called by dependency manager after "init ()" is called and after
- * the services provided by the class are registered in the service registry
- */
- void start() {
- }
-
- /**
- * Function called by the dependency manager before the services exported by
- * the component are unregistered, this will be followed by a "destroy ()"
- * calls
- */
- void stop() {
- }
// this method uses reflection to update an object from it's delta.
public boolean neutronLoadBalancerPoolMemberInUse(String loadBalancerPoolMemberID) {
return !neutronLoadBalancerPoolMemberExists(loadBalancerPoolMemberID);
}
-
- private void loadConfiguration() {
- for (ConfigurationObject conf : configurationService.retrieveConfiguration(this, FILE_NAME)) {
- NeutronLoadBalancerPoolMember nn = (NeutronLoadBalancerPoolMember) conf;
- loadBalancerPoolMemberDB.put(nn.getPoolMemberID(), nn);
- }
- }
-
- @Override
- public Status saveConfiguration() {
- return configurationService.persistConfiguration(
- new ArrayList<ConfigurationObject>(loadBalancerPoolMemberDB.values()),
- FILE_NAME);
- }
-
- @Override
- public Object readObject(ObjectInputStream ois) throws FileNotFoundException, IOException, ClassNotFoundException {
- return ois.readObject();
- }
}
package org.opendaylight.controller.networkconfig.neutron.implementation;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.ObjectInputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import org.apache.felix.dm.Component;
-import org.opendaylight.controller.clustering.services.CacheConfigException;
-import org.opendaylight.controller.clustering.services.CacheExistException;
-import org.opendaylight.controller.clustering.services.IClusterContainerServices;
-import org.opendaylight.controller.clustering.services.IClusterServices;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-import org.opendaylight.controller.configuration.IConfigurationContainerAware;
-import org.opendaylight.controller.configuration.IConfigurationContainerService;
import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
-import org.opendaylight.controller.sal.utils.IObjectReader;
-import org.opendaylight.controller.sal.utils.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class NeutronNetworkInterface implements INeutronNetworkCRUD, IConfigurationContainerAware,
- IObjectReader {
+public class NeutronNetworkInterface implements INeutronNetworkCRUD {
private static final Logger logger = LoggerFactory.getLogger(NeutronNetworkInterface.class);
- private static final String FILE_NAME ="neutron.network.conf";
- private String containerName = null;
+ private ConcurrentMap<String, NeutronNetwork> networkDB = new ConcurrentHashMap<String, NeutronNetwork>();
- private ConcurrentMap<String, NeutronNetwork> networkDB;
- private IClusterContainerServices clusterContainerService = null;
- private IConfigurationContainerService configurationService;
- // methods needed for creating caches
- void setClusterContainerService(IClusterContainerServices s) {
- logger.debug("Cluster Service set");
- this.clusterContainerService = s;
- }
-
- void unsetClusterContainerService(IClusterContainerServices s) {
- if (this.clusterContainerService == s) {
- logger.debug("Cluster Service removed!");
- this.clusterContainerService = null;
- }
- }
-
- public void setConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service set: {}", service);
- this.configurationService = service;
- }
-
- public void unsetConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service removed: {}", service);
- this.configurationService = null;
- }
-
- private void allocateCache() {
- if (this.clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't create cache");
- return;
- }
- logger.debug("Creating Cache for Neutron Networks");
- try {
- // neutron caches
- this.clusterContainerService.createCache("neutronNetworks",
- EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL));
- } catch (CacheConfigException cce) {
- logger.error("Cache couldn't be created for Neutron Networks - check cache mode");
- } catch (CacheExistException cce) {
- logger.error("Cache for Neutron Networks already exists, destroy and recreate");
- }
- logger.debug("Cache successfully created for Neutron Networks");
- }
-
- @SuppressWarnings({ "unchecked" })
- private void retrieveCache() {
- if (this.clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't retrieve cache");
- return;
- }
- logger.debug("Retrieving cache for Neutron Networks");
- networkDB = (ConcurrentMap<String, NeutronNetwork>) this.clusterContainerService.getCache("neutronNetworks");
- if (networkDB == null) {
- logger.error("Cache couldn't be retrieved for Neutron Networks");
- }
- logger.debug("Cache was successfully retrieved for Neutron Networks");
- }
-
- private void startUp() {
- allocateCache();
- retrieveCache();
- loadConfiguration();
- }
-
- /**
- * Function called by the dependency manager when all the required
- * dependencies are satisfied
- *
- */
- void init(Component c) {
- Dictionary<?, ?> props = c.getServiceProperties();
- if (props != null) {
- this.containerName = (String) props.get("containerName");
- logger.debug("Running containerName: {}", this.containerName);
- } else {
- // In the Global instance case the containerName is empty
- this.containerName = "";
- }
- startUp();
- }
-
- private void destroyCache() {
- if (this.clusterContainerService == null) {
- logger.error("un-initialized clusterMger, can't destroy cache");
- return;
- }
- logger.debug("Destroying Cache for Neutron Networks");
- this.clusterContainerService.destroyCache("Neutron Networks");
- }
-
- /**
- * Function called by the dependency manager when at least one dependency
- * become unsatisfied or when the component is shutting down because for
- * example bundle is being stopped.
- *
- */
- void destroy() {
- destroyCache();
- }
-
- /**
- * Function called by dependency manager after "init ()" is called and after
- * the services provided by the class are registered in the service registry
- *
- */
- void start() {
- }
-
- /**
- * Function called by the dependency manager before the services exported by
- * the component are unregistered, this will be followed by a "destroy ()"
- * calls
- *
- */
- void stop() {
- }
// this method uses reflection to update an object from it's delta.
}
return false;
}
-
- private void loadConfiguration() {
- for (ConfigurationObject conf : configurationService.retrieveConfiguration(this, FILE_NAME)) {
- NeutronNetwork nn = (NeutronNetwork) conf;
- networkDB.put(nn.getID(), nn);
- }
- }
-
- @Override
- public Status saveConfiguration() {
- return configurationService.persistConfiguration(new ArrayList<ConfigurationObject>(networkDB.values()),
- FILE_NAME);
- }
-
- @Override
- public Object readObject(ObjectInputStream ois) throws FileNotFoundException, IOException, ClassNotFoundException {
- return ois.readObject();
- }
-
}
package org.opendaylight.controller.networkconfig.neutron.implementation;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.ObjectInputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.EnumSet;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import org.apache.felix.dm.Component;
-import org.opendaylight.controller.clustering.services.CacheConfigException;
-import org.opendaylight.controller.clustering.services.CacheExistException;
-import org.opendaylight.controller.clustering.services.IClusterContainerServices;
-import org.opendaylight.controller.clustering.services.IClusterServices;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-import org.opendaylight.controller.configuration.IConfigurationContainerAware;
-import org.opendaylight.controller.configuration.IConfigurationContainerService;
import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD;
import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD;
import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
import org.opendaylight.controller.networkconfig.neutron.Neutron_IPs;
-import org.opendaylight.controller.sal.utils.IObjectReader;
-import org.opendaylight.controller.sal.utils.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class NeutronPortInterface implements INeutronPortCRUD, IConfigurationContainerAware,
- IObjectReader {
+public class NeutronPortInterface implements INeutronPortCRUD {
private static final Logger logger = LoggerFactory.getLogger(NeutronPortInterface.class);
- private static final String FILE_NAME ="neutron.port.conf";
- private String containerName = null;
+ private ConcurrentMap<String, NeutronPort> portDB = new ConcurrentHashMap<String, NeutronPort>();
- private IClusterContainerServices clusterContainerService = null;
- private IConfigurationContainerService configurationService;
- private ConcurrentMap<String, NeutronPort> portDB;
- // methods needed for creating caches
-
- void setClusterContainerService(IClusterContainerServices s) {
- logger.debug("Cluster Service set");
- clusterContainerService = s;
- }
-
- void unsetClusterContainerService(IClusterContainerServices s) {
- if (clusterContainerService == s) {
- logger.debug("Cluster Service removed!");
- clusterContainerService = null;
- }
- }
-
- public void setConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service set: {}", service);
- configurationService = service;
- }
-
- public void unsetConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service removed: {}", service);
- configurationService = null;
- }
-
- private void allocateCache() {
- if (clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't create cache");
- return;
- }
- logger.debug("Creating Cache for OpenDOVE");
- try {
- // neutron caches
- clusterContainerService.createCache("neutronPorts",
- EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL));
- } catch (CacheConfigException cce) {
- logger.error("Cache couldn't be created for OpenDOVE - check cache mode");
- } catch (CacheExistException cce) {
- logger.error("Cache for OpenDOVE already exists, destroy and recreate");
- }
- logger.debug("Cache successfully created for OpenDOVE");
- }
-
- @SuppressWarnings({ "unchecked" })
- private void retrieveCache() {
- if (clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't retrieve cache");
- return;
- }
-
- logger.debug("Retrieving cache for Neutron Ports");
- portDB = (ConcurrentMap<String, NeutronPort>) clusterContainerService
- .getCache("neutronPorts");
- if (portDB == null) {
- logger.error("Cache couldn't be retrieved for Neutron Ports");
- }
- logger.debug("Cache was successfully retrieved for Neutron Ports");
- }
-
- private void destroyCache() {
- if (clusterContainerService == null) {
- logger.error("un-initialized clusterMger, can't destroy cache");
- return;
- }
- logger.debug("Destroying Cache for HostTracker");
- clusterContainerService.destroyCache("neutronPorts");
- }
-
- private void startUp() {
- allocateCache();
- retrieveCache();
- loadConfiguration();
- }
-
- /**
- * Function called by the dependency manager when all the required
- * dependencies are satisfied
- *
- */
- void init(Component c) {
- Dictionary<?, ?> props = c.getServiceProperties();
- if (props != null) {
- containerName = (String) props.get("containerName");
- logger.debug("Running containerName: {}", containerName);
- } else {
- // In the Global instance case the containerName is empty
- containerName = "";
- }
- startUp();
- }
-
- /**
- * Function called by the dependency manager when at least one dependency
- * become unsatisfied or when the component is shutting down because for
- * example bundle is being stopped.
- *
- */
- void destroy() {
- destroyCache();
- }
-
- /**
- * Function called by dependency manager after "init ()" is called and after
- * the services provided by the class are registered in the service registry
- *
- */
- void start() {
- }
-
- /**
- * Function called by the dependency manager before the services exported by
- * the component are unregistered, this will be followed by a "destroy ()"
- * calls
- *
- */
- void stop() {
- }
// this method uses reflection to update an object from it's delta.
}
return null;
}
-
- private void loadConfiguration() {
- for (ConfigurationObject conf : configurationService.retrieveConfiguration(this, FILE_NAME)) {
- NeutronPort nn = (NeutronPort) conf;
- portDB.put(nn.getID(), nn);
- }
- }
-
- @Override
- public Status saveConfiguration() {
- return configurationService.persistConfiguration(new ArrayList<ConfigurationObject>(portDB.values()),
- FILE_NAME);
- }
-
- @Override
- public Object readObject(ObjectInputStream ois) throws FileNotFoundException, IOException, ClassNotFoundException {
- return ois.readObject();
- }
-
}
package org.opendaylight.controller.networkconfig.neutron.implementation;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.ObjectInputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import org.apache.felix.dm.Component;
-import org.opendaylight.controller.clustering.services.CacheConfigException;
-import org.opendaylight.controller.clustering.services.CacheExistException;
-import org.opendaylight.controller.clustering.services.IClusterContainerServices;
-import org.opendaylight.controller.clustering.services.IClusterServices;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-import org.opendaylight.controller.configuration.IConfigurationContainerAware;
-import org.opendaylight.controller.configuration.IConfigurationContainerService;
import org.opendaylight.controller.networkconfig.neutron.INeutronRouterCRUD;
import org.opendaylight.controller.networkconfig.neutron.NeutronRouter;
-import org.opendaylight.controller.sal.utils.IObjectReader;
-import org.opendaylight.controller.sal.utils.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class NeutronRouterInterface implements INeutronRouterCRUD, IConfigurationContainerAware,
- IObjectReader {
+public class NeutronRouterInterface implements INeutronRouterCRUD {
private static final Logger logger = LoggerFactory.getLogger(NeutronRouterInterface.class);
- private static final String FILE_NAME ="neutron.router.conf";
- private String containerName = null;
-
- private IClusterContainerServices clusterContainerService = null;
- private IConfigurationContainerService configurationService;
- private ConcurrentMap<String, NeutronRouter> routerDB;
+ private ConcurrentMap<String, NeutronRouter> routerDB = new ConcurrentHashMap<String, NeutronRouter>();
// methods needed for creating caches
- void setClusterContainerService(IClusterContainerServices s) {
- logger.debug("Cluster Service set");
- this.clusterContainerService = s;
- }
-
- void unsetClusterContainerService(IClusterContainerServices s) {
- if (this.clusterContainerService == s) {
- logger.debug("Cluster Service removed!");
- this.clusterContainerService = null;
- }
- }
-
- public void setConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service set: {}", service);
- this.configurationService = service;
- }
-
- public void unsetConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service removed: {}", service);
- this.configurationService = null;
- }
-
- private void allocateCache() {
- if (this.clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't create cache");
- return;
- }
- logger.debug("Creating Cache for Neutron Routers");
- try {
- // neutron caches
- this.clusterContainerService.createCache("neutronRouters",
- EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL));
- } catch (CacheConfigException cce) {
- logger.error("Cache couldn't be created for Neutron Routers - check cache mode");
- } catch (CacheExistException cce) {
- logger.error("Cache for Neutron Routers already exists, destroy and recreate");
- }
- logger.debug("Cache successfully created for Neutron Routers");
- }
-
- @SuppressWarnings({ "unchecked" })
- private void retrieveCache() {
- if (this.clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't retrieve cache");
- return;
- }
-
- logger.debug("Retrieving cache for Neutron Routers");
- routerDB = (ConcurrentMap<String, NeutronRouter>) this.clusterContainerService
- .getCache("neutronRouters");
- if (routerDB == null) {
- logger.error("Cache couldn't be retrieved for Neutron Routers");
- }
- logger.debug("Cache was successfully retrieved for Neutron Routers");
- }
-
- private void destroyCache() {
- if (this.clusterContainerService == null) {
- logger.error("un-initialized clusterMger, can't destroy cache");
- return;
- }
- logger.debug("Destroying Cache for HostTracker");
- this.clusterContainerService.destroyCache("neutronRouters");
- }
-
- private void startUp() {
- allocateCache();
- retrieveCache();
- loadConfiguration();
- }
-
- /**
- * Function called by the dependency manager when all the required
- * dependencies are satisfied
- *
- */
- void init(Component c) {
- Dictionary<?, ?> props = c.getServiceProperties();
- if (props != null) {
- this.containerName = (String) props.get("containerName");
- logger.debug("Running containerName: {}", this.containerName);
- } else {
- // In the Global instance case the containerName is empty
- this.containerName = "";
- }
- startUp();
- }
-
- /**
- * Function called by the dependency manager when at least one dependency
- * become unsatisfied or when the component is shutting down because for
- * example bundle is being stopped.
- *
- */
- void destroy() {
- destroyCache();
- }
-
- /**
- * Function called by dependency manager after "init ()" is called and after
- * the services provided by the class are registered in the service registry
- *
- */
- void start() {
- }
- /**
- * Function called by the dependency manager before the services exported by
- * the component are unregistered, this will be followed by a "destroy ()"
- * calls
- *
- */
- void stop() {
- }
// this method uses reflection to update an object from it's delta.
return (target.getInterfaces().size() > 0);
}
- private void loadConfiguration() {
- for (ConfigurationObject conf : configurationService.retrieveConfiguration(this, FILE_NAME)) {
- NeutronRouter nr = (NeutronRouter) conf;
- routerDB.put(nr.getID(), nr);
- }
- }
-
- @Override
- public Status saveConfiguration() {
- return configurationService.persistConfiguration(new ArrayList<ConfigurationObject>(routerDB.values()),
- FILE_NAME);
- }
-
- @Override
- public Object readObject(ObjectInputStream ois) throws FileNotFoundException, IOException, ClassNotFoundException {
- return ois.readObject();
- }
-
}
package org.opendaylight.controller.networkconfig.neutron.implementation;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.ObjectInputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.EnumSet;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.List;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import org.apache.felix.dm.Component;
-import org.opendaylight.controller.clustering.services.CacheConfigException;
-import org.opendaylight.controller.clustering.services.CacheExistException;
-import org.opendaylight.controller.clustering.services.IClusterContainerServices;
-import org.opendaylight.controller.clustering.services.IClusterServices;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-import org.opendaylight.controller.configuration.IConfigurationContainerAware;
-import org.opendaylight.controller.configuration.IConfigurationContainerService;
+
import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityGroupCRUD;
import org.opendaylight.controller.networkconfig.neutron.NeutronSecurityGroup;
-import org.opendaylight.controller.sal.utils.IObjectReader;
-import org.opendaylight.controller.sal.utils.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class NeutronSecurityGroupInterface implements INeutronSecurityGroupCRUD, IConfigurationContainerAware, IObjectReader {
+public class NeutronSecurityGroupInterface implements INeutronSecurityGroupCRUD {
private static final Logger logger = LoggerFactory.getLogger(NeutronSecurityGroupInterface.class);
- private static final String FILE_NAME ="neutron.securitygroup.conf";
- private String containerName = null;
-
- private IClusterContainerServices clusterContainerService = null;
- private IConfigurationContainerService configurationService;
- private ConcurrentMap<String, NeutronSecurityGroup> securityGroupDB;
-
- // methods needed for creating caches
- void setClusterContainerService(IClusterContainerServices s) {
- logger.debug("Cluster Service set");
- clusterContainerService = s;
- }
+ private ConcurrentMap<String, NeutronSecurityGroup> securityGroupDB = new ConcurrentHashMap<String, NeutronSecurityGroup>();
- void unsetClusterContainerService(IClusterContainerServices s) {
- if (clusterContainerService == s) {
- logger.debug("Cluster Service removed!");
- clusterContainerService = null;
- }
- }
- public void setConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service set: {}", service);
- configurationService = service;
- }
-
- public void unsetConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service removed: {}", service);
- configurationService = null;
- }
-
- private void allocateCache() {
- if (this.clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't create cache");
- return;
- }
- logger.debug("Creating Cache for Neutron Security Groups");
- try {
- // neutron caches
- this.clusterContainerService.createCache("neutronSecurityGroups",
- EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL));
- } catch (CacheConfigException cce) {
- logger.error("Cache couldn't be created for Neutron Security Groups - check cache mode");
- } catch (CacheExistException cce) {
- logger.error("Cache for Neutron Security Groups already exists, destroy and recreate");
- }
- logger.debug("Cache successfully created for Neutron Security Groups");
- }
-
- @SuppressWarnings({ "unchecked" })
- private void retrieveCache() {
- if (clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't retrieve cache");
- return;
- }
-
- logger.debug("Retrieving cache for Neutron Security Groups");
- securityGroupDB = (ConcurrentMap<String, NeutronSecurityGroup>) clusterContainerService
- .getCache("neutronSecurityGroups");
- if (securityGroupDB == null) {
- logger.error("Cache couldn't be retrieved for Neutron Security Groups");
- }
- logger.debug("Cache was successfully retrieved for Neutron Security Groups");
- }
-
- private void destroyCache() {
- if (clusterContainerService == null) {
- logger.error("un-initialized clusterMger, can't destroy cache");
- return;
- }
- logger.debug("Destroying Cache for Neutron Security Groups");
- clusterContainerService.destroyCache("neutronSecurityGroups");
- }
-
- private void startUp() {
- allocateCache();
- retrieveCache();
- loadConfiguration();
- }
-
- /**
- * Function called by the dependency manager when all the required
- * dependencies are satisfied
- *
- */
- void init(Component c) {
- Dictionary<?, ?> props = c.getServiceProperties();
- if (props != null) {
- this.containerName = (String) props.get("containerName");
- logger.debug("Running containerName: {}", this.containerName);
- } else {
- // In the Global instance case the containerName is empty
- this.containerName = "";
- }
- startUp();
- }
-
- /**
- * Function called by the dependency manager when at least one dependency
- * become unsatisfied or when the component is shutting down because for
- * example bundle is being stopped.
- *
- */
- void destroy() {
- destroyCache();
- }
-
- /**
- * Function called by dependency manager after "init ()" is called and after
- * the services provided by the class are registered in the service registry
- *
- */
- void start() {
- }
-
- /**
- * Function called by the dependency manager before the services exported by
- * the component are unregistered, this will be followed by a "destroy ()"
- * calls
- *
- */
- void stop() {
- }
// this method uses reflection to update an object from it's delta.
return !neutronSecurityGroupExists(securityGroupUUID);
}
- private void loadConfiguration() {
- for (ConfigurationObject conf : configurationService.retrieveConfiguration(this, FILE_NAME)) {
- NeutronSecurityGroup nn = (NeutronSecurityGroup) conf;
- securityGroupDB.put(nn.getSecurityGroupUUID(), nn);
- }
- }
-
- @Override
- public Status saveConfiguration() {
- return configurationService.persistConfiguration(new ArrayList<ConfigurationObject>(securityGroupDB.values()),
- FILE_NAME);
- }
-
- @Override
- public Object readObject(ObjectInputStream ois) throws FileNotFoundException, IOException, ClassNotFoundException {
- return ois.readObject();
- }
-
}
\ No newline at end of file
package org.opendaylight.controller.networkconfig.neutron.implementation;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.ObjectInputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.EnumSet;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.List;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import org.apache.felix.dm.Component;
-import org.opendaylight.controller.clustering.services.CacheConfigException;
-import org.opendaylight.controller.clustering.services.CacheExistException;
-import org.opendaylight.controller.clustering.services.IClusterContainerServices;
-import org.opendaylight.controller.clustering.services.IClusterServices;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-import org.opendaylight.controller.configuration.IConfigurationContainerAware;
-import org.opendaylight.controller.configuration.IConfigurationContainerService;
import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityRuleCRUD;
import org.opendaylight.controller.networkconfig.neutron.NeutronSecurityRule;
-import org.opendaylight.controller.sal.utils.IObjectReader;
-import org.opendaylight.controller.sal.utils.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class NeutronSecurityRuleInterface implements INeutronSecurityRuleCRUD, IConfigurationContainerAware, IObjectReader {
+public class NeutronSecurityRuleInterface implements INeutronSecurityRuleCRUD {
private static final Logger logger = LoggerFactory.getLogger(NeutronSecurityRuleInterface.class);
- private static final String FILE_NAME = "neutron.securityrule.conf";
- private String containerName = null;
-
- private IClusterContainerServices clusterContainerService = null;
- private IConfigurationContainerService configurationService;
- private ConcurrentMap<String, NeutronSecurityRule> securityRuleDB;
-
- // methods needed for creating caches
- void setClusterContainerService(IClusterContainerServices s) {
- logger.debug("Cluster Service set");
- clusterContainerService = s;
- }
-
- void unsetClusterContainerService(IClusterContainerServices s) {
- if (clusterContainerService == s) {
- logger.debug("Cluster Service removed!");
- clusterContainerService = null;
- }
- }
-
- public void setConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service set: {}", service);
- configurationService = service;
- }
-
- public void unsetConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service removed: {}", service);
- configurationService = null;
- }
-
- private void allocateCache() {
- if (this.clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't create cache");
- return;
- }
- logger.debug("Creating Cache for Neutron Security Rules");
- try {
- // neutron caches
- this.clusterContainerService.createCache("neutronSecurityRules",
- EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL));
- } catch (CacheConfigException cce) {
- logger.error("Cache couldn't be created for Neutron Security Rules - check cache mode");
- } catch (CacheExistException cce) {
- logger.error("Cache for Neutron Security Rules already exists, destroy and recreate");
- }
- logger.debug("Cache successfully created for Neutron Security Rules");
- }
-
- @SuppressWarnings({"unchecked"})
- private void retrieveCache() {
- if (clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't retrieve cache");
- return;
- }
-
- logger.debug("Retrieving cache for Neutron Security Rules");
- securityRuleDB = (ConcurrentMap<String, NeutronSecurityRule>) clusterContainerService
- .getCache("neutronSecurityRules");
- if (securityRuleDB == null) {
- logger.error("Cache couldn't be retrieved for Neutron Security Rules");
- }
- logger.debug("Cache was successfully retrieved for Neutron Security Rules");
- }
-
- private void destroyCache() {
- if (clusterContainerService == null) {
- logger.error("un-initialized clusterMger, can't destroy cache");
- return;
- }
- logger.debug("Destroying Cache for Neutron Security Rules");
- clusterContainerService.destroyCache("neutronSecurityRules");
- }
-
- private void startUp() {
- allocateCache();
- retrieveCache();
- loadConfiguration();
- }
-
- /**
- * Function called by the dependency manager when all the required
- * dependencies are satisfied
- */
- void init(Component c) {
- Dictionary<?, ?> props = c.getServiceProperties();
- if (props != null) {
- this.containerName = (String) props.get("containerName");
- logger.debug("Running containerName: {}", this.containerName);
- } else {
- // In the Global instance case the containerName is empty
- this.containerName = "";
- }
- startUp();
- }
-
- /**
- * Function called by the dependency manager when at least one dependency
- * become unsatisfied or when the component is shutting down because for
- * example bundle is being stopped.
- */
- void destroy() {
- destroyCache();
- }
-
- /**
- * Function called by dependency manager after "init ()" is called and after
- * the services provided by the class are registered in the service registry
- */
- void start() {
- }
-
- /**
- * Function called by the dependency manager before the services exported by
- * the component are unregistered, this will be followed by a "destroy ()"
- * calls
- */
- void stop() {
- }
+ private ConcurrentMap<String, NeutronSecurityRule> securityRuleDB = new ConcurrentHashMap<String, NeutronSecurityRule>();
// this method uses reflection to update an object from it's delta.
private boolean overwrite(Object target, Object delta) {
return !neutronSecurityRuleExists(securityRuleUUID);
}
- private void loadConfiguration() {
- for (ConfigurationObject conf : configurationService.retrieveConfiguration(this, FILE_NAME)) {
- NeutronSecurityRule nn = (NeutronSecurityRule) conf;
- securityRuleDB.put(nn.getSecurityRuleUUID(), nn);
- }
- }
-
- @Override
- public Status saveConfiguration() {
- return configurationService.persistConfiguration(new ArrayList<ConfigurationObject>(securityRuleDB.values()),
- FILE_NAME);
- }
-
- @Override
- public Object readObject(ObjectInputStream ois) throws FileNotFoundException, IOException, ClassNotFoundException {
- return ois.readObject();
- }
-
}
\ No newline at end of file
package org.opendaylight.controller.networkconfig.neutron.implementation;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.ObjectInputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import org.apache.felix.dm.Component;
-import org.opendaylight.controller.clustering.services.CacheConfigException;
-import org.opendaylight.controller.clustering.services.CacheExistException;
-import org.opendaylight.controller.clustering.services.IClusterContainerServices;
-import org.opendaylight.controller.clustering.services.IClusterServices;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-import org.opendaylight.controller.configuration.IConfigurationContainerAware;
-import org.opendaylight.controller.configuration.IConfigurationContainerService;
import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD;
import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
-import org.opendaylight.controller.sal.utils.IObjectReader;
-import org.opendaylight.controller.sal.utils.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class NeutronSubnetInterface implements INeutronSubnetCRUD, IConfigurationContainerAware,
- IObjectReader {
+public class NeutronSubnetInterface implements INeutronSubnetCRUD {
private static final Logger logger = LoggerFactory.getLogger(NeutronSubnetInterface.class);
- private static final String FILE_NAME ="neutron.subnet.conf";
+ private ConcurrentMap<String, NeutronSubnet> subnetDB = new ConcurrentHashMap<String, NeutronSubnet>();
- private String containerName = null;
- private IClusterContainerServices clusterContainerService = null;
- private IConfigurationContainerService configurationService;
- private ConcurrentMap<String, NeutronSubnet> subnetDB;
-
- // methods needed for creating caches
-
- void setClusterContainerService(IClusterContainerServices s) {
- logger.debug("Cluster Service set");
- this.clusterContainerService = s;
- }
-
- void unsetClusterContainerService(IClusterContainerServices s) {
- if (this.clusterContainerService == s) {
- logger.debug("Cluster Service removed!");
- this.clusterContainerService = null;
- }
- }
-
- public void setConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service set: {}", service);
- this.configurationService = service;
- }
-
- public void unsetConfigurationContainerService(IConfigurationContainerService service) {
- logger.trace("Configuration service removed: {}", service);
- this.configurationService = null;
- }
-
- private void allocateCache() {
- if (this.clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't create cache");
- return;
- }
- logger.debug("Creating Cache for Neutron Subnets");
- try {
- // neutron caches
- this.clusterContainerService.createCache("neutronSubnets",
- EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL));
- } catch (CacheConfigException cce) {
- logger.error("Cache couldn't be created for Neutron Subnets - check cache mode");
- } catch (CacheExistException cce) {
- logger.error("Cache for Neutron Subnets already exists, destroy and recreate");
- }
- logger.debug("Cache successfully created for Neutron Subnets");
- }
-
- @SuppressWarnings({ "unchecked" })
- private void retrieveCache() {
- if (this.clusterContainerService == null) {
- logger.error("un-initialized clusterContainerService, can't retrieve cache");
- return;
- }
-
- logger.debug("Retrieving cache for Neutron Subnets");
- subnetDB = (ConcurrentMap<String, NeutronSubnet>) this.clusterContainerService
- .getCache("neutronSubnets");
- if (subnetDB == null) {
- logger.error("Cache couldn't be retrieved for Neutron Subnets");
- }
- logger.debug("Cache was successfully retrieved for Neutron Subnets");
- }
-
- private void destroyCache() {
- if (this.clusterContainerService == null) {
- logger.error("un-initialized clusterMger, can't destroy cache");
- return;
- }
- logger.debug("Destroying Cache for HostTracker");
- this.clusterContainerService.destroyCache("neutronSubnets");
- }
-
- private void startUp() {
- allocateCache();
- retrieveCache();
- loadConfiguration();
- }
-
- /**
- * Function called by the dependency manager when all the required
- * dependencies are satisfied
- *
- */
- void init(Component c) {
- Dictionary<?, ?> props = c.getServiceProperties();
- if (props != null) {
- this.containerName = (String) props.get("containerName");
- logger.debug("Running containerName: {}", this.containerName);
- } else {
- // In the Global instance case the containerName is empty
- this.containerName = "";
- }
- startUp();
- }
-
- /**
- * Function called by the dependency manager when at least one dependency
- * become unsatisfied or when the component is shutting down because for
- * example bundle is being stopped.
- *
- */
- void destroy() {
- destroyCache();
- }
-
- /**
- * Function called by dependency manager after "init ()" is called and after
- * the services provided by the class are registered in the service registry
- *
- */
- void start() {
- }
-
- /**
- * Function called by the dependency manager before the services exported by
- * the component are unregistered, this will be followed by a "destroy ()"
- * calls
- *
- */
- void stop() {
- }
// this method uses reflection to update an object from it's delta.
NeutronSubnet target = subnetDB.get(subnetUUID);
return (target.getPortsInSubnet().size() > 0);
}
-
- private void loadConfiguration() {
- for (ConfigurationObject conf : configurationService.retrieveConfiguration(this, FILE_NAME)) {
- NeutronSubnet ns = (NeutronSubnet) conf;
- subnetDB.put(ns.getID(), ns);
- }
- }
-
- @Override
- public Status saveConfiguration() {
- return configurationService.persistConfiguration(new ArrayList<ConfigurationObject>(subnetDB.values()),
- FILE_NAME);
- }
-
- @Override
- public Object readObject(ObjectInputStream ois) throws FileNotFoundException, IOException, ClassNotFoundException {
- return ois.readObject();
- }
-
}
<artifactId>jersey-core</artifactId>
</dependency>
<dependency>
- <groupId>org.codehaus.enunciate</groupId>
- <artifactId>enunciate-core-annotations</artifactId>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-server</artifactId>
</dependency>
<dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>org.eclipse.persistence.antlr</artifactId>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-servlet</artifactId>
</dependency>
<dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>org.eclipse.persistence.core</artifactId>
+ <groupId>org.codehaus.enunciate</groupId>
+ <artifactId>enunciate-core-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.moxy</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>commons.northbound</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>containermanager</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>networkconfig.neutron</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal</artifactId>
- </dependency>
</dependencies>
<build>
<extensions>true</extensions>
<configuration>
<instructions>
- <Import-Package>org.opendaylight.controller.sal.utils,
- org.opendaylight.controller.containermanager,
- org.opendaylight.controller.northbound.commons,
- org.opendaylight.controller.northbound.commons.exception,
- org.opendaylight.controller.northbound.commons.utils,
- org.opendaylight.controller.networkconfig.neutron,
+ <Import-Package>org.opendaylight.controller.networkconfig.neutron,
org.eclipse.persistence.jaxb.rs,
com.sun.jersey.spi.container.servlet,
javax.ws.rs,
javax.xml.bind.annotation,
javax.xml.bind,
org.slf4j,
+ org.osgi.framework,
!org.codehaus.enunciate.jaxrs</Import-Package>
<Web-ContextPath>/controller/nb/v2/neutron</Web-ContextPath>
</instructions>
--- /dev/null
+/*
+ * Copyright (c) 2013 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.controller.networkconfig.neutron.northbound;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+/**
+ * Status Code 400 (Bad Request)
+ *
+ * The request could not be understood by the server due to malformed syntax.
+ * The client SHOULD NOT repeat the request without modifications.
+ */
+public class BadRequestException extends WebApplicationException {
+ private static final long serialVersionUID = 1L;
+
+ public BadRequestException(String string) {
+ super(Response.status(Response.Status.BAD_REQUEST).entity(string).type(MediaType.TEXT_PLAIN).build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 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.controller.networkconfig.neutron.northbound;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.MediaType;
+
+/**
+ * Status Code 500 (Internal Server Error)
+ *
+ * The server encountered an unexpected condition which prevented
+ * it from fulfilling the request.
+ *
+ *
+ *
+ */
+public class InternalServerErrorException extends WebApplicationException {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Constructor for the INTERNAL_SERVER_ERROR custom handler
+ *
+ * @param string Error message to specify further the
+ * INTERNAL_SERVER_ERROR response
+ *
+ */
+ public InternalServerErrorException(String string) {
+ super(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
+ string).type(MediaType.TEXT_PLAIN).build());
+ }
+}
import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallRuleCRUD;
import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
import org.opendaylight.controller.networkconfig.neutron.NeutronFirewall;
-import org.opendaylight.controller.northbound.commons.RestMessages;
-import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
-import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
-import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
-import org.opendaylight.controller.sal.utils.ServiceHelper;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
throw new BadRequestException("Firewall UUID already exists");
}
firewallInterface.addNeutronFirewall(singleton);
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronFirewallAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronFirewallAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronFirewallAware service = (INeutronFirewallAware) instance;
List<NeutronFirewall> bulk = input.getBulk();
Iterator<NeutronFirewall> i = bulk.iterator();
HashMap<String, NeutronFirewall> testMap = new HashMap<String, NeutronFirewall>();
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronFirewallAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronFirewallAware.class, this);
while (i.hasNext()) {
NeutronFirewall test = i.next();
throw new BadRequestException("Attribute edit blocked by Neutron");
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronFirewallAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronFirewallAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronFirewallAware service = (INeutronFirewallAware) instance;
return Response.status(409).build();
}
NeutronFirewall singleton = firewallInterface.getNeutronFirewall(firewallUUID);
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronFirewallAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronFirewallAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronFirewallAware service = (INeutronFirewallAware) instance;
package org.opendaylight.controller.networkconfig.neutron.northbound;
-import org.codehaus.enunciate.jaxrs.ResponseCode;
-import org.codehaus.enunciate.jaxrs.StatusCodes;
-import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallPolicyAware;
-import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallPolicyCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
-import org.opendaylight.controller.networkconfig.neutron.NeutronFirewallPolicy;
-import org.opendaylight.controller.northbound.commons.RestMessages;
-import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
-import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
-import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
-import org.opendaylight.controller.sal.utils.ServiceHelper;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
+
+import org.codehaus.enunciate.jaxrs.ResponseCode;
+import org.codehaus.enunciate.jaxrs.StatusCodes;
+import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallPolicyAware;
+import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallPolicyCRUD;
+import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
+import org.opendaylight.controller.networkconfig.neutron.NeutronFirewallPolicy;
/**
* Neutron Northbound REST APIs for Firewall Policies.<br>
}
firewallPolicyInterface.addNeutronFirewallPolicy(singleton);
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronFirewallPolicyAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronFirewallPolicyAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronFirewallPolicyAware service = (INeutronFirewallPolicyAware) instance;
List<NeutronFirewallPolicy> bulk = input.getBulk();
Iterator<NeutronFirewallPolicy> i = bulk.iterator();
HashMap<String, NeutronFirewallPolicy> testMap = new HashMap<String, NeutronFirewallPolicy>();
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronFirewallPolicyAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronFirewallPolicyAware.class, this);
while (i.hasNext()) {
NeutronFirewallPolicy test = i.next();
throw new BadRequestException("Attribute edit blocked by Neutron");
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronFirewallPolicyAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronFirewallPolicyAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronFirewallPolicyAware service = (INeutronFirewallPolicyAware) instance;
return Response.status(409).build();
}
NeutronFirewallPolicy singleton = firewallPolicyInterface.getNeutronFirewallPolicy(firewallPolicyUUID);
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronFirewallPolicyAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronFirewallPolicyAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronFirewallPolicyAware service = (INeutronFirewallPolicyAware) instance;
package org.opendaylight.controller.networkconfig.neutron.northbound;
-import org.codehaus.enunciate.jaxrs.ResponseCode;
-import org.codehaus.enunciate.jaxrs.StatusCodes;
-import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallPolicyCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallRuleAware;
-import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallRuleCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
-import org.opendaylight.controller.networkconfig.neutron.NeutronFirewallRule;
-import org.opendaylight.controller.northbound.commons.RestMessages;
-import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
-import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
-import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
-import org.opendaylight.controller.sal.utils.ServiceHelper;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
+
+import org.codehaus.enunciate.jaxrs.ResponseCode;
+import org.codehaus.enunciate.jaxrs.StatusCodes;
+import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallPolicyCRUD;
+import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallRuleAware;
+import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallRuleCRUD;
+import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
+import org.opendaylight.controller.networkconfig.neutron.NeutronFirewallRule;
/**
* Neutron Northbound REST APIs for Firewall Rule.<br>
throw new BadRequestException("Firewall Rule UUID already exists");
}
firewallRuleInterface.addNeutronFirewallRule(singleton);
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronFirewallRuleAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronFirewallRuleAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronFirewallRuleAware service = (INeutronFirewallRuleAware) instance;
List<NeutronFirewallRule> bulk = input.getBulk();
Iterator<NeutronFirewallRule> i = bulk.iterator();
HashMap<String, NeutronFirewallRule> testMap = new HashMap<String, NeutronFirewallRule>();
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronFirewallRuleAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronFirewallRuleAware.class, this);
while (i.hasNext()) {
NeutronFirewallRule test = i.next();
throw new BadRequestException("Attribute edit blocked by Neutron");
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronFirewallRuleAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronFirewallRuleAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronFirewallRuleAware service = (INeutronFirewallRuleAware) instance;
return Response.status(409).build();
}
NeutronFirewallRule singleton = firewallRuleInterface.getNeutronFirewallRule(firewallRuleUUID);
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronFirewallRuleAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronFirewallRuleAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronFirewallRuleAware service = (INeutronFirewallRuleAware) instance;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
import org.opendaylight.controller.networkconfig.neutron.Neutron_IPs;
-import org.opendaylight.controller.northbound.commons.RestMessages;
-import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
-import org.opendaylight.controller.northbound.commons.exception.ResourceConflictException;
-import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
-import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
-import org.opendaylight.controller.sal.utils.ServiceHelper;
/**
* Neutron Northbound REST APIs.<br>
throw new ResourceConflictException("fixed IP is in use.");
singleton.setFixedIPAddress(fixedIP);
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronFloatingIPAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronFloatingIPAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronFloatingIPAware service = (INeutronFloatingIPAware) instance;
singleton.setFixedIPAddress(fixedIP);
}
NeutronFloatingIP target = floatingIPInterface.getFloatingIP(floatingipUUID);
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronFloatingIPAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronFloatingIPAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronFloatingIPAware service = (INeutronFloatingIPAware) instance;
throw new ResourceNotFoundException("Floating IP UUID doesn't exist.");
// TODO: need to undo port association if it exists
NeutronFloatingIP singleton = floatingIPInterface.getFloatingIP(floatingipUUID);
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronFloatingIPAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronFloatingIPAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronFloatingIPAware service = (INeutronFloatingIPAware) instance;
package org.opendaylight.controller.networkconfig.neutron.northbound;
-import org.codehaus.enunciate.jaxrs.ResponseCode;
-import org.codehaus.enunciate.jaxrs.StatusCodes;
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerHealthMonitorAware;
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerHealthMonitorCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancer;
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerHealthMonitor;
-import org.opendaylight.controller.northbound.commons.RestMessages;
-import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
-import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
-import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
-import org.opendaylight.controller.sal.utils.ServiceHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
+
+import org.codehaus.enunciate.jaxrs.ResponseCode;
+import org.codehaus.enunciate.jaxrs.StatusCodes;
+import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerHealthMonitorAware;
+import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerHealthMonitorCRUD;
+import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
+import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancer;
+import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerHealthMonitor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Neutron Northbound REST APIs for Load Balancer HealthMonitor.<br>
}
loadBalancerHealthMonitorInterface.addNeutronLoadBalancerHealthMonitor(singleton);
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronLoadBalancerHealthMonitorAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerHealthMonitorAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronLoadBalancerHealthMonitorAware service = (INeutronLoadBalancerHealthMonitorAware) instance;
List<NeutronLoadBalancerHealthMonitor> bulk = input.getBulk();
Iterator<NeutronLoadBalancerHealthMonitor> i = bulk.iterator();
HashMap<String, NeutronLoadBalancerHealthMonitor> testMap = new HashMap<String, NeutronLoadBalancerHealthMonitor>();
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronLoadBalancerHealthMonitorAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerHealthMonitorAware.class, this);
while (i.hasNext()) {
NeutronLoadBalancerHealthMonitor test = i.next();
throw new BadRequestException("Attribute edit blocked by Neutron");
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronLoadBalancerHealthMonitorAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerHealthMonitorAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronLoadBalancerHealthMonitorAware service = (INeutronLoadBalancerHealthMonitorAware) instance;
return Response.status(409).build();
}
NeutronLoadBalancerHealthMonitor singleton = loadBalancerHealthMonitorInterface.getNeutronLoadBalancerHealthMonitor(loadBalancerHealthMonitorID);
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronLoadBalancerHealthMonitorAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerHealthMonitorAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronLoadBalancerHealthMonitorAware service = (INeutronLoadBalancerHealthMonitorAware) instance;
package org.opendaylight.controller.networkconfig.neutron.northbound;
-import org.codehaus.enunciate.jaxrs.ResponseCode;
-import org.codehaus.enunciate.jaxrs.StatusCodes;
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerListenerAware;
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerListenerCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerListener;
-import org.opendaylight.controller.northbound.commons.RestMessages;
-import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
-import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
-import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
-import org.opendaylight.controller.sal.utils.ServiceHelper;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
+
+import org.codehaus.enunciate.jaxrs.ResponseCode;
+import org.codehaus.enunciate.jaxrs.StatusCodes;
+import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerListenerAware;
+import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerListenerCRUD;
+import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
+import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerListener;
/**
* Neutron Northbound REST APIs for LoadBalancerListener Policies.<br>
}
loadBalancerListenerInterface.addNeutronLoadBalancerListener(singleton);
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronLoadBalancerListenerAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerListenerAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronLoadBalancerListenerAware service = (INeutronLoadBalancerListenerAware) instance;
List<NeutronLoadBalancerListener> bulk = input.getBulk();
Iterator<NeutronLoadBalancerListener> i = bulk.iterator();
HashMap<String, NeutronLoadBalancerListener> testMap = new HashMap<String, NeutronLoadBalancerListener>();
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronLoadBalancerListenerAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerListenerAware.class, this);
while (i.hasNext()) {
NeutronLoadBalancerListener test = i.next();
throw new BadRequestException("Attribute edit blocked by Neutron");
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronLoadBalancerListenerAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerListenerAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronLoadBalancerListenerAware service = (INeutronLoadBalancerListenerAware) instance;
return Response.status(409).build();
}
NeutronLoadBalancerListener singleton = loadBalancerListenerInterface.getNeutronLoadBalancerListener(loadBalancerListenerID);
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronLoadBalancerListenerAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerListenerAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronLoadBalancerListenerAware service = (INeutronLoadBalancerListenerAware) instance;
package org.opendaylight.controller.networkconfig.neutron.northbound;
-import org.codehaus.enunciate.jaxrs.ResponseCode;
-import org.codehaus.enunciate.jaxrs.StatusCodes;
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerAware;
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancer;
-import org.opendaylight.controller.northbound.commons.RestMessages;
-import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
-import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
-import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
-import org.opendaylight.controller.sal.utils.ServiceHelper;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
+
+import org.codehaus.enunciate.jaxrs.ResponseCode;
+import org.codehaus.enunciate.jaxrs.StatusCodes;
+import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerAware;
+import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerCRUD;
+import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
+import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancer;
/**
* Neutron Northbound REST APIs for LoadBalancers.<br>
if (loadBalancerInterface.neutronLoadBalancerExists(singleton.getLoadBalancerID())) {
throw new BadRequestException("LoadBalancer UUID already exists");
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronLoadBalancerAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronLoadBalancerAware service = (INeutronLoadBalancerAware) instance;
List<NeutronLoadBalancer> bulk = input.getBulk();
Iterator<NeutronLoadBalancer> i = bulk.iterator();
HashMap<String, NeutronLoadBalancer> testMap = new HashMap<String, NeutronLoadBalancer>();
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronLoadBalancerAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerAware.class, this);
while (i.hasNext()) {
NeutronLoadBalancer test = i.next();
throw new BadRequestException("Attribute edit blocked by Neutron");
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronLoadBalancerAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronLoadBalancerAware service = (INeutronLoadBalancerAware) instance;
return Response.status(409).build();
}
NeutronLoadBalancer singleton = loadBalancerInterface.getNeutronLoadBalancer(loadBalancerID);
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronLoadBalancerAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronLoadBalancerAware service = (INeutronLoadBalancerAware) instance;
package org.opendaylight.controller.networkconfig.neutron.northbound;
-import org.codehaus.enunciate.jaxrs.ResponseCode;
-import org.codehaus.enunciate.jaxrs.StatusCodes;
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolMemberAware;
-import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerPool;
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerPoolMember;
-import org.opendaylight.controller.northbound.commons.RestMessages;
-import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
-import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
-import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
-import org.opendaylight.controller.sal.utils.ServiceHelper;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
+import org.codehaus.enunciate.jaxrs.ResponseCode;
+import org.codehaus.enunciate.jaxrs.StatusCodes;
+import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolCRUD;
+import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolMemberAware;
+import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
+import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerPool;
+import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerPoolMember;
@Path("/pools/{loadBalancerPoolUUID}/members")
public class NeutronLoadBalancerPoolMembersNorthbound {
throw new BadRequestException("LoadBalancerPoolMember UUID already exists");
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronLoadBalancerPoolMemberAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerPoolMemberAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronLoadBalancerPoolMemberAware service = (INeutronLoadBalancerPoolMemberAware) instance;
List<NeutronLoadBalancerPoolMember> bulk = input.getBulk();
Iterator<NeutronLoadBalancerPoolMember> i = bulk.iterator();
HashMap<String, NeutronLoadBalancerPoolMember> testMap = new HashMap<String, NeutronLoadBalancerPoolMember>();
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronLoadBalancerPoolMemberAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerPoolMemberAware.class, this);
while (i.hasNext()) {
NeutronLoadBalancerPoolMember test = i.next();
String loadBalancerPoolMemberUUID = test.getPoolMemberID();
if (singleton == null)
throw new BadRequestException("LoadBalancerPoolMember UUID does not exist.");
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronLoadBalancerPoolMemberAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerPoolMemberAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronLoadBalancerPoolMemberAware service = (INeutronLoadBalancerPoolMemberAware) instance;
package org.opendaylight.controller.networkconfig.neutron.northbound;
-import org.codehaus.enunciate.jaxrs.ResponseCode;
-import org.codehaus.enunciate.jaxrs.StatusCodes;
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolAware;
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerPool;
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerPoolMember;
-import org.opendaylight.controller.northbound.commons.RestMessages;
-import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
-import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
-import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
-import org.opendaylight.controller.sal.utils.ServiceHelper;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
+import org.codehaus.enunciate.jaxrs.ResponseCode;
+import org.codehaus.enunciate.jaxrs.StatusCodes;
+import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolAware;
+import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolCRUD;
+import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
+import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerPool;
+import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerPoolMember;
/**
* Neutron Northbound REST APIs for LoadBalancerPool Policies.<br>
if (loadBalancerPoolInterface.neutronLoadBalancerPoolExists(singleton.getLoadBalancerPoolID())) {
throw new BadRequestException("LoadBalancerPool UUID already exists");
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronLoadBalancerPoolAware.class, this, null);
+
+ Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerPoolAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronLoadBalancerPoolAware service = (INeutronLoadBalancerPoolAware) instance;
List<NeutronLoadBalancerPool> bulk = input.getBulk();
Iterator<NeutronLoadBalancerPool> i = bulk.iterator();
HashMap<String, NeutronLoadBalancerPool> testMap = new HashMap<String, NeutronLoadBalancerPool>();
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronLoadBalancerPoolAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerPoolAware.class, this);
while (i.hasNext()) {
NeutronLoadBalancerPool test = i.next();
throw new BadRequestException("Attribute edit blocked by Neutron");
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronLoadBalancerPoolAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerPoolAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronLoadBalancerPoolAware service = (INeutronLoadBalancerPoolAware) instance;
return Response.status(409).build();
}
NeutronLoadBalancerPool singleton = loadBalancerPoolInterface.getNeutronLoadBalancerPool(loadBalancerPoolUUID);
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronLoadBalancerPoolAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerPoolAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronLoadBalancerPoolAware service = (INeutronLoadBalancerPoolAware) instance;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriInfo;
import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
import org.codehaus.enunciate.jaxrs.ResponseCode;
import org.codehaus.enunciate.jaxrs.StatusCodes;
import org.codehaus.enunciate.jaxrs.TypeHint;
-
import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkAware;
import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
-import org.opendaylight.controller.northbound.commons.RestMessages;
-import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
-import org.opendaylight.controller.northbound.commons.exception.ResourceConflictException;
-import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
-import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
-import org.opendaylight.controller.sal.utils.ServiceHelper;
/**
* Neutron Northbound REST APIs for Network.<br>
throw new BadRequestException("network UUID already exists");
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronNetworkAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronNetworkAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronNetworkAware service = (INeutronNetworkAware) instance;
List<NeutronNetwork> bulk = input.getBulk();
Iterator<NeutronNetwork> i = bulk.iterator();
HashMap<String, NeutronNetwork> testMap = new HashMap<String, NeutronNetwork>();
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronNetworkAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronNetworkAware.class, this);
while (i.hasNext()) {
NeutronNetwork test = i.next();
throw new BadRequestException("attribute edit blocked by Neutron");
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronNetworkAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronNetworkAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronNetworkAware service = (INeutronNetworkAware) instance;
}
NeutronNetwork singleton = networkInterface.getNetwork(netUUID);
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronNetworkAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronNetworkAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronNetworkAware service = (INeutronNetworkAware) instance;
import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
import org.opendaylight.controller.networkconfig.neutron.Neutron_IPs;
-import org.opendaylight.controller.northbound.commons.RestMessages;
-import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
-import org.opendaylight.controller.northbound.commons.exception.ResourceConflictException;
-import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
-import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
-import org.opendaylight.controller.sal.utils.ServiceHelper;
/**
* Neutron Northbound REST APIs.<br>
}
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronPortAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronPortAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronPortAware service = (INeutronPortAware) instance;
List<NeutronPort> bulk = input.getBulk();
Iterator<NeutronPort> i = bulk.iterator();
HashMap<String, NeutronPort> testMap = new HashMap<String, NeutronPort>();
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronPortAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronPortAware.class, this);
while (i.hasNext()) {
NeutronPort test = i.next();
throw new BadRequestException("attribute change blocked by Neutron");
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronPortAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronPortAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronPortAware service = (INeutronPortAware) instance;
Response.status(403).build();
}
NeutronPort singleton = portInterface.getPort(portUUID);
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronPortAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronPortAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronPortAware service = (INeutronPortAware) instance;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import org.opendaylight.controller.networkconfig.neutron.NeutronRouter;
import org.opendaylight.controller.networkconfig.neutron.NeutronRouter_Interface;
import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
-import org.opendaylight.controller.northbound.commons.RestMessages;
-import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
-import org.opendaylight.controller.northbound.commons.exception.ResourceConflictException;
-import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
-import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
-import org.opendaylight.controller.sal.utils.ServiceHelper;
/**
if (!externNetwork.isRouterExternal())
throw new BadRequestException("External Network Pointer isn't marked as router:external");
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronRouterAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronRouterAware service = (INeutronRouterAware) instance;
singleton.getStatus() != null)
throw new BadRequestException("Request attribute change not allowed");
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronRouterAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronRouterAware service = (INeutronRouterAware) instance;
if (routerInterface.routerInUse(routerUUID))
throw new ResourceConflictException("Router UUID in Use");
NeutronRouter singleton = routerInterface.getRouter(routerUUID);
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronRouterAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronRouterAware service = (INeutronRouterAware) instance;
if (targetPort.getDeviceID() != null ||
targetPort.getDeviceOwner() != null)
throw new ResourceConflictException("Target Port already allocated");
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronRouterAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronRouterAware service = (INeutronRouterAware) instance;
input.setID(target.getID());
input.setTenantID(target.getTenantID());
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronRouterAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronRouterAware service = (INeutronRouterAware) instance;
port.setDeviceID(null);
port.setDeviceOwner(null);
target.removeInterface(input.getPortUUID());
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronRouterAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this);
for (Object instance : instances) {
INeutronRouterAware service = (INeutronRouterAware) instance;
service.neutronRouterInterfaceDetached(target, input);
throw new ResourceConflictException("Target Port IP not in Target Subnet");
input.setID(target.getID());
input.setTenantID(target.getTenantID());
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronRouterAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronRouterAware service = (INeutronRouterAware) instance;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityGroupCRUD;
import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
import org.opendaylight.controller.networkconfig.neutron.NeutronSecurityGroup;
-import org.opendaylight.controller.northbound.commons.RestMessages;
-import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
-import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
-import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
-import org.opendaylight.controller.sal.utils.ServiceHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
throw new BadRequestException("Security Group UUID already exists");
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronSecurityGroupAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronSecurityGroupAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronSecurityGroupAware service = (INeutronSecurityGroupAware) instance;
List<NeutronSecurityGroup> bulk = input.getBulk();
Iterator<NeutronSecurityGroup> i = bulk.iterator();
HashMap<String, NeutronSecurityGroup> testMap = new HashMap<String, NeutronSecurityGroup>();
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronSecurityGroupAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronSecurityGroupAware.class, this);
while (i.hasNext()) {
NeutronSecurityGroup test = i.next();
throw new BadRequestException("Attribute edit blocked by Neutron");
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronSecurityGroupAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronSecurityGroupAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronSecurityGroupAware service = (INeutronSecurityGroupAware) instance;
return Response.status(409).build();
}
NeutronSecurityGroup singleton = securityGroupInterface.getNeutronSecurityGroup(securityGroupUUID);
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronSecurityGroupAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronSecurityGroupAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronSecurityGroupAware service = (INeutronSecurityGroupAware) instance;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityRuleCRUD;
import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
import org.opendaylight.controller.networkconfig.neutron.NeutronSecurityRule;
-import org.opendaylight.controller.northbound.commons.RestMessages;
-import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
-import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
-import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
-import org.opendaylight.controller.sal.utils.ServiceHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
if (securityRuleInterface.neutronSecurityRuleExists(singleton.getSecurityRuleUUID())) {
throw new BadRequestException("Security Rule UUID already exists");
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronSecurityRuleAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronSecurityRuleAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronSecurityRuleAware service = (INeutronSecurityRuleAware) instance;
List<NeutronSecurityRule> bulk = input.getBulk();
Iterator<NeutronSecurityRule> i = bulk.iterator();
HashMap<String, NeutronSecurityRule> testMap = new HashMap<String, NeutronSecurityRule>();
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronSecurityRuleAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronSecurityRuleAware.class, this);
while (i.hasNext()) {
NeutronSecurityRule test = i.next();
throw new BadRequestException("Attribute edit blocked by Neutron");
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronSecurityRuleAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronSecurityRuleAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronSecurityRuleAware service = (INeutronSecurityRuleAware) instance;
return Response.status(409).build();
}
NeutronSecurityRule singleton = securityRuleInterface.getNeutronSecurityRule(securityRuleUUID);
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronSecurityRuleAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronSecurityRuleAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronSecurityRuleAware service = (INeutronSecurityRuleAware) instance;
import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD;
import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
-import org.opendaylight.controller.northbound.commons.RestMessages;
-import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
-import org.opendaylight.controller.northbound.commons.exception.ResourceConflictException;
-import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
-import org.opendaylight.controller.northbound.commons.exception.InternalServerErrorException;
-import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
-import org.opendaylight.controller.sal.utils.ServiceHelper;
/**
* Neutron Northbound REST APIs for Subnets.<br>
if (singleton.gatewayIP_Pool_overlap()) {
throw new ResourceConflictException("IP pool overlaps with gateway");
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronSubnetAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronSubnetAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronSubnetAware service = (INeutronSubnetAware) instance;
List<NeutronSubnet> bulk = input.getBulk();
Iterator<NeutronSubnet> i = bulk.iterator();
HashMap<String, NeutronSubnet> testMap = new HashMap<String, NeutronSubnet>();
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronSubnetAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronSubnetAware.class, this);
while (i.hasNext()) {
NeutronSubnet test = i.next();
throw new BadRequestException("Attribute edit blocked by Neutron");
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronSubnetAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronSubnetAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronSubnetAware service = (INeutronSubnetAware) instance;
return Response.status(409).build();
}
NeutronSubnet singleton = subnetInterface.getSubnet(subnetUUID);
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronSubnetAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronSubnetAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronSubnetAware service = (INeutronSubnetAware) instance;
--- /dev/null
+package org.opendaylight.controller.networkconfig.neutron.northbound;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NeutronUtil {
+ private static final Logger logger = LoggerFactory
+ .getLogger(NeutronUtil.class);
+ public static Object[] getInstances(Class<?> clazz,Object bundle) {
+ Object instances[] = null;
+ try {
+ BundleContext bCtx = FrameworkUtil.getBundle(bundle.getClass())
+ .getBundleContext();
+
+ ServiceReference<?>[] services = null;
+ services = bCtx.getServiceReferences(clazz.getName(),
+ null);
+ if (services != null) {
+ instances = new Object[services.length];
+ for (int i = 0; i < services.length; i++) {
+ instances[i] = bCtx.getService(services[i]);
+ }
+ }
+ } catch (Exception e) {
+ logger.error("Instance reference is NULL");
+ }
+ return instances;
+ }
+}
import java.util.Comparator;
import java.util.List;
import javax.ws.rs.core.UriInfo;
+
import org.opendaylight.controller.networkconfig.neutron.INeutronObject;
import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
-import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
-import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
public class PaginatedRequestFactory {
private static final Comparator<INeutronObject> NEUTRON_OBJECT_COMPARATOR = new Comparator<INeutronObject>() {
--- /dev/null
+/*
+ * Copyright (c) 2013 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.controller.networkconfig.neutron.northbound;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.MediaType;
+
+/**
+ * Status Code 409 (Conflict)
+ *
+ * The request could not be completed due to a conflict with the
+ * current state of the resource. This code is only allowed in
+ * situations where it is expected that the user might be able to
+ * resolve the conflict and resubmit the request. The response body
+ * SHOULD include enough information for the user to recognize the
+ * source of the conflict. Ideally, the response entity would include
+ * enough information for the user or user agent to fix the problem;
+ * however, that might not be possible and is not required.
+ *
+ *
+ *
+ */
+public class ResourceConflictException extends WebApplicationException {
+ private static final long serialVersionUID = 1L;
+
+ public ResourceConflictException(String string) {
+ super(Response.status(Response.Status.CONFLICT).entity(string).type(
+ MediaType.TEXT_PLAIN).build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 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.controller.networkconfig.neutron.northbound;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.MediaType;
+
+/**
+ * Status Code 404 (Not Found)
+ *
+ * The server has not found anything matching the Request-URI.
+ * No indication is given of whether the condition is temporary or permanent.
+ * The 410 (Gone) status code SHOULD be used if the server knows,
+ * through some internally configurable mechanism, that an old resource
+ * is permanently unavailable and has no forwarding address.
+ * This status code is commonly used when the server does not wish to
+ * reveal exactly why the request has been refused, or when no other
+ * response is applicable.
+ *
+ *
+ *
+ */
+public class ResourceNotFoundException extends WebApplicationException {
+ private static final long serialVersionUID = 1L;
+
+ public ResourceNotFoundException(String string) {
+ super(Response.status(Response.Status.NOT_FOUND).entity(string).type(
+ MediaType.TEXT_PLAIN).build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 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.controller.networkconfig.neutron.northbound;
+
+public enum RestMessages {
+ SUCCESS("Success"), NOCONTAINER("Container does not exist"), NOSUBNET("Subnet does not exist"), NOSTATICROUTE(
+ "Static Route does not exist"), NOHOST("Host does not exist"), NOFLOW("Flow does not exist"), NONODE(
+ "Node does not exist"), NOPOLICY("Policy does not exist"), NORESOURCE("Resource does not exist"), RESOURCECONFLICT(
+ "Operation failed due to Resource Conflict"), NODEFAULT("Container default is not a custom container"), DEFAULTDISABLED(
+ "Container(s) are configured. Container default is not operational"), NOTALLOWEDONDEFAULT(
+ "Container default is a static resource, no modification allowed on it"), UNKNOWNACTION("Unknown action"), INVALIDJSON(
+ "JSON message is invalid"), INVALIDADDRESS("Invalid InetAddress"), AVAILABLESOON(
+ "Resource is not implemented yet"), INTERNALERROR("Internal Error"), SERVICEUNAVAILABLE(
+ "Service is not available. Could be down for maintanence"), INVALIDDATA(
+ "Data is invalid or conflicts with URI");
+
+ private String message;
+
+ private RestMessages(String msg) {
+ message = msg;
+ }
+
+ @Override
+ public String toString() {
+ return message;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 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.controller.networkconfig.neutron.northbound;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.MediaType;
+
+/**
+ * Status Code 503 (Service Unavailable Error)
+ *
+ * The server is currently unable to handle the request due to a temporary
+ * overloading or maintenance of the server.
+ * The implication is that this is a temporary condition which will be alleviated
+ * after some delay.
+ *
+ *
+ */
+public class ServiceUnavailableException extends WebApplicationException {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Constructor for the SERVICE_UNAVAILABLE custom handler
+ *
+ * @param string Error message to specify further the
+ * SERVICE_UNAVAILABLE response
+ *
+ */
+ public ServiceUnavailableException(String string) {
+ super(Response.status(Response.Status.SERVICE_UNAVAILABLE).entity(
+ string).type(MediaType.TEXT_PLAIN).build());
+ }
+}
<artifactId>commons-net</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>clustering.services</artifactId>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>configuration</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal</artifactId>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
</dependency>
</dependencies>
<build>
<extensions>true</extensions>
<configuration>
<instructions>
- <Import-Package>org.opendaylight.controller.configuration,
- org.opendaylight.controller.clustering.services,
- org.opendaylight.controller.sal.core,
- org.opendaylight.controller.sal.utils,
- org.apache.felix.dm,
- org.apache.commons.net.util,
- org.osgi.service.component,
- org.slf4j,
- javax.xml.bind.annotation</Import-Package>
+ <Import-Package>*</Import-Package>
</instructions>
<manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
</configuration>
package org.opendaylight.controller.networkconfig.neutron;
-import org.opendaylight.controller.sal.utils.ServiceHelper;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class NeutronCRUDInterfaces {
+ private static final Logger logger = LoggerFactory
+ .getLogger(NeutronCRUDInterfaces.class);
public static INeutronNetworkCRUD getINeutronNetworkCRUD(Object o) {
- INeutronNetworkCRUD answer = (INeutronNetworkCRUD) ServiceHelper.getGlobalInstance(INeutronNetworkCRUD.class, o);
+ INeutronNetworkCRUD answer = (INeutronNetworkCRUD) getInstances(INeutronNetworkCRUD.class, o);
return answer;
}
public static INeutronSubnetCRUD getINeutronSubnetCRUD(Object o) {
- INeutronSubnetCRUD answer = (INeutronSubnetCRUD) ServiceHelper.getGlobalInstance(INeutronSubnetCRUD.class, o);
+ INeutronSubnetCRUD answer = (INeutronSubnetCRUD) getInstances(INeutronSubnetCRUD.class, o);
return answer;
}
public static INeutronPortCRUD getINeutronPortCRUD(Object o) {
- INeutronPortCRUD answer = (INeutronPortCRUD) ServiceHelper.getGlobalInstance(INeutronPortCRUD.class, o);
+ INeutronPortCRUD answer = (INeutronPortCRUD) getInstances(INeutronPortCRUD.class, o);
return answer;
}
public static INeutronRouterCRUD getINeutronRouterCRUD(Object o) {
- INeutronRouterCRUD answer = (INeutronRouterCRUD) ServiceHelper.getGlobalInstance(INeutronRouterCRUD.class, o);
+ INeutronRouterCRUD answer = (INeutronRouterCRUD) getInstances(INeutronRouterCRUD.class, o);
return answer;
}
public static INeutronFloatingIPCRUD getINeutronFloatingIPCRUD(Object o) {
- INeutronFloatingIPCRUD answer = (INeutronFloatingIPCRUD) ServiceHelper.getGlobalInstance(INeutronFloatingIPCRUD.class, o);
+ INeutronFloatingIPCRUD answer = (INeutronFloatingIPCRUD) getInstances(INeutronFloatingIPCRUD.class, o);
return answer;
}
public static INeutronSecurityGroupCRUD getINeutronSecurityGroupCRUD(Object o) {
- INeutronSecurityGroupCRUD answer = (INeutronSecurityGroupCRUD) ServiceHelper.getGlobalInstance(INeutronSecurityGroupCRUD.class, o);
+ INeutronSecurityGroupCRUD answer = (INeutronSecurityGroupCRUD) getInstances(INeutronSecurityGroupCRUD.class, o);
return answer;
}
public static INeutronSecurityRuleCRUD getINeutronSecurityRuleCRUD(Object o) {
- INeutronSecurityRuleCRUD answer = (INeutronSecurityRuleCRUD) ServiceHelper.getGlobalInstance(INeutronSecurityRuleCRUD.class, o);
+ INeutronSecurityRuleCRUD answer = (INeutronSecurityRuleCRUD) getInstances(INeutronSecurityRuleCRUD.class, o);
return answer;
}
public static INeutronFirewallCRUD getINeutronFirewallCRUD(Object o) {
- INeutronFirewallCRUD answer = (INeutronFirewallCRUD) ServiceHelper.getGlobalInstance(INeutronFirewallCRUD.class, o);
+ INeutronFirewallCRUD answer = (INeutronFirewallCRUD) getInstances(INeutronFirewallCRUD.class, o);
return answer;
}
public static INeutronFirewallPolicyCRUD getINeutronFirewallPolicyCRUD(Object o) {
- INeutronFirewallPolicyCRUD answer = (INeutronFirewallPolicyCRUD) ServiceHelper.getGlobalInstance(INeutronFirewallPolicyCRUD.class, o);
+ INeutronFirewallPolicyCRUD answer = (INeutronFirewallPolicyCRUD) getInstances(INeutronFirewallPolicyCRUD.class, o);
return answer;
}
public static INeutronFirewallRuleCRUD getINeutronFirewallRuleCRUD(Object o) {
- INeutronFirewallRuleCRUD answer = (INeutronFirewallRuleCRUD) ServiceHelper.getGlobalInstance(INeutronFirewallRuleCRUD.class, o);
+ INeutronFirewallRuleCRUD answer = (INeutronFirewallRuleCRUD) getInstances(INeutronFirewallRuleCRUD.class, o);
return answer;
}
public static INeutronLoadBalancerCRUD getINeutronLoadBalancerCRUD(Object o) {
- INeutronLoadBalancerCRUD answer = (INeutronLoadBalancerCRUD) ServiceHelper.getGlobalInstance(INeutronLoadBalancerCRUD.class, o);
+ INeutronLoadBalancerCRUD answer = (INeutronLoadBalancerCRUD) getInstances(INeutronLoadBalancerCRUD.class, o);
return answer;
}
public static INeutronLoadBalancerPoolCRUD getINeutronLoadBalancerPoolCRUD(Object o) {
- INeutronLoadBalancerPoolCRUD answer = (INeutronLoadBalancerPoolCRUD) ServiceHelper.getGlobalInstance(INeutronLoadBalancerPoolCRUD.class, o);
+ INeutronLoadBalancerPoolCRUD answer = (INeutronLoadBalancerPoolCRUD) getInstances(INeutronLoadBalancerPoolCRUD.class, o);
return answer;
}
public static INeutronLoadBalancerListenerCRUD getINeutronLoadBalancerListenerCRUD(Object o) {
- INeutronLoadBalancerListenerCRUD answer = (INeutronLoadBalancerListenerCRUD) ServiceHelper.getGlobalInstance(INeutronLoadBalancerListenerCRUD.class, o);
+ INeutronLoadBalancerListenerCRUD answer = (INeutronLoadBalancerListenerCRUD) getInstances(INeutronLoadBalancerListenerCRUD.class, o);
return answer;
}
public static INeutronLoadBalancerHealthMonitorCRUD getINeutronLoadBalancerHealthMonitorCRUD(Object o) {
- INeutronLoadBalancerHealthMonitorCRUD answer = (INeutronLoadBalancerHealthMonitorCRUD) ServiceHelper.getGlobalInstance(INeutronLoadBalancerHealthMonitorCRUD.class, o);
+ INeutronLoadBalancerHealthMonitorCRUD answer = (INeutronLoadBalancerHealthMonitorCRUD) getInstances(INeutronLoadBalancerHealthMonitorCRUD.class, o);
return answer;
}
public static INeutronLoadBalancerPoolMemberCRUD getINeutronLoadBalancerPoolMemberCRUD(Object o) {
- INeutronLoadBalancerPoolMemberCRUD answer = (INeutronLoadBalancerPoolMemberCRUD) ServiceHelper.getGlobalInstance(INeutronLoadBalancerPoolMemberCRUD.class, o);
+ INeutronLoadBalancerPoolMemberCRUD answer = (INeutronLoadBalancerPoolMemberCRUD) getInstances(INeutronLoadBalancerPoolMemberCRUD.class, o);
return answer;
}
+
+ public static Object getInstances(Class<?> clazz,Object bundle) {
+ try {
+ BundleContext bCtx = FrameworkUtil.getBundle(bundle.getClass())
+ .getBundleContext();
+
+ ServiceReference<?>[] services = null;
+ services = bCtx.getServiceReferences(clazz.getName(),
+ null);
+ if (services != null) {
+ return bCtx.getService(services[0]);
+ }
+ } catch (Exception e) {
+ logger.error("Instance reference is NULL");
+ }
+ return null;
+ }
}
\ No newline at end of file
package org.opendaylight.controller.networkconfig.neutron;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
-public class NeutronFirewall extends ConfigurationObject implements Serializable {
+public class NeutronFirewall implements Serializable {
private static final long serialVersionUID = 1L;
@XmlElement(name="id")
package org.opendaylight.controller.networkconfig.neutron;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
-public class NeutronFirewallPolicy extends ConfigurationObject implements Serializable {
+public class NeutronFirewallPolicy implements Serializable {
private static final long serialVersionUID = 1L;
@XmlElement(name="id")
package org.opendaylight.controller.networkconfig.neutron;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
-public class NeutronFirewallRule extends ConfigurationObject implements Serializable {
+public class NeutronFirewallRule implements Serializable {
private static final long serialVersionUID = 1L;
@XmlElement(name = "id")
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
-public class NeutronFloatingIP extends ConfigurationObject implements Serializable {
+public class NeutronFloatingIP implements Serializable {
private static final long serialVersionUID = 1L;
// See OpenStack Network API v2.0 Reference for description of
package org.opendaylight.controller.networkconfig.neutron;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
-public class NeutronLoadBalancer extends ConfigurationObject implements Serializable {
+public class NeutronLoadBalancer implements Serializable {
private static final long serialVersionUID = 1L;
@XmlElement(name="id")
package org.opendaylight.controller.networkconfig.neutron;
-import org.opendaylight.controller.configuration.ConfigurationObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
-public class NeutronLoadBalancerHealthMonitor extends ConfigurationObject implements Serializable {
+public class NeutronLoadBalancerHealthMonitor implements Serializable {
private static final long serialVersionUID = 1L;
private static final Logger logger = LoggerFactory.getLogger(NeutronLoadBalancer.class);
package org.opendaylight.controller.networkconfig.neutron;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
-public class NeutronLoadBalancerListener extends ConfigurationObject implements Serializable {
+public class NeutronLoadBalancerListener implements Serializable {
private static final long serialVersionUID = 1L;
@XmlElement(name="id")
package org.opendaylight.controller.networkconfig.neutron;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
-public class NeutronLoadBalancerPool extends ConfigurationObject implements Serializable {
+public class NeutronLoadBalancerPool implements Serializable {
private static final long serialVersionUID = 1L;
@XmlElement(name="id")
package org.opendaylight.controller.networkconfig.neutron;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
-public class NeutronLoadBalancerPoolMember extends ConfigurationObject implements Serializable {
+public class NeutronLoadBalancerPoolMember implements Serializable {
private static final long serialVersionUID = 1L;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-
@XmlRootElement(name = "network")
@XmlAccessorType(XmlAccessType.NONE)
-public class NeutronNetwork extends ConfigurationObject implements Serializable, INeutronObject {
+public class NeutronNetwork implements Serializable, INeutronObject {
// See OpenStack Network API v2.0 Reference for description of
// annotated attributes
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
-public class NeutronPort extends ConfigurationObject implements Serializable, INeutronObject {
+public class NeutronPort implements Serializable, INeutronObject {
private static final long serialVersionUID = 1L;
// See OpenStack Network API v2.0 Reference for description of
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
-public class NeutronRouter extends ConfigurationObject implements Serializable, INeutronObject {
+public class NeutronRouter implements Serializable, INeutronObject {
private static final long serialVersionUID = 1L;
// See OpenStack Network API v2.0 Reference for description of
package org.opendaylight.controller.networkconfig.neutron;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
-public class NeutronSecurityGroup extends ConfigurationObject implements Serializable {
+public class NeutronSecurityGroup implements Serializable {
private static final long serialVersionUID = 1L;
@XmlElement(name = "id")
package org.opendaylight.controller.networkconfig.neutron;
-import org.opendaylight.controller.configuration.ConfigurationObject;
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
-public class NeutronSecurityRule extends ConfigurationObject implements Serializable {
+public class NeutronSecurityRule implements Serializable {
private static final long serialVersionUID = 1L;
@XmlElement(name = "id")
import org.apache.commons.net.util.SubnetUtils;
import org.apache.commons.net.util.SubnetUtils.SubnetInfo;
-import org.opendaylight.controller.configuration.ConfigurationObject;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
-public class NeutronSubnet extends ConfigurationObject implements Serializable, INeutronObject {
+public class NeutronSubnet implements Serializable, INeutronObject {
private static final long serialVersionUID = 1L;
// See OpenStack Network API v2.0 Reference for description of
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
-import org.opendaylight.controller.configuration.ConfigurationObject;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
-public class Neutron_IPs extends ConfigurationObject implements Serializable {
+public class Neutron_IPs implements Serializable {
private static final long serialVersionUID = 1L;
// See OpenStack Network API v2.0 Reference for description of