From: Tony Tkacik Date: Fri, 8 Aug 2014 10:07:24 +0000 (+0000) Subject: Merge "Fix config-manager activator" X-Git-Tag: release/helium~322 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=c74d5c2399e500fe3e690edc8cee497b1cb6f867;hp=eff56082a308f3be21cd4eefd03e0799a6b04714 Merge "Fix config-manager activator" --- diff --git a/features/config-netty/pom.xml b/features/config-netty/pom.xml index 98b97d1d95..16fd975130 100644 --- a/features/config-netty/pom.xml +++ b/features/config-netty/pom.xml @@ -19,7 +19,6 @@ org.opendaylight.controller config-persister-features - ${config.version} features xml runtime diff --git a/features/config-persister/pom.xml b/features/config-persister/pom.xml index 969d0c8841..ec1520ed98 100644 --- a/features/config-persister/pom.xml +++ b/features/config-persister/pom.xml @@ -27,7 +27,6 @@ org.opendaylight.controller netconf-features - ${netconf.version} features xml runtime @@ -35,7 +34,6 @@ org.opendaylight.controller config-features - ${config.version} features xml runtime diff --git a/features/netconf/pom.xml b/features/netconf/pom.xml index 90c088eaba..856557c1e8 100644 --- a/features/netconf/pom.xml +++ b/features/netconf/pom.xml @@ -19,7 +19,6 @@ org.opendaylight.controller config-features - ${config.version} features xml runtime @@ -27,7 +26,6 @@ org.opendaylight.controller features-odl-protocol-framework - ${protocol-framework.version} features xml runtime diff --git a/features/protocol-framework/pom.xml b/features/protocol-framework/pom.xml index 045ac2dffe..ba5dd18fc2 100644 --- a/features/protocol-framework/pom.xml +++ b/features/protocol-framework/pom.xml @@ -19,7 +19,6 @@ org.opendaylight.controller config-features - ${config.version} features xml runtime diff --git a/opendaylight/commons/opendaylight/pom.xml b/opendaylight/commons/opendaylight/pom.xml index ff8735a518..4f678f6854 100644 --- a/opendaylight/commons/opendaylight/pom.xml +++ b/opendaylight/commons/opendaylight/pom.xml @@ -110,7 +110,6 @@ 2.0.1 1.1.1 2.0 - 4.8.1 1.0.0-SNAPSHOT 3.0.0 3.0.1 @@ -160,15 +159,17 @@ ${user.name}-private-view https://sonar.opendaylight.org/ + 2.4 jacoco java + target/code-coverage/jacoco.exec + target/code-coverage/jacoco-it.exec org.openflow.openflowj,net.sf.jung2,org.opendaylight.controller.protobuff.messages 1.0.0 1.2.1 3.1.4.RELEASE 3.1.3.RELEASE 3.1.3.RELEASE - org.openflow.openflowj,net.sf.jung2 0.4.2-SNAPSHOT 0.4.2-SNAPSHOT 0.5.1-SNAPSHOT @@ -926,11 +927,6 @@ filter-valve ${filtervalve.version} - - org.opendaylight.controller - flow-management-compatibility - ${mdsal.version} - org.opendaylight.controller flowprogrammer.northbound @@ -1288,6 +1284,16 @@ sal-distributed-datastore ${mdsal.version} + + org.opendaylight.controller + sal-clustering-commons + ${mdsal.version} + + + org.opendaylight.controller + sal-clustering-config + ${mdsal.version} + org.opendaylight.controller @@ -1495,11 +1501,6 @@ model-flow-base ${mdsal.version} - - org.opendaylight.controller.model - model-flow-management - ${mdsal.version} - org.opendaylight.controller.model model-flow-service @@ -1776,12 +1777,6 @@ slf4j-simple ${slf4j.version} - - junit - junit - ${junit.version} - test - org.opendaylight.controller commons.logback_settings @@ -1807,9 +1802,75 @@ ${yangtools.version} test + + org.opendaylight.controller + config-features + ${config.version} + features + xml + runtime + + + org.opendaylight.controller + features-odl-protocol-framework + ${protocol-framework.version} + features + xml + runtime + + + org.opendaylight.controller + netconf-features + ${netconf.version} + features + xml + runtime + + + org.opendaylight.controller + config-persister-features + ${config.version} + features + xml + runtime + + + org.opendaylight.controller + config-netty-features + ${config.version} + features + xml + runtime + + + org.opendaylight.controller + features-adsal + ${sal.version} + features + xml + runtime + + + org.opendaylight.controller + mdsal-features + ${mdsal.version} + features + xml + runtime + + + + + org.codehaus.sonar-plugins.java + sonar-jacoco-listeners + ${sonar-jacoco-listeners.version} + test + + + @@ -2103,6 +2164,30 @@ org.jacoco jacoco-maven-plugin ${jacoco.version} + + + prepare-ut-agent + process-test-classes + + prepare-agent + + + ${sonar.jacoco.reportPath} + jacoco.agent.ut.arg + + + + prepare-it-agent + pre-integration-test + + prepare-agent + + + ${sonar.jacoco.itReportPath} + jacoco.agent.it.arg + + + org.opendaylight.yangtools @@ -2179,13 +2264,20 @@ maven-failsafe-plugin ${failsafe.version} - ${testvm.argLine} + ${testvm.argLine} ${jacoco.agent.it.arg} logback.configurationFile logback.xml + + + + listener + org.sonar.java.jacoco.JUnitListener + + @@ -2209,19 +2301,30 @@ maven-surefire-plugin ${surefire.version} - ${testvm.argLine} + ${testvm.argLine} ${jacoco.agent.ut.arg} logback.configurationFile logback.xml + + + + listener + org.sonar.java.jacoco.JUnitListener + + org.codehaus.mojo build-helper-maven-plugin + + org.jacoco + jacoco-maven-plugin + diff --git a/opendaylight/config/config-manager/pom.xml b/opendaylight/config/config-manager/pom.xml index fc2c0fd85b..c98a47660e 100644 --- a/opendaylight/config/config-manager/pom.xml +++ b/opendaylight/config/config-manager/pom.xml @@ -91,16 +91,6 @@ org.apache.maven.plugins maven-jar-plugin - - org.apache.maven.plugins - maven-surefire-plugin - - 1 - false - false - 1 - - diff --git a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/runtimembean/RuntimeBeanRegistratorImplTest.java b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/runtimembean/RuntimeBeanRegistratorImplTest.java index ce3648d160..16de00508a 100644 --- a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/runtimembean/RuntimeBeanRegistratorImplTest.java +++ b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/runtimembean/RuntimeBeanRegistratorImplTest.java @@ -7,10 +7,12 @@ */ package org.opendaylight.controller.config.manager.impl.runtimembean; +import static org.hamcrest.CoreMatchers.containsString; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; -import static org.junit.internal.matchers.StringContains.containsString; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; import java.lang.management.ManagementFactory; import java.util.Map; @@ -29,9 +31,6 @@ import org.opendaylight.controller.config.manager.impl.jmx.BaseJMXRegistrator; import org.opendaylight.controller.config.manager.impl.jmx.HierarchicalRuntimeBeanRegistrationImpl; import org.opendaylight.controller.config.manager.impl.jmx.RootRuntimeBeanRegistratorImpl; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; - public class RuntimeBeanRegistratorImplTest extends AbstractLockedPlatformMBeanServerTest { static final String module1 = "module1"; @@ -60,11 +59,11 @@ public class RuntimeBeanRegistratorImplTest extends assertEquals(0, baseJMXRegistrator.getRegisteredObjectNames().size()); } - protected void checkExists(ObjectName on) throws Exception { + protected void checkExists(final ObjectName on) throws Exception { platformMBeanServer.getMBeanInfo(on); } - protected void checkNotExists(ObjectName on) throws Exception { + protected void checkNotExists(final ObjectName on) throws Exception { try { platformMBeanServer.getMBeanInfo(on); fail(); @@ -98,7 +97,7 @@ public class RuntimeBeanRegistratorImplTest extends } private HierarchicalRuntimeBeanRegistration createAdditional( - HierarchicalRuntimeBeanRegistrationImpl rootRegistration) + final HierarchicalRuntimeBeanRegistrationImpl rootRegistration) throws Exception { HierarchicalRuntimeBeanRegistrationImpl registration = rootRegistration diff --git a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/parallelapsp/test/DependentWiringTest.java b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/parallelapsp/test/DependentWiringTest.java index c9810d0521..165a6c7ed6 100644 --- a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/parallelapsp/test/DependentWiringTest.java +++ b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/parallelapsp/test/DependentWiringTest.java @@ -7,14 +7,16 @@ */ package org.opendaylight.controller.config.manager.testingservices.parallelapsp.test; +import static org.hamcrest.CoreMatchers.containsString; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import static org.junit.internal.matchers.StringContains.containsString; import java.util.Map; + import javax.management.ObjectName; + import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/opendaylight/config/config-netty-config/src/main/resources/initial/00-netty.xml b/opendaylight/config/config-netty-config/src/main/resources/initial/00-netty.xml index 686d363110..2bf5b36d7a 100644 --- a/opendaylight/config/config-netty-config/src/main/resources/initial/00-netty.xml +++ b/opendaylight/config/config-netty-config/src/main/resources/initial/00-netty.xml @@ -15,7 +15,7 @@ urn:opendaylight:params:xml:ns:yang:controller:netty:timer?module=netty-timer&revision=2013-11-19 - + @@ -35,7 +35,7 @@ singleton - + netty:netty-threadgroup diff --git a/opendaylight/config/config-util/pom.xml b/opendaylight/config/config-util/pom.xml index 7429f4d574..fd9c1b91e3 100644 --- a/opendaylight/config/config-util/pom.xml +++ b/opendaylight/config/config-util/pom.xml @@ -32,16 +32,6 @@ org.apache.maven.plugins maven-jar-plugin - - org.apache.maven.plugins - maven-surefire-plugin - - 1 - false - false - 1 - - org.apache.felix maven-bundle-plugin diff --git a/opendaylight/config/pom.xml b/opendaylight/config/pom.xml index 26fac47e71..343d13e9c1 100644 --- a/opendaylight/config/pom.xml +++ b/opendaylight/config/pom.xml @@ -94,18 +94,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - true - classes - 1C - false - true - 2 - - org.codehaus.groovy.maven gmaven-plugin diff --git a/opendaylight/config/yang-jmx-generator-it/pom.xml b/opendaylight/config/yang-jmx-generator-it/pom.xml index c91881bd3e..f9e0c7036a 100644 --- a/opendaylight/config/yang-jmx-generator-it/pom.xml +++ b/opendaylight/config/yang-jmx-generator-it/pom.xml @@ -42,39 +42,4 @@ test - - - - - org.apache.maven.plugins - maven-surefire-plugin - - 1 - false - false - - - - default-test - - true - - - - integration-tests - - test - - integration-test - - - **/org/opendaylight/controller/config/yangjmxgenerator/it/*.java - - false - - - - - - diff --git a/opendaylight/config/yang-jmx-generator/pom.xml b/opendaylight/config/yang-jmx-generator/pom.xml index fbae840fc6..133b07ff86 100644 --- a/opendaylight/config/yang-jmx-generator/pom.xml +++ b/opendaylight/config/yang-jmx-generator/pom.xml @@ -58,12 +58,6 @@ yang-parser-impl test - - org.hamcrest - hamcrest-core - 1.1 - test - diff --git a/opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/RuntimeBeanEntryTest.java b/opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/RuntimeBeanEntryTest.java index b570302563..e80ebc67a5 100644 --- a/opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/RuntimeBeanEntryTest.java +++ b/opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/RuntimeBeanEntryTest.java @@ -7,7 +7,22 @@ */ package org.opendaylight.controller.config.yangjmxgenerator; +import static junit.framework.Assert.assertNotNull; +import static junit.framework.Assert.assertNull; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.doReturn; + +import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +import javax.management.openmbean.SimpleType; + import org.junit.Test; import org.mockito.Mockito; import org.opendaylight.controller.config.yangjmxgenerator.attribute.JavaAttribute; @@ -18,20 +33,6 @@ import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode; import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; -import javax.management.openmbean.SimpleType; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Map; - -import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertNull; -import static org.hamcrest.CoreMatchers.is; - -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.doReturn; - public class RuntimeBeanEntryTest extends AbstractYangTest { public static final String PACKAGE_NAME = "packages.sis"; @@ -54,10 +55,10 @@ public class RuntimeBeanEntryTest extends AbstractYangTest { Map runtimeBeans = RuntimeBeanEntry .extractClassNameToRuntimeBeanMap(PACKAGE_NAME, caseNode, "test-name", new TypeProviderWrapper(new TypeProviderImpl(context)), "test", jmxImplModule); - assertThat(runtimeBeans.size(), is(1)); + assertEquals(1, runtimeBeans.size()); RuntimeBeanEntry runtimeMXBean = runtimeBeans.get("testRuntimeMXBean"); - assertThat(runtimeMXBean.isRoot(), is(true)); - assertThat(runtimeMXBean.getYangName(), is("test-name")); + assertTrue(runtimeMXBean.isRoot()); + assertEquals("test-name", runtimeMXBean.getYangName()); } @Test @@ -72,7 +73,7 @@ public class RuntimeBeanEntryTest extends AbstractYangTest { threadsJavaModule, modulesToSIEs, context, new TypeProviderWrapper(new TypeProviderImpl(context)), PACKAGE_NAME); - assertThat(namesToMBEs.isEmpty(), is(false)); + assertFalse(namesToMBEs.isEmpty()); // get threadfactory-naming bean ModuleMXBeanEntry threadfactoryNamingMXBean = namesToMBEs @@ -82,13 +83,13 @@ public class RuntimeBeanEntryTest extends AbstractYangTest { // get runtime beans Collection runtimeBeanEntries = threadfactoryNamingMXBean .getRuntimeBeans(); - assertThat(runtimeBeanEntries.isEmpty(), is(false)); + assertFalse(runtimeBeanEntries.isEmpty()); // get root runtime bean RuntimeBeanEntry threadfactoryRuntimeBeanEntry = getRuntimeBeanEntryByJavaName( runtimeBeanEntries, "NamingThreadFactoryRuntimeMXBean"); assertNotNull(threadfactoryRuntimeBeanEntry); - assertThat(threadfactoryRuntimeBeanEntry.isRoot(), is(true)); + assertTrue(threadfactoryRuntimeBeanEntry.isRoot()); // get thread runtime bean RuntimeBeanEntry runtimeBeanEntry = getRuntimeBeanEntryByJavaName( @@ -96,43 +97,41 @@ public class RuntimeBeanEntryTest extends AbstractYangTest { assertNotNull(runtimeBeanEntry); // test thread runtime bean properties - assertThat(runtimeBeanEntry.getJavaNamePrefix(), - is(THREAD_RUNTIME_BEAN_JAVA_PREFIX)); - assertThat(runtimeBeanEntry.getPackageName(), is(PACKAGE_NAME)); - assertThat(runtimeBeanEntry.getFullyQualifiedName(runtimeBeanEntry - .getJavaNameOfRuntimeMXBean()), is(PACKAGE_NAME + "." - + THREAD_RUNTIME_BEAN_JAVA_NAME)); - assertThat(runtimeBeanEntry.getYangName(), - is(THREAD_RUNTIME_BEAN_YANG_NAME)); + assertEquals(THREAD_RUNTIME_BEAN_JAVA_PREFIX, runtimeBeanEntry.getJavaNamePrefix()); + assertEquals(PACKAGE_NAME, runtimeBeanEntry.getPackageName()); + assertEquals(PACKAGE_NAME + "." + THREAD_RUNTIME_BEAN_JAVA_NAME, + runtimeBeanEntry.getFullyQualifiedName(runtimeBeanEntry + .getJavaNameOfRuntimeMXBean())); + assertEquals(THREAD_RUNTIME_BEAN_YANG_NAME, runtimeBeanEntry.getYangName()); // get thread runtime bean rpcs List rpcs = new ArrayList( runtimeBeanEntry.getRpcs()); - assertThat(rpcs.size(), is(2)); + assertEquals(2, rpcs.size()); // get sleep rpc and test it RuntimeBeanEntry.Rpc rpc = getRpcByName(rpcs, SLEEP_RPC_NAME); assertNotNull(rpc); - assertThat(rpc.getYangName(), is(SLEEP_RPC_NAME)); + assertEquals(SLEEP_RPC_NAME, rpc.getYangName()); - assertThat(((JavaAttribute)rpc.getReturnType()).getType().getFullyQualifiedName().endsWith(SLEEP_RPC_OUTPUT), is(true)); + assertTrue(((JavaAttribute)rpc.getReturnType()).getType().getFullyQualifiedName().endsWith(SLEEP_RPC_OUTPUT)); // get sleep rpc input attribute and test it List attributes = rpc.getParameters(); - assertThat(attributes.size(), is(1)); + assertEquals(1, attributes.size()); JavaAttribute attribute = attributes.get(0); - assertThat(attribute.getAttributeYangName(), is(SLEEP_RPC_INPUT_NAME)); - assertThat(attribute.getType().getName(), is(SLEEP_RPC_INPUT_TYPE)); - assertThat(attribute.getLowerCaseCammelCase(), is(SLEEP_RPC_INPUT_NAME)); - assertThat(attribute.getUpperCaseCammelCase(), is("Millis")); + assertEquals(SLEEP_RPC_INPUT_NAME, attribute.getAttributeYangName()); + assertEquals(SLEEP_RPC_INPUT_TYPE, attribute.getType().getName()); + assertEquals(SLEEP_RPC_INPUT_NAME, attribute.getLowerCaseCammelCase()); + assertEquals("Millis", attribute.getUpperCaseCammelCase()); assertNull(attribute.getNullableDefault()); assertNull(attribute.getNullableDescription()); - assertThat(attribute.getOpenType(), is(SimpleType.class)); + assertTrue(attribute.getOpenType() instanceof SimpleType); } private RuntimeBeanEntry getRuntimeBeanEntryByJavaName( final Collection runtimeBeanEntries, - String javaName) { + final String javaName) { if (runtimeBeanEntries != null && !runtimeBeanEntries.isEmpty()) { for (RuntimeBeanEntry runtimeBeanEntry : runtimeBeanEntries) { if (runtimeBeanEntry.getJavaNameOfRuntimeMXBean().equals( @@ -145,7 +144,7 @@ public class RuntimeBeanEntryTest extends AbstractYangTest { } private RuntimeBeanEntry.Rpc getRpcByName( - final List rpcs, String name) { + final List rpcs, final String name) { if (rpcs != null && !rpcs.isEmpty()) { for (RuntimeBeanEntry.Rpc rpc : rpcs) { if (rpc.getName().equals(name)) { diff --git a/opendaylight/distribution/opendaylight-karaf/pom.xml b/opendaylight/distribution/opendaylight-karaf/pom.xml index 977fab1334..5effbb09fc 100644 --- a/opendaylight/distribution/opendaylight-karaf/pom.xml +++ b/opendaylight/distribution/opendaylight-karaf/pom.xml @@ -64,7 +64,6 @@ org.opendaylight.controller config-netty-features - ${config.version} features xml runtime @@ -74,7 +73,6 @@ org.opendaylight.controller features-adsal - ${sal.version} features xml runtime @@ -92,7 +90,6 @@ org.opendaylight.controller mdsal-features - ${mdsal.version} features xml runtime diff --git a/opendaylight/distribution/opendaylight/pom.xml b/opendaylight/distribution/opendaylight/pom.xml index f8796e0ae4..7ab56e6d03 100644 --- a/opendaylight/distribution/opendaylight/pom.xml +++ b/opendaylight/distribution/opendaylight/pom.xml @@ -745,8 +745,8 @@ generate-resources ${project.build.directory}/configuration - sal-rest-connector-config,config-netty-config,md-sal-config,netconf-config,toaster-config,netconf-connector-config - **\/*.xml + sal-rest-connector-config,config-netty-config,md-sal-config,netconf-config,toaster-config,netconf-connector-config,sal-clustering-config + **\/*.xml,**/*.conf true false @@ -1296,11 +1296,14 @@ jeromq 0.3.1 - - org.opendaylight.controller - sal-distributed-datastore - - + + org.opendaylight.controller + sal-distributed-datastore + + + org.opendaylight.controller + sal-clustering-config + diff --git a/opendaylight/md-sal/compatibility/flow-management-compatibility/pom.xml b/opendaylight/md-sal/compatibility/flow-management-compatibility/pom.xml deleted file mode 100644 index 7770c15349..0000000000 --- a/opendaylight/md-sal/compatibility/flow-management-compatibility/pom.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - 4.0.0 - - org.opendaylight.controller - compatibility-parent - 1.1-SNAPSHOT - - flow-management-compatibility - bundle - - - - com.google.guava - guava - - - org.opendaylight.controller - forwardingrulesmanager - - - org.opendaylight.controller - sal-binding-api - - - org.opendaylight.controller - sal-common-util - - - org.opendaylight.controller - sal-compatibility - - - org.opendaylight.controller.model - model-flow-management - - - org.slf4j - slf4j-api - - - junit - junit - test - - - org.mockito - mockito-all - test - - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - Forwarding Rules Manager Adapter for MD-SAL - - - - - - - scm:git:ssh://git.opendaylight.org:29418/controller.git - scm:git:ssh://git.opendaylight.org:29418/controller.git - HEAD - https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL - - diff --git a/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/ConfigurationReader.java b/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/ConfigurationReader.java deleted file mode 100644 index 411af282bd..0000000000 --- a/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/ConfigurationReader.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * 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.frm.compatibility; - -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.List; - -import org.opendaylight.controller.forwardingrulesmanager.FlowConfig; -import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManager; -import org.opendaylight.controller.sal.compatibility.NodeMapping; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.Flows; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.FlowsBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ConfigurationReader implements FlowManagementReader { - - private final static Logger LOG = LoggerFactory.getLogger(ConfigurationReader.class); - - private IForwardingRulesManager manager; - - @Override - public Flows readAllFlows() { - List staticFlows = this.manager.getStaticFlows(); - List flowMap = new ArrayList(staticFlows.size()); - - for (FlowConfig conf : staticFlows) { - flowMap.add(FlowConfigMapping.toConfigurationFlow(conf)); - } - final FlowsBuilder flowsBuilder = new FlowsBuilder(); - return (flowsBuilder.setFlow(flowMap)).build(); - } - - @Override - public Flow readFlow(final FlowKey key) { - try { - final FlowConfig flowConf = - this.manager.getStaticFlow(String.valueOf(key.getId()), NodeMapping.toADNode(key.getNode())); - return FlowConfigMapping.toConfigurationFlow(flowConf); - } catch (Exception e) { - String errMsg = MessageFormat.format("readFlow by key {} fail", key); - LOG.error(errMsg, e); - throw new RuntimeException(errMsg, e); - } - } - - public IForwardingRulesManager getManager() { - return this.manager; - } - - public void setManager(final IForwardingRulesManager manager) { - this.manager = manager; - } -} diff --git a/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FRMRuntimeDataProvider.java b/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FRMRuntimeDataProvider.java deleted file mode 100644 index 0653eeb2a6..0000000000 --- a/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FRMRuntimeDataProvider.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * 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.frm.compatibility; - -import org.opendaylight.controller.forwardingrulesmanager.FlowConfig; -import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManager; -import org.opendaylight.controller.md.sal.common.api.data.DataChangeListener; -import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler; -import org.opendaylight.controller.md.sal.common.api.data.DataModification; -import org.opendaylight.controller.sal.binding.api.data.DataProviderService; -import org.opendaylight.controller.sal.binding.api.data.RuntimeDataProvider; -import org.opendaylight.controller.sal.common.util.Arguments; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.Flows; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey; -import org.opendaylight.yangtools.concepts.Registration; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.Identifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; - -import com.google.common.base.Objects; -import com.google.common.base.Preconditions; - -public class FRMRuntimeDataProvider implements RuntimeDataProvider, DataCommitHandler,DataObject> { - - private final static InstanceIdentifier FLOWS_PATH = InstanceIdentifier. builder(Flows.class).toInstance(); - - private final FlowManagementReader configuration = new ConfigurationReader(); - private DataChangeListener, DataObject> changeListener; - private DataProviderService dataService; - private IForwardingRulesManager manager; - - public Registration init() { - return this.dataService.registerCommitHandler(FRMRuntimeDataProvider.FLOWS_PATH, this); - } - - @Override - public DataObject readConfigurationData(final InstanceIdentifier path) { - return this.readFrom(this.configuration, path); - } - - @Override - public DataObject readOperationalData(final InstanceIdentifier path) { - return this.readFrom(this.configuration, path); - } - - public DataObject readFrom(final FlowManagementReader store, final InstanceIdentifier path) { - if (Objects.equal(FRMRuntimeDataProvider.FLOWS_PATH, path)) { - return store.readAllFlows(); - } - if (FRMRuntimeDataProvider.FLOWS_PATH.contains(path)) { - return store.readFlow(this.toFlowKey(path)); - } - return null; - } - - @Override - public FlowCommitTransaction requestCommit(final DataModification, DataObject> modification) { - return new FlowCommitTransaction(this, modification); - } - - public FlowKey toFlowKey(final InstanceIdentifier identifier) { - Preconditions.> checkNotNull(identifier); - - Iterable path = identifier.getPathArguments(); - PathArgument get = path.iterator().next(); - final Identifier itemKey = Arguments. checkInstanceOf(get, IdentifiableItem.class).getKey(); - return Arguments. checkInstanceOf(itemKey, FlowKey.class); - } - - public RpcResult finish(final FlowCommitTransaction transaction) { - Iterable toRemove = transaction.getToRemove(); - for (final FlowConfig flow : toRemove) { - this.manager.removeStaticFlow(flow.getName(), flow.getNode()); - } - Iterable toUpdate = transaction.getToUpdate(); - for (final FlowConfig flow : toUpdate) { - this.manager.removeStaticFlow(flow.getName(), flow.getNode()); - this.manager.addStaticFlow(flow); - } - return RpcResultBuilder. success().build(); - } - - public RpcResult rollback(final FlowCommitTransaction transaction) { - return null; - } - - public DataProviderService getDataService() { - return this.dataService; - } - - public void setDataService(final DataProviderService dataService) { - this.dataService = dataService; - } - - public DataChangeListener, DataObject> getChangeListener() { - return this.changeListener; - } - - public void setChangeListener(final DataChangeListener, DataObject> changeListener) { - this.changeListener = changeListener; - } - - public IForwardingRulesManager getManager() { - return this.manager; - } - - public void setManager(final IForwardingRulesManager manager) { - this.manager = manager; - } -} diff --git a/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowCommitTransaction.java b/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowCommitTransaction.java deleted file mode 100644 index bf0050d6c0..0000000000 --- a/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowCommitTransaction.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * 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.frm.compatibility; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Map.Entry; -import java.util.Set; - -import org.opendaylight.controller.forwardingrulesmanager.FlowConfig; -import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction; -import org.opendaylight.controller.md.sal.common.api.data.DataModification; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.RpcResult; - -public class FlowCommitTransaction implements DataCommitTransaction, DataObject> { - - private final DataModification, DataObject> modification; - private final HashSet toAdd = new HashSet(); - private final FRMRuntimeDataProvider flowManager; - private Iterable toUpdate; - private Iterable toRemove; - - public FlowCommitTransaction( - final FRMRuntimeDataProvider flowManager, - final DataModification, DataObject> modification) { - this.flowManager = flowManager; - this.modification = modification; - this.processModification(); - } - - @Override - public RpcResult finish() throws IllegalStateException { - return this.flowManager.finish(this); - } - - @Override - public RpcResult rollback() throws IllegalStateException { - return this.flowManager.rollback(this); - } - - public void processModification() { - final Set, DataObject>> updated = - this.modification.getUpdatedConfigurationData().entrySet(); - final List forUpdate = new ArrayList(updated.size()); - - if (updated != null && !(updated.isEmpty())) { - for (Entry, DataObject> entry : updated) { - if (FlowConfigMapping.isFlowPath(entry.getKey())) { - forUpdate.add(FlowConfigMapping.toFlowConfig((Flow) entry.getValue())); - } - } - } - this.toUpdate = Collections.unmodifiableCollection(forUpdate); - - final Set> removedConfigurationData = - this.modification.getRemovedConfigurationData(); - final List forRemove = new ArrayList(removedConfigurationData.size()); - - if (removedConfigurationData != null && !(removedConfigurationData.isEmpty())) { - for (InstanceIdentifier data : removedConfigurationData) { - if (FlowConfigMapping.isFlowPath(data)) { - forRemove.add(FlowConfigMapping.toFlowConfig(data)); - } - } - } - this.toRemove = Collections.unmodifiableCollection(forRemove); - } - - @Override - public DataModification, DataObject> getModification() { - return this.modification; - } - - public FRMRuntimeDataProvider getFlowManager() { - return this.flowManager; - } - - public HashSet getToAdd() { - return this.toAdd; - } - - public Iterable getToUpdate() { - return this.toUpdate; - } - - public Iterable getToRemove() { - return this.toRemove; - } -} diff --git a/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowConfigMapping.java b/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowConfigMapping.java deleted file mode 100644 index 58c60ec1c5..0000000000 --- a/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowConfigMapping.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * 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.frm.compatibility; - -import java.text.MessageFormat; -import java.util.Iterator; - -import org.opendaylight.controller.forwardingrulesmanager.FlowConfig; -import org.opendaylight.controller.sal.compatibility.MDFlowMapping; -import org.opendaylight.controller.sal.compatibility.NodeMapping; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded; -import org.opendaylight.yangtools.yang.binding.Identifiable; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class FlowConfigMapping { - - private final static Logger LOG = LoggerFactory.getLogger(FlowConfigMapping.class); - - /* nodes/node/flow -> 0 / 1 / 2 */ - private static final int FLOW_KEY_IDENTIFIER_DEEP = 2; - - public static Flow toConfigurationFlow(final FlowConfig sourceCfg) { - final FlowAdded source = MDFlowMapping.flowAdded(sourceCfg.getFlow()); - final FlowBuilder flowBuilder = new FlowBuilder(); - flowBuilder.setInstructions(source.getInstructions()); - flowBuilder.setCookie(source.getCookie()); - flowBuilder.setHardTimeout(source.getHardTimeout()); - flowBuilder.setIdleTimeout(source.getIdleTimeout()); - flowBuilder.setMatch(source.getMatch()); - flowBuilder.setNode(source.getNode()); - - FlowKey flowKey = - new FlowKey(Long.valueOf(sourceCfg.getName()), flowBuilder.getNode()); - flowBuilder.setKey(flowKey); - return flowBuilder.build(); - } - - public static FlowConfig toFlowConfig(final Flow sourceCfg) { - try { - final FlowConfig flowConfig = new FlowConfig(); - flowConfig.setName(String.valueOf(sourceCfg.getId())); - flowConfig.setNode(NodeMapping.toADNode(sourceCfg.getNode())); - return flowConfig; - } catch (Exception e) { - String errMsg = MessageFormat.format("Convert from Flow {} to FlowConfig fail", sourceCfg); - LOG.error(errMsg, e); - throw new RuntimeException(errMsg, e); - } - } - - public static FlowConfig toFlowConfig(final InstanceIdentifier identifier) { - try { - PathArgument pathArg = FlowConfigMapping.getSecondPathArgumentFromPath(identifier); - if (pathArg != null) { - final FlowConfig flowConfig = new FlowConfig(); - FlowKey key = ((IdentifiableItem) pathArg).getKey(); - flowConfig.setName(String.valueOf(key.getId())); - flowConfig.setNode(NodeMapping.toADNode(key.getNode())); - return flowConfig; - } - return null; - } catch (Exception e) { - String errMsg = MessageFormat.format("Convert from InstanceIdentifier {} to FlowConfig fail", identifier); - LOG.error(errMsg, e); - throw new RuntimeException(errMsg, e); - } - } - - public static boolean isFlowPath(final InstanceIdentifier path) { - PathArgument pathArg = FlowConfigMapping.getSecondPathArgumentFromPath(path); - if (pathArg == null) { - return false; - } - if (pathArg instanceof IdentifiableItem) { - final Identifiable key = ((IdentifiableItem>) pathArg).getKey(); - if ((key instanceof FlowKey)) { - return true; - } - } - return false; - } - - private static PathArgument getSecondPathArgumentFromPath(final InstanceIdentifier path) { - if (path != null && path.getPathArguments() != null) { - Iterator iterator = path.getPathArguments().iterator(); - int deep = 0; - while (iterator.hasNext()) { - PathArgument pathArg = iterator.next(); - if (deep == FlowConfigMapping.FLOW_KEY_IDENTIFIER_DEEP) { - return pathArg; - } - deep++; - } - } - return null; - } -} diff --git a/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowManagementReader.java b/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowManagementReader.java deleted file mode 100644 index cb61c8a095..0000000000 --- a/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowManagementReader.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * 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.frm.compatibility; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.Flows; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey; - -public interface FlowManagementReader { - - Flows readAllFlows(); - - Flow readFlow(FlowKey key); - -} diff --git a/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/SampleConsumer.java b/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/SampleConsumer.java deleted file mode 100644 index a91cef6136..0000000000 --- a/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/SampleConsumer.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.frm.compatibility; - -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext; -import org.opendaylight.controller.sal.binding.api.data.DataBrokerService; -import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.Flows; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -public class SampleConsumer { - - ConsumerContext context; - - void addFlowExample() { - - DataBrokerService dataService = context.getSALService(DataBrokerService.class); - - DataModificationTransaction transaction = dataService.beginTransaction(); - Flow flow = createSampleFlow("foo", null); - InstanceIdentifier path = InstanceIdentifier.builder(Flows.class).child(Flow.class, flow.getKey()) - .toInstance(); - transaction.putConfigurationData(path, flow); - - transaction.commit(); - - dataService.readConfigurationData(path); - } - - Flow createSampleFlow(String name, NodeRef node) { - FlowBuilder ret = new FlowBuilder(); - FlowKey key = new FlowKey(Long.parseLong(name), node); - ret.setKey(key); - return ret.build(); - } -} diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/pom.xml b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/pom.xml deleted file mode 100644 index 62dc2ffa1a..0000000000 --- a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/pom.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - 4.0.0 - - org.opendaylight.controller - compatibility-parent - 1.1-SNAPSHOT - - inventory-topology-compatibility - bundle - - - - com.google.guava - guava - - - org.opendaylight.controller - forwardingrulesmanager - - - org.opendaylight.controller - sal-binding-api - - - org.opendaylight.controller - sal-binding-util - - - org.opendaylight.controller - sal-common-util - - - org.opendaylight.controller - sal-compatibility - - - org.opendaylight.controller - switchmanager - - - org.opendaylight.controller - topologymanager - - - org.opendaylight.controller.model - model-flow-management - - - org.opendaylight.controller.model - model-topology - - - org.slf4j - slf4j-api - - - junit - junit - test - - - org.mockito - mockito-all - test - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - Forwarding Rules Manager Adapter - for MD-SAL - - - - - - - scm:git:ssh://git.opendaylight.org:29418/controller.git - scm:git:ssh://git.opendaylight.org:29418/controller.git - HEAD - https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL - - diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/inventory/InventoryReader.java b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/inventory/InventoryReader.java deleted file mode 100644 index b37b50159f..0000000000 --- a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/inventory/InventoryReader.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * 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.compatibility.inventory; - -import java.util.ArrayList; -import java.util.Set; - -import org.opendaylight.controller.sal.binding.api.data.RuntimeDataProvider; -import org.opendaylight.controller.sal.compatibility.InventoryMapping; -import org.opendaylight.controller.switchmanager.ISwitchManager; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class InventoryReader implements RuntimeDataProvider { - private static final Logger LOG = LoggerFactory.getLogger(InventoryReader.class); - private ISwitchManager switchManager; - - public ISwitchManager getSwitchManager() { - return switchManager; - } - - public void setSwitchManager(final ISwitchManager switchManager) { - this.switchManager = switchManager; - } - - @Override - public DataObject readConfigurationData(final InstanceIdentifier path) { - // Topology and Inventory are operational only - return null; - } - - @SuppressWarnings("unchecked") - @Override - public DataObject readOperationalData(final InstanceIdentifier path) { - final Class type = path.getTargetType(); - if (Nodes.class.equals(type)) { - return readNodes(((InstanceIdentifier) path)); - } - if (Node.class.equals(type)) { - return readNode(((InstanceIdentifier) path)); - } - if (NodeConnector.class.equals(type)) { - return readNodeConnector(((InstanceIdentifier) path)); - } - - LOG.debug("Unsupported type {}", type); - return null; - } - - private NodeConnector readNodeConnector(final InstanceIdentifier identifier) { - return constructNodeConnector(InventoryMapping.toAdNodeConnector(identifier)); - } - - private Node readNode(final InstanceIdentifier identifier) { - return constructNode(InventoryMapping.toAdNode(identifier)); - } - - private Node constructNode(final org.opendaylight.controller.sal.core.Node node) { - final Set connectors = getSwitchManager().getNodeConnectors(node); - final ArrayList tpList = new ArrayList(connectors.size()); - for (final org.opendaylight.controller.sal.core.NodeConnector connector : connectors) { - tpList.add(constructNodeConnector(connector)); - } - - return new NodeBuilder() - .setKey(InventoryMapping.toNodeKey(node)) - .setNodeConnector(tpList) - .build(); - } - - private Nodes readNodes(final InstanceIdentifier identifier) { - final Set nodes = getSwitchManager().getNodes(); - final ArrayList nodeList = new ArrayList(nodes.size()); - for (final org.opendaylight.controller.sal.core.Node node : nodes) { - nodeList.add(constructNode(node)); - } - - return new NodesBuilder().setNode(nodeList).build(); - } - - private static NodeConnector constructNodeConnector(final org.opendaylight.controller.sal.core.NodeConnector connector) { - return new NodeConnectorBuilder().setKey(InventoryMapping.toNodeConnectorKey(connector)).build(); - } -} diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/switchmanager/CompatibleSwitchManager.java b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/switchmanager/CompatibleSwitchManager.java deleted file mode 100644 index 82c5b7bf61..0000000000 --- a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/switchmanager/CompatibleSwitchManager.java +++ /dev/null @@ -1,347 +0,0 @@ -/** - * 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.compatibility.switchmanager; - -import java.net.InetAddress; -import java.net.NetworkInterface; -import java.net.SocketException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.opendaylight.controller.sal.binding.api.data.DataBrokerService; -import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; -import org.opendaylight.controller.sal.compatibility.NodeMapping; -import org.opendaylight.controller.sal.core.Bandwidth; -import org.opendaylight.controller.sal.core.ConstructionException; -import org.opendaylight.controller.sal.core.Description; -import org.opendaylight.controller.sal.core.ForwardingMode; -import org.opendaylight.controller.sal.core.MacAddress; -import org.opendaylight.controller.sal.core.NodeConnector; -import org.opendaylight.controller.sal.core.Property; -import org.opendaylight.controller.sal.core.Tier; -import org.opendaylight.controller.sal.utils.Status; -import org.opendaylight.controller.switchmanager.ISwitchManager; -import org.opendaylight.controller.switchmanager.Subnet; -import org.opendaylight.controller.switchmanager.Switch; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class CompatibleSwitchManager extends ConfigurableSwitchManager implements ISwitchManager { - private static final Logger LOG = LoggerFactory.getLogger(CompatibleSwitchManager.class); - - private DataBrokerService _dataService; - - public DataBrokerService getDataService() { - return this._dataService; - } - - public void setDataService(final DataBrokerService dataService) { - this._dataService = dataService; - } - - @Override - public Status addNodeConnectorProp(final NodeConnector nodeConnector, final Property prop) { - final DataModificationTransaction it = getDataService().beginTransaction(); - final NodeConnectorRef path = NodeMapping.toNodeConnectorRef(nodeConnector); - return null; - } - - @Override - public Property createProperty(final String propName, final String propValue) { - try { - if (propName.equalsIgnoreCase(Description.propertyName)) { - return new Description(propValue); - } else if (propName.equalsIgnoreCase(Tier.TierPropName)) { - return new Tier(Integer.parseInt(propValue)); - } else if (propName.equalsIgnoreCase(Bandwidth.BandwidthPropName)) { - return new Bandwidth(Long.parseLong(propValue)); - } else if (propName.equalsIgnoreCase(ForwardingMode.name)) { - return new ForwardingMode(Integer.parseInt(propValue)); - } else if (propName.equalsIgnoreCase(MacAddress.name)) { - return new MacAddress(propValue); - } else { - LOG.debug("Not able to create {} property", propName); - } - } catch (Exception e) { - LOG.debug("createProperty caught exception {}", e.getMessage()); - } - - return null; - } - - @Override - public boolean doesNodeConnectorExist(final NodeConnector nc) { - return (getDataService().readOperationalData(NodeMapping.toNodeConnectorRef(nc).getValue()) != null); - } - - @Override - public byte[] getControllerMAC() { - final Enumeration nis; - try { - nis = NetworkInterface.getNetworkInterfaces(); - } catch (SocketException e) { - LOG.error("Failed to acquire list of interfaces, cannot determine controller MAC", e); - return null; - } - - while (nis.hasMoreElements()) { - final NetworkInterface ni = nis.nextElement(); - try { - return ni.getHardwareAddress(); - } catch (SocketException e) { - LOG.error("Failed to acquire controller MAC from interface {}", ni, e); - } - } - - // This happens when running controller on windows VM, for example - // Try parsing the OS command output - LOG.warn("Failed to acquire controller MAC: No physical interface found"); - return null; - } - - @Override - public Map getControllerProperties() { - return Collections.emptyMap(); - } - - @Override - public Property getControllerProperty(final String propertyName) { - return null; - } - - @Override - public List getNetworkDevices() { - final InstanceIdentifier path = InstanceIdentifier.builder(Nodes.class).toInstance(); - final Nodes data = ((Nodes) getDataService().readOperationalData(path)); - final ArrayList ret = new ArrayList<>(); - for (final Node node : data.getNode()) { - try { - ret.add(toSwitch(node)); - } catch (ConstructionException e) { - throw new IllegalStateException(String.format("Failed to create switch {}", node), e); - } - } - return ret; - } - - @Override - public NodeConnector getNodeConnector(final org.opendaylight.controller.sal.core.Node node, final String nodeConnectorName) { - final NodeConnectorKey key = new NodeConnectorKey(new NodeConnectorId(nodeConnectorName)); - try { - return new NodeConnector(NodeMapping.MD_SAL_TYPE, key, node); - } catch (ConstructionException e) { - throw new IllegalStateException(String.format("Failed to create node connector for {} {}", node, nodeConnectorName), e); - } - } - - @Override - public Property getNodeConnectorProp(final NodeConnector nodeConnector, final String propName) { - return getNodeConnectorProps(nodeConnector).get(propName); - } - - @Override - public Map getNodeConnectorProps(final NodeConnector nodeConnector) { - final NodeConnectorRef ref = NodeMapping.toNodeConnectorRef(nodeConnector); - return toAdProperties(readNodeConnector(ref.getValue())); - } - - @Override - public Set getNodeConnectors(final org.opendaylight.controller.sal.core.Node node) { - final Node data = this.readNode(NodeMapping.toNodeRef(node).getValue()); - final HashSet ret = new HashSet<>(); - for (final org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector nc : data.getNodeConnector()) { - try { - ret.add(new NodeConnector(NodeMapping.MD_SAL_TYPE, nc.getKey(), node)); - } catch (ConstructionException e) { - throw new IllegalStateException(String.format("Failed to create node {} connector", node, nc.getKey()), e); - } - } - return ret; - } - - @Override - public String getNodeDescription(final org.opendaylight.controller.sal.core.Node node) { - return ((Description) getNodeProps(node).get(Description.propertyName)).getValue(); - } - - @Override - public byte[] getNodeMAC(final org.opendaylight.controller.sal.core.Node node) { - return ((MacAddress) getNodeProps(node).get(MacAddress.name)).getMacAddress(); - } - - @Override - public Property getNodeProp(final org.opendaylight.controller.sal.core.Node node, final String propName) { - return getNodeProps(node).get(propName); - } - - @Override - public Map getNodeProps(final org.opendaylight.controller.sal.core.Node node) { - final NodeRef ref = NodeMapping.toNodeRef(node); - return toAdProperties(((Node) getDataService().readOperationalData(ref.getValue()))); - } - - @Override - public Set getNodes() { - final InstanceIdentifier path = InstanceIdentifier.builder(Nodes.class).toInstance(); - final Nodes data = ((Nodes) getDataService().readOperationalData(path)); - final HashSet ret = new HashSet<>(); - for (final Node node : data.getNode()) { - try { - ret.add(new org.opendaylight.controller.sal.core.Node(NodeMapping.MD_SAL_TYPE, node.getKey())); - } catch (ConstructionException e) { - throw new IllegalStateException(String.format("Failed to create node for {}", node), e); - } - } - return ret; - } - - private static Switch toSwitch(final Node node) throws ConstructionException { - return new Switch(new org.opendaylight.controller.sal.core.Node(NodeMapping.MD_SAL_TYPE, node.getKey())); - } - - @Override - public Set getPhysicalNodeConnectors(final org.opendaylight.controller.sal.core.Node node) { - final NodeRef ref = NodeMapping.toNodeRef(node); - final Node data = readNode(ref.getValue()); - final HashSet ret = new HashSet<>(); - for (final org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector nc : data.getNodeConnector()) { - final FlowCapableNodeConnector flowConnector = nc.getAugmentation(FlowCapableNodeConnector.class); - try { - ret.add(new NodeConnector(NodeMapping.MD_SAL_TYPE, nc.getKey(), node)); - } catch (ConstructionException e) { - throw new IllegalStateException(String.format("Failed to create connector for {} on node {}", nc.getKey(), node), e); - } - } - return ret; - } - - private static Map toAdProperties(final org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector connector) { - return Collections.emptyMap(); - } - - private static Map toAdProperties(final Node connector) { - return Collections.emptyMap(); - } - - private Node readNode(final InstanceIdentifier ref) { - return (Node) getDataService().readOperationalData((ref)); - } - - private org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector readNodeConnector(final InstanceIdentifier ref) { - return ((org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector) getDataService().readOperationalData(ref)); - } - - @Override - public List getSpanPorts(final org.opendaylight.controller.sal.core.Node node) { - throw new UnsupportedOperationException("TODO: auto-generated method stub"); - } - - @Override - public Subnet getSubnetByNetworkAddress(final InetAddress networkAddress) { - throw new UnsupportedOperationException("TODO: auto-generated method stub"); - } - - @Override - public Set getUpNodeConnectors(final org.opendaylight.controller.sal.core.Node node) { - final Node data = readNode(NodeMapping.toNodeRef(node).getValue()); - final HashSet ret = new HashSet<>(); - for (final org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector nc : data.getNodeConnector()) { - final FlowCapableNodeConnector flowConn = nc.getAugmentation(FlowCapableNodeConnector.class); - if (flowConn != null && flowConn.getState() != null && !flowConn.getState().isLinkDown()) { - try { - ret.add(new NodeConnector(NodeMapping.MD_SAL_TYPE, nc.getKey(), node)); - } catch (ConstructionException e) { - throw new IllegalStateException(String.format("Failed to create node connector for node {} connector {}", node, nc), e); - } - } - } - return ret; - } - - @Override - public Boolean isNodeConnectorEnabled(final NodeConnector nodeConnector) { - final NodeConnectorRef ref = NodeMapping.toNodeConnectorRef(nodeConnector); - final org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector data = readNodeConnector(ref.getValue()); - return true; - } - - @Override - public boolean isSpecial(final NodeConnector p) { - final NodeConnectorRef ref = NodeMapping.toNodeConnectorRef(p); - final org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector data = readNodeConnector(ref.getValue()); - return true; - } - - @Override - public Status removeControllerProperty(final String propertyName) { - return null; - } - - @Override - public Status removeNodeAllProps(final org.opendaylight.controller.sal.core.Node node) { - return null; - } - - @Override - public Status removeNodeConnectorAllProps(final NodeConnector nodeConnector) { - return null; - } - - @Override - public Status removeNodeConnectorProp(final NodeConnector nc, final String propName) { - return null; - } - - @Override - public Status removeNodeProp(final org.opendaylight.controller.sal.core.Node node, final String propName) { - return null; - } - - @Override - public Status removePortsFromSubnet(final String name, final List nodeConnectors) { - return null; - } - - @Override - public Status removeSubnet(final String name) { - return null; - } - - @Override - public Status setControllerProperty(final Property property) { - return null; - } - - @Override - public void setNodeProp(final org.opendaylight.controller.sal.core.Node node, final Property prop) { - throw new UnsupportedOperationException("TODO: auto-generated method stub"); - } - - @Override - public Status addPortsToSubnet(final String name, final List nodeConnectors) { - throw new UnsupportedOperationException("TODO: auto-generated method stub"); - } - - @Override - public Set getConfiguredNotConnectedSwitches() { - return null; - } -} diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/switchmanager/ConfigurableSwitchManager.java b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/switchmanager/ConfigurableSwitchManager.java deleted file mode 100644 index 63f682a361..0000000000 --- a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/switchmanager/ConfigurableSwitchManager.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * 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.compatibility.switchmanager; - -import java.util.List; - -import org.opendaylight.controller.sal.utils.Status; -import org.opendaylight.controller.switchmanager.ISwitchManager; -import org.opendaylight.controller.switchmanager.SpanConfig; -import org.opendaylight.controller.switchmanager.SubnetConfig; -import org.opendaylight.controller.switchmanager.SwitchConfig; - -/** - * These methods should be backed by config subsystem. - */ -public abstract class ConfigurableSwitchManager implements ISwitchManager { - @Override - public Status saveSwitchConfig() { - throw new UnsupportedOperationException("TODO: auto-generated method stub"); - } - - @Override - public Status removeSpanConfig(final SpanConfig cfgObject) { - throw new UnsupportedOperationException("TODO: auto-generated method stub"); - } - - @Override - public Status addSubnet(final SubnetConfig configObject) { - throw new UnsupportedOperationException("TODO: auto-generated method stub"); - } - - @Override - public final Status addSpanConfig(final SpanConfig configObject) { - throw new UnsupportedOperationException("TODO: auto-generated method stub"); - } - - @Override - public final List getSpanConfigList() { - throw new UnsupportedOperationException("TODO: auto-generated method stub"); - } - - @Override - public final void updateSwitchConfig(final SwitchConfig cfgObject) { - throw new UnsupportedOperationException("TODO: auto-generated method stub"); - } - - @Override - public final Status updateNodeConfig(final SwitchConfig switchConfig) { - throw new UnsupportedOperationException("TODO: auto-generated method stub"); - } - - @Override - public final SubnetConfig getSubnetConfig(final String subnet) { - throw new UnsupportedOperationException("TODO: auto-generated method stub"); - } - - @Override - public final Status removeNodeConfig(final String nodeId) { - throw new UnsupportedOperationException("TODO: auto-generated method stub"); - } - - @Override - public final Status removeSubnet(final SubnetConfig configObject) { - throw new UnsupportedOperationException("TODO: auto-generated method stub"); - } - - @Override - public final List getSubnetsConfigList() { - throw new UnsupportedOperationException("TODO: auto-generated method stub"); - } - - @Override - public final SwitchConfig getSwitchConfig(final String nodeId) { - throw new UnsupportedOperationException("TODO: auto-generated method stub"); - } - - @Override - public Status modifySubnet(final SubnetConfig configObject) { - throw new UnsupportedOperationException("TODO: auto-generated method stub"); - } -} diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topology/TopologyMapping.java b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topology/TopologyMapping.java deleted file mode 100644 index 8e50bd881e..0000000000 --- a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topology/TopologyMapping.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * 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.compatibility.topology; - -import java.util.Iterator; - -import org.opendaylight.controller.sal.compatibility.InventoryMapping; -import org.opendaylight.controller.sal.core.ConstructionException; -import org.opendaylight.controller.sal.core.Edge; -import org.opendaylight.controller.sal.core.NodeConnector; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.LinkId; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkKey; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; - -import com.google.common.base.Splitter; - -public class TopologyMapping { - private static final String HEAD_TAIL_STRING = "::::"; - private static final Splitter HEAD_TAIL_SPLITTER = Splitter.on(HEAD_TAIL_STRING); - - public TopologyMapping(final TopologyKey path, final InstanceIdentifier key) { - // No-op for now. Multi-instance will require fixing InventoryMapping first. - } - - public Edge toAdTopologyEdge(final InstanceIdentifier identifier) throws ConstructionException { - @SuppressWarnings("unchecked") - final LinkKey linkKey = ((KeyedInstanceIdentifier)identifier).getKey(); - - final Iterator it = HEAD_TAIL_SPLITTER.split(linkKey.getLinkId().getValue()).iterator(); - final NodeConnector tail = InventoryMapping.nodeConnectorFromId(it.next()); - final NodeConnector head = InventoryMapping.nodeConnectorFromId(it.next()); - return new Edge(tail, head); - } - - public NodeConnector toAdTopologyNodeConnector(final InstanceIdentifier identifier) { - @SuppressWarnings("unchecked") - final TerminationPointKey tpKey = ((KeyedInstanceIdentifier)identifier).getKey(); - - return InventoryMapping.nodeConnectorFromId(tpKey.getTpId().getValue()); - } - - public org.opendaylight.controller.sal.core.Node toAdTopologyNode(final InstanceIdentifier identifier) { - @SuppressWarnings("unchecked") - final NodeKey nodeKey = ((KeyedInstanceIdentifier)identifier).getKey(); - - return InventoryMapping.nodeFromNodeId(nodeKey.getNodeId().getValue()); - } - - public NodeKey toTopologyNodeKey(final org.opendaylight.controller.sal.core.Node node) { - return new NodeKey(new NodeId(InventoryMapping.toNodeId(node))); - } - - public TerminationPointKey toTopologyTerminationPointKey(final NodeConnector nc) { - return new TerminationPointKey(new TpId(InventoryMapping.toNodeConnectorId(nc))); - } - - public LinkKey toTopologyLinkKey(final Edge edge) { - final TerminationPointKey sourceTp = toTopologyTerminationPointKey(edge.getTailNodeConnector()); - final TerminationPointKey destTp = toTopologyTerminationPointKey(edge.getHeadNodeConnector()); - - final StringBuilder sb = new StringBuilder(); - sb.append(sourceTp.getTpId().toString()); - sb.append(HEAD_TAIL_STRING); - sb.append(destTp.getTpId().toString()); - return new LinkKey(new LinkId(sb.toString())); - } -} diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topology/TopologyReader.java b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topology/TopologyReader.java deleted file mode 100644 index a4ac6f94ee..0000000000 --- a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topology/TopologyReader.java +++ /dev/null @@ -1,199 +0,0 @@ -/** - * 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.compatibility.topology; - -import java.util.ArrayList; -import java.util.Map; -import java.util.Set; - -import org.opendaylight.controller.sal.binding.api.data.RuntimeDataProvider; -import org.opendaylight.controller.sal.core.ConstructionException; -import org.opendaylight.controller.sal.core.Edge; -import org.opendaylight.controller.sal.core.NodeConnector; -import org.opendaylight.controller.sal.core.Property; -import org.opendaylight.controller.switchmanager.ISwitchManager; -import org.opendaylight.controller.topologymanager.ITopologyManager; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.link.attributes.DestinationBuilder; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.link.attributes.SourceBuilder; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkBuilder; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TopologyReader implements RuntimeDataProvider { - private static final Logger LOG = LoggerFactory.getLogger(TopologyReader.class); - private final InstanceIdentifier topologyPath; - private final TopologyKey topologyKey; - private final TopologyMapping mapping; - private ITopologyManager topologyManager; - private ISwitchManager switchManager; - - public ISwitchManager getSwitchManager() { - return this.switchManager; - } - - public void setSwitchManager(final ISwitchManager switchManager) { - this.switchManager = switchManager; - } - - public ITopologyManager getTopologyManager() { - return this.topologyManager; - } - - public void setTopologyManager(final ITopologyManager topologyManager) { - this.topologyManager = topologyManager; - } - - public TopologyKey getTopologyKey() { - return this.topologyKey; - } - - public TopologyMapping getMapping() { - return this.mapping; - } - - public TopologyReader() { - this.topologyKey = new TopologyKey(new TopologyId("compatibility:ad-sal")); - this.topologyPath = InstanceIdentifier.builder(NetworkTopology.class) - .child(Topology.class, topologyKey) - .toInstance(); - this.mapping = new TopologyMapping(topologyKey, topologyPath); - } - - @Override - public DataObject readConfigurationData(final InstanceIdentifier path) { - // Topology and Inventory are operational only - return null; - } - - @SuppressWarnings("unchecked") - @Override - public DataObject readOperationalData(final InstanceIdentifier path) { - if (!topologyPath.contains(path)) { - return null; - } - - final Class type = path.getTargetType(); - if (Link.class.equals(type)) { - return readLink((InstanceIdentifier) path); - } - if (Node.class.equals(type)) { - return readNode((InstanceIdentifier) path); - } - if (TerminationPoint.class.equals(type)) { - return readTerminationPoint((InstanceIdentifier) path); - - } - if (Topology.class.equals(type)) { - return readTopology((InstanceIdentifier) path); - } - - LOG.debug("Unsupported type {}", type); - return null; - } - - private Link readLink(final InstanceIdentifier identifier) { - final Edge edge; - try { - edge = this.mapping.toAdTopologyEdge(identifier); - } catch (ConstructionException e) { - throw new IllegalStateException(String.format("Failed to construct edge for link %s", identifier), e); - } - - final Map> edges; - if (topologyManager != null) { - edges = topologyManager.getEdges(); - } else { - edges = null; - } - - final Set properties; - if (edges != null) { - properties = edges.get(edge); - } else { - properties = null; - } - - return constructLink(edge); - } - - private TerminationPoint readTerminationPoint(final InstanceIdentifier identifier) { - return constructTerminationPoint(mapping.toAdTopologyNodeConnector(identifier)); - } - - private Node readNode(final InstanceIdentifier identifier) { - return constructNode(mapping.toAdTopologyNode(identifier)); - } - - private Topology readTopology(final InstanceIdentifier identifier) { - final Set nodes = getSwitchManager().getNodes(); - final ArrayList nodeList = new ArrayList(nodes.size()); - for (final org.opendaylight.controller.sal.core.Node node : nodes) { - nodeList.add(constructNode(node)); - } - - final Map> edges = getTopologyManager().getEdges(); - final ArrayList linkList = new ArrayList(edges.size()); - for (final Edge edge : edges.keySet()) { - linkList.add(constructLink(edge)); - } - - return new TopologyBuilder() - .setKey(topologyKey) - .setNode(nodeList) - .setLink(linkList) - .build(); - } - - private Link constructLink(final Edge edge) { - final NodeConnector sourceNc = edge.getTailNodeConnector(); - final NodeConnector destNc = edge.getHeadNodeConnector(); - - final LinkBuilder it = new LinkBuilder().setKey(mapping.toTopologyLinkKey(edge)); - - it.setSource(new SourceBuilder() - .setSourceNode(mapping.toTopologyNodeKey(sourceNc.getNode()).getNodeId()) - .setSourceTp(mapping.toTopologyTerminationPointKey(sourceNc).getTpId()) - .build()); - - it.setDestination(new DestinationBuilder() - .setDestNode(mapping.toTopologyNodeKey(destNc.getNode()).getNodeId()) - .setDestTp(mapping.toTopologyTerminationPointKey(destNc).getTpId()) - .build()); - - return it.build(); - } - - private Node constructNode(final org.opendaylight.controller.sal.core.Node node) { - final Set connectors = getSwitchManager().getNodeConnectors(node); - final ArrayList tpList = new ArrayList(connectors.size()); - for (final NodeConnector connector : connectors) { - tpList.add(constructTerminationPoint(connector)); - } - - return new NodeBuilder() - .setKey(mapping.toTopologyNodeKey(node)) - .setTerminationPoint(tpList) - .build(); - } - - private TerminationPoint constructTerminationPoint(final NodeConnector connector) { - return new TerminationPointBuilder().setKey(mapping.toTopologyTerminationPointKey(connector)).build(); - } -} diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/AdSalTopologyMapping.java b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/AdSalTopologyMapping.java deleted file mode 100644 index a7a7a9ac3a..0000000000 --- a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/AdSalTopologyMapping.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * 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.compatibility.topologymanager; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.opendaylight.controller.sal.compatibility.NodeMapping; -import org.opendaylight.controller.sal.core.ConstructionException; -import org.opendaylight.controller.sal.core.Edge; -import org.opendaylight.controller.sal.core.NodeConnector; -import org.opendaylight.controller.sal.core.Property; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.link.attributes.Destination; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.link.attributes.Source; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -public class AdSalTopologyMapping { - private final InstanceIdentifier topologyPath; - - public AdSalTopologyMapping(final TopologyKey topology) { - this.topologyPath = InstanceIdentifier.builder(NetworkTopology.class) - .child(Topology.class, topology).toInstance(); - } - - public InstanceIdentifier getTopologyPath() { - return topologyPath; - } - - public InstanceIdentifier toTerminationPoint(final NodeConnector connector) { - return getTopologyPath().builder() - .child(Node.class) - .child(TerminationPoint.class, toTerminationPointKey(connector)) - .toInstance(); - } - - public Map> toEdgePropertiesMap(final Iterable links) { - final HashMap> ret = new HashMap<>(); - for (final Link link : links) { - try { - ret.put(toEdge(link), toProperties(link)); - } catch (ConstructionException e) { - throw new IllegalStateException(String.format("Failed to create edge properties for {}", link), e); - } - } - return ret; - } - - public static Set toEdges(final Iterable links) throws ConstructionException { - final HashSet ret = new HashSet(); - for (final Link link : links) { - ret.add(toEdge(link)); - } - return ret; - } - - public static Edge toEdge(final Link link) throws ConstructionException { - final NodeConnector tail = toNodeConnector(link.getSource()); - final NodeConnector head = toNodeConnector(link.getDestination()); - return new Edge(tail, head); - } - - public static org.opendaylight.controller.sal.core.Node toAdNode(final Node node) throws ConstructionException { - return toAdNode(node.getNodeId()); - } - - public static org.opendaylight.controller.sal.core.Node toAdNode(final NodeId node) throws ConstructionException { - final NodeKey key = new NodeKey( - new org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId(node)); - return new org.opendaylight.controller.sal.core.Node(NodeMapping.MD_SAL_TYPE, key); - } - - public static NodeConnector toNodeConnector(final Source ref) throws ConstructionException { - final org.opendaylight.controller.sal.core.Node adNode = toAdNode(ref.getSourceNode()); - final NodeConnectorKey key = new NodeConnectorKey(new NodeConnectorId(ref.getSourceTp())); - return new NodeConnector(NodeMapping.MD_SAL_TYPE, key, adNode); - } - - public static NodeConnector toNodeConnector(final Destination ref) throws ConstructionException { - final org.opendaylight.controller.sal.core.Node adNode = toAdNode(ref.getDestNode()); - final NodeConnectorKey key = new NodeConnectorKey(new NodeConnectorId(ref.getDestTp())); - return new NodeConnector(NodeMapping.MD_SAL_TYPE, key, adNode); - } - - public TerminationPointKey toTerminationPointKey(final NodeConnector connector) { - return null; - } - - public Set toProperties(final Link link) { - return null; - } -} diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/CompatibleTopologyManager.java b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/CompatibleTopologyManager.java deleted file mode 100644 index 11320a12cd..0000000000 --- a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/CompatibleTopologyManager.java +++ /dev/null @@ -1,149 +0,0 @@ -/** - * 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.compatibility.topologymanager; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.opendaylight.controller.md.sal.binding.util.TypeSafeDataReader; -import org.opendaylight.controller.sal.core.ConstructionException; -import org.opendaylight.controller.sal.core.Edge; -import org.opendaylight.controller.sal.core.Host; -import org.opendaylight.controller.sal.core.NodeConnector; -import org.opendaylight.controller.sal.core.Property; -import org.opendaylight.controller.sal.core.UpdateType; -import org.opendaylight.controller.sal.utils.Status; -import org.opendaylight.controller.topologymanager.ITopologyManager; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -import com.google.common.base.Predicate; -import com.google.common.collect.FluentIterable; - -@SuppressWarnings("all") -public class CompatibleTopologyManager extends ConfigurableLinkManager implements ITopologyManager { - private AdSalTopologyMapping topologyMapping; - private TypeSafeDataReader dataReader; - - public TypeSafeDataReader getDataReader() { - return dataReader; - } - - public void setDataReader(final TypeSafeDataReader dataReader) { - this.dataReader = dataReader; - } - - public AdSalTopologyMapping getTopologyMapping() { - return topologyMapping; - } - - public void setTopologyMapping(final AdSalTopologyMapping topologyMapping) { - this.topologyMapping = topologyMapping; - } - - @Override - public Map> getEdges() { - final Topology topology = getDataReader().readOperationalData(topologyMapping.getTopologyPath()); - return this.topologyMapping.toEdgePropertiesMap(topology.getLink()); - } - - @Override - public Map> getNodeEdges() { - final Topology topology = getDataReader().readOperationalData(topologyMapping.getTopologyPath()); - final HashMap> ret = new HashMap<>(); - for (final Node node : topology.getNode()) { - try { - ret.put(topologyMapping.toAdNode(node), topologyMapping.toEdges( - FluentIterable.from(topology.getLink()).filter(new Predicate() { - @Override - public boolean apply(final Link input) { - final NodeId nodeId = node.getNodeId(); - if (nodeId.equals(input.getSource().getSourceNode())) { - return true; - } - if (nodeId.equals(input.getDestination().getDestNode())) { - return true; - } - - return false; - } - }))); - } catch (ConstructionException e) { - throw new IllegalStateException(String.format("Failed to construct node for {}", node), e); - } - } - return ret; - } - - /** - * Returns true if point is connected to link - */ - private boolean isInternal(final TerminationPoint point) { - final Topology topology = getDataReader().readConfigurationData(topologyMapping.getTopologyPath()); - final TpId tpId = point.getKey().getTpId(); - return FluentIterable.from(topology.getLink()).anyMatch(new Predicate() { - @Override - public boolean apply(final Link input) { - if (tpId.equals(input.getSource().getSourceTp())) { - return true; - } - if (tpId.equals(input.getDestination().getDestTp())) { - return true; - } - return false; - } - }); - } - - @Override - public Set getNodeConnectorWithHost() { - return null; - } - - @Override - public Host getHostAttachedToNodeConnector(final NodeConnector p) { - final InstanceIdentifier tpPath = topologyMapping.toTerminationPoint(p); - throw new UnsupportedOperationException("TODO: auto-generated method stub"); - } - - @Override - public List getHostsAttachedToNodeConnector(final NodeConnector p) { - final Topology topology = getDataReader().readOperationalData(topologyMapping.getTopologyPath()); - throw new UnsupportedOperationException("Hosts not mapped yet"); - } - - @Override - public Map> getNodesWithNodeConnectorHost() { - throw new UnsupportedOperationException("TODO: auto-generated method stub"); - } - - @Override - public boolean isInternal(final NodeConnector p) { - final TerminationPoint connector = getDataReader() - .readConfigurationData(topologyMapping.toTerminationPoint(p)); - return this.isInternal(connector); - } - - @Override - public void updateHostLink(final NodeConnector p, final Host h, final UpdateType t, final Set props) { - // Update app defined topology - } - - @Override - public Status saveConfig() { - // FIXME: commit configuration - return null; - } -} diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/ConfigurableLinkManager.java b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/ConfigurableLinkManager.java deleted file mode 100644 index 2d85f76278..0000000000 --- a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/ConfigurableLinkManager.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * 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.compatibility.topologymanager; - -import java.util.concurrent.ConcurrentMap; - -import org.opendaylight.controller.sal.utils.Status; -import org.opendaylight.controller.topologymanager.ITopologyManager; -import org.opendaylight.controller.topologymanager.TopologyUserLinkConfig; - -public abstract class ConfigurableLinkManager implements ITopologyManager { - @Override - public final Status addUserLink(final TopologyUserLinkConfig link) { - throw new UnsupportedOperationException("TODO: auto-generated method stub"); - } - - @Override - public final Status deleteUserLink(final String linkName) { - throw new UnsupportedOperationException("TODO: auto-generated method stub"); - } - - @Override - public final ConcurrentMap getUserLinks() { - throw new UnsupportedOperationException("TODO: auto-generated method stub"); - } -} diff --git a/opendaylight/md-sal/compatibility/pom.xml b/opendaylight/md-sal/compatibility/pom.xml index 688e6ac09b..b9e9d19b48 100644 --- a/opendaylight/md-sal/compatibility/pom.xml +++ b/opendaylight/md-sal/compatibility/pom.xml @@ -12,8 +12,6 @@ sal-compatibility - inventory-topology-compatibility - flow-management-compatibility diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeMapping.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeMapping.java index 02964c6d55..be087abdb4 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeMapping.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeMapping.java @@ -7,11 +7,13 @@ */ package org.opendaylight.controller.sal.compatibility; +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Objects; +import com.google.common.base.Preconditions; import java.math.BigInteger; import java.util.Date; import java.util.HashSet; import java.util.List; - import org.opendaylight.controller.sal.common.util.Arguments; import org.opendaylight.controller.sal.core.AdvertisedBandwidth; import org.opendaylight.controller.sal.core.Bandwidth; @@ -62,16 +64,14 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Objects; -import com.google.common.base.Preconditions; - public final class NodeMapping { private static final Logger LOG = LoggerFactory .getLogger(NodeMapping.class); - /** openflow id prefix */ + /** + * openflow id prefix + */ public static final String OPENFLOW_ID_PREFIX = "openflow:"; public final static String MD_SAL_TYPE = "MD_SAL_DEPRECATED"; @@ -90,8 +90,14 @@ public final class NodeMapping { } public static org.opendaylight.controller.sal.core.Node toADNode(final NodeId id) throws ConstructionException { - Long aDNodeId = openflowFullNodeIdToLong(NodeMapping.toADNodeId(id)); - return new org.opendaylight.controller.sal.core.Node(NodeIDType.OPENFLOW, aDNodeId); + String nodeId = NodeMapping.toADNodeId(id); + String nodeIdasNumber = nodeId.replaceFirst("^.*:", ""); + if (isInteger(nodeIdasNumber)) { + Long aDNodeId = openflowFullNodeIdToLong(nodeIdasNumber); + return new org.opendaylight.controller.sal.core.Node(NodeIDType.OPENFLOW, aDNodeId); + } else { + return new org.opendaylight.controller.sal.core.Node(NodeIDType.PRODUCTION, nodeId); + } } /** @@ -103,7 +109,7 @@ public final class NodeMapping { if (adNodeId == null) { return null; } - return new BigInteger(adNodeId.replaceFirst("^.*:", "")).longValue(); + return new BigInteger(adNodeId).longValue(); } public static NodeId toNodeId(final InstanceIdentifier id) { @@ -137,8 +143,8 @@ public final class NodeMapping { } /** - * @param ncid nodeConnector identifier, e.g.: OF:21 or CTRL - * @param node + * @param ncid nodeConnector identifier, e.g.: OF:21 or CTRL + * @param aDNode * @return nodeConnector attached to given node * @throws ConstructionException */ @@ -155,7 +161,7 @@ public final class NodeMapping { * @return */ private static NodeId toNodeId(org.opendaylight.controller.sal.core.Node aDNode) { - return new NodeId(aDNode.getType() + ":" +String.valueOf(aDNode.getID())); + return new NodeId(aDNode.getType() + ":" + String.valueOf(aDNode.getID())); } public static String toNodeConnectorType(final NodeConnectorId ncId, final NodeId nodeId) { @@ -212,7 +218,7 @@ public final class NodeMapping { public static NodeRef toNodeRef(final org.opendaylight.controller.sal.core.Node node) { Preconditions.checkArgument(NodeIDType.OPENFLOW.equals(node.getType())); final Long nodeId = Arguments.checkInstanceOf(node.getID(), Long.class); - final NodeKey nodeKey = new NodeKey(new NodeId(OPENFLOW_ID_PREFIX+nodeId)); + final NodeKey nodeKey = new NodeKey(new NodeId(OPENFLOW_ID_PREFIX + nodeId)); final InstanceIdentifier nodePath = InstanceIdentifier.builder(Nodes.class).child(NODE_CLASS, nodeKey).toInstance(); return new NodeRef(nodePath); } @@ -257,7 +263,7 @@ public final class NodeMapping { } /** - * @param id + * @param nodeRef * @return node description in AD form, e.g.: OF|00:00:00:...:01 */ private static Description toADDescription(NodeRef nodeRef) { @@ -463,4 +469,17 @@ public final class NodeMapping { public static Buffers toADBuffers(final Long buffers) { return new Buffers(buffers.intValue()); } + + + private static final boolean isInteger(String value) { + if (value.isEmpty()) return false; + for (int i = 0; i < value.length(); i++) { + if (i == 0 && value.charAt(i) == '-') { + if (value.length() == 1) return false; + else continue; + } + if (Character.digit(value.charAt(i), 10) < 0) return false; + } + return true; + } } diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/NodeMappingTest.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/NodeMappingTest.java index cef7ae7a42..a776ef2312 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/NodeMappingTest.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/NodeMappingTest.java @@ -101,6 +101,16 @@ public class NodeMappingTest { } catch (ConstructionException e) { Assert.fail("should succeed to construct Node: "+e.getMessage()); } + + final String nodeUriPrefix = "opendaylight-inventory:nodes/node/"; + nodeId = new NodeId(nodeUriPrefix + "iosv-2"); + try { + observed = NodeMapping.toADNode(nodeId); + Assert.assertEquals("PR|opendaylight-inventory:nodes/node/iosv-2", observed.toString()); + } catch (ConstructionException e) { + Assert.fail("should succeed to construct Node: "+e.getMessage()); + } + } /** diff --git a/opendaylight/md-sal/forwardingrules-manager/pom.xml b/opendaylight/md-sal/forwardingrules-manager/pom.xml index ed5e192193..5a9b190219 100644 --- a/opendaylight/md-sal/forwardingrules-manager/pom.xml +++ b/opendaylight/md-sal/forwardingrules-manager/pom.xml @@ -19,10 +19,6 @@ org.opendaylight.controller sal-binding-api - - org.opendaylight.controller.model - model-flow-management - org.opendaylight.controller.model model-flow-service diff --git a/opendaylight/md-sal/md-sal-config/src/main/resources/initial/01-md-sal.xml b/opendaylight/md-sal/md-sal-config/src/main/resources/initial/01-md-sal.xml index f25b7d91bd..35a77662b5 100644 --- a/opendaylight/md-sal/md-sal-config/src/main/resources/initial/01-md-sal.xml +++ b/opendaylight/md-sal/md-sal-config/src/main/resources/initial/01-md-sal.xml @@ -57,19 +57,19 @@ prefix:distributed-operational-datastore-provider distributed-operational-store-module - + dom:schema-service yang-schema-service - + prefix:distributed-config-datastore-provider distributed-config-store-module - + dom:schema-service yang-schema-service - + --> diff --git a/opendaylight/md-sal/pom.xml b/opendaylight/md-sal/pom.xml index 02fbde8f18..6c6760d789 100644 --- a/opendaylight/md-sal/pom.xml +++ b/opendaylight/md-sal/pom.xml @@ -66,8 +66,11 @@ sal-inmemory-datastore - - sal-protocolbuffer-encoding + + sal-clustering-commons + + + sal-clustering-config sal-distributed-datastore diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/AbstractReplicatedLogImpl.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/AbstractReplicatedLogImpl.java index 24bfa3de21..b5b034afb9 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/AbstractReplicatedLogImpl.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/AbstractReplicatedLogImpl.java @@ -100,16 +100,26 @@ public abstract class AbstractReplicatedLogImpl implements ReplicatedLog { @Override public List getFrom(long logEntryIndex) { + return getFrom(logEntryIndex, journal.size()); + } + + @Override + public List getFrom(long logEntryIndex, int max) { int adjustedIndex = adjustedIndex(logEntryIndex); int size = journal.size(); List entries = new ArrayList<>(100); if (adjustedIndex >= 0 && adjustedIndex < size) { // physical index should be less than list size and >= 0 - entries.addAll(journal.subList(adjustedIndex, size)); + int maxIndex = adjustedIndex + max; + if(maxIndex > size){ + maxIndex = size; + } + entries.addAll(journal.subList(adjustedIndex, maxIndex)); } return entries; } + @Override public long size() { return journal.size(); diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/DefaultConfigParamsImpl.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/DefaultConfigParamsImpl.java index c633337226..6432fa4811 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/DefaultConfigParamsImpl.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/DefaultConfigParamsImpl.java @@ -33,7 +33,7 @@ public class DefaultConfigParamsImpl implements ConfigParams { * Since this is set to 100 milliseconds the Election timeout should be * at least 200 milliseconds */ - protected static final FiniteDuration HEART_BEAT_INTERVAL = + public static final FiniteDuration HEART_BEAT_INTERVAL = new FiniteDuration(100, TimeUnit.MILLISECONDS); @@ -51,7 +51,7 @@ public class DefaultConfigParamsImpl implements ConfigParams { @Override public FiniteDuration getElectionTimeOutInterval() { // returns 2 times the heart beat interval - return HEART_BEAT_INTERVAL.$times(2); + return getHeartBeatInterval().$times(2); } @Override diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java index caa0e507c1..0a979d24ee 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java @@ -148,6 +148,7 @@ public abstract class RaftActor extends UntypedPersistentActor { replicatedLog.lastIndex(), replicatedLog.snapshotIndex, replicatedLog.snapshotTerm, replicatedLog.size()); currentBehavior = switchBehavior(RaftState.Follower); + onStateChanged(); } } @@ -206,7 +207,11 @@ public abstract class RaftActor extends UntypedPersistentActor { RaftState state = currentBehavior.handleMessage(getSender(), message); + RaftActorBehavior oldBehavior = currentBehavior; currentBehavior = switchBehavior(state); + if(oldBehavior != currentBehavior){ + onStateChanged(); + } } } @@ -271,9 +276,21 @@ public abstract class RaftActor extends UntypedPersistentActor { String peerAddress = context.getPeerAddress(leaderId); LOG.debug("getLeader leaderId = " + leaderId + " peerAddress = " + peerAddress); + + if(peerAddress == null){ + return null; + } return context.actorSelection(peerAddress); } + /** + * + * @return the current leader's id + */ + protected String getLeaderId(){ + return currentBehavior.getLeaderId(); + } + protected RaftState getRaftState() { return currentBehavior.state(); } @@ -375,7 +392,7 @@ public abstract class RaftActor extends UntypedPersistentActor { behavior = new Leader(context); } - onStateChanged(); + return behavior; } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLog.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLog.java index b7c8955aad..e6e160bc02 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLog.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLog.java @@ -84,6 +84,11 @@ public interface ReplicatedLog { */ List getFrom(long index); + /** + * + * @param index the index of the log entry + */ + List getFrom(long index, int max); /** * diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/Leader.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/Leader.java index 2a44e8b7a5..a50666233c 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/Leader.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/Leader.java @@ -310,7 +310,7 @@ public class Leader extends AbstractRaftActorBehavior { // that has fallen too far behind with the log but yet is not // eligible to receive a snapshot entries = - context.getReplicatedLog().getFrom(nextIndex); + context.getReplicatedLog().getFrom(nextIndex, 1); } followerActor.tell( diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractReplicatedLogImplTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractReplicatedLogImplTest.java index ae8e525233..913665861d 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractReplicatedLogImplTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractReplicatedLogImplTest.java @@ -7,6 +7,7 @@ */ package org.opendaylight.controller.cluster.raft; +import junit.framework.Assert; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -31,6 +32,12 @@ public class AbstractReplicatedLogImplTest { @Before public void setUp() { replicatedLogImpl = new MockAbstractReplicatedLogImpl(); + // create a set of initial entries in the in-memory log + replicatedLogImpl.append(new MockReplicatedLogEntry(1, 0, new MockPayload("A"))); + replicatedLogImpl.append(new MockReplicatedLogEntry(1, 1, new MockPayload("B"))); + replicatedLogImpl.append(new MockReplicatedLogEntry(1, 2, new MockPayload("C"))); + replicatedLogImpl.append(new MockReplicatedLogEntry(2, 3, new MockPayload("D"))); + } @After @@ -43,11 +50,6 @@ public class AbstractReplicatedLogImplTest { @Test public void testIndexOperations() { - // create a set of initial entries in the in-memory log - replicatedLogImpl.append(new MockReplicatedLogEntry(1, 0, new MockPayload("A"))); - replicatedLogImpl.append(new MockReplicatedLogEntry(1, 1, new MockPayload("B"))); - replicatedLogImpl.append(new MockReplicatedLogEntry(1, 2, new MockPayload("C"))); - replicatedLogImpl.append(new MockReplicatedLogEntry(2, 3, new MockPayload("D"))); // check if the values returned are correct, with snapshotIndex = -1 assertEquals("B", replicatedLogImpl.get(1).getData().toString()); @@ -112,6 +114,22 @@ public class AbstractReplicatedLogImplTest { } + @Test + public void testGetFromWithMax(){ + List from = replicatedLogImpl.getFrom(0, 1); + Assert.assertEquals(1, from.size()); + Assert.assertEquals(1, from.get(0).getTerm()); + + from = replicatedLogImpl.getFrom(0, 20); + Assert.assertEquals(4, from.size()); + Assert.assertEquals(2, from.get(3).getTerm()); + + from = replicatedLogImpl.getFrom(1, 2); + Assert.assertEquals(2, from.size()); + Assert.assertEquals(1, from.get(1).getTerm()); + + } + // create a snapshot for test public Map takeSnapshot(int numEntries) { Map map = new HashMap(numEntries); diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MockRaftActorContext.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MockRaftActorContext.java index aa50fa7442..70671a6a21 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MockRaftActorContext.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MockRaftActorContext.java @@ -248,6 +248,23 @@ public class MockRaftActorContext implements RaftActorContext { return entries; } + @Override public List getFrom(long index, int max) { + if(index >= log.size() || index < 0){ + return Collections.EMPTY_LIST; + } + List entries = new ArrayList<>(); + int maxIndex = (int) index + max; + if(maxIndex > log.size()){ + maxIndex = log.size(); + } + + for(int i=(int) index ; i < maxIndex ; i++) { + entries.add(get(i)); + } + return entries; + + } + @Override public long size() { return log.size(); } diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/CandidateTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/CandidateTest.java index c763683705..d478b17555 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/CandidateTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/CandidateTest.java @@ -6,6 +6,7 @@ import akka.testkit.JavaTestKit; import junit.framework.Assert; import org.junit.Before; import org.junit.Test; +import org.opendaylight.controller.cluster.raft.DefaultConfigParamsImpl; import org.opendaylight.controller.cluster.raft.MockRaftActorContext; import org.opendaylight.controller.cluster.raft.RaftActorContext; import org.opendaylight.controller.cluster.raft.RaftState; @@ -80,12 +81,12 @@ public class CandidateTest extends AbstractRaftActorBehaviorTest { public void testThatAnElectionTimeoutIsTriggered(){ new JavaTestKit(getSystem()) {{ - new Within(duration("1 seconds")) { + new Within(DefaultConfigParamsImpl.HEART_BEAT_INTERVAL.$times(6)) { protected void run() { Candidate candidate = new Candidate(createActorContext(getTestActor())); - final Boolean out = new ExpectMsg(duration("1 seconds"), "ElectionTimeout") { + final Boolean out = new ExpectMsg(DefaultConfigParamsImpl.HEART_BEAT_INTERVAL.$times(6), "ElectionTimeout") { // do not put code outside this method, will run afterwards protected Boolean match(Object in) { if (in instanceof ElectionTimeout) { diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/FollowerTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/FollowerTest.java index c015d950c4..c5a81aa1c9 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/FollowerTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/FollowerTest.java @@ -5,6 +5,7 @@ import akka.actor.Props; import akka.testkit.JavaTestKit; import junit.framework.Assert; import org.junit.Test; +import org.opendaylight.controller.cluster.raft.DefaultConfigParamsImpl; import org.opendaylight.controller.cluster.raft.MockRaftActorContext; import org.opendaylight.controller.cluster.raft.RaftActorContext; import org.opendaylight.controller.cluster.raft.RaftState; @@ -41,12 +42,12 @@ public class FollowerTest extends AbstractRaftActorBehaviorTest { public void testThatAnElectionTimeoutIsTriggered(){ new JavaTestKit(getSystem()) {{ - new Within(duration("1 seconds")) { + new Within(DefaultConfigParamsImpl.HEART_BEAT_INTERVAL.$times(6)) { protected void run() { Follower follower = new Follower(createActorContext(getTestActor())); - final Boolean out = new ExpectMsg(duration("1 seconds"), "ElectionTimeout") { + final Boolean out = new ExpectMsg(DefaultConfigParamsImpl.HEART_BEAT_INTERVAL.$times(6), "ElectionTimeout") { // do not put code outside this method, will run afterwards protected Boolean match(Object in) { if (in instanceof ElectionTimeout) { diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ForwardedBackwardsCompatibleDataBroker.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ForwardedBackwardsCompatibleDataBroker.java index c924b74a12..237d9678f9 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ForwardedBackwardsCompatibleDataBroker.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ForwardedBackwardsCompatibleDataBroker.java @@ -39,7 +39,7 @@ import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; import org.opendaylight.yangtools.concepts.Delegator; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.concepts.Registration; -import org.opendaylight.yangtools.concepts.util.ListenerRegistry; +import org.opendaylight.yangtools.util.ListenerRegistry; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RpcRouterCodegenInstance.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RpcRouterCodegenInstance.java index 709b62fee2..783e5c0cd4 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RpcRouterCodegenInstance.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RpcRouterCodegenInstance.java @@ -22,7 +22,7 @@ import org.opendaylight.controller.sal.binding.api.rpc.RpcRoutingTable; import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper; import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.concepts.util.ListenerRegistry; +import org.opendaylight.yangtools.util.ListenerRegistry; import org.opendaylight.yangtools.yang.binding.BaseIdentity; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.RpcService; diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/DataTransactionImpl.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/DataTransactionImpl.java index 1ea2eba87f..15314d3bdc 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/DataTransactionImpl.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/DataTransactionImpl.java @@ -11,7 +11,7 @@ import org.opendaylight.controller.md.sal.common.api.TransactionStatus; import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataTransaction; import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.concepts.util.ListenerRegistry; +import org.opendaylight.yangtools.util.ListenerRegistry; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/MountPointManagerImpl.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/MountPointManagerImpl.java index 05651bfabe..c390fe7049 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/MountPointManagerImpl.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/MountPointManagerImpl.java @@ -15,7 +15,7 @@ import org.opendaylight.controller.md.sal.binding.util.AbstractBindingSalProvide import org.opendaylight.controller.sal.binding.api.mount.MountProviderInstance; import org.opendaylight.controller.sal.binding.api.mount.MountProviderService; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.concepts.util.ListenerRegistry; +import org.opendaylight.yangtools.util.ListenerRegistry; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationBrokerImpl.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationBrokerImpl.java index 258ba51777..58e46ceca3 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationBrokerImpl.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationBrokerImpl.java @@ -19,7 +19,7 @@ import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder; import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory.NotificationInvoker; import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.concepts.util.ListenerRegistry; +import org.opendaylight.yangtools.util.ListenerRegistry; import org.opendaylight.yangtools.yang.binding.Notification; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcProviderRegistryImpl.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcProviderRegistryImpl.java index f2e467038f..13a9f1cc10 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcProviderRegistryImpl.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcProviderRegistryImpl.java @@ -33,7 +33,7 @@ import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper; import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder; import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.concepts.util.ListenerRegistry; +import org.opendaylight.yangtools.util.ListenerRegistry; import org.opendaylight.yangtools.yang.binding.BaseIdentity; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.RpcService; diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/MockSchemaService.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/MockSchemaService.java index 63a4ffb23a..356a4b810e 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/MockSchemaService.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/MockSchemaService.java @@ -10,7 +10,7 @@ package org.opendaylight.controller.sal.binding.test.util; import org.opendaylight.controller.sal.core.api.model.SchemaService; import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProvider; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.concepts.util.ListenerRegistry; +import org.opendaylight.yangtools.util.ListenerRegistry; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; diff --git a/opendaylight/md-sal/sal-binding-dom-it/pom.xml b/opendaylight/md-sal/sal-binding-dom-it/pom.xml index 42d5cfff65..7a66c41196 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/pom.xml +++ b/opendaylight/md-sal/sal-binding-dom-it/pom.xml @@ -29,11 +29,6 @@ test-jar test - - org.opendaylight.controller.model - model-flow-management - test - org.opendaylight.controller.model model-flow-service diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug01Test.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug01Test.java deleted file mode 100644 index 34a71ac0c4..0000000000 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug01Test.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * 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.sal.binding.test.bugfix; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import org.junit.Ignore; -import org.junit.Test; -import org.opendaylight.controller.md.sal.common.api.TransactionStatus; -import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; -import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest; -import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.Flows; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; - -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.MoreExecutors; - -@SuppressWarnings("deprecation") -public class DOMCodecBug01Test extends AbstractDataServiceTest { - - private static final long FLOW_ID = 1234; - private static final String NODE_ID = "node:1"; - - private static final NodeKey NODE_KEY = new NodeKey(new NodeId(NODE_ID)); - - private static final InstanceIdentifier NODE_INSTANCE_ID_BA = InstanceIdentifier.builder(Nodes.class) // - .child(Node.class, NODE_KEY).toInstance(); - - private static final NodeRef NODE_REF = new NodeRef(NODE_INSTANCE_ID_BA); - - private static final FlowKey FLOW_KEY = new FlowKey(FLOW_ID, NODE_REF); - - private static final InstanceIdentifier FLOW_INSTANCE_ID_BA = // - InstanceIdentifier.builder(Flows.class) // - .child(Flow.class, FLOW_KEY) // - .toInstance(); - - - - /** - * - * Testcase for https://bugs.opendaylight.org/show_bug.cgi?id= - * - * Cannot compile CoDec for - * org.opendaylight.yang.gen.v1.urn.opendaylight.flow - * .config.rev130819.flows.Flow - * - * When invoking following code in the consumer, user got an - * IllegalStateException during creation of mapping between Java DTOs and - * data-dom. - * - * Exception was compilation error which was caused by incorect generation - * of code. - * - * Reported by Depthi V V - * - * @deprecated This test tests indirect generation, which should be tested - * different way. the test creates conflicting transactions - * and assumes correct commit - to test codec generation - * - */ - @Test - @Ignore - @Deprecated - public void testIndirectGeneration() throws Exception { - - ExecutorService basePool = Executors.newFixedThreadPool(2); - ListeningExecutorService listenablePool = MoreExecutors.listeningDecorator(basePool); - - createFlow(); - - Object lock = new Object(); - CreateFlowTask task1 = new CreateFlowTask(lock); - CreateFlowTask task2 = new CreateFlowTask(lock); - CreateFlowTask task3 = new CreateFlowTask(lock); - - ListenableFuture task1Future = listenablePool.submit(task1); - ListenableFuture task2Future = listenablePool.submit(task2); - ListenableFuture task3Future = listenablePool.submit(task3); - - - @SuppressWarnings("unchecked") - ListenableFuture> compositeFuture = Futures.allAsList(task1Future,task2Future,task3Future); - - Thread.sleep(500); - //lock.notifyAll(); - compositeFuture.get(); - - verifyDataAreStoredProperly(); - - DataModificationTransaction modification2 = baDataService.beginTransaction(); - modification2.removeConfigurationData(FLOW_INSTANCE_ID_BA); - - DataObject originalData = modification2.getOriginalConfigurationData().get(FLOW_INSTANCE_ID_BA); - assertNotNull(originalData); - RpcResult ret2 = modification2.commit().get(); - - assertNotNull(ret2); - assertEquals(TransactionStatus.COMMITED, ret2.getResult()); - - // Data are not in the store. - assertNull(baDataService.readConfigurationData(FLOW_INSTANCE_ID_BA)); - - } - - private void createFlow() throws Exception { - - DataModificationTransaction modification = baDataService.beginTransaction(); - - FlowBuilder flow = new FlowBuilder(); - MatchBuilder match = new MatchBuilder(); - VlanMatchBuilder vlanBuilder = new VlanMatchBuilder(); - VlanIdBuilder vlanIdBuilder = new VlanIdBuilder(); - VlanId vlanId = new VlanId(10); - vlanBuilder.setVlanId(vlanIdBuilder.setVlanId(vlanId).build()); - match.setVlanMatch(vlanBuilder.build()); - - flow.setKey(FLOW_KEY); - flow.setMatch(match.build()); - flow.setNode(NODE_REF); - InstructionsBuilder instructions = new InstructionsBuilder(); - InstructionBuilder instruction = new InstructionBuilder(); - - instruction.setOrder(10); - ApplyActionsBuilder applyActions = new ApplyActionsBuilder(); - List actionList = new ArrayList<>(); - PopMplsActionBuilder popMplsAction = new PopMplsActionBuilder(); - popMplsAction.setEthernetType(34); - actionList.add(new ActionBuilder().setAction(new PopMplsActionCaseBuilder().setPopMplsAction(popMplsAction.build()).build()).setOrder(10).build()); - - applyActions.setAction(actionList ); - - instruction.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(applyActions.build()).build()); - - - List instructionList = Collections.singletonList(instruction.build()); - instructions.setInstruction(instructionList ); - - flow.setInstructions(instructions.build()); - modification.putConfigurationData(FLOW_INSTANCE_ID_BA, flow.build()); - RpcResult ret = modification.commit().get(); - assertNotNull(ret); - assertEquals(TransactionStatus.COMMITED, ret.getResult()); - } - - private void createFlow2() throws Exception { - DataModificationTransaction modification = baDataService.beginTransaction(); - long id = 123; - FlowKey key = new FlowKey(id, new NodeRef(NODE_INSTANCE_ID_BA)); - InstanceIdentifier path1; - FlowBuilder flow = new FlowBuilder(); - flow.setKey(key); - MatchBuilder match = new MatchBuilder(); - match.setLayer4Match(new TcpMatchBuilder().build()); - flow.setMatch(match.build()); - - path1 = InstanceIdentifier.builder(Flows.class).child(Flow.class, key).toInstance(); - // DataObject cls = (DataObject) modification.readConfigurationData(path1); - modification.putConfigurationData(path1, flow.build()); - modification.commit(); - - } - - private class CreateFlowTask implements Callable { - - public CreateFlowTask(final Object startSync) { - } - - @Override - public Void call() { - try { - //startSyncObj ect.wait(); - //Thread.sleep(500); - createFlow(); - createFlow2(); - } catch (Exception e) { - throw new RuntimeException(e); - } - return null; - } - } - - private void verifyDataAreStoredProperly() { - CompositeNode biFlows = biDataService.readConfigurationData(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.of(Flows.QNAME)); - assertNotNull(biFlows); - CompositeNode biFlow = biFlows.getFirstCompositeByName(Flow.QNAME); - assertNotNull(biFlow); - } - - -} diff --git a/opendaylight/md-sal/sal-binding-it/pom.xml b/opendaylight/md-sal/sal-binding-it/pom.xml index 98515966d9..1912462cf0 100644 --- a/opendaylight/md-sal/sal-binding-it/pom.xml +++ b/opendaylight/md-sal/sal-binding-it/pom.xml @@ -8,12 +8,6 @@ sal-binding-it - - ../sal-binding-broker/target/jacoco-it.exec - - ../sal-binding-broker/target/jacoco.exec - - ch.qos.logback @@ -128,11 +122,6 @@ org.slf4j log4j-over-slf4j - - org.opendaylight.controller.model - model-flow-management - provided - org.opendaylight.controller.model model-flow-service @@ -169,65 +158,9 @@ - - org.jacoco - jacoco-maven-plugin - ${jacoco.version} - - ../sal-binding-broker/target/jacoco-it.exec - - org.opendaylight.controller.* - - - - - pre-test - - prepare-agent - - - - post-test - - true - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - false - - - - org.jacoco - jacoco-maven-plugin - - - org.opendaylight.controller.* - - - - - pre-test - - prepare-agent - - - - post-test - - report - - test - - - org.ops4j.pax.exam maven-paxexam-plugin diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/README-FIRST b/opendaylight/md-sal/sal-clustering-commons/README-FIRST similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/README-FIRST rename to opendaylight/md-sal/sal-clustering-commons/README-FIRST diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/pom.xml b/opendaylight/md-sal/sal-clustering-commons/pom.xml similarity index 98% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/pom.xml rename to opendaylight/md-sal/sal-clustering-commons/pom.xml index 28e629a92c..6db4d3a094 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/pom.xml +++ b/opendaylight/md-sal/sal-clustering-commons/pom.xml @@ -8,7 +8,7 @@ 1.1-SNAPSHOT - sal-protocolbuffer-encoding + sal-clustering-commons bundle diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/run.sh b/opendaylight/md-sal/sal-clustering-commons/run.sh similarity index 93% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/run.sh rename to opendaylight/md-sal/sal-clustering-commons/run.sh index f0907db664..d3d0324fa0 100755 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/run.sh +++ b/opendaylight/md-sal/sal-clustering-commons/run.sh @@ -30,7 +30,7 @@ # org.opendaylight.controller.protobuff.messages to properly exclude from sonar. ######################################################################################################## -protoc --proto_path=src/main/resources --java_out=src/main/java src/main/resources/*.proto +protoc --proto_path=src/main/resources --proto_path=../sal-akka-raft/src/main/resources --java_out=src/main/java src/main/resources/*.proto echo "Done generating Java source files." diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NodeToNormalizedNodeBuilder.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/NodeToNormalizedNodeBuilder.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NodeToNormalizedNodeBuilder.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/NodeToNormalizedNodeBuilder.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NodeValueCodec.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/NodeValueCodec.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NodeValueCodec.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/NodeValueCodec.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodec.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodec.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodec.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodec.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToProtocolBufferNode.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToProtocolBufferNode.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToProtocolBufferNode.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToProtocolBufferNode.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/AugmentationIdentifierGenerator.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/AugmentationIdentifierGenerator.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/AugmentationIdentifierGenerator.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/AugmentationIdentifierGenerator.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierFactory.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierFactory.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierFactory.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierFactory.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierGenerator.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierGenerator.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierGenerator.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierGenerator.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierWithPredicatesGenerator.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierWithPredicatesGenerator.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierWithPredicatesGenerator.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierWithPredicatesGenerator.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierWithValueGenerator.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierWithValueGenerator.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierWithValueGenerator.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierWithValueGenerator.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeGetter.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeGetter.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeGetter.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeGetter.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeNavigator.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeNavigator.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeNavigator.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeNavigator.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodePrinter.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodePrinter.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodePrinter.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodePrinter.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeVisitor.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeVisitor.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeVisitor.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeVisitor.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/PathUtils.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/PathUtils.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/PathUtils.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/PathUtils.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/QNameFactory.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/QNameFactory.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/QNameFactory.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/QNameFactory.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/util/EncoderDecoderUtil.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/util/EncoderDecoderUtil.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/util/EncoderDecoderUtil.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/util/EncoderDecoderUtil.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtils.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtils.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtils.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtils.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/mdsal/CompositeModificationPayload.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/mdsal/CompositeModificationPayload.java similarity index 90% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/mdsal/CompositeModificationPayload.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/mdsal/CompositeModificationPayload.java index 99f4751875..87b246bd7e 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/mdsal/CompositeModificationPayload.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/mdsal/CompositeModificationPayload.java @@ -1,13 +1,3 @@ -/* - * - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: CompositeModificationPayload.proto diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/cohort3pc/ThreePhaseCommitCohortMessages.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/cohort3pc/ThreePhaseCommitCohortMessages.java similarity index 99% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/cohort3pc/ThreePhaseCommitCohortMessages.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/cohort3pc/ThreePhaseCommitCohortMessages.java index 49cb1ead9c..22a93c0e10 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/cohort3pc/ThreePhaseCommitCohortMessages.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/cohort3pc/ThreePhaseCommitCohortMessages.java @@ -1,13 +1,3 @@ -/* - * - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: Cohort.proto diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/common/NormalizedNodeMessages.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/common/NormalizedNodeMessages.java similarity index 99% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/common/NormalizedNodeMessages.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/common/NormalizedNodeMessages.java index f88b66bcd3..35c2940be3 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/common/NormalizedNodeMessages.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/common/NormalizedNodeMessages.java @@ -1,13 +1,3 @@ -/* - * - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: Common.proto diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/common/SimpleNormalizedNodeMessage.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/common/SimpleNormalizedNodeMessage.java similarity index 98% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/common/SimpleNormalizedNodeMessage.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/common/SimpleNormalizedNodeMessage.java index 7cee40df7a..67ab472d0c 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/common/SimpleNormalizedNodeMessage.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/common/SimpleNormalizedNodeMessage.java @@ -1,13 +1,3 @@ -/* - * - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: SimpleNormalizedNode.proto diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/datachange/notification/DataChangeListenerMessages.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/datachange/notification/DataChangeListenerMessages.java similarity index 99% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/datachange/notification/DataChangeListenerMessages.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/datachange/notification/DataChangeListenerMessages.java index 1a98112073..384b389f92 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/datachange/notification/DataChangeListenerMessages.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/datachange/notification/DataChangeListenerMessages.java @@ -1,13 +1,3 @@ -/* - * - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: DataChangeListener.proto diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/persistent/PersistentMessages.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/persistent/PersistentMessages.java similarity index 99% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/persistent/PersistentMessages.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/persistent/PersistentMessages.java index 088630aa32..d354348da8 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/persistent/PersistentMessages.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/persistent/PersistentMessages.java @@ -1,13 +1,3 @@ -/* - * - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: Persistent.proto diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/registration/ListenerRegistrationMessages.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/registration/ListenerRegistrationMessages.java similarity index 99% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/registration/ListenerRegistrationMessages.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/registration/ListenerRegistrationMessages.java index 0f439d8c7c..77cbd4da46 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/registration/ListenerRegistrationMessages.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/registration/ListenerRegistrationMessages.java @@ -1,13 +1,3 @@ -/* - * - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: ListenerRegistration.proto diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/shard/ShardManagerMessages.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/shard/ShardManagerMessages.java similarity index 99% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/shard/ShardManagerMessages.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/shard/ShardManagerMessages.java index 7141863591..2324dfc2a2 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/shard/ShardManagerMessages.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/shard/ShardManagerMessages.java @@ -1,13 +1,3 @@ -/* - * - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: ShardManager.proto diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionChainMessages.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionChainMessages.java similarity index 99% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionChainMessages.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionChainMessages.java index 68bf325336..63dd5e7081 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionChainMessages.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionChainMessages.java @@ -1,13 +1,3 @@ -/* - * - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: ShardTransactionChain.proto diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionMessages.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionMessages.java similarity index 98% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionMessages.java rename to opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionMessages.java index 52411f322b..33ac9f6ca1 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionMessages.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionMessages.java @@ -1,13 +1,3 @@ -/* - * - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: ShardTransaction.proto @@ -653,6 +643,16 @@ public final class ShardTransactionMessages { */ com.google.protobuf.ByteString getTransactionIdBytes(); + + // required int32 transactionType = 2; + /** + * required int32 transactionType = 2; + */ + boolean hasTransactionType(); + /** + * required int32 transactionType = 2; + */ + int getTransactionType(); } /** * Protobuf type {@code org.opendaylight.controller.mdsal.CreateTransaction} @@ -710,6 +710,11 @@ public final class ShardTransactionMessages { transactionId_ = input.readBytes(); break; } + case 16: { + bitField0_ |= 0x00000002; + transactionType_ = input.readInt32(); + break; + } } } } catch (com.google.protobuf.InvalidProtocolBufferException e) { @@ -793,8 +798,25 @@ public final class ShardTransactionMessages { } } + // required int32 transactionType = 2; + public static final int TRANSACTIONTYPE_FIELD_NUMBER = 2; + private int transactionType_; + /** + * required int32 transactionType = 2; + */ + public boolean hasTransactionType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required int32 transactionType = 2; + */ + public int getTransactionType() { + return transactionType_; + } + private void initFields() { transactionId_ = ""; + transactionType_ = 0; } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { @@ -805,6 +827,10 @@ public final class ShardTransactionMessages { memoizedIsInitialized = 0; return false; } + if (!hasTransactionType()) { + memoizedIsInitialized = 0; + return false; + } memoizedIsInitialized = 1; return true; } @@ -815,6 +841,9 @@ public final class ShardTransactionMessages { if (((bitField0_ & 0x00000001) == 0x00000001)) { output.writeBytes(1, getTransactionIdBytes()); } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeInt32(2, transactionType_); + } getUnknownFields().writeTo(output); } @@ -828,6 +857,10 @@ public final class ShardTransactionMessages { size += com.google.protobuf.CodedOutputStream .computeBytesSize(1, getTransactionIdBytes()); } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, transactionType_); + } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; @@ -946,6 +979,8 @@ public final class ShardTransactionMessages { super.clear(); transactionId_ = ""; bitField0_ = (bitField0_ & ~0x00000001); + transactionType_ = 0; + bitField0_ = (bitField0_ & ~0x00000002); return this; } @@ -978,6 +1013,10 @@ public final class ShardTransactionMessages { to_bitField0_ |= 0x00000001; } result.transactionId_ = transactionId_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.transactionType_ = transactionType_; result.bitField0_ = to_bitField0_; onBuilt(); return result; @@ -999,6 +1038,9 @@ public final class ShardTransactionMessages { transactionId_ = other.transactionId_; onChanged(); } + if (other.hasTransactionType()) { + setTransactionType(other.getTransactionType()); + } this.mergeUnknownFields(other.getUnknownFields()); return this; } @@ -1008,6 +1050,10 @@ public final class ShardTransactionMessages { return false; } + if (!hasTransactionType()) { + + return false; + } return true; } @@ -1104,6 +1150,39 @@ public final class ShardTransactionMessages { return this; } + // required int32 transactionType = 2; + private int transactionType_ ; + /** + * required int32 transactionType = 2; + */ + public boolean hasTransactionType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required int32 transactionType = 2; + */ + public int getTransactionType() { + return transactionType_; + } + /** + * required int32 transactionType = 2; + */ + public Builder setTransactionType(int value) { + bitField0_ |= 0x00000002; + transactionType_ = value; + onChanged(); + return this; + } + /** + * required int32 transactionType = 2; + */ + public Builder clearTransactionType() { + bitField0_ = (bitField0_ & ~0x00000002); + transactionType_ = 0; + onChanged(); + return this; + } + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.CreateTransaction) } @@ -6581,32 +6660,33 @@ public final class ShardTransactionMessages { java.lang.String[] descriptorData = { "\n\026ShardTransaction.proto\022!org.opendaylig" + "ht.controller.mdsal\032\014Common.proto\"\022\n\020Clo" + - "seTransaction\"\027\n\025CloseTransactionReply\"*" + + "seTransaction\"\027\n\025CloseTransactionReply\"C" + "\n\021CreateTransaction\022\025\n\rtransactionId\030\001 \002" + - "(\t\"M\n\026CreateTransactionReply\022\034\n\024transact" + - "ionActorPath\030\001 \002(\t\022\025\n\rtransactionId\030\002 \002(" + - "\t\"\022\n\020ReadyTransaction\"*\n\025ReadyTransactio" + - "nReply\022\021\n\tactorPath\030\001 \002(\t\"l\n\nDeleteData\022" + - "^\n\037instanceIdentifierPathArguments\030\001 \002(\013" + - "25.org.opendaylight.controller.mdsal.Ins", - "tanceIdentifier\"\021\n\017DeleteDataReply\"j\n\010Re" + - "adData\022^\n\037instanceIdentifierPathArgument" + - "s\030\001 \002(\01325.org.opendaylight.controller.md" + - "sal.InstanceIdentifier\"P\n\rReadDataReply\022" + - "?\n\016normalizedNode\030\001 \001(\0132\'.org.opendaylig" + - "ht.controller.mdsal.Node\"\254\001\n\tWriteData\022^" + - "\n\037instanceIdentifierPathArguments\030\001 \002(\0132" + - "5.org.opendaylight.controller.mdsal.Inst" + - "anceIdentifier\022?\n\016normalizedNode\030\002 \002(\0132\'" + - ".org.opendaylight.controller.mdsal.Node\"", - "\020\n\016WriteDataReply\"\254\001\n\tMergeData\022^\n\037insta" + + "(\t\022\027\n\017transactionType\030\002 \002(\005\"M\n\026CreateTra" + + "nsactionReply\022\034\n\024transactionActorPath\030\001 " + + "\002(\t\022\025\n\rtransactionId\030\002 \002(\t\"\022\n\020ReadyTrans" + + "action\"*\n\025ReadyTransactionReply\022\021\n\tactor" + + "Path\030\001 \002(\t\"l\n\nDeleteData\022^\n\037instanceIden" + + "tifierPathArguments\030\001 \002(\01325.org.opendayl", + "ight.controller.mdsal.InstanceIdentifier" + + "\"\021\n\017DeleteDataReply\"j\n\010ReadData\022^\n\037insta" + "nceIdentifierPathArguments\030\001 \002(\01325.org.o" + "pendaylight.controller.mdsal.InstanceIde" + - "ntifier\022?\n\016normalizedNode\030\002 \002(\0132\'.org.op" + - "endaylight.controller.mdsal.Node\"\020\n\016Merg" + - "eDataReplyBV\n:org.opendaylight.controlle" + - "r.protobuff.messages.transactionB\030ShardT" + - "ransactionMessages" + "ntifier\"P\n\rReadDataReply\022?\n\016normalizedNo" + + "de\030\001 \001(\0132\'.org.opendaylight.controller.m" + + "dsal.Node\"\254\001\n\tWriteData\022^\n\037instanceIdent" + + "ifierPathArguments\030\001 \002(\01325.org.opendayli" + + "ght.controller.mdsal.InstanceIdentifier\022" + + "?\n\016normalizedNode\030\002 \002(\0132\'.org.opendaylig", + "ht.controller.mdsal.Node\"\020\n\016WriteDataRep" + + "ly\"\254\001\n\tMergeData\022^\n\037instanceIdentifierPa" + + "thArguments\030\001 \002(\01325.org.opendaylight.con" + + "troller.mdsal.InstanceIdentifier\022?\n\016norm" + + "alizedNode\030\002 \002(\0132\'.org.opendaylight.cont" + + "roller.mdsal.Node\"\020\n\016MergeDataReplyBV\n:o" + + "rg.opendaylight.controller.protobuff.mes" + + "sages.transactionB\030ShardTransactionMessa" + + "ges" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { @@ -6630,7 +6710,7 @@ public final class ShardTransactionMessages { internal_static_org_opendaylight_controller_mdsal_CreateTransaction_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_org_opendaylight_controller_mdsal_CreateTransaction_descriptor, - new java.lang.String[] { "TransactionId", }); + new java.lang.String[] { "TransactionId", "TransactionType", }); internal_static_org_opendaylight_controller_mdsal_CreateTransactionReply_descriptor = getDescriptor().getMessageTypes().get(3); internal_static_org_opendaylight_controller_mdsal_CreateTransactionReply_fieldAccessorTable = new diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/Cohort.proto b/opendaylight/md-sal/sal-clustering-commons/src/main/resources/Cohort.proto similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/Cohort.proto rename to opendaylight/md-sal/sal-clustering-commons/src/main/resources/Cohort.proto diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/Common.proto b/opendaylight/md-sal/sal-clustering-commons/src/main/resources/Common.proto similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/Common.proto rename to opendaylight/md-sal/sal-clustering-commons/src/main/resources/Common.proto diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/CompositeModificationPayload.proto b/opendaylight/md-sal/sal-clustering-commons/src/main/resources/CompositeModificationPayload.proto similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/CompositeModificationPayload.proto rename to opendaylight/md-sal/sal-clustering-commons/src/main/resources/CompositeModificationPayload.proto diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/DataChangeListener.proto b/opendaylight/md-sal/sal-clustering-commons/src/main/resources/DataChangeListener.proto similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/DataChangeListener.proto rename to opendaylight/md-sal/sal-clustering-commons/src/main/resources/DataChangeListener.proto diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ListenerRegistration.proto b/opendaylight/md-sal/sal-clustering-commons/src/main/resources/ListenerRegistration.proto similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ListenerRegistration.proto rename to opendaylight/md-sal/sal-clustering-commons/src/main/resources/ListenerRegistration.proto diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/Persistent.proto b/opendaylight/md-sal/sal-clustering-commons/src/main/resources/Persistent.proto similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/Persistent.proto rename to opendaylight/md-sal/sal-clustering-commons/src/main/resources/Persistent.proto diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ShardManager.proto b/opendaylight/md-sal/sal-clustering-commons/src/main/resources/ShardManager.proto similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ShardManager.proto rename to opendaylight/md-sal/sal-clustering-commons/src/main/resources/ShardManager.proto diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ShardTransaction.proto b/opendaylight/md-sal/sal-clustering-commons/src/main/resources/ShardTransaction.proto similarity index 96% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ShardTransaction.proto rename to opendaylight/md-sal/sal-clustering-commons/src/main/resources/ShardTransaction.proto index 9684b7d72f..4177bd7a05 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ShardTransaction.proto +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/resources/ShardTransaction.proto @@ -14,6 +14,7 @@ message CloseTransactionReply{ message CreateTransaction{ required string transactionId = 1; + required int32 transactionType =2; } message CreateTransactionReply{ diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ShardTransactionChain.proto b/opendaylight/md-sal/sal-clustering-commons/src/main/resources/ShardTransactionChain.proto similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ShardTransactionChain.proto rename to opendaylight/md-sal/sal-clustering-commons/src/main/resources/ShardTransactionChain.proto diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/SimpleNormalizedNode.proto b/opendaylight/md-sal/sal-clustering-commons/src/main/resources/SimpleNormalizedNode.proto similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/SimpleNormalizedNode.proto rename to opendaylight/md-sal/sal-clustering-commons/src/main/resources/SimpleNormalizedNode.proto diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodecTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodecTest.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodecTest.java rename to opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodecTest.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierFactoryTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierFactoryTest.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierFactoryTest.java rename to opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierFactoryTest.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtilsTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtilsTest.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtilsTest.java rename to opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtilsTest.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/NormalizedNodeXmlConverterTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/NormalizedNodeXmlConverterTest.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/NormalizedNodeXmlConverterTest.java rename to opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/NormalizedNodeXmlConverterTest.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java rename to opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/AbstractMessagesTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/protobuff/messages/AbstractMessagesTest.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/AbstractMessagesTest.java rename to opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/protobuff/messages/AbstractMessagesTest.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/cohort3pc/ThreePhaseCommitCohortMessagesTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/protobuff/messages/cohort3pc/ThreePhaseCommitCohortMessagesTest.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/cohort3pc/ThreePhaseCommitCohortMessagesTest.java rename to opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/protobuff/messages/cohort3pc/ThreePhaseCommitCohortMessagesTest.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/common/NormalizedNodeMessagesTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/protobuff/messages/common/NormalizedNodeMessagesTest.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/common/NormalizedNodeMessagesTest.java rename to opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/protobuff/messages/common/NormalizedNodeMessagesTest.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/datachange/notification/DataChangeListenerMessagesTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/protobuff/messages/datachange/notification/DataChangeListenerMessagesTest.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/datachange/notification/DataChangeListenerMessagesTest.java rename to opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/protobuff/messages/datachange/notification/DataChangeListenerMessagesTest.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/persistent/PersistentMessagesTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/protobuff/messages/persistent/PersistentMessagesTest.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/persistent/PersistentMessagesTest.java rename to opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/protobuff/messages/persistent/PersistentMessagesTest.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/registration/ListenerRegistrationMessagesTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/protobuff/messages/registration/ListenerRegistrationMessagesTest.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/registration/ListenerRegistrationMessagesTest.java rename to opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/protobuff/messages/registration/ListenerRegistrationMessagesTest.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/shard/ShardManagerMessagesTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/protobuff/messages/shard/ShardManagerMessagesTest.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/shard/ShardManagerMessagesTest.java rename to opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/protobuff/messages/shard/ShardManagerMessagesTest.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionChainMessagesTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionChainMessagesTest.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionChainMessagesTest.java rename to opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionChainMessagesTest.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionMessagesTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionMessagesTest.java similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionMessagesTest.java rename to opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionMessagesTest.java diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/application.conf b/opendaylight/md-sal/sal-clustering-commons/src/test/resources/application.conf similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/application.conf rename to opendaylight/md-sal/sal-clustering-commons/src/test/resources/application.conf diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/augment_choice.xml b/opendaylight/md-sal/sal-clustering-commons/src/test/resources/augment_choice.xml similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/augment_choice.xml rename to opendaylight/md-sal/sal-clustering-commons/src/test/resources/augment_choice.xml diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/augment_choice.yang b/opendaylight/md-sal/sal-clustering-commons/src/test/resources/augment_choice.yang similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/augment_choice.yang rename to opendaylight/md-sal/sal-clustering-commons/src/test/resources/augment_choice.yang diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/odl-datastore-augmentation.yang b/opendaylight/md-sal/sal-clustering-commons/src/test/resources/odl-datastore-augmentation.yang similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/odl-datastore-augmentation.yang rename to opendaylight/md-sal/sal-clustering-commons/src/test/resources/odl-datastore-augmentation.yang diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/odl-datastore-test-notification.yang b/opendaylight/md-sal/sal-clustering-commons/src/test/resources/odl-datastore-test-notification.yang similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/odl-datastore-test-notification.yang rename to opendaylight/md-sal/sal-clustering-commons/src/test/resources/odl-datastore-test-notification.yang diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/odl-datastore-test.yang b/opendaylight/md-sal/sal-clustering-commons/src/test/resources/odl-datastore-test.yang similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/odl-datastore-test.yang rename to opendaylight/md-sal/sal-clustering-commons/src/test/resources/odl-datastore-test.yang diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/simple_xml_with_attributes.xml b/opendaylight/md-sal/sal-clustering-commons/src/test/resources/simple_xml_with_attributes.xml similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/simple_xml_with_attributes.xml rename to opendaylight/md-sal/sal-clustering-commons/src/test/resources/simple_xml_with_attributes.xml diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/test.yang b/opendaylight/md-sal/sal-clustering-commons/src/test/resources/test.yang similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/test.yang rename to opendaylight/md-sal/sal-clustering-commons/src/test/resources/test.yang diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/DataChangeListenerMessagesData b/opendaylight/md-sal/sal-clustering-commons/src/test/resources/version-compatibility-serialized-data/DataChangeListenerMessagesData similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/DataChangeListenerMessagesData rename to opendaylight/md-sal/sal-clustering-commons/src/test/resources/version-compatibility-serialized-data/DataChangeListenerMessagesData diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ListenerRegistrationMessagesData b/opendaylight/md-sal/sal-clustering-commons/src/test/resources/version-compatibility-serialized-data/ListenerRegistrationMessagesData similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ListenerRegistrationMessagesData rename to opendaylight/md-sal/sal-clustering-commons/src/test/resources/version-compatibility-serialized-data/ListenerRegistrationMessagesData diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/NormalizedNodeMessagesTestData b/opendaylight/md-sal/sal-clustering-commons/src/test/resources/version-compatibility-serialized-data/NormalizedNodeMessagesTestData similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/NormalizedNodeMessagesTestData rename to opendaylight/md-sal/sal-clustering-commons/src/test/resources/version-compatibility-serialized-data/NormalizedNodeMessagesTestData diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/PersistentMessagesTestData b/opendaylight/md-sal/sal-clustering-commons/src/test/resources/version-compatibility-serialized-data/PersistentMessagesTestData similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/PersistentMessagesTestData rename to opendaylight/md-sal/sal-clustering-commons/src/test/resources/version-compatibility-serialized-data/PersistentMessagesTestData diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ShardManagerMessagesTestData b/opendaylight/md-sal/sal-clustering-commons/src/test/resources/version-compatibility-serialized-data/ShardManagerMessagesTestData similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ShardManagerMessagesTestData rename to opendaylight/md-sal/sal-clustering-commons/src/test/resources/version-compatibility-serialized-data/ShardManagerMessagesTestData diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ShardTransactionChainMessagesTestData b/opendaylight/md-sal/sal-clustering-commons/src/test/resources/version-compatibility-serialized-data/ShardTransactionChainMessagesTestData similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ShardTransactionChainMessagesTestData rename to opendaylight/md-sal/sal-clustering-commons/src/test/resources/version-compatibility-serialized-data/ShardTransactionChainMessagesTestData diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ShardTransactionMessagesTestData b/opendaylight/md-sal/sal-clustering-commons/src/test/resources/version-compatibility-serialized-data/ShardTransactionMessagesTestData similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ShardTransactionMessagesTestData rename to opendaylight/md-sal/sal-clustering-commons/src/test/resources/version-compatibility-serialized-data/ShardTransactionMessagesTestData diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ThreePhaseCommitCohortMessagesTestData b/opendaylight/md-sal/sal-clustering-commons/src/test/resources/version-compatibility-serialized-data/ThreePhaseCommitCohortMessagesTestData similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ThreePhaseCommitCohortMessagesTestData rename to opendaylight/md-sal/sal-clustering-commons/src/test/resources/version-compatibility-serialized-data/ThreePhaseCommitCohortMessagesTestData diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/readme.txt b/opendaylight/md-sal/sal-clustering-commons/src/test/resources/version-compatibility-serialized-data/readme.txt similarity index 100% rename from opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/readme.txt rename to opendaylight/md-sal/sal-clustering-commons/src/test/resources/version-compatibility-serialized-data/readme.txt diff --git a/opendaylight/md-sal/sal-clustering-config/pom.xml b/opendaylight/md-sal/sal-clustering-config/pom.xml new file mode 100644 index 0000000000..d726823b98 --- /dev/null +++ b/opendaylight/md-sal/sal-clustering-config/pom.xml @@ -0,0 +1,46 @@ + + + + + 4.0.0 + + org.opendaylight.controller + sal-parent + 1.1-SNAPSHOT + + sal-clustering-config + Configuration files for md-sal clustering + jar + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/initial/*.conf + xml + config + + + + + + + + + diff --git a/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/05-clustering.xml.conf b/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/05-clustering.xml.conf new file mode 100644 index 0000000000..7891ee2088 --- /dev/null +++ b/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/05-clustering.xml.conf @@ -0,0 +1,85 @@ + + + + + + + + + prefix:dom-inmemory-data-broker + inmemory-data-broker + + + dom:schema-service + yang-schema-service + + + + config-dom-store-spi:config-dom-datastore + distributed-config-store-service + + + + operational-dom-store-spi:operational-dom-datastore + distributed-operational-store-service + + + + + prefix:distributed-operational-datastore-provider + distributed-operational-store-module + + dom:schema-service + yang-schema-service + + + + + prefix:distributed-config-datastore-provider + distributed-config-store-module + + dom:schema-service + yang-schema-service + + + + + prefix:remote-rpc-connector + remote-rpc-connector + + dom:dom-broker-osgi-registry + dom-broker + + + + + + + + config-dom-store-spi:config-dom-datastore + + distributed-config-store-service + /modules/module[type='distributed-config-datastore-provider'][name='distributed-config-store-module'] + + + + operational-dom-store-spi:operational-dom-datastore + + distributed-operational-store-service + /modules/module[type='distributed-operational-datastore-provider'][name='distributed-operational-store-module'] + + + + + + + + urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl?module=opendaylight-sal-dom-broker-impl&revision=2013-10-28 + + diff --git a/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/akka.conf b/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/akka.conf new file mode 100644 index 0000000000..9749ae27ae --- /dev/null +++ b/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/akka.conf @@ -0,0 +1,55 @@ + +odl-cluster-data { + akka { + actor { + provider = "akka.cluster.ClusterActorRefProvider" + serializers { + java = "akka.serialization.JavaSerializer" + proto = "akka.remote.serialization.ProtobufSerializer" + } + + serialization-bindings { + "com.google.protobuf.Message" = proto + + } + } + remote { + log-remote-lifecycle-events = off + netty.tcp { + hostname = "" + port = 2550 + maximum-frame-size = 2097152 + send-buffer-size = 52428800 + receive-buffer-size = 52428800 + } + } + + cluster { + seed-nodes = ["akka.tcp://opendaylight-cluster-data@:2550"] + + auto-down-unreachable-after = 10s + } + } +} + +odl-cluster-rpc { + akka { + actor { + provider = "akka.cluster.ClusterActorRefProvider" + + } + remote { + log-remote-lifecycle-events = off + netty.tcp { + hostname = "" + port = 2551 + } + } + + cluster { + seed-nodes = ["akka.tcp://opendaylight-cluster-rpc@:2551"] + + auto-down-unreachable-after = 10s + } + } +} diff --git a/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/module-shards.conf b/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/module-shards.conf new file mode 100644 index 0000000000..8449abb7b0 --- /dev/null +++ b/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/module-shards.conf @@ -0,0 +1,70 @@ +# This file describes which shards live on which members +# The format for a module-shards is as follows, +# { +# name = "" +# shards = [ +# { +# name="" +# replicas = [ +# "" +# ] +# ] +# } +# +# For Helium we support only one shard per module. Beyond Helium +# we will support more than 1 +# The replicas section is a collection of member names. This information +# will be used to decide on which members replicas of a particular shard will be +# located. Once replication is integrated with the distributed data store then +# this section can have multiple entries. +# +# + + +module-shards = [ + { + name = "default" + shards = [ + { + name="default" + replicas = [ + "member-1" + ] + } + ] + }, + { + name = "topology" + shards = [ + { + name="topology" + replicas = [ + "member-1" + ] + } + ] + }, + { + name = "inventory" + shards = [ + { + name="inventory" + replicas = [ + "member-1" + ] + } + ] + }, + { + name = "toaster" + shards = [ + { + name="toaster" + replicas = [ + "member-1" + ] + } + ] + } + +] diff --git a/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/modules.conf b/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/modules.conf new file mode 100644 index 0000000000..68347eeda9 --- /dev/null +++ b/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/modules.conf @@ -0,0 +1,32 @@ +# This file should describe all the modules that need to be placed in a separate shard +# The format of the configuration is as follows +# { +# name = "" +# namespace = "" +# shard-strategy = "module" +# } +# +# Note that at this time the only shard-strategy we support is module which basically +# will put all the data of a single module in two shards (one for config and one for +# operational data) + +modules = [ + { + name = "inventory" + namespace = "urn:opendaylight:inventory" + shard-strategy = "module" + }, + + { + name = "topology" + namespace = "urn:TBD:params:xml:ns:yang:network-topology" + shard-strategy = "module" + }, + + { + name = "toaster" + namespace = "http://netconfcentral.org/ns/toaster" + shard-strategy = "module" + } + +] diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionCommitDeadlockException.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionCommitDeadlockException.java new file mode 100644 index 0000000000..60313bf109 --- /dev/null +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionCommitDeadlockException.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2014 Brocade Communications 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.common.api.data; + +import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; + +import com.google.common.base.Function; + +/** + * A type of TransactionCommitFailedException that indicates a situation that would result in a + * threading deadlock. This can occur if a caller that submits a write transaction tries to perform + * a blocking call via one of the get methods on the returned ListenableFuture. Callers + * should process the commit result asynchronously (via Futures#addCallback) to ensure deadlock + * won't occur. + * + * @author Thomas Pantelis + */ +public class TransactionCommitDeadlockException extends TransactionCommitFailedException { + + private static final long serialVersionUID = 1L; + + private static final String DEADLOCK_MESSAGE = + "An attempt to block on a ListenableFuture via a get method from a write " + + "transaction submit was detected that would result in deadlock. The commit " + + "result must be obtained asynchronously, e.g. via Futures#addCallback, to avoid deadlock."; + + public static Function DEADLOCK_EXECUTOR_FUNCTION = new Function() { + @Override + public Exception apply(Void notUsed) { + return new TransactionCommitDeadlockException( DEADLOCK_MESSAGE, + RpcResultBuilder.newError(ErrorType.APPLICATION, "lock-denied", DEADLOCK_MESSAGE)); + } + }; + + public TransactionCommitDeadlockException(String message, final RpcError... errors) { + super(message, errors); + } +} diff --git a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/service/AbstractDataBroker.java b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/service/AbstractDataBroker.java index a732f2f1b9..ca6e6e9718 100644 --- a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/service/AbstractDataBroker.java +++ b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/service/AbstractDataBroker.java @@ -36,7 +36,7 @@ import org.opendaylight.yangtools.concepts.CompositeObjectRegistration; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.concepts.Path; import org.opendaylight.yangtools.concepts.Registration; -import org.opendaylight.yangtools.concepts.util.ListenerRegistry; +import org.opendaylight.yangtools.util.ListenerRegistry; import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/opendaylight/md-sal/sal-distributed-datastore/pom.xml b/opendaylight/md-sal/sal-distributed-datastore/pom.xml index 94c895dab3..848d425bf9 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/pom.xml +++ b/opendaylight/md-sal/sal-distributed-datastore/pom.xml @@ -120,7 +120,7 @@ org.opendaylight.controller - sal-protocolbuffer-encoding + sal-clustering-commons 1.1-SNAPSHOT @@ -165,7 +165,7 @@ !*snappy;!org.jboss.*;* - sal-protocolbuffer-encoding; + sal-clustering-commons; sal-akka-raft; !sal*; !*config-api*; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ActorSystemFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ActorSystemFactory.java index baf04fe43b..15c0548761 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ActorSystemFactory.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ActorSystemFactory.java @@ -20,8 +20,8 @@ public class ActorSystemFactory { @Nullable @Override public ActorSystem apply(@Nullable Void aVoid) { ActorSystem system = - ActorSystem.create("opendaylight-cluster", ConfigFactory - .load().getConfig("ODLCluster")); + ActorSystem.create("opendaylight-cluster-data", ConfigFactory + .load().getConfig("odl-cluster-data")); system.actorOf(Props.create(TerminationMonitor.class), "termination-monitor"); return system; } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListener.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListener.java index b435eda7a3..cdf04dd093 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListener.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListener.java @@ -33,7 +33,7 @@ public class DataChangeListener extends AbstractUntypedActor { } @Override public void handleReceive(Object message) throws Exception { - if(message.getClass().equals(DataChanged.SERIALIZABLE_CLASS)){ + if(message instanceof DataChanged){ dataChanged(message); } else if(message instanceof EnableNotification){ enableNotification((EnableNotification) message); @@ -51,13 +51,13 @@ public class DataChangeListener extends AbstractUntypedActor { return; } - DataChanged reply = DataChanged.fromSerialize(schemaContext,message, pathId); + DataChanged reply = (DataChanged) message; AsyncDataChangeEvent> change = reply.getChange(); this.listener.onDataChanged(change); if(getSender() != null){ - getSender().tell(new DataChangedReply().toSerializable(), getSelf()); + getSender().tell(new DataChangedReply(), getSelf()); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerProxy.java index cd9c330268..a4ca456268 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerProxy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerProxy.java @@ -30,6 +30,6 @@ public class DataChangeListenerProxy implements AsyncDataChangeListener> change) { - dataChangeListenerActor.tell(new DataChanged(schemaContext,change).toSerializable(), null); + dataChangeListenerActor.tell(new DataChanged(schemaContext,change), null); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java index 780f28f358..479af79748 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java @@ -8,11 +8,10 @@ package org.opendaylight.controller.cluster.datastore; -import java.util.concurrent.Executors; - import akka.actor.ActorRef; import akka.actor.ActorSystem; - +import com.google.common.util.concurrent.ListeningExecutorService; +import com.google.common.util.concurrent.MoreExecutors; import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListener; import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListenerReply; import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext; @@ -33,8 +32,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.MoreExecutors; +import java.util.concurrent.Executors; /** * @@ -88,13 +86,12 @@ public class DistributedDataStore implements DOMStore, SchemaContextListener, Au Object result = actorContext.executeLocalShardOperation(shardName, new RegisterChangeListener(path, dataChangeListenerActor.path(), - scope).toSerializable(), + scope), ActorContext.ASK_DURATION ); if (result != null) { - RegisterChangeListenerReply reply = RegisterChangeListenerReply - .fromSerializable(actorContext.getActorSystem(), result); + RegisterChangeListenerReply reply = (RegisterChangeListenerReply) result; return new DataChangeListenerRegistrationProxy(actorContext .actorSelection(reply.getListenerRegistrationPath()), listener, dataChangeListenerActor); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java index 23e27c9f5f..10dbbc84d8 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java @@ -15,11 +15,10 @@ import akka.event.Logging; import akka.event.LoggingAdapter; import akka.japi.Creator; import akka.serialization.Serialization; - +import com.google.common.base.Optional; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; - import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardMBeanFactory; import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats; import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply; @@ -35,6 +34,8 @@ import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeList import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext; import org.opendaylight.controller.cluster.datastore.modification.Modification; import org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification; +import org.opendaylight.controller.cluster.raft.ConfigParams; +import org.opendaylight.controller.cluster.raft.DefaultConfigParamsImpl; import org.opendaylight.controller.cluster.raft.RaftActor; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener; import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; @@ -44,6 +45,7 @@ import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import scala.concurrent.duration.FiniteDuration; import java.util.ArrayList; import java.util.HashMap; @@ -51,6 +53,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; /** * A Shard represents a portion of the logical data tree
@@ -60,6 +63,8 @@ import java.util.concurrent.Executors; */ public class Shard extends RaftActor { + private static final ConfigParams configParams = new ShardConfigParams(); + public static final String DEFAULT_NAME = "default"; private final ListeningExecutorService storeExecutor = @@ -86,7 +91,7 @@ public class Shard extends RaftActor { private final List dataChangeListeners = new ArrayList<>(); private Shard(String name, Map peerAddresses) { - super(name, peerAddresses); + super(name, peerAddresses, Optional.of(configParams)); this.name = name; @@ -123,8 +128,8 @@ public class Shard extends RaftActor { } else if(getLeader() != null){ getLeader().forward(message, getContext()); } - } else if (message.getClass().equals(RegisterChangeListener.SERIALIZABLE_CLASS)) { - registerChangeListener(RegisterChangeListener.fromSerializable(getContext().system(), message)); + } else if (message instanceof RegisterChangeListener) { + registerChangeListener((RegisterChangeListener) message); } else if (message instanceof UpdateSchemaContext) { updateSchemaContext((UpdateSchemaContext) message); } else if (message instanceof ForwardedCommitTransaction) { @@ -143,13 +148,29 @@ public class Shard extends RaftActor { } } + private ActorRef createTypedTransactionActor(CreateTransaction createTransaction,String transactionId){ + if(createTransaction.getTransactionType()== TransactionProxy.TransactionType.READ_ONLY.ordinal()){ + return getContext().actorOf( + ShardTransaction.props( store.newReadOnlyTransaction(), getSelf(), schemaContext), transactionId); + + }else if (createTransaction.getTransactionType()== TransactionProxy.TransactionType.READ_WRITE.ordinal()){ + return getContext().actorOf( + ShardTransaction.props( store.newReadWriteTransaction(), getSelf(), schemaContext), transactionId); + + + }else if (createTransaction.getTransactionType()== TransactionProxy.TransactionType.WRITE_ONLY.ordinal()){ + return getContext().actorOf( + ShardTransaction.props( store.newWriteOnlyTransaction(), getSelf(), schemaContext), transactionId); + }else{ + throw new IllegalArgumentException ("CreateTransaction message has unidentified transaction type="+createTransaction.getTransactionType()) ; + } + } + private void createTransaction(CreateTransaction createTransaction) { - DOMStoreReadWriteTransaction transaction = - store.newReadWriteTransaction(); + String transactionId = "shard-" + createTransaction.getTransactionId(); LOG.info("Creating transaction : {} " , transactionId); - ActorRef transactionActor = getContext().actorOf( - ShardTransaction.props(transaction, getSelf(), schemaContext), transactionId); + ActorRef transactionActor = createTypedTransactionActor(createTransaction,transactionId); getSender() .tell(new CreateTransactionReply(Serialization.serializedActorPath(transactionActor), createTransaction.getTransactionId()).toSerializable(), @@ -257,7 +278,7 @@ public class Shard extends RaftActor { LOG.debug("registerDataChangeListener sending reply, listenerRegistrationPath = " + listenerRegistration.path().toString()); getSender() - .tell(new RegisterChangeListenerReply(listenerRegistration.path()).toSerializable(), + .tell(new RegisterChangeListenerReply(listenerRegistration.path()), getSelf()); } @@ -304,9 +325,25 @@ public class Shard extends RaftActor { for(ActorSelection dataChangeListener : dataChangeListeners){ dataChangeListener.tell(new EnableNotification(isLeader()), getSelf()); } + + if(getLeaderId() != null){ + shardMBean.setLeader(getLeaderId()); + } + + shardMBean.setRaftState(getRaftState().name()); } @Override public String persistenceId() { return this.name; } + + + private static class ShardConfigParams extends DefaultConfigParamsImpl { + public static final FiniteDuration HEART_BEAT_INTERVAL = + new FiniteDuration(500, TimeUnit.MILLISECONDS); + + @Override public FiniteDuration getHeartBeatInterval() { + return HEART_BEAT_INTERVAL; + } + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardReadTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardReadTransaction.java new file mode 100644 index 0000000000..f78935b5e7 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardReadTransaction.java @@ -0,0 +1,58 @@ +/* + * + * 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.cluster.datastore; + +import akka.actor.ActorRef; +import akka.actor.PoisonPill; +import akka.event.Logging; +import akka.event.LoggingAdapter; +import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction; +import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionReply; +import org.opendaylight.controller.cluster.datastore.messages.ReadData; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; + +/** + * @author: syedbahm + * Date: 8/6/14 + */ +public class ShardReadTransaction extends ShardTransaction { + private final DOMStoreReadTransaction transaction; + private final LoggingAdapter log = + Logging.getLogger(getContext().system(), this); + + public ShardReadTransaction(DOMStoreReadTransaction transaction, ActorRef shardActor, SchemaContext schemaContext) { + super(shardActor, schemaContext); + this.transaction = transaction; + + } + + public ShardReadTransaction(DOMStoreTransactionChain transactionChain, DOMStoreReadTransaction transaction, ActorRef shardActor, SchemaContext schemaContext) { + super(transactionChain, shardActor, schemaContext); + this.transaction = transaction; + } + + @Override + public void handleReceive(Object message) throws Exception { + if (ReadData.SERIALIZABLE_CLASS.equals(message.getClass())) { + readData(transaction,ReadData.fromSerializable(message)); + } else { + super.handleReceive(message); + } + } + protected void closeTransaction(CloseTransaction message) { + transaction.close(); + getSender().tell(new CloseTransactionReply().toSerializable(), getSelf()); + getSelf().tell(PoisonPill.getInstance(), getSelf()); + } + +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardReadWriteTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardReadWriteTransaction.java new file mode 100644 index 0000000000..6733bcfb9f --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardReadWriteTransaction.java @@ -0,0 +1,68 @@ +/* + * + * 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.cluster.datastore; + +import akka.actor.ActorRef; +import akka.actor.PoisonPill; +import akka.event.Logging; +import akka.event.LoggingAdapter; +import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction; +import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionReply; +import org.opendaylight.controller.cluster.datastore.messages.DeleteData; +import org.opendaylight.controller.cluster.datastore.messages.MergeData; +import org.opendaylight.controller.cluster.datastore.messages.ReadData; +import org.opendaylight.controller.cluster.datastore.messages.ReadyTransaction; +import org.opendaylight.controller.cluster.datastore.messages.WriteData; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; + +/** + * @author: syedbahm + * Date: 8/6/14 + */ +public class ShardReadWriteTransaction extends ShardTransaction { + private final DOMStoreReadWriteTransaction transaction; + private final LoggingAdapter log = + Logging.getLogger(getContext().system(), this); + public ShardReadWriteTransaction(DOMStoreTransactionChain transactionChain, DOMStoreReadWriteTransaction transaction, ActorRef shardActor, SchemaContext schemaContext) { + super(transactionChain, shardActor, schemaContext); + this.transaction = transaction; + } + + public ShardReadWriteTransaction(DOMStoreReadWriteTransaction transaction, ActorRef shardActor, SchemaContext schemaContext) { + super( shardActor, schemaContext); + this.transaction = transaction; + } + + @Override + public void handleReceive(Object message) throws Exception { + if (ReadData.SERIALIZABLE_CLASS.equals(message.getClass())) { + readData(transaction,ReadData.fromSerializable(message)); + }else if (WriteData.SERIALIZABLE_CLASS.equals(message.getClass())) { + writeData(transaction, WriteData.fromSerializable(message, schemaContext)); + } else if (MergeData.SERIALIZABLE_CLASS.equals(message.getClass())) { + mergeData(transaction, MergeData.fromSerializable(message, schemaContext)); + } else if (DeleteData.SERIALIZABLE_CLASS.equals(message.getClass())) { + deleteData(transaction,DeleteData.fromSerizalizable(message)); + } else if (ReadyTransaction.SERIALIZABLE_CLASS.equals(message.getClass())) { + readyTransaction(transaction,new ReadyTransaction()); + }else { + super.handleReceive(message); + } + } + + protected void closeTransaction(CloseTransaction message) { + transaction.close(); + getSender().tell(new CloseTransactionReply().toSerializable(), getSelf()); + getSelf().tell(PoisonPill.getInstance(), getSelf()); + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransaction.java index 737f57bf5d..3a916bda2c 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransaction.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransaction.java @@ -9,7 +9,6 @@ package org.opendaylight.controller.cluster.datastore; import akka.actor.ActorRef; -import akka.actor.PoisonPill; import akka.actor.Props; import akka.event.Logging; import akka.event.LoggingAdapter; @@ -17,7 +16,6 @@ import akka.japi.Creator; import com.google.common.base.Optional; import com.google.common.util.concurrent.ListenableFuture; import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction; -import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionReply; import org.opendaylight.controller.cluster.datastore.messages.DeleteData; import org.opendaylight.controller.cluster.datastore.messages.DeleteDataReply; import org.opendaylight.controller.cluster.datastore.messages.MergeData; @@ -34,9 +32,11 @@ import org.opendaylight.controller.cluster.datastore.modification.ImmutableCompo import org.opendaylight.controller.cluster.datastore.modification.MergeModification; import org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification; import org.opendaylight.controller.cluster.datastore.modification.WriteModification; +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.DOMStoreTransactionChain; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.model.api.SchemaContext; @@ -65,170 +65,200 @@ import java.util.concurrent.ExecutionException; *
  • {@link org.opendaylight.controller.cluster.datastore.messages.CloseTransaction} *

    */ -public class ShardTransaction extends AbstractUntypedActor { - - private final ActorRef shardActor; - private final SchemaContext schemaContext; - - // FIXME : see below - // If transactionChain is not null then this transaction is part of a - // transactionChain. Not really clear as to what that buys us - private final DOMStoreTransactionChain transactionChain; - - private final DOMStoreReadWriteTransaction transaction; - - private final MutableCompositeModification modification = - new MutableCompositeModification(); - - private final LoggingAdapter log = - Logging.getLogger(getContext().system(), this); - - public ShardTransaction(DOMStoreReadWriteTransaction transaction, - ActorRef shardActor, SchemaContext schemaContext) { - this(null, transaction, shardActor, schemaContext); - } - - public ShardTransaction(DOMStoreTransactionChain transactionChain, DOMStoreReadWriteTransaction transaction, - ActorRef shardActor, SchemaContext schemaContext) { - this.transactionChain = transactionChain; - this.transaction = transaction; - this.shardActor = shardActor; - this.schemaContext = schemaContext; - } - - - - public static Props props(final DOMStoreReadWriteTransaction transaction, - final ActorRef shardActor, final SchemaContext schemaContext) { - return Props.create(new Creator() { - - @Override - public ShardTransaction create() throws Exception { - return new ShardTransaction(transaction, shardActor, schemaContext); - } - }); - } - - public static Props props(final DOMStoreTransactionChain transactionChain, final DOMStoreReadWriteTransaction transaction, - final ActorRef shardActor, final SchemaContext schemaContext) { - return Props.create(new Creator() { - - @Override - public ShardTransaction create() throws Exception { - return new ShardTransaction(transactionChain, transaction, shardActor, schemaContext); - } - }); +public abstract class ShardTransaction extends AbstractUntypedActor { + + private final ActorRef shardActor; + protected final SchemaContext schemaContext; + + // FIXME : see below + // If transactionChain is not null then this transaction is part of a + // transactionChain. Not really clear as to what that buys us + private final DOMStoreTransactionChain transactionChain; + + + private final MutableCompositeModification modification = + new MutableCompositeModification(); + + private final LoggingAdapter log = + Logging.getLogger(getContext().system(), this); + + protected ShardTransaction( + ActorRef shardActor, SchemaContext schemaContext) { + this(null, shardActor, schemaContext); + } + + protected ShardTransaction(DOMStoreTransactionChain transactionChain, + ActorRef shardActor, SchemaContext schemaContext) { + this.transactionChain = transactionChain; + //this.transaction = transaction; + this.shardActor = shardActor; + this.schemaContext = schemaContext; + } + + + + public static Props props(final DOMStoreReadTransaction transaction, + final ActorRef shardActor, final SchemaContext schemaContext) { + return Props.create(new Creator() { + + @Override + public ShardTransaction create() throws Exception { + return new ShardReadTransaction(transaction, shardActor, schemaContext); + } + }); + } + + public static Props props(final DOMStoreTransactionChain transactionChain, final DOMStoreReadTransaction transaction, + final ActorRef shardActor, final SchemaContext schemaContext) { + return Props.create(new Creator() { + + @Override + public ShardTransaction create() throws Exception { + return new ShardReadTransaction(transactionChain, transaction, shardActor, schemaContext); + } + }); + } + + public static Props props(final DOMStoreReadWriteTransaction transaction, + final ActorRef shardActor, final SchemaContext schemaContext) { + return Props.create(new Creator() { + + @Override + public ShardTransaction create() throws Exception { + return new ShardReadWriteTransaction(transaction, shardActor, schemaContext); + } + }); + } + + public static Props props(final DOMStoreTransactionChain transactionChain, final DOMStoreReadWriteTransaction transaction, + final ActorRef shardActor, final SchemaContext schemaContext) { + return Props.create(new Creator() { + + @Override + public ShardTransaction create() throws Exception { + return new ShardReadWriteTransaction(transactionChain, transaction, shardActor, schemaContext); + } + }); + } + + + public static Props props(final DOMStoreWriteTransaction transaction, + final ActorRef shardActor, final SchemaContext schemaContext) { + return Props.create(new Creator() { + + @Override + public ShardTransaction create() throws Exception { + return new ShardWriteTransaction(transaction, shardActor, schemaContext); + } + }); + } + + public static Props props(final DOMStoreTransactionChain transactionChain, final DOMStoreWriteTransaction transaction, + final ActorRef shardActor, final SchemaContext schemaContext) { + return Props.create(new Creator() { + + @Override + public ShardTransaction create() throws Exception { + return new ShardWriteTransaction(transactionChain, transaction, shardActor, schemaContext); + } + }); + } + + + @Override + public void handleReceive(Object message) throws Exception { + if (message.getClass().equals(CloseTransaction.SERIALIZABLE_CLASS)) { + closeTransaction(new CloseTransaction()); + } else if (message instanceof GetCompositedModification) { + // This is here for testing only + getSender().tell(new GetCompositeModificationReply( + new ImmutableCompositeModification(modification)), getSelf()); + }else{ + throw new Exception ("ShardTransaction:handleRecieve received an unknown message"+message); } - - - @Override - public void handleReceive(Object message) throws Exception { - if (ReadData.SERIALIZABLE_CLASS.equals(message.getClass())) { - readData(ReadData.fromSerializable(message)); - } else if (WriteData.SERIALIZABLE_CLASS.equals(message.getClass())) { - writeData(WriteData.fromSerializable(message, schemaContext)); - } else if (MergeData.SERIALIZABLE_CLASS.equals(message.getClass())) { - mergeData(MergeData.fromSerializable(message, schemaContext)); - } else if (DeleteData.SERIALIZABLE_CLASS.equals(message.getClass())) { - deleteData(DeleteData.fromSerizalizable(message)); - } else if (ReadyTransaction.SERIALIZABLE_CLASS.equals(message.getClass())) { - readyTransaction(new ReadyTransaction()); - } else if (message.getClass().equals(CloseTransaction.SERIALIZABLE_CLASS)) { - closeTransaction(new CloseTransaction()); - } else if (message instanceof GetCompositedModification) { - // This is here for testing only - getSender().tell(new GetCompositeModificationReply( - new ImmutableCompositeModification(modification)), getSelf()); - }else{ - throw new Exception ("Shard:handleRecieve received an unknown message"+message); + } + + abstract protected void closeTransaction(CloseTransaction message); + + protected void readData(DOMStoreReadTransaction transaction,ReadData message) { + final ActorRef sender = getSender(); + final ActorRef self = getSelf(); + final YangInstanceIdentifier path = message.getPath(); + final ListenableFuture>> future = + transaction.read(path); + + future.addListener(new Runnable() { + @Override + public void run() { + try { + Optional> optional = future.get(); + if (optional.isPresent()) { + sender.tell(new ReadDataReply(schemaContext,optional.get()).toSerializable(), self); + } else { + sender.tell(new ReadDataReply(schemaContext,null).toSerializable(), self); + } + } catch (InterruptedException | ExecutionException e) { + log.error(e, + "An exception happened when reading data from path : " + + path.toString()); } - } - private void readData(ReadData message) { - final ActorRef sender = getSender(); - final ActorRef self = getSelf(); - final YangInstanceIdentifier path = message.getPath(); - final ListenableFuture>> future = - transaction.read(path); - - future.addListener(new Runnable() { - @Override - public void run() { - try { - Optional> optional = future.get(); - if (optional.isPresent()) { - sender.tell(new ReadDataReply(schemaContext,optional.get()).toSerializable(), self); - } else { - sender.tell(new ReadDataReply(schemaContext,null).toSerializable(), self); - } - } catch (InterruptedException | ExecutionException e) { - log.error(e, - "An exception happened when reading data from path : " - + path.toString()); - } - - } - }, getContext().dispatcher()); - } + } + }, getContext().dispatcher()); + } - private void writeData(WriteData message) { - modification.addModification( - new WriteModification(message.getPath(), message.getData(),schemaContext)); - LOG.debug("writeData at path : " + message.getPath().toString()); - transaction.write(message.getPath(), message.getData()); - getSender().tell(new WriteDataReply().toSerializable(), getSelf()); - } + protected void writeData(DOMStoreWriteTransaction transaction, WriteData message) { + modification.addModification( + new WriteModification(message.getPath(), message.getData(),schemaContext)); + LOG.debug("writeData at path : " + message.getPath().toString()); + transaction.write(message.getPath(), message.getData()); + getSender().tell(new WriteDataReply().toSerializable(), getSelf()); + } - private void mergeData(MergeData message) { - modification.addModification( - new MergeModification(message.getPath(), message.getData(), schemaContext)); - LOG.debug("mergeData at path : " + message.getPath().toString()); - transaction.merge(message.getPath(), message.getData()); - getSender().tell(new MergeDataReply().toSerializable(), getSelf()); - } + protected void mergeData(DOMStoreWriteTransaction transaction, MergeData message) { + modification.addModification( + new MergeModification(message.getPath(), message.getData(), schemaContext)); + LOG.debug("mergeData at path : " + message.getPath().toString()); + transaction.merge(message.getPath(), message.getData()); + getSender().tell(new MergeDataReply().toSerializable(), getSelf()); + } - private void deleteData(DeleteData message) { - modification.addModification(new DeleteModification(message.getPath())); - transaction.delete(message.getPath()); - getSender().tell(new DeleteDataReply().toSerializable(), getSelf()); - } + protected void deleteData(DOMStoreWriteTransaction transaction, DeleteData message) { + modification.addModification(new DeleteModification(message.getPath())); + transaction.delete(message.getPath()); + getSender().tell(new DeleteDataReply().toSerializable(), getSelf()); + } - private void readyTransaction(ReadyTransaction message) { - DOMStoreThreePhaseCommitCohort cohort = transaction.ready(); - ActorRef cohortActor = getContext().actorOf( - ThreePhaseCommitCohort.props(cohort, shardActor, modification), "cohort"); - getSender() - .tell(new ReadyTransactionReply(cohortActor.path()).toSerializable(), getSelf()); + protected void readyTransaction(DOMStoreWriteTransaction transaction, ReadyTransaction message) { + DOMStoreThreePhaseCommitCohort cohort = transaction.ready(); + ActorRef cohortActor = getContext().actorOf( + ThreePhaseCommitCohort.props(cohort, shardActor, modification), "cohort"); + getSender() + .tell(new ReadyTransactionReply(cohortActor.path()).toSerializable(), getSelf()); - } - - private void closeTransaction(CloseTransaction message) { - transaction.close(); - getSender().tell(new CloseTransactionReply().toSerializable(), getSelf()); - getSelf().tell(PoisonPill.getInstance(), getSelf()); - } + } - // These classes are in here for test purposes only + // These classes are in here for test purposes only - static class GetCompositedModification { + static class GetCompositedModification { - } + } - static class GetCompositeModificationReply { - private final CompositeModification modification; + static class GetCompositeModificationReply { + private final CompositeModification modification; - GetCompositeModificationReply(CompositeModification modification) { - this.modification = modification; - } + GetCompositeModificationReply(CompositeModification modification) { + this.modification = modification; + } - public CompositeModification getModification() { - return modification; - } + public CompositeModification getModification() { + return modification; } + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionChain.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionChain.java index 50042411b1..ce63f1107d 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionChain.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionChain.java @@ -15,7 +15,6 @@ import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionCh import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionChainReply; import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction; import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionReply; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain; import org.opendaylight.yangtools.yang.model.api.SchemaContext; @@ -45,11 +44,27 @@ public class ShardTransactionChain extends AbstractUntypedActor { } } + private ActorRef createTypedTransactionActor(CreateTransaction createTransaction,String transactionId){ + if(createTransaction.getTransactionType()== TransactionProxy.TransactionType.READ_ONLY.ordinal()){ + return getContext().actorOf( + ShardTransaction.props( chain.newReadOnlyTransaction(), getSelf(), schemaContext), transactionId); + + }else if (createTransaction.getTransactionType()== TransactionProxy.TransactionType.READ_WRITE.ordinal()){ + return getContext().actorOf( + ShardTransaction.props( chain.newReadWriteTransaction(), getSelf(), schemaContext), transactionId); + + + }else if (createTransaction.getTransactionType()== TransactionProxy.TransactionType.WRITE_ONLY.ordinal()){ + return getContext().actorOf( + ShardTransaction.props( chain.newWriteOnlyTransaction(), getSelf(), schemaContext), transactionId); + }else{ + throw new IllegalArgumentException ("CreateTransaction message has unidentified transaction type="+createTransaction.getTransactionType()) ; + } + } + private void createTransaction(CreateTransaction createTransaction) { - DOMStoreReadWriteTransaction transaction = - chain.newReadWriteTransaction(); - ActorRef transactionActor = getContext().actorOf(ShardTransaction - .props(chain, transaction, getContext().parent(), schemaContext), "shard-" + createTransaction.getTransactionId()); + + ActorRef transactionActor = createTypedTransactionActor(createTransaction, "shard-" + createTransaction.getTransactionId()); getSender() .tell(new CreateTransactionReply(transactionActor.path().toString(),createTransaction.getTransactionId()).toSerializable(), getSelf()); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardWriteTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardWriteTransaction.java new file mode 100644 index 0000000000..2a5429ba81 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardWriteTransaction.java @@ -0,0 +1,66 @@ +/* + * + * 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.cluster.datastore; + +import akka.actor.ActorRef; +import akka.actor.PoisonPill; +import akka.event.Logging; +import akka.event.LoggingAdapter; +import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction; +import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionReply; +import org.opendaylight.controller.cluster.datastore.messages.DeleteData; +import org.opendaylight.controller.cluster.datastore.messages.MergeData; +import org.opendaylight.controller.cluster.datastore.messages.ReadyTransaction; +import org.opendaylight.controller.cluster.datastore.messages.WriteData; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; + +/** + * @author: syedbahm + * Date: 8/6/14 + */ +public class ShardWriteTransaction extends ShardTransaction { + private final DOMStoreWriteTransaction transaction; + private final LoggingAdapter log = + Logging.getLogger(getContext().system(), this); + public ShardWriteTransaction(DOMStoreWriteTransaction transaction, ActorRef shardActor, SchemaContext schemaContext) { + super( shardActor, schemaContext); + this.transaction = transaction; + + } + + public ShardWriteTransaction(DOMStoreTransactionChain transactionChain, DOMStoreWriteTransaction transaction, ActorRef shardActor, SchemaContext schemaContext) { + super(transactionChain, shardActor, schemaContext); + this.transaction = transaction; + } + + @Override + public void handleReceive(Object message) throws Exception { + if (WriteData.SERIALIZABLE_CLASS.equals(message.getClass())) { + writeData(transaction, WriteData.fromSerializable(message, schemaContext)); + } else if (MergeData.SERIALIZABLE_CLASS.equals(message.getClass())) { + mergeData(transaction, MergeData.fromSerializable(message, schemaContext)); + } else if (DeleteData.SERIALIZABLE_CLASS.equals(message.getClass())) { + deleteData(transaction,DeleteData.fromSerizalizable(message)); + } else if (ReadyTransaction.SERIALIZABLE_CLASS.equals(message.getClass())) { + readyTransaction(transaction,new ReadyTransaction()); + }else { + super.handleReceive(message); + } + } + + protected void closeTransaction(CloseTransaction message) { + transaction.close(); + getSender().tell(new CloseTransactionReply().toSerializable(), getSelf()); + getSelf().tell(PoisonPill.getInstance(), getSelf()); + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxy.java index 56220656ad..915b13dd8b 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxy.java @@ -76,7 +76,6 @@ public class ThreePhaseCommitCohortProxy implements CanCommitTransactionReply reply = CanCommitTransactionReply.fromSerializable(response); if (!reply.getCanCommit()) { - System.out.println("**TOM - failed: false"); return false; } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java index 333a8f8617..fa98905a66 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java @@ -180,7 +180,7 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction { try { Object response = actorContext.executeShardOperation(shardName, - new CreateTransaction(identifier).toSerializable(), + new CreateTransaction(identifier,this.transactionType.ordinal() ).toSerializable(), ActorContext.ASK_DURATION); if (response.getClass() .equals(CreateTransactionReply.SERIALIZABLE_CLASS)) { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardStats.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardStats.java index 2da6aae85f..4eb6a8cef9 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardStats.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardStats.java @@ -9,6 +9,8 @@ public class ShardStats extends AbstractBaseMBean implements ShardStatsMBean { private Long committedTransactionsCount; private Long journalMessagesCount; final private String shardName; + private String leader; + private String raftState; ShardStats(String shardName){ this.shardName = shardName; @@ -33,6 +35,13 @@ public class ShardStats extends AbstractBaseMBean implements ShardStatsMBean { return journalMessagesCount; } + @Override public String getLeader() { + return leader; + } + + @Override public String getRaftState() { + return raftState; + } public Long incrementCommittedTransactionCount() { return committedTransactionsCount++; @@ -49,6 +58,13 @@ public class ShardStats extends AbstractBaseMBean implements ShardStatsMBean { } + public void setLeader(String leader){ + this.leader = leader; + } + + public void setRaftState(String raftState){ + this.raftState = raftState; + } @Override diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardStatsMBean.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardStatsMBean.java index c107e49e85..9ebcc7fa5a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardStatsMBean.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardStatsMBean.java @@ -7,5 +7,6 @@ public interface ShardStatsMBean { String getShardName(); Long getCommittedTransactionsCount(); Long getJournalMessagesCount(); - + String getLeader(); + String getRaftState(); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransaction.java index 795131fdbf..b27ad86be9 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransaction.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransaction.java @@ -15,23 +15,28 @@ import org.opendaylight.controller.protobuff.messages.transaction.ShardTransacti public class CreateTransaction implements SerializableMessage { public static Class SERIALIZABLE_CLASS = ShardTransactionMessages.CreateTransaction.class; private final String transactionId; + private final int transactionType; - public CreateTransaction(String transactionId){ + public CreateTransaction(String transactionId, int transactionType){ this.transactionId = transactionId; + this.transactionType = transactionType; } public String getTransactionId() { return transactionId; } + public int getTransactionType() { return transactionType;} + @Override public Object toSerializable() { - return ShardTransactionMessages.CreateTransaction.newBuilder().setTransactionId(transactionId).build(); + return ShardTransactionMessages.CreateTransaction.newBuilder().setTransactionId(transactionId).setTransactionType(transactionType).build(); } public static CreateTransaction fromSerializable(Object message){ - return new CreateTransaction(((ShardTransactionMessages.CreateTransaction)message).getTransactionId()); + ShardTransactionMessages.CreateTransaction createTransaction = (ShardTransactionMessages.CreateTransaction)message; + return new CreateTransaction(createTransaction.getTransactionId(),createTransaction.getTransactionType() ); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategy.java index 6f4b65a6f3..fc7ebd94dd 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategy.java @@ -11,6 +11,8 @@ package org.opendaylight.controller.cluster.datastore.shardstrategy; import org.opendaylight.controller.cluster.datastore.Configuration; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import java.util.List; + public class ModuleShardStrategy implements ShardStrategy { public static final String NAME = "module"; @@ -25,6 +27,11 @@ public class ModuleShardStrategy implements ShardStrategy { } @Override public String findShard(YangInstanceIdentifier path) { - return configuration.getShardNamesFromModuleName(moduleName).get(0); + List shardNames = + configuration.getShardNamesFromModuleName(moduleName); + if(shardNames.size() == 0){ + return DefaultShardStrategy.DEFAULT_SHARD; + } + return shardNames.get(0); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategy.java index 2df945edd5..9a05c381ea 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategy.java @@ -16,6 +16,9 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; public interface ShardStrategy { /** * Find the name of the shard in which the data pointed to by the specified path belongs in + *

    + * Should return the name of the default shard DefaultShardStrategy.DEFAULT_SHARD + * if no matching shard was found * * @param path The location of the data in the logical tree * @return diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedConfigDataStoreProviderModule.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedConfigDataStoreProviderModule.java index 039446baf3..87a621f9d3 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedConfigDataStoreProviderModule.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedConfigDataStoreProviderModule.java @@ -26,7 +26,7 @@ public class DistributedConfigDataStoreProviderModule extends @Override public java.lang.AutoCloseable createInstance() { return DistributedDataStoreFactory - .createInstance("config", getSchemaServiceDependency()); + .createInstance("config", getConfigSchemaServiceDependency()); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedOperationalDataStoreProviderModule.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedOperationalDataStoreProviderModule.java index 1a06629bb7..6af2748a8f 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedOperationalDataStoreProviderModule.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedOperationalDataStoreProviderModule.java @@ -26,7 +26,7 @@ public class DistributedOperationalDataStoreProviderModule extends @Override public java.lang.AutoCloseable createInstance() { return DistributedDataStoreFactory - .createInstance("operational", getSchemaServiceDependency()); + .createInstance("operational", getOperationalSchemaServiceDependency()); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/application.conf b/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/application.conf index 76914c2c84..daac89c4c8 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/application.conf +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/application.conf @@ -1,15 +1,60 @@ -ODLCluster{ -actor { - serializers { - java = "akka.serialization.JavaSerializer" - proto = "akka.remote.serialization.ProtobufSerializer" - } +odl-cluster-data { + akka { + cluster { + roles = [ + "member-1" + ] + } + actor { + provider = "akka.cluster.ClusterActorRefProvider" + serializers { + java = "akka.serialization.JavaSerializer" + proto = "akka.remote.serialization.ProtobufSerializer" + } + + serialization-bindings { + "com.google.protobuf.Message" = proto + + } + } + remote { + log-remote-lifecycle-events = off + netty.tcp { + hostname = "127.0.0.1" + port = 2550 + maximum-frame-size = 2097152 + send-buffer-size = 52428800 + receive-buffer-size = 52428800 + } + } - serialization-bindings { - "com.google.protobuf.Message" = proto + cluster { + seed-nodes = ["akka.tcp://opendaylight-cluster-data@127.0.0.1:2550"] - } + auto-down-unreachable-after = 10s } + } +} + +odl-cluster-rpc { + akka { + actor { + provider = "akka.cluster.ClusterActorRefProvider" -} \ No newline at end of file + } + remote { + log-remote-lifecycle-events = off + netty.tcp { + hostname = "127.0.0.1" + port = 2551 + } + } + + cluster { + seed-nodes = ["akka.tcp://opendaylight-cluster-rpc@127.0.0.1:2551"] + + auto-down-unreachable-after = 10s + } + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/modules.conf b/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/modules.conf index 05ef33f759..e820703eeb 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/modules.conf +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/modules.conf @@ -1,7 +1,7 @@ modules = [ { name = "inventory" - namespace = "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test:people" + namespace = "urn:opendaylight:inventory" shard-strategy = "module" } ] diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/yang/distributed-datastore-provider.yang b/opendaylight/md-sal/sal-distributed-datastore/src/main/yang/distributed-datastore-provider.yang index 5d3758986c..6f355cbe63 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/yang/distributed-datastore-provider.yang +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/yang/distributed-datastore-provider.yang @@ -40,7 +40,7 @@ module distributed-datastore-provider { augment "/config:modules/config:module/config:configuration" { case distributed-config-datastore-provider { when "/config:modules/config:module/config:type = 'distributed-config-datastore-provider'"; - container schema-service { + container config-schema-service { uses config:service-ref { refine type { mandatory false; @@ -55,7 +55,7 @@ module distributed-datastore-provider { augment "/config:modules/config:module/config:configuration" { case distributed-operational-datastore-provider { when "/config:modules/config:module/config:type = 'distributed-operational-datastore-provider'"; - container schema-service { + container operational-schema-service { uses config:service-ref { refine type { mandatory false; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/BasicIntegrationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/BasicIntegrationTest.java index 11ad559744..6599bd8eeb 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/BasicIntegrationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/BasicIntegrationTest.java @@ -12,6 +12,7 @@ import akka.actor.ActorPath; import akka.actor.ActorRef; import akka.actor.ActorSelection; import akka.actor.Props; +import akka.event.Logging; import akka.testkit.JavaTestKit; import junit.framework.Assert; import org.junit.Test; @@ -35,6 +36,8 @@ import scala.concurrent.duration.FiniteDuration; import java.util.Collections; +import static junit.framework.Assert.assertEquals; + public class BasicIntegrationTest extends AbstractActorTest { @Test @@ -61,17 +64,24 @@ public class BasicIntegrationTest extends AbstractActorTest { getRef()); - // Wait for Shard to become a Leader - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } + // Wait for a specific log message to show up + final boolean result = + new JavaTestKit.EventFilter(Logging.Info.class + ) { + protected Boolean run() { + return true; + } + }.from(shard.path().toString()) + .message("Switching from state Candidate to Leader") + .occurrences(1).exec(); + + assertEquals(true, result); + // 1. Create a TransactionChain shard.tell(new CreateTransactionChain().toSerializable(), getRef()); final ActorSelection transactionChain = - new ExpectMsg("CreateTransactionChainReply") { + new ExpectMsg(duration("1 seconds"), "CreateTransactionChainReply") { protected ActorSelection match(Object in) { if (in.getClass().equals(CreateTransactionChainReply.SERIALIZABLE_CLASS)) { ActorPath transactionChainPath = @@ -90,10 +100,10 @@ public class BasicIntegrationTest extends AbstractActorTest { System.out.println("Successfully created transaction chain"); // 2. Create a Transaction on the TransactionChain - transactionChain.tell(new CreateTransaction("txn-1").toSerializable(), getRef()); + transactionChain.tell(new CreateTransaction("txn-1", TransactionProxy.TransactionType.WRITE_ONLY.ordinal() ).toSerializable(), getRef()); final ActorSelection transaction = - new ExpectMsg("CreateTransactionReply") { + new ExpectMsg(duration("1 seconds"), "CreateTransactionReply") { protected ActorSelection match(Object in) { if (CreateTransactionReply.SERIALIZABLE_CLASS.equals(in.getClass())) { CreateTransactionReply reply = CreateTransactionReply.fromSerializable(in); @@ -115,7 +125,7 @@ public class BasicIntegrationTest extends AbstractActorTest { ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext()).toSerializable(), getRef()); - Boolean writeDone = new ExpectMsg("WriteDataReply") { + Boolean writeDone = new ExpectMsg(duration("1 seconds"), "WriteDataReply") { protected Boolean match(Object in) { if (in.getClass().equals(WriteDataReply.SERIALIZABLE_CLASS)) { return true; @@ -134,7 +144,7 @@ public class BasicIntegrationTest extends AbstractActorTest { transaction.tell(new ReadyTransaction().toSerializable(), getRef()); final ActorSelection cohort = - new ExpectMsg("ReadyTransactionReply") { + new ExpectMsg(duration("1 seconds"), "ReadyTransactionReply") { protected ActorSelection match(Object in) { if (in.getClass().equals(ReadyTransactionReply.SERIALIZABLE_CLASS)) { ActorPath cohortPath = @@ -157,7 +167,7 @@ public class BasicIntegrationTest extends AbstractActorTest { cohort.tell(new PreCommitTransaction().toSerializable(), getRef()); Boolean preCommitDone = - new ExpectMsg("PreCommitTransactionReply") { + new ExpectMsg(duration("1 seconds"), "PreCommitTransactionReply") { protected Boolean match(Object in) { if (in.getClass().equals(PreCommitTransactionReply.SERIALIZABLE_CLASS)) { return true; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerProxyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerProxyTest.java index 8c1cbbbba0..b2ee4a49fe 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerProxyTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerProxyTest.java @@ -94,7 +94,7 @@ public class DataChangeListenerProxyTest extends AbstractActorTest { Assert.assertEquals(1, listMessages.size()); - Assert.assertTrue(listMessages.get(0).getClass().equals(DataChanged.SERIALIZABLE_CLASS)); + Assert.assertTrue(listMessages.get(0).getClass().equals(DataChanged.class)); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationTest.java index 8413bac3a7..920248521a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationTest.java @@ -41,7 +41,7 @@ public class DataChangeListenerRegistrationTest extends AbstractActorTest { subject.tell(new CloseDataChangeListenerRegistration().toSerializable(), getRef()); - final String out = new ExpectMsg("match hint") { + final String out = new ExpectMsg(duration("1 seconds"), "match hint") { // do not put code outside this method, will run afterwards protected String match(Object in) { if (in.getClass().equals(CloseDataChangeListenerRegistrationReply.SERIALIZABLE_CLASS)) { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerTest.java index c4ec8b45fc..26ec583b3e 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerTest.java @@ -102,13 +102,13 @@ public class DataChangeListenerTest extends AbstractActorTest { subject.tell(new EnableNotification(true), getRef()); subject.tell( - new DataChanged(CompositeModel.createTestContext(),new MockDataChangedEvent()).toSerializable(), + new DataChanged(CompositeModel.createTestContext(),new MockDataChangedEvent()), getRef()); final Boolean out = new ExpectMsg(duration("800 millis"), "dataChanged") { // do not put code outside this method, will run afterwards protected Boolean match(Object in) { - if (in != null && in.getClass().equals(DataChangedReply.SERIALIZABLE_CLASS)) { + if (in != null && in.getClass().equals(DataChangedReply.class)) { return true; } else { @@ -141,7 +141,7 @@ public class DataChangeListenerTest extends AbstractActorTest { protected void run() { subject.tell( - new DataChanged(CompositeModel.createTestContext(),new MockDataChangedEvent()).toSerializable(), + new DataChanged(CompositeModel.createTestContext(),new MockDataChangedEvent()), getRef()); expectNoMsg(); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java index 0a0c04b915..fc527b6bff 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java @@ -1,11 +1,12 @@ package org.opendaylight.controller.cluster.datastore; import akka.actor.ActorSystem; +import akka.event.Logging; import akka.testkit.JavaTestKit; - import com.google.common.base.Optional; import com.google.common.util.concurrent.ListenableFuture; import junit.framework.Assert; +import org.apache.commons.io.FileUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -20,19 +21,29 @@ import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCoh import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; +import java.io.File; +import java.io.IOException; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertTrue; +import static junit.framework.Assert.fail; -public class DistributedDataStoreIntegrationTest{ +public class DistributedDataStoreIntegrationTest { private static ActorSystem system; @Before - public void setUp() { + public void setUp() throws IOException { + File journal = new File("journal"); + + if(journal.exists()) { + FileUtils.deleteDirectory(journal); + } + + System.setProperty("shard.persistent", "false"); system = ActorSystem.create("test"); } @@ -49,82 +60,153 @@ public class DistributedDataStoreIntegrationTest{ @Test public void integrationTest() throws Exception { - Configuration configuration = new ConfigurationImpl("module-shards.conf", "modules.conf"); + final Configuration configuration = new ConfigurationImpl("module-shards.conf", "modules.conf"); ShardStrategyFactory.setConfiguration(configuration); - DistributedDataStore distributedDataStore = - new DistributedDataStore(getSystem(), "config", new MockClusterWrapper(), configuration); - distributedDataStore.onGlobalContextUpdated(TestModel.createTestContext()); - Thread.sleep(1500); - DOMStoreReadWriteTransaction transaction = - distributedDataStore.newReadWriteTransaction(); + new JavaTestKit(getSystem()) { + { + + new Within(duration("10 seconds")) { + protected void run() { + try { + final DistributedDataStore distributedDataStore = + new DistributedDataStore(getSystem(), "config", new MockClusterWrapper(), configuration); + + distributedDataStore.onGlobalContextUpdated(TestModel.createTestContext()); + + // Wait for a specific log message to show up + final boolean result = + new JavaTestKit.EventFilter(Logging.Info.class + ) { + protected Boolean run() { + return true; + } + }.from("akka://test/user/shardmanager-config/member-1-shard-test-1-config") + .message("Switching from state Candidate to Leader") + .occurrences(1).exec(); + + assertEquals(true, result); + + DOMStoreReadWriteTransaction transaction = + distributedDataStore.newReadWriteTransaction(); - transaction.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); + transaction + .write(TestModel.TEST_PATH, ImmutableNodes + .containerNode(TestModel.TEST_QNAME)); - ListenableFuture>> future = - transaction.read(TestModel.TEST_PATH); + ListenableFuture>> + future = + transaction.read(TestModel.TEST_PATH); - Optional> optional = future.get(); + Optional> optional = + future.get(); - Assert.assertTrue(optional.isPresent()); + Assert.assertTrue("Node not found", optional.isPresent()); - NormalizedNode normalizedNode = optional.get(); + NormalizedNode normalizedNode = + optional.get(); - assertEquals(TestModel.TEST_QNAME, normalizedNode.getNodeType()); + assertEquals(TestModel.TEST_QNAME, + normalizedNode.getNodeType()); - DOMStoreThreePhaseCommitCohort ready = transaction.ready(); + DOMStoreThreePhaseCommitCohort ready = + transaction.ready(); - ListenableFuture canCommit = ready.canCommit(); + ListenableFuture canCommit = + ready.canCommit(); - assertTrue(canCommit.get(5, TimeUnit.SECONDS)); + assertTrue(canCommit.get(5, TimeUnit.SECONDS)); - ListenableFuture preCommit = ready.preCommit(); + ListenableFuture preCommit = + ready.preCommit(); - preCommit.get(5, TimeUnit.SECONDS); + preCommit.get(5, TimeUnit.SECONDS); - ListenableFuture commit = ready.commit(); + ListenableFuture commit = ready.commit(); + + commit.get(5, TimeUnit.SECONDS); + } catch (ExecutionException | TimeoutException | InterruptedException e){ + fail(e.getMessage()); + } + } + }; + } + }; - commit.get(5, TimeUnit.SECONDS); } - @Test + //FIXME : Disabling test because it's flaky + //@Test public void integrationTestWithMultiShardConfiguration() throws ExecutionException, InterruptedException, TimeoutException { - Configuration configuration = new ConfigurationImpl("module-shards.conf", "modules.conf"); + final Configuration configuration = new ConfigurationImpl("module-shards.conf", "modules.conf"); ShardStrategyFactory.setConfiguration(configuration); - DistributedDataStore distributedDataStore = - new DistributedDataStore(getSystem(), "config", new MockClusterWrapper(), configuration); + new JavaTestKit(getSystem()) { + { + + new Within(duration("10 seconds")) { + protected void run() { + try { + final DistributedDataStore distributedDataStore = + new DistributedDataStore(getSystem(), "config", + new MockClusterWrapper(), configuration); + + distributedDataStore.onGlobalContextUpdated( + SchemaContextHelper.full()); + + // Wait for a specific log message to show up + final boolean result = + new JavaTestKit.EventFilter( + Logging.Info.class + ) { + protected Boolean run() { + return true; + } + }.from( + "akka://test/user/shardmanager-config/member-1-shard-cars-1-config") + .message( + "Switching from state Candidate to Leader") + .occurrences(1) + .exec(); + + Thread.sleep(1000); + + + DOMStoreReadWriteTransaction transaction = + distributedDataStore.newReadWriteTransaction(); - distributedDataStore.onGlobalContextUpdated(SchemaContextHelper.full()); + transaction.write(CarsModel.BASE_PATH, CarsModel.emptyContainer()); + transaction.write(PeopleModel.BASE_PATH, PeopleModel.emptyContainer()); - // This sleep is fragile - test can fail intermittently if all Shards aren't updated with - // the SchemaContext in time. Is there any way we can make this deterministic? - Thread.sleep(2000); + DOMStoreThreePhaseCommitCohort ready = transaction.ready(); - DOMStoreReadWriteTransaction transaction = - distributedDataStore.newReadWriteTransaction(); + ListenableFuture canCommit = ready.canCommit(); - transaction.write(CarsModel.BASE_PATH, CarsModel.emptyContainer()); - transaction.write(PeopleModel.BASE_PATH, PeopleModel.emptyContainer()); + assertTrue(canCommit.get(5, TimeUnit.SECONDS)); - DOMStoreThreePhaseCommitCohort ready = transaction.ready(); + ListenableFuture preCommit = ready.preCommit(); - ListenableFuture canCommit = ready.canCommit(); + preCommit.get(5, TimeUnit.SECONDS); - assertTrue(canCommit.get(5, TimeUnit.SECONDS)); + ListenableFuture commit = ready.commit(); - ListenableFuture preCommit = ready.preCommit(); + commit.get(5, TimeUnit.SECONDS); - preCommit.get(5, TimeUnit.SECONDS); + assertEquals(true, result); + } catch(ExecutionException | TimeoutException | InterruptedException e){ + fail(e.getMessage()); + } + } + }; + } + }; - ListenableFuture commit = ready.commit(); - commit.get(5, TimeUnit.SECONDS); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreTest.java index 03191f70f1..d1beab9049 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreTest.java @@ -73,7 +73,7 @@ public class DistributedDataStoreTest extends AbstractActorTest{ @org.junit.Test public void testRegisterChangeListenerWhenShardIsLocal() throws Exception { - mockActorContext.setExecuteLocalShardOperationResponse(new RegisterChangeListenerReply(doNothingActorRef.path()).toSerializable()); + mockActorContext.setExecuteLocalShardOperationResponse(new RegisterChangeListenerReply(doNothingActorRef.path())); ListenerRegistration registration = distributedDataStore.registerChangeListener(TestModel.TEST_PATH, new AsyncDataChangeListener>() { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java index 268ed3c273..e9ad450ed8 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java @@ -75,7 +75,7 @@ public class ShardManagerTest { subject.tell(new FindPrimary(Shard.DEFAULT_NAME).toSerializable(), getRef()); - expectMsgClass(PrimaryFound.SERIALIZABLE_CLASS); + expectMsgClass(duration("1 seconds"), PrimaryFound.SERIALIZABLE_CLASS); expectNoMsg(); } @@ -170,7 +170,7 @@ public class ShardManagerTest { subject.tell(new FindPrimary("astronauts").toSerializable(), getRef()); - final String out = new ExpectMsg("primary found") { + final String out = new ExpectMsg(duration("1 seconds"), "primary found") { // do not put code outside this method, will run afterwards protected String match(Object in) { if (in.getClass().equals(PrimaryFound.SERIALIZABLE_CLASS)) { @@ -208,13 +208,13 @@ public class ShardManagerTest { subject.tell(new FindPrimary("astronauts").toSerializable(), getRef()); - expectMsgClass(PrimaryFound.SERIALIZABLE_CLASS); + expectMsgClass(duration("1 seconds"), PrimaryFound.SERIALIZABLE_CLASS); MockClusterWrapper.sendMemberRemoved(subject, "member-2", getRef().path().toString()); subject.tell(new FindPrimary("astronauts").toSerializable(), getRef()); - expectMsgClass(PrimaryNotFound.SERIALIZABLE_CLASS); + expectMsgClass(duration("1 seconds"), PrimaryNotFound.SERIALIZABLE_CLASS); expectNoMsg(); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java index 38920d86ca..431a266b14 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java @@ -2,7 +2,9 @@ package org.opendaylight.controller.cluster.datastore; import akka.actor.ActorRef; import akka.actor.Props; +import akka.event.Logging; import akka.testkit.JavaTestKit; +import junit.framework.Assert; import org.junit.Test; import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction; import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionChain; @@ -38,19 +40,25 @@ public class ShardTest extends AbstractActorTest { getSystem().actorOf(props, "testCreateTransactionChain"); - // Wait for Shard to become a Leader - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } + // Wait for a specific log message to show up + final boolean result = + new JavaTestKit.EventFilter(Logging.Info.class + ) { + protected Boolean run() { + return true; + } + }.from(subject.path().toString()) + .message("Switching from state Candidate to Leader") + .occurrences(1).exec(); + + Assert.assertEquals(true, result); new Within(duration("1 seconds")) { protected void run() { subject.tell(new CreateTransactionChain().toSerializable(), getRef()); - final String out = new ExpectMsg("match hint") { + final String out = new ExpectMsg(duration("1 seconds"), "match hint") { // do not put code outside this method, will run afterwards protected String match(Object in) { if (in.getClass().equals(CreateTransactionChainReply.SERIALIZABLE_CLASS)){ @@ -91,7 +99,7 @@ public class ShardTest extends AbstractActorTest { getRef()); subject.tell(new RegisterChangeListener(TestModel.TEST_PATH, - getRef().path(), AsyncDataBroker.DataChangeScope.BASE).toSerializable(), + getRef().path(), AsyncDataBroker.DataChangeScope.BASE), getRef()); final Boolean notificationEnabled = new ExpectMsg("enable notification") { @@ -107,12 +115,12 @@ public class ShardTest extends AbstractActorTest { assertFalse(notificationEnabled); - final String out = new ExpectMsg("match hint") { + final String out = new ExpectMsg(duration("1 seconds"), "match hint") { // do not put code outside this method, will run afterwards protected String match(Object in) { - if (in.getClass().equals(RegisterChangeListenerReply.SERIALIZABLE_CLASS)) { + if (in.getClass().equals(RegisterChangeListenerReply.class)) { RegisterChangeListenerReply reply = - RegisterChangeListenerReply.fromSerializable(getSystem(),in); + (RegisterChangeListenerReply) in; return reply.getListenerRegistrationPath() .toString(); } else { @@ -138,13 +146,18 @@ public class ShardTest extends AbstractActorTest { getSystem().actorOf(props, "testCreateTransaction"); - // Wait for Shard to become a Leader - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } + // Wait for a specific log message to show up + final boolean result = + new JavaTestKit.EventFilter(Logging.Info.class + ) { + protected Boolean run() { + return true; + } + }.from(subject.path().toString()) + .message("Switching from state Candidate to Leader") + .occurrences(1).exec(); + Assert.assertEquals(true, result); new Within(duration("1 seconds")) { protected void run() { @@ -153,10 +166,10 @@ public class ShardTest extends AbstractActorTest { new UpdateSchemaContext(TestModel.createTestContext()), getRef()); - subject.tell(new CreateTransaction("txn-1").toSerializable(), + subject.tell(new CreateTransaction("txn-1", TransactionProxy.TransactionType.READ_ONLY.ordinal() ).toSerializable(), getRef()); - final String out = new ExpectMsg("match hint") { + final String out = new ExpectMsg(duration("1 seconds"), "match hint") { // do not put code outside this method, will run afterwards protected String match(Object in) { if (in instanceof CreateTransactionReply) { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionChainTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionChainTest.java index 6330ad8acc..b35880a6a5 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionChainTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionChainTest.java @@ -33,9 +33,9 @@ public class ShardTransactionChainTest extends AbstractActorTest { new Within(duration("1 seconds")) { protected void run() { - subject.tell(new CreateTransaction("txn-1").toSerializable(), getRef()); + subject.tell(new CreateTransaction("txn-1", TransactionProxy.TransactionType.READ_ONLY.ordinal() ).toSerializable(), getRef()); - final String out = new ExpectMsg("match hint") { + final String out = new ExpectMsg(duration("1 seconds"), "match hint") { // do not put code outside this method, will run afterwards protected String match(Object in) { if (in.getClass().equals(CreateTransactionReply.SERIALIZABLE_CLASS)) { @@ -70,7 +70,7 @@ public class ShardTransactionChainTest extends AbstractActorTest { subject.tell(new CloseTransactionChain().toSerializable(), getRef()); - final String out = new ExpectMsg("match hint") { + final String out = new ExpectMsg(duration("1 seconds"), "match hint") { // do not put code outside this method, will run afterwards protected String match(Object in) { if (in.getClass().equals(CloseTransactionChainReply.SERIALIZABLE_CLASS)) { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionTest.java index 7884eeccda..632ecc29cd 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionTest.java @@ -4,8 +4,10 @@ import akka.actor.ActorRef; import akka.actor.Props; import akka.actor.Terminated; import akka.testkit.JavaTestKit; +import akka.testkit.TestActorRef; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; +import org.junit.Assert; import org.junit.Test; import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction; import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionReply; @@ -53,7 +55,7 @@ public class ShardTransactionTest extends AbstractActorTest { new JavaTestKit(getSystem()) {{ final ActorRef shard = getSystem().actorOf(Shard.props("config", Collections.EMPTY_MAP)); final Props props = - ShardTransaction.props(store.newReadWriteTransaction(), shard, testSchemaContext); + ShardTransaction.props(store.newReadOnlyTransaction(), shard, testSchemaContext); final ActorRef subject = getSystem().actorOf(props, "testReadData"); new Within(duration("1 seconds")) { @@ -63,7 +65,7 @@ public class ShardTransactionTest extends AbstractActorTest { new ReadData(YangInstanceIdentifier.builder().build()).toSerializable(), getRef()); - final String out = new ExpectMsg("match hint") { + final String out = new ExpectMsg(duration("1 seconds"), "match hint") { // do not put code outside this method, will run afterwards protected String match(Object in) { if (in.getClass().equals(ReadDataReply.SERIALIZABLE_CLASS)) { @@ -93,7 +95,7 @@ public class ShardTransactionTest extends AbstractActorTest { new JavaTestKit(getSystem()) {{ final ActorRef shard = getSystem().actorOf(Shard.props("config", Collections.EMPTY_MAP)); final Props props = - ShardTransaction.props(store.newReadWriteTransaction(), shard, testSchemaContext); + ShardTransaction.props( store.newReadOnlyTransaction(), shard, testSchemaContext); final ActorRef subject = getSystem().actorOf(props, "testReadDataWhenDataNotFound"); new Within(duration("1 seconds")) { @@ -103,7 +105,7 @@ public class ShardTransactionTest extends AbstractActorTest { new ReadData(TestModel.TEST_PATH).toSerializable(), getRef()); - final String out = new ExpectMsg("match hint") { + final String out = new ExpectMsg(duration("1 seconds"), "match hint") { // do not put code outside this method, will run afterwards protected String match(Object in) { if (in.getClass().equals(ReadDataReply.SERIALIZABLE_CLASS)) { @@ -139,7 +141,7 @@ public class ShardTransactionTest extends AbstractActorTest { getRef()); final CompositeModification compositeModification = - new ExpectMsg("match hint") { + new ExpectMsg(duration("1 seconds"), "match hint") { // do not put code outside this method, will run afterwards protected CompositeModification match(Object in) { if (in instanceof ShardTransaction.GetCompositeModificationReply) { @@ -167,7 +169,7 @@ public class ShardTransactionTest extends AbstractActorTest { new JavaTestKit(getSystem()) {{ final ActorRef shard = getSystem().actorOf(Shard.props("config", Collections.EMPTY_MAP)); final Props props = - ShardTransaction.props(store.newReadWriteTransaction(), shard, TestModel.createTestContext()); + ShardTransaction.props(store.newWriteOnlyTransaction(), shard, TestModel.createTestContext()); final ActorRef subject = getSystem().actorOf(props, "testWriteData"); @@ -178,7 +180,7 @@ public class ShardTransactionTest extends AbstractActorTest { ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext()).toSerializable(), getRef()); - final String out = new ExpectMsg("match hint") { + final String out = new ExpectMsg(duration("1 seconds"), "match hint") { // do not put code outside this method, will run afterwards protected String match(Object in) { if (in.getClass().equals(WriteDataReply.SERIALIZABLE_CLASS)) { @@ -244,7 +246,7 @@ public class ShardTransactionTest extends AbstractActorTest { new JavaTestKit(getSystem()) {{ final ActorRef shard = getSystem().actorOf(Shard.props("config", Collections.EMPTY_MAP)); final Props props = - ShardTransaction.props(store.newReadWriteTransaction(), shard, TestModel.createTestContext()); + ShardTransaction.props( store.newWriteOnlyTransaction(), shard, TestModel.createTestContext()); final ActorRef subject = getSystem().actorOf(props, "testDeleteData"); @@ -253,7 +255,7 @@ public class ShardTransactionTest extends AbstractActorTest { subject.tell(new DeleteData(TestModel.TEST_PATH).toSerializable(), getRef()); - final String out = new ExpectMsg("match hint") { + final String out = new ExpectMsg(duration("1 seconds"), "match hint") { // do not put code outside this method, will run afterwards protected String match(Object in) { if (in.getClass().equals(DeleteDataReply.SERIALIZABLE_CLASS)) { @@ -281,7 +283,7 @@ public class ShardTransactionTest extends AbstractActorTest { new JavaTestKit(getSystem()) {{ final ActorRef shard = getSystem().actorOf(Shard.props("config", Collections.EMPTY_MAP)); final Props props = - ShardTransaction.props(store.newReadWriteTransaction(), shard, TestModel.createTestContext()); + ShardTransaction.props( store.newReadWriteTransaction(), shard, TestModel.createTestContext()); final ActorRef subject = getSystem().actorOf(props, "testReadyTransaction"); @@ -290,7 +292,7 @@ public class ShardTransactionTest extends AbstractActorTest { subject.tell(new ReadyTransaction().toSerializable(), getRef()); - final String out = new ExpectMsg("match hint") { + final String out = new ExpectMsg(duration("1 seconds"), "match hint") { // do not put code outside this method, will run afterwards protected String match(Object in) { if (in.getClass().equals(ReadyTransactionReply.SERIALIZABLE_CLASS)) { @@ -328,7 +330,7 @@ public class ShardTransactionTest extends AbstractActorTest { subject.tell(new CloseTransaction().toSerializable(), getRef()); - final String out = new ExpectMsg("match hint") { + final String out = new ExpectMsg(duration("1 seconds"), "match hint") { // do not put code outside this method, will run afterwards protected String match(Object in) { if (in.getClass().equals(CloseTransactionReply.SERIALIZABLE_CLASS)) { @@ -341,7 +343,7 @@ public class ShardTransactionTest extends AbstractActorTest { assertEquals("match", out); - final String termination = new ExpectMsg("match hint") { + final String termination = new ExpectMsg(duration("1 seconds"), "match hint") { // do not put code outside this method, will run afterwards protected String match(Object in) { if (in instanceof Terminated) { @@ -361,4 +363,24 @@ public class ShardTransactionTest extends AbstractActorTest { }}; } + + + @Test + public void testNegativePerformingWriteOperationOnReadTransaction() throws Exception { + try { + + final ActorRef shard = getSystem().actorOf(Shard.props("config", Collections.EMPTY_MAP)); + final Props props = + ShardTransaction.props(store.newReadOnlyTransaction(), shard, TestModel.createTestContext()); + final TestActorRef subject = TestActorRef.apply(props,getSystem()); + + subject.receive(new DeleteData(TestModel.TEST_PATH).toSerializable(), ActorRef.noSender()); + Assert.assertFalse(true); + + + } catch (Exception cs) { + assertEquals(cs.getClass().getSimpleName(), Exception.class.getSimpleName()); + assertTrue(cs.getMessage().startsWith("ShardTransaction:handleRecieve received an unknown message")); + } + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategyTest.java index 88753e4b0a..3394cdc959 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategyTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategyTest.java @@ -1,6 +1,5 @@ package org.opendaylight.controller.cluster.datastore.shardstrategy; -import junit.framework.Assert; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; @@ -8,6 +7,10 @@ import org.junit.rules.ExpectedException; import org.opendaylight.controller.cluster.datastore.Configuration; import org.opendaylight.controller.cluster.datastore.ConfigurationImpl; import org.opendaylight.controller.md.cluster.datastore.model.CarsModel; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; + +import static junit.framework.Assert.assertEquals; public class ModuleShardStrategyTest { @Rule @@ -28,6 +31,23 @@ public class ModuleShardStrategyTest { String shard = moduleShardStrategy.findShard(CarsModel.BASE_PATH); - Assert.assertEquals("cars-1", shard); + assertEquals("cars-1", shard); + } + + @Test + public void testFindShardWhenModuleConfigurationPresentInModulesButMissingInModuleShards() { + + final QName BASE_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test:missing", "2014-03-13", + "missing"); + + final YangInstanceIdentifier BASE_PATH = YangInstanceIdentifier.of(BASE_QNAME); + + ModuleShardStrategy moduleShardStrategy = + new ModuleShardStrategy("missing", configuration); + + String shard = moduleShardStrategy.findShard(BASE_PATH); + + assertEquals(DefaultShardStrategy.DEFAULT_SHARD, shard); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/application.conf b/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/application.conf index aebff27c7d..eda1c304e4 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/application.conf +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/application.conf @@ -1,4 +1,5 @@ akka { + loggers = [akka.testkit.TestEventListener] actor { serializers { java = "akka.serialization.JavaSerializer" diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/modules.conf b/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/modules.conf index 22854cb11a..f4919e7895 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/modules.conf +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/modules.conf @@ -15,4 +15,10 @@ modules = [ shard-strategy = "module" } + { + name = "missing" + namespace = "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:missing" + shard-strategy = "module" + } + ] diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcImplementationUnavailableException.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcImplementationUnavailableException.java new file mode 100644 index 0000000000..371082223a --- /dev/null +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcImplementationUnavailableException.java @@ -0,0 +1,23 @@ +/* + * 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.sal.core.api; + +/** + * Exception reported when no RPC implementation is found in the system. + */ +public class RpcImplementationUnavailableException extends RuntimeException { + private static final long serialVersionUID = 1L; + + public RpcImplementationUnavailableException(final String message) { + super(message); + } + + public RpcImplementationUnavailableException(final String message, final Throwable cause) { + super(message, cause); + } +} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomInmemoryDataBrokerModule.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomInmemoryDataBrokerModule.java index 667c0fc282..22dad6af23 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomInmemoryDataBrokerModule.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomInmemoryDataBrokerModule.java @@ -10,9 +10,11 @@ package org.opendaylight.controller.config.yang.md.sal.dom.impl; import java.util.concurrent.Executors; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitDeadlockException; import org.opendaylight.controller.md.sal.dom.broker.impl.DOMDataBrokerImpl; import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; import org.opendaylight.controller.sal.core.spi.data.DOMStore; +import org.opendaylight.yangtools.util.concurrent.DeadlockDetectingListeningExecutorService; import com.google.common.collect.ImmutableMap; import com.google.common.util.concurrent.ListeningExecutorService; @@ -64,7 +66,9 @@ public final class DomInmemoryDataBrokerModule extends . builder().put(LogicalDatastoreType.OPERATIONAL, operStore) .put(LogicalDatastoreType.CONFIGURATION, configStore).build(); - DOMDataBrokerImpl newDataBroker = new DOMDataBrokerImpl(datastores, MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor())); + DOMDataBrokerImpl newDataBroker = new DOMDataBrokerImpl(datastores, + new DeadlockDetectingListeningExecutorService(Executors.newSingleThreadExecutor(), + TransactionCommitDeadlockException.DEADLOCK_EXECUTOR_FUNCTION)); return newDataBroker; } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/mount/DOMMountPointServiceImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/mount/DOMMountPointServiceImpl.java index 41650666cd..8944e197cc 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/mount/DOMMountPointServiceImpl.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/mount/DOMMountPointServiceImpl.java @@ -21,7 +21,7 @@ import org.opendaylight.controller.md.sal.dom.broker.spi.mount.SimpleDOMMountPoi import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.concepts.ObjectRegistration; -import org.opendaylight.yangtools.concepts.util.ListenerRegistry; +import org.opendaylight.yangtools.util.ListenerRegistry; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.SchemaContext; diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointManager.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointManager.java index b01db3d515..fef2a808c3 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointManager.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointManager.java @@ -18,7 +18,7 @@ import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance; import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener; import org.opendaylight.controller.sal.core.api.mount.MountProvisionService; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.concepts.util.ListenerRegistry; +import org.opendaylight.yangtools.util.ListenerRegistry; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; public class BackwardsCompatibleMountPointManager implements MountProvisionService, MountProvisionListener { diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataTransactionImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataTransactionImpl.java index f0dd5b921c..df4549f1f8 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataTransactionImpl.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataTransactionImpl.java @@ -11,7 +11,7 @@ import org.opendaylight.controller.md.sal.common.api.TransactionStatus; import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataTransaction; import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.concepts.util.ListenerRegistry; +import org.opendaylight.yangtools.util.ListenerRegistry; import org.opendaylight.yangtools.yang.data.api.CompositeNode; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointManagerImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointManagerImpl.java index d84f1dc031..434cf85bec 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointManagerImpl.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointManagerImpl.java @@ -17,7 +17,7 @@ import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance; import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener; import org.opendaylight.controller.sal.core.api.mount.MountProvisionService; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.concepts.util.ListenerRegistry; +import org.opendaylight.yangtools.util.ListenerRegistry; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; @Deprecated diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/RoutedRpcSelector.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/RoutedRpcSelector.java index 19ff03b7d2..c8e3c0b6e0 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/RoutedRpcSelector.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/RoutedRpcSelector.java @@ -8,7 +8,9 @@ package org.opendaylight.controller.sal.dom.broker.impl; import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkState; + +import com.google.common.collect.ImmutableSet; +import com.google.common.util.concurrent.ListenableFuture; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -22,11 +24,8 @@ import org.opendaylight.yangtools.concepts.Identifiable; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.SimpleNode; - -import com.google.common.collect.ImmutableSet; -import com.google.common.util.concurrent.ListenableFuture; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; class RoutedRpcSelector implements RpcImplementation, AutoCloseable, Identifiable { @@ -81,9 +80,9 @@ class RoutedRpcSelector implements RpcImplementation, AutoCloseable, Identifiabl } if (potential == null) { return router.invokeRpc(rpc, (YangInstanceIdentifier) route, input); + } else { + return potential.invokeRpc(rpc, input); } - checkState(potential != null, "No implementation is available for rpc:%s path:%s", rpc, route); - return potential.invokeRpc(rpc, input); } public void addPath(final QName context, final YangInstanceIdentifier path, final RoutedRpcRegImpl routedRpcRegImpl) { diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareRpcBroker.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareRpcBroker.java index 44e7abc3aa..b4d7d2d001 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareRpcBroker.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareRpcBroker.java @@ -10,6 +10,13 @@ package org.opendaylight.controller.sal.dom.broker.impl; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; +import com.google.common.base.Preconditions; +import com.google.common.collect.FluentIterable; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; + import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -22,12 +29,13 @@ import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration; import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration; import org.opendaylight.controller.sal.core.api.RoutedRpcDefaultImplementation; import org.opendaylight.controller.sal.core.api.RpcImplementation; +import org.opendaylight.controller.sal.core.api.RpcImplementationUnavailableException; import org.opendaylight.controller.sal.core.api.RpcRegistrationListener; import org.opendaylight.controller.sal.core.api.RpcRoutingContext; import org.opendaylight.controller.sal.dom.broker.spi.RpcRouter; import org.opendaylight.yangtools.concepts.Identifiable; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.concepts.util.ListenerRegistry; +import org.opendaylight.yangtools.util.ListenerRegistry; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.data.api.CompositeNode; @@ -38,12 +46,9 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.base.Preconditions; -import com.google.common.collect.FluentIterable; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.util.concurrent.ListenableFuture; - +/** + * RPC broker responsible for routing requests to remote systems. + */ public class SchemaAwareRpcBroker implements RpcRouter, Identifiable, RoutedRpcDefaultImplementation { private static final Logger LOG = LoggerFactory.getLogger(SchemaAwareRpcBroker.class); @@ -217,8 +222,12 @@ public class SchemaAwareRpcBroker implements RpcRouter, Identifiable, Ro @Override public ListenableFuture> invokeRpc(final QName rpc, final YangInstanceIdentifier route, final CompositeNode input) { - checkState(defaultDelegate != null, "No implementation is available for rpc:%s path:%s", rpc, route); - return defaultDelegate.invokeRpc(rpc, route, input); + if (defaultDelegate == null) { + return Futures.immediateFailedCheckedFuture(new RpcImplementationUnavailableException("No RPC implementation found")); + } + + LOG.debug("Forwarding RPC {} path {} to delegate {}", rpc, route); + return defaultDelegate.invokeRpc(rpc, route, input); } void remove(final GlobalRpcRegistration registration) { diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerTest.java index b006ca94e5..0bb16a39b9 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerTest.java +++ b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerTest.java @@ -3,26 +3,40 @@ package org.opendaylight.controller.md.sal.dom.broker.impl; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION; import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL; +import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; +import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; +import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitDeadlockException; +import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener; import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction; import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; +import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; import org.opendaylight.controller.md.sal.dom.store.impl.TestModel; import org.opendaylight.controller.sal.core.spi.data.DOMStore; +import org.opendaylight.yangtools.util.concurrent.DeadlockDetectingListeningExecutorService; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; +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.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; @@ -31,6 +45,7 @@ public class DOMBrokerTest { private SchemaContext schemaContext; private DOMDataBrokerImpl domBroker; + private ListeningExecutorService executor; @Before public void setupStore() { @@ -46,11 +61,19 @@ public class DOMBrokerTest { .put(OPERATIONAL, operStore) // .build(); - ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()); + executor = new DeadlockDetectingListeningExecutorService(Executors.newSingleThreadExecutor(), + TransactionCommitDeadlockException.DEADLOCK_EXECUTOR_FUNCTION); domBroker = new DOMDataBrokerImpl(stores, executor); } - @Test + @After + public void tearDown() { + if( executor != null ) { + executor.shutdownNow(); + } + } + + @Test(timeout=10000) public void testTransactionIsolation() throws InterruptedException, ExecutionException { assertNotNull(domBroker); @@ -86,7 +109,7 @@ public class DOMBrokerTest { assertFalse(readTxContainer.get().isPresent()); } - @Test + @Test(timeout=10000) public void testTransactionCommit() throws InterruptedException, ExecutionException { DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction(); @@ -114,6 +137,173 @@ public class DOMBrokerTest { assertTrue(afterCommitRead.isPresent()); } + /** + * Tests a simple DataChangeListener notification after a write. + */ + @Test + public void testDataChangeListener() throws Throwable { + + final NormalizedNode testNode = ImmutableNodes.containerNode( TestModel.TEST_QNAME ); + + TestDOMDataChangeListener dcListener = new TestDOMDataChangeListener(); + + domBroker.registerDataChangeListener( OPERATIONAL, TestModel.TEST_PATH, + dcListener, DataChangeScope.BASE ); + + final DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction(); + assertNotNull( writeTx ); + + writeTx.put( OPERATIONAL, TestModel.TEST_PATH, testNode ); + + AtomicReference caughtEx = submitTxAsync( writeTx ); + + dcListener.waitForChange(); + + if( caughtEx.get() != null ) { + throw caughtEx.get(); + } + + NormalizedNode actualNode = dcListener.change.getCreatedData().get( TestModel.TEST_PATH ); + assertEquals( "Created node", testNode, actualNode ); + } + + /** + * Tests a DataChangeListener that does an async submit of a write Tx in its onDataChanged method. + * This should succeed without deadlock. + */ + @Test + public void testDataChangeListenerDoingAsyncWriteTxSubmit() throws Throwable { + + final AtomicReference caughtCommitEx = new AtomicReference<>(); + final CountDownLatch commitCompletedLatch = new CountDownLatch( 1 ); + + TestDOMDataChangeListener dcListener = new TestDOMDataChangeListener() { + @Override + public void onDataChanged( AsyncDataChangeEvent> change ) { + + DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction(); + writeTx.put( OPERATIONAL, TestModel.TEST2_PATH, + ImmutableNodes.containerNode( TestModel.TEST2_QNAME ) ); + Futures.addCallback( writeTx.submit(), new FutureCallback() { + @Override + public void onSuccess( Void result ) { + commitCompletedLatch.countDown(); + } + + @Override + public void onFailure( Throwable t ) { + caughtCommitEx.set( t ); + commitCompletedLatch.countDown(); + } + } ); + + super.onDataChanged( change ); + } + }; + + domBroker.registerDataChangeListener( OPERATIONAL, TestModel.TEST_PATH, + dcListener, DataChangeScope.BASE ); + + final DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction(); + assertNotNull( writeTx ); + + writeTx.put( OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode( TestModel.TEST_QNAME ) ); + + AtomicReference caughtEx = submitTxAsync( writeTx ); + + dcListener.waitForChange(); + + if( caughtEx.get() != null ) { + throw caughtEx.get(); + } + + assertTrue( "Commit Future was not invoked", commitCompletedLatch.await( 5, TimeUnit.SECONDS ) ); + + if( caughtCommitEx.get() != null ) { + throw caughtCommitEx.get(); + } + } + + /** + * Tests a DataChangeListener that does a blocking submit of a write Tx in its onDataChanged method. + * This should throw an exception and not deadlock. + */ + @Test(expected=TransactionCommitDeadlockException.class) + public void testDataChangeListenerDoingBlockingWriteTxSubmit() throws Throwable { + + final AtomicReference caughtCommitEx = new AtomicReference<>(); + + TestDOMDataChangeListener dcListener = new TestDOMDataChangeListener() { + @Override + public void onDataChanged( AsyncDataChangeEvent> change ) { + DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction(); + writeTx.put( OPERATIONAL, TestModel.TEST2_PATH, + ImmutableNodes.containerNode( TestModel.TEST2_QNAME ) ); + try { + writeTx.submit().get(); + } catch( ExecutionException e ) { + caughtCommitEx.set( e.getCause() ); + } catch( Exception e ) { + caughtCommitEx.set( e ); + } + finally { + super.onDataChanged( change ); + } + } + }; + + domBroker.registerDataChangeListener( OPERATIONAL, TestModel.TEST_PATH, + dcListener, DataChangeScope.BASE ); + + final DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction(); + assertNotNull( writeTx ); + + writeTx.put( OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode( TestModel.TEST_QNAME ) ); + + AtomicReference caughtEx = submitTxAsync( writeTx ); + dcListener.waitForChange(); + if( caughtEx.get() != null ) { + throw caughtEx.get(); + } + + if( caughtCommitEx.get() != null ) { + throw caughtCommitEx.get(); + } + } + + AtomicReference submitTxAsync( final DOMDataWriteTransaction writeTx ) { + final AtomicReference caughtEx = new AtomicReference<>(); + new Thread() { + @Override + public void run() { + + try { + writeTx.submit(); + } catch( Throwable e ) { + caughtEx.set( e ); + } + } + + }.start(); + + return caughtEx; + } + + static class TestDOMDataChangeListener implements DOMDataChangeListener { + + volatile AsyncDataChangeEvent> change; + private final CountDownLatch latch = new CountDownLatch( 1 ); + + @Override + public void onDataChanged( AsyncDataChangeEvent> change ) { + this.change = change; + latch.countDown(); + } + + void waitForChange() throws InterruptedException { + assertTrue( "onDataChanged was not called", latch.await( 5, TimeUnit.SECONDS ) ); + } + } } diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java index d5ba2a2b9a..09835ec5e3 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java +++ b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java @@ -21,6 +21,8 @@ public class TestModel { public static final QName TEST_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13", "test"); + public static final QName TEST2_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13", + "test2"); public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME, "outer-list"); public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME, "inner-list"); public static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME, "outer-choice"); @@ -30,6 +32,7 @@ public class TestModel { private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang"; public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME); + public static final YangInstanceIdentifier TEST2_PATH = YangInstanceIdentifier.of(TEST2_QNAME); public static final YangInstanceIdentifier OUTER_LIST_PATH = YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build(); public static final QName TWO_QNAME = QName.create(TEST_QNAME,"two"); public static final QName THREE_QNAME = QName.create(TEST_QNAME,"three"); diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/resources/odl-datastore-test.yang b/opendaylight/md-sal/sal-dom-broker/src/test/resources/odl-datastore-test.yang index 17541fecab..5fbf470f09 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/test/resources/odl-datastore-test.yang +++ b/opendaylight/md-sal/sal-dom-broker/src/test/resources/odl-datastore-test.yang @@ -39,4 +39,7 @@ module odl-datastore-test { } } } + + container test2 { + } } \ No newline at end of file diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeEventsTask.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeEventsTask.java index ff64cd64c4..3ddf0b60fa 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeEventsTask.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeEventsTask.java @@ -9,9 +9,15 @@ package org.opendaylight.controller.md.sal.dom.store.impl; import static org.opendaylight.controller.md.sal.dom.store.impl.DOMImmutableDataChangeEvent.builder; +import com.google.common.base.Optional; +import com.google.common.base.Preconditions; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; +import com.google.common.collect.Multimap; + import java.util.Collection; import java.util.Collections; -import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map.Entry; @@ -37,13 +43,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; -import com.google.common.collect.Multimap; - /** * Resolve Data Change Events based on modifications and listeners * @@ -278,6 +277,11 @@ final class ResolveDataChangeEventsTask implements Callable listeners, final NormalizedNode beforeData, final NormalizedNode afterData) { + // FIXME: BUG-1493: check the listeners to prune unneeded changes: + // for subtrees, we have to do all + // for one, we need to expand children + // for base, we just report replacement + if (beforeData instanceof NormalizedNodeContainer) { // Node is container (contains child) and we have interested // listeners registered for it, that means we need to do @@ -306,14 +310,12 @@ final class ResolveDataChangeEventsTask implements Callable listeners, final NormalizedNodeContainer> beforeCont, final NormalizedNodeContainer> afterCont) { - final Set alreadyProcessed = new HashSet<>(); final List childChanges = new LinkedList<>(); - DataChangeScope potentialScope = DataChangeScope.BASE; // We look at all children from before and compare it with after state. for (NormalizedNode beforeChild : beforeCont.getValue()) { - PathArgument childId = beforeChild.getIdentifier(); - alreadyProcessed.add(childId); + final PathArgument childId = beforeChild.getIdentifier(); + YangInstanceIdentifier childPath = path.node(childId); Collection childListeners = getListenerChildrenWildcarded(listeners, childId); Optional> afterChild = afterCont.getChild(childId); @@ -323,15 +325,17 @@ final class ResolveDataChangeEventsTask implements Callable afterChild : afterCont.getValue()) { - PathArgument childId = afterChild.getIdentifier(); - if (!alreadyProcessed.contains(childId)) { - // We did not processed that child already - // and it was not present in previous loop, that means it is - // created. + final PathArgument childId = afterChild.getIdentifier(); + + /* + * We have already iterated of the before-children, so have already + * emitted modify/delete events. This means the child has been + * created. + */ + if (!beforeCont.getChild(childId).isPresent()) { Collection childListeners = getListenerChildrenWildcarded(listeners, childId); YangInstanceIdentifier childPath = path.node(childId); childChanges.add(resolveSameEventRecursivelly(childPath , childListeners, afterChild, @@ -342,7 +346,7 @@ final class ResolveDataChangeEventsTask implements Callable messageTransformer; private final SchemaContextProviderFactory schemaContextProviderFactory; private final SchemaSourceProviderFactory sourceProviderFactory; + private final NetconfStateSchemas.NetconfStateSchemasResolver stateSchemasResolver; private final NotificationHandler notificationHandler; public static NetconfDevice createNetconfDevice(final RemoteDeviceId id, final AbstractCachingSchemaSourceProvider schemaSourceProvider, final ExecutorService executor, final RemoteDeviceHandler salFacade) { + return createNetconfDevice(id, schemaSourceProvider, executor, salFacade, new NetconfStateSchemas.NetconfStateSchemasResolverImpl()); + } + + @VisibleForTesting + protected static NetconfDevice createNetconfDevice(final RemoteDeviceId id, + final AbstractCachingSchemaSourceProvider schemaSourceProvider, + final ExecutorService executor, final RemoteDeviceHandler salFacade, + final NetconfStateSchemas.NetconfStateSchemasResolver stateSchemasResolver) { return new NetconfDevice(id, salFacade, executor, new NetconfMessageTransformer(), new NetconfDeviceSchemaProviderFactory(id), new SchemaSourceProviderFactory() { @@ -67,18 +78,20 @@ public final class NetconfDevice implements RemoteDevice salFacade, - final ExecutorService processingExecutor, final MessageTransformer messageTransformer, - final SchemaContextProviderFactory schemaContextProviderFactory, - final SchemaSourceProviderFactory sourceProviderFactory) { + final ExecutorService processingExecutor, final MessageTransformer messageTransformer, + final SchemaContextProviderFactory schemaContextProviderFactory, + final SchemaSourceProviderFactory sourceProviderFactory, + final NetconfStateSchemas.NetconfStateSchemasResolver stateSchemasResolver) { this.id = id; this.messageTransformer = messageTransformer; this.salFacade = salFacade; this.sourceProviderFactory = sourceProviderFactory; + this.stateSchemasResolver = stateSchemasResolver; this.processingExecutor = MoreExecutors.listeningDecorator(processingExecutor); this.schemaContextProviderFactory = schemaContextProviderFactory; this.notificationHandler = new NotificationHandler(salFacade, messageTransformer, id); @@ -98,6 +111,11 @@ public final class NetconfDevice implements RemoteDevice delegate = sourceProviderFactory.createSourceProvider(deviceRpc); final SchemaContextProvider schemaContextProvider = setUpSchemaContext(delegate, remoteSessionCapabilities); updateMessageTransformer(schemaContextProvider); @@ -204,6 +222,6 @@ public final class NetconfDevice implements RemoteDeviceemptySet()); + + private static final YangInstanceIdentifier STATE_SCHEMAS_IDENTIFIER = + YangInstanceIdentifier.builder().node(NetconfState.QNAME).node(Schemas.QNAME).build(); + private static final YangInstanceIdentifier DATA_STATE_SCHEMAS_IDENTIFIER = + YangInstanceIdentifier.builder().node(NetconfMessageTransformUtil.NETCONF_DATA_QNAME) + .node(NetconfState.QNAME).node(Schemas.QNAME).build(); + + private static final CompositeNode GET_SCHEMAS_RPC; + static { + final Node filter = NetconfMessageTransformUtil.toFilterStructure(STATE_SCHEMAS_IDENTIFIER); + GET_SCHEMAS_RPC + = NodeFactory.createImmutableCompositeNode(NetconfMessageTransformUtil.NETCONF_GET_QNAME, null, Lists.>newArrayList(filter)); + } + + private final Set availableYangSchemas; + + public NetconfStateSchemas(final Set availableYangSchemas) { + this.availableYangSchemas = availableYangSchemas; + } + + public Set getAvailableYangSchemas() { + return availableYangSchemas; + } + + public Set getAvailableYangSchemasQNames() { + return Sets.newHashSet(Collections2.transform(getAvailableYangSchemas(), new Function() { + @Override + public QName apply(final RemoteYangSchema input) { + return input.getQName(); + } + })); + } + + /** + * Issue get request to remote device and parse response to find all schemas under netconf-state/schemas + */ + private static NetconfStateSchemas create(final NetconfDeviceRpc deviceRpc, final NetconfSessionCapabilities remoteSessionCapabilities, final RemoteDeviceId id) { + if(remoteSessionCapabilities.isMonitoringSupported() == false) { + logger.warn("{}: Netconf monitoring not supported on device, cannot detect available schemas"); + return EMPTY; + } + + final RpcResult schemasNodeResult; + try { + schemasNodeResult = deviceRpc.invokeRpc(NetconfMessageTransformUtil.NETCONF_GET_QNAME, GET_SCHEMAS_RPC).get(); + } catch (final InterruptedException e) { + Thread.currentThread().interrupt(); + throw new RuntimeException(id + ": Interrupted while waiting for response to " + STATE_SCHEMAS_IDENTIFIER, e); + } catch (final ExecutionException e) { + logger.warn("{}: Unable to detect available schemas, get to {} failed", id, STATE_SCHEMAS_IDENTIFIER, e); + return EMPTY; + } + + if(schemasNodeResult.isSuccessful() == false) { + logger.warn("{}: Unable to detect available schemas, get to {} failed, {}", id, STATE_SCHEMAS_IDENTIFIER, schemasNodeResult.getErrors()); + return EMPTY; + } + + final CompositeNode schemasNode = + (CompositeNode) NetconfMessageTransformUtil.findNode(schemasNodeResult.getResult(), DATA_STATE_SCHEMAS_IDENTIFIER); + return create(schemasNode); + } + + /** + * Parse response of get(netconf-state/schemas) to find all schemas under netconf-state/schemas + */ + @VisibleForTesting + protected static NetconfStateSchemas create(final CompositeNode schemasNode) { + final Set availableYangSchemas = Sets.newHashSet(); + + for (final CompositeNode schemaNode : schemasNode.getCompositesByName(Schema.QNAME.withoutRevision())) { + availableYangSchemas.add(RemoteYangSchema.createFromCompositeNode(schemaNode)); + } + + return new NetconfStateSchemas(availableYangSchemas); + } + + public final static class RemoteYangSchema { + private final QName qname; + + private RemoteYangSchema(final QName qname) { + this.qname = qname; + } + + public QName getQName() { + return qname; + } + + static RemoteYangSchema createFromCompositeNode(final CompositeNode schemaNode) { + Preconditions.checkArgument(schemaNode.getKey().equals(Schema.QNAME.withoutRevision()), "Wrong QName %s", schemaNode.getKey()); + + QName childNode = NetconfMessageTransformUtil.IETF_NETCONF_MONITORING_SCHEMA_FORMAT.withoutRevision(); + + final String formatAsString = getSingleChildNodeValue(schemaNode, childNode).get(); + Preconditions.checkArgument(formatAsString.equals(Yang.QNAME.getLocalName()), + "Expecting format to be only %s, not %s", Yang.QNAME.getLocalName(), formatAsString); + + childNode = NetconfMessageTransformUtil.IETF_NETCONF_MONITORING_SCHEMA_LOCATION.withoutRevision(); + final Set locationsAsString = getAllChildNodeValues(schemaNode, childNode); + Preconditions.checkArgument(locationsAsString.contains(Schema.Location.Enumeration.NETCONF.toString()), + "Expecting location to be %s, not %s", Schema.Location.Enumeration.NETCONF.toString(), locationsAsString); + + childNode = NetconfMessageTransformUtil.IETF_NETCONF_MONITORING_SCHEMA_NAMESPACE.withoutRevision(); + final String namespaceAsString = getSingleChildNodeValue(schemaNode, childNode).get(); + + childNode = NetconfMessageTransformUtil.IETF_NETCONF_MONITORING_SCHEMA_VERSION.withoutRevision(); + // Revision does not have to be filled + final Optional revisionAsString = getSingleChildNodeValue(schemaNode, childNode); + + childNode = NetconfMessageTransformUtil.IETF_NETCONF_MONITORING_SCHEMA_IDENTIFIER.withoutRevision(); + final String moduleNameAsString = getSingleChildNodeValue(schemaNode, childNode).get(); + + final QName moduleQName = revisionAsString.isPresent() + ? QName.create(namespaceAsString, revisionAsString.get(), moduleNameAsString) + : QName.create(URI.create(namespaceAsString), null, moduleNameAsString).withoutRevision(); + + return new RemoteYangSchema(moduleQName); + } + + private static Set getAllChildNodeValues(final CompositeNode schemaNode, final QName childNodeQName) { + final Set extractedValues = Sets.newHashSet(); + for (final SimpleNode childNode : schemaNode.getSimpleNodesByName(childNodeQName)) { + extractedValues.add(getValueOfSimpleNode(childNodeQName, childNode).get()); + } + return extractedValues; + } + + private static Optional getSingleChildNodeValue(final CompositeNode schemaNode, final QName childNode) { + final SimpleNode node = schemaNode.getFirstSimpleByName(childNode); + return getValueOfSimpleNode(childNode, node); + } + + private static Optional getValueOfSimpleNode(final QName childNode, final SimpleNode node) { + Preconditions.checkNotNull(node, "Child node %s not present", childNode); + final Object value = node.getValue(); + return value == null ? Optional.absent() : Optional.of(value.toString().trim()); + } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + final RemoteYangSchema that = (RemoteYangSchema) o; + + if (!qname.equals(that.qname)) return false; + + return true; + } + + @Override + public int hashCode() { + return qname.hashCode(); + } + } +} diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/listener/NetconfDeviceCommunicator.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/listener/NetconfDeviceCommunicator.java index 3871cdfa4f..2f24adcdbe 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/listener/NetconfDeviceCommunicator.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/listener/NetconfDeviceCommunicator.java @@ -229,7 +229,7 @@ public class NetconfDeviceCommunicator implements NetconfClientSessionListener, try { NetconfMessageTransformUtil.checkSuccessReply(message); } - catch( NetconfDocumentedException e ) { + catch(final NetconfDocumentedException e) { logger.warn( "{}: Error reply from remote device, request: {}, response: {}", id, msgToS( request.request ), msgToS( message ), e ); diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/tx/NetconfDeviceReadOnlyTx.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/tx/NetconfDeviceReadOnlyTx.java index 533df9cce7..04a99511a1 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/tx/NetconfDeviceReadOnlyTx.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/tx/NetconfDeviceReadOnlyTx.java @@ -30,8 +30,6 @@ import org.opendaylight.controller.sal.core.api.RpcImplementation; import org.opendaylight.yangtools.util.concurrent.MappingCheckedFuture; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.Node; -import org.opendaylight.yangtools.yang.data.api.SimpleNode; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.slf4j.Logger; @@ -63,7 +61,7 @@ public final class NetconfDeviceReadOnlyTx implements DOMDataReadOnlyTransaction checkReadSuccess(result, path); final CompositeNode data = result.getResult().getFirstCompositeByName(NETCONF_DATA_QNAME); - final CompositeNode node = (CompositeNode) findNode(data, path); + final CompositeNode node = (CompositeNode) NetconfMessageTransformUtil.findNode(data, path); return data == null ? Optional.>absent() : @@ -105,7 +103,7 @@ public final class NetconfDeviceReadOnlyTx implements DOMDataReadOnlyTransaction checkReadSuccess(result, path); final CompositeNode data = result.getResult().getFirstCompositeByName(NETCONF_DATA_QNAME); - final CompositeNode node = (CompositeNode) findNode(data, path); + final CompositeNode node = (CompositeNode) NetconfMessageTransformUtil.findNode(data, path); return data == null ? Optional.>absent() : @@ -116,33 +114,6 @@ public final class NetconfDeviceReadOnlyTx implements DOMDataReadOnlyTransaction return MappingCheckedFuture.create(transformedFuture, ReadFailedException.MAPPER); } - private static Node findNode(final CompositeNode node, final YangInstanceIdentifier identifier) { - - Node current = node; - for (final YangInstanceIdentifier.PathArgument arg : identifier.getPathArguments()) { - if (current instanceof SimpleNode) { - return null; - } else if (current instanceof CompositeNode) { - final CompositeNode currentComposite = (CompositeNode) current; - - current = currentComposite.getFirstCompositeByName(arg.getNodeType()); - if (current == null) { - current = currentComposite.getFirstCompositeByName(arg.getNodeType().withoutRevision()); - } - if (current == null) { - current = currentComposite.getFirstSimpleByName(arg.getNodeType()); - } - if (current == null) { - current = currentComposite.getFirstSimpleByName(arg.getNodeType().withoutRevision()); - } - if (current == null) { - return null; - } - } - } - return current; - } - @Override public void close() { // NOOP diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/schema/mapping/NetconfMessageTransformer.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/schema/mapping/NetconfMessageTransformer.java index 47ef9039d1..5e61dfb028 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/schema/mapping/NetconfMessageTransformer.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/schema/mapping/NetconfMessageTransformer.java @@ -96,7 +96,7 @@ public class NetconfMessageTransformer implements MessageTransformer findNode(final CompositeNode node, final YangInstanceIdentifier identifier) { + + Node current = node; + for (final YangInstanceIdentifier.PathArgument arg : identifier.getPathArguments()) { + if (current instanceof SimpleNode) { + return null; + } else if (current instanceof CompositeNode) { + final CompositeNode currentComposite = (CompositeNode) current; + + current = currentComposite.getFirstCompositeByName(arg.getNodeType()); + if (current == null) { + current = currentComposite.getFirstCompositeByName(arg.getNodeType().withoutRevision()); + } + if (current == null) { + current = currentComposite.getFirstSimpleByName(arg.getNodeType()); + } + if (current == null) { + current = currentComposite.getFirstSimpleByName(arg.getNodeType().withoutRevision()); + } + if (current == null) { + return null; + } + } + } + return current; + } } diff --git a/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceTest.java b/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceTest.java index 46ea4ff73c..fa488dadd3 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceTest.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceTest.java @@ -15,6 +15,9 @@ import static org.mockito.Mockito.timeout; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import com.google.common.base.Optional; +import com.google.common.collect.Lists; +import com.google.common.util.concurrent.Futures; import java.io.InputStream; import java.util.ArrayList; import java.util.Collection; @@ -23,7 +26,6 @@ import java.util.List; import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; - import org.junit.Test; import org.mockito.Mockito; import org.opendaylight.controller.netconf.api.NetconfMessage; @@ -34,6 +36,7 @@ import org.opendaylight.controller.sal.connect.api.RemoteDeviceHandler; import org.opendaylight.controller.sal.connect.api.SchemaContextProviderFactory; import org.opendaylight.controller.sal.connect.api.SchemaSourceProviderFactory; import org.opendaylight.controller.sal.connect.netconf.listener.NetconfSessionCapabilities; +import org.opendaylight.controller.sal.connect.netconf.sal.NetconfDeviceRpc; import org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil; import org.opendaylight.controller.sal.connect.util.RemoteDeviceId; import org.opendaylight.controller.sal.core.api.RpcImplementation; @@ -47,10 +50,6 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider; import org.opendaylight.yangtools.yang.model.util.repo.SchemaSourceProvider; import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl; -import com.google.common.base.Optional; -import com.google.common.collect.Lists; -import com.google.common.util.concurrent.Futures; - public class NetconfDeviceTest { private static final NetconfMessage netconfMessage; @@ -71,13 +70,20 @@ public class NetconfDeviceTest { public static final String TEST_NAMESPACE = "test:namespace"; public static final String TEST_MODULE = "test-module"; public static final String TEST_REVISION = "2013-07-22"; + private NetconfStateSchemas.NetconfStateSchemasResolver stateSchemasResolver = new NetconfStateSchemas.NetconfStateSchemasResolver() { + + @Override + public NetconfStateSchemas resolve(final NetconfDeviceRpc deviceRpc, final NetconfSessionCapabilities remoteSessionCapabilities, final RemoteDeviceId id) { + return NetconfStateSchemas.EMPTY; + } + }; @Test public void testNetconfDeviceWithoutMonitoring() throws Exception { final RemoteDeviceHandler facade = getFacade(); final RemoteDeviceCommunicator listener = getListener(); - final NetconfDevice device = new NetconfDevice(getId(), facade, getExecutor(), getMessageTransformer(), getSchemaContextProviderFactory(), getSourceProviderFactory()); + final NetconfDevice device = new NetconfDevice(getId(), facade, getExecutor(), getMessageTransformer(), getSchemaContextProviderFactory(), getSourceProviderFactory(), stateSchemasResolver); device.onRemoteSessionUp(getSessionCaps(false, Collections.emptyList()), listener); Mockito.verify(facade, Mockito.timeout(5000)).onDeviceDisconnected(); @@ -89,7 +95,7 @@ public class NetconfDeviceTest { final RemoteDeviceCommunicator listener = getListener(); final MessageTransformer messageTransformer = getMessageTransformer(); - final NetconfDevice device = new NetconfDevice(getId(), facade, getExecutor(), messageTransformer, getSchemaContextProviderFactory(), getSourceProviderFactory()); + final NetconfDevice device = new NetconfDevice(getId(), facade, getExecutor(), messageTransformer, getSchemaContextProviderFactory(), getSourceProviderFactory(), stateSchemasResolver); device.onNotification(netconfMessage); device.onNotification(netconfMessage); @@ -118,7 +124,7 @@ public class NetconfDeviceTest { final SchemaSourceProviderFactory sourceProviderFactory = getSourceProviderFactory(); final MessageTransformer messageTransformer = getMessageTransformer(); - final NetconfDevice device = new NetconfDevice(getId(), facade, getExecutor(), messageTransformer, schemaContextProviderFactory, sourceProviderFactory); + final NetconfDevice device = new NetconfDevice(getId(), facade, getExecutor(), messageTransformer, schemaContextProviderFactory, sourceProviderFactory, stateSchemasResolver); final NetconfSessionCapabilities sessionCaps = getSessionCaps(true, Lists.newArrayList(TEST_NAMESPACE + "?module=" + TEST_MODULE + "&revision=" + TEST_REVISION)); device.onRemoteSessionUp(sessionCaps, listener); diff --git a/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfStateSchemasTest.java b/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfStateSchemasTest.java new file mode 100644 index 0000000000..16a915e730 --- /dev/null +++ b/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfStateSchemasTest.java @@ -0,0 +1,29 @@ +package org.opendaylight.controller.sal.connect.netconf; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.junit.matchers.JUnitMatchers.hasItem; + +import java.util.Set; +import org.junit.Test; +import org.opendaylight.controller.netconf.util.xml.XmlUtil; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.CompositeNode; +import org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlDocumentUtils; +import org.w3c.dom.Document; + +public class NetconfStateSchemasTest { + + @Test + public void testCreate() throws Exception { + final Document schemasXml = XmlUtil.readXmlToDocument(getClass().getResourceAsStream("/netconf-state.schemas.payload.xml")); + final CompositeNode compositeNodeSchemas = (CompositeNode) XmlDocumentUtils.toDomNode(schemasXml); + final NetconfStateSchemas schemas = NetconfStateSchemas.create(compositeNodeSchemas); + + final Set availableYangSchemasQNames = schemas.getAvailableYangSchemasQNames(); + assertEquals(73, availableYangSchemasQNames.size()); + + assertThat(availableYangSchemasQNames, + hasItem(QName.create("urn:TBD:params:xml:ns:yang:network-topology", "2013-07-12", "network-topology"))); + } +} diff --git a/opendaylight/md-sal/sal-netconf-connector/src/test/resources/netconf-state.schemas.payload.xml b/opendaylight/md-sal/sal-netconf-connector/src/test/resources/netconf-state.schemas.payload.xml new file mode 100644 index 0000000000..649ecb76a4 --- /dev/null +++ b/opendaylight/md-sal/sal-netconf-connector/src/test/resources/netconf-state.schemas.payload.xml @@ -0,0 +1,514 @@ + + + urn:opendaylight:params:xml:ns:yang:controller:threadpool + NETCONF + threadpool + yang + 2013-04-09 + + + urn:opendaylight:params:xml:ns:yang:controller:logback:config + NETCONF + config-logging + yang + 2013-07-16 + + + urn:opendaylight:model:statistics:types + NETCONF + opendaylight-statistics-types + yang + 2013-09-25 + + + urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:config-dom-store + NETCONF + opendaylight-config-dom-datastore + yang + 2014-06-17 + + + urn:opendaylight:flow:table:statistics + NETCONF + opendaylight-flow-table-statistics + yang + 2013-12-15 + + + urn:opendaylight:meter:service + NETCONF + sal-meter + yang + 2013-09-18 + + + urn:opendaylight:params:xml:ns:yang:controller:config:toaster-provider:impl + NETCONF + toaster-provider-impl + yang + 2014-01-31 + + + urn:opendaylight:table:types + NETCONF + opendaylight-table-types + yang + 2013-10-26 + + + urn:opendaylight:table:service + NETCONF + sal-table + yang + 2013-10-26 + + + urn:opendaylight:params:xml:ns:yang:controller:shutdown + NETCONF + shutdown + yang + 2013-12-18 + + + urn:opendaylight:port:service + NETCONF + sal-port + yang + 2013-11-07 + + + urn:opendaylight:params:xml:ns:yang:controller:netty:eventexecutor + NETCONF + netty-event-executor + yang + 2013-11-12 + + + urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote + NETCONF + sal-remote + yang + 2014-01-14 + + + urn:opendaylight:model:topology:view + NETCONF + opendaylight-topology-view + yang + 2013-10-30 + + + urn:opendaylight:params:xml:ns:yang:controller:netty:threadgroup + NETCONF + threadgroup + yang + 2013-11-07 + + + urn:TBD:params:xml:ns:yang:network-topology + NETCONF + network-topology + yang + 2013-07-12 + + + urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:fixed + NETCONF + threadpool-impl-fixed + yang + 2013-12-01 + + + urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl + NETCONF + opendaylight-sal-binding-broker-impl + yang + 2013-10-28 + + + urn:ietf:params:xml:ns:yang:ietf-restconf + NETCONF + ietf-restconf + yang + 2013-10-19 + + + urn:opendaylight:node:error:service + NETCONF + node-error + yang + 2014-04-10 + + + urn:opendaylight:flow:errors + NETCONF + flow-errors + yang + 2013-11-16 + + + urn:opendaylight:flow:service + NETCONF + sal-flow + yang + 2013-08-19 + + + urn:ietf:params:xml:ns:yang:rpc-context + NETCONF + rpc-context + yang + 2013-06-17 + + + urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:operational-dom-store + + NETCONF + opendaylight-operational-dom-datastore + yang + 2014-06-17 + + + urn:opendaylight:flow:types:queue + NETCONF + opendaylight-queue-types + yang + 2013-09-25 + + + urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring + NETCONF + ietf-netconf-monitoring + yang + 2010-10-04 + + + urn:opendaylight:netconf-node-inventory + NETCONF + netconf-node-inventory + yang + 2014-01-08 + + + urn:ietf:params:xml:ns:yang:ietf-yang-types + NETCONF + ietf-yang-types + yang + 2013-07-15 + + + urn:opendaylight:meter:statistics + NETCONF + opendaylight-meter-statistics + yang + 2013-11-11 + + + urn:opendaylight:flow:inventory + NETCONF + flow-node-inventory + yang + 2013-08-19 + + + urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf + NETCONF + odl-sal-netconf-connector-cfg + yang + 2013-10-28 + + + urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:scheduled + NETCONF + threadpool-impl-scheduled + yang + 2013-12-01 + + + urn:TBD:params:xml:ns:yang:network-topology + NETCONF + network-topology + yang + 2013-10-21 + + + http://netconfcentral.org/ns/toaster + NETCONF + toaster + yang + 2009-11-20 + + + urn:opendaylight:params:xml:ns:yang:controller:config:netconf + NETCONF + odl-netconf-cfg + yang + 2014-04-08 + + + urn:opendaylight:meter:types + NETCONF + opendaylight-meter-types + yang + 2013-09-18 + + + urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl + NETCONF + opendaylight-sal-dom-broker-impl + yang + 2013-10-28 + + + urn:opendaylight:flow:topology:discovery + NETCONF + flow-topology-discovery + yang + 2013-08-19 + + + urn:opendaylight:yang:extension:yang-ext + NETCONF + yang-ext + yang + 2013-07-09 + + + urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl + NETCONF + threadpool-impl + yang + 2013-04-05 + + + urn:opendaylight:flow:types:port + NETCONF + opendaylight-port-types + yang + 2013-09-25 + + + urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding + NETCONF + opendaylight-md-sal-binding + yang + 2013-10-28 + + + urn:opendaylight:packet:service + NETCONF + packet-processing + yang + 2013-07-09 + + + urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible + NETCONF + threadpool-impl-flexible + yang + 2013-12-01 + + + urn:opendaylight:queue:service + NETCONF + sal-queue + yang + 2013-11-07 + + + urn:ietf:params:xml:ns:yang:ietf-inet-types + NETCONF + ietf-inet-types + yang + 2010-09-24 + + + urn:opendaylight:params:xml:ns:yang:controller:md:sal:rest:connector + NETCONF + opendaylight-rest-connector + yang + 2014-07-24 + + + urn:opendaylight:flow:transaction + NETCONF + flow-capable-transaction + yang + 2013-11-03 + + + urn:opendaylight:flow:statistics + NETCONF + opendaylight-flow-statistics + yang + 2013-08-19 + + + urn:opendaylight:params:xml:ns:yang:controller:protocol:framework + NETCONF + protocol-framework + yang + 2014-03-13 + + + urn:opendaylight:model:match:types + NETCONF + opendaylight-match-types + yang + 2013-10-26 + + + urn:ietf:params:xml:ns:yang:ietf-yang-types + NETCONF + ietf-yang-types + yang + 2010-09-24 + + + urn:opendaylight:group:service + NETCONF + sal-group + yang + 2013-09-18 + + + urn:opendaylight:params:xml:ns:yang:controller:inmemory-datastore-provider + NETCONF + opendaylight-inmemory-datastore-provider + yang + 2014-06-17 + + + urn:opendaylight:params:xml:ns:yang:controller:netty:timer + NETCONF + netty-timer + yang + 2013-11-19 + + + urn:opendaylight:group:statistics + NETCONF + opendaylight-group-statistics + yang + 2013-11-11 + + + urn:opendaylight:params:xml:ns:yang:controller:config + NETCONF + config + yang + 2013-04-05 + + + urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher + NETCONF + odl-netconfig-client-cfg + yang + 2014-04-08 + + + urn:opendaylight:l2:types + NETCONF + opendaylight-l2-types + yang + 2013-08-27 + + + urn:opendaylight:action:types + NETCONF + opendaylight-action-types + yang + 2013-11-12 + + + urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom + NETCONF + opendaylight-md-sal-dom + yang + 2013-10-28 + + + urn:opendaylight:params:xml:ns:yang:controller:md:sal:common + NETCONF + opendaylight-md-sal-common + yang + 2013-10-28 + + + urn:opendaylight:group:types + NETCONF + opendaylight-group-types + yang + 2013-10-18 + + + urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring-extension + NETCONF + ietf-netconf-monitoring-extension + yang + 2013-12-10 + + + urn:opendaylight:inventory + NETCONF + opendaylight-inventory + yang + 2013-08-19 + + + urn:opendaylight:params:xml:ns:yang:controller:netty + NETCONF + netty + yang + 2013-11-19 + + + urn:opendaylight:model:topology:general + NETCONF + opendaylight-topology + yang + 2013-10-30 + + + urn:opendaylight:port:statistics + NETCONF + opendaylight-port-statistics + yang + + + + urn:opendaylight:queue:statistics + NETCONF + opendaylight-queue-statistics + yang + 2013-12-16 + + + urn:opendaylight:params:xml:ns:yang:controller:config:kitchen-service:impl + NETCONF + kitchen-service-impl + yang + 2014-01-31 + + + urn:opendaylight:flow:types + NETCONF + opendaylight-flow-types + yang + 2013-10-26 + + + urn:opendaylight:params:xml:ns:yang:controller:shutdown:impl + NETCONF + shutdown-impl + yang + 2013-12-18 + + + urn:opendaylight:model:topology:inventory + NETCONF + opendaylight-topology-inventory + yang + 2013-10-30 + + \ No newline at end of file diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/ActorSystemFactory.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/ActorSystemFactory.java index bd49b6239c..f1ca3ccd50 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/ActorSystemFactory.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/ActorSystemFactory.java @@ -27,7 +27,6 @@ public class ActorSystemFactory { * @param bundleContext */ public static final void createInstance(final BundleContext bundleContext) { - if(actorSystem == null) { // Create an OSGi bundle classloader for actor system BundleDelegatingClassLoader classLoader = new BundleDelegatingClassLoader(bundleContext.getBundle(), @@ -35,8 +34,8 @@ public class ActorSystemFactory { synchronized (ActorSystemFactory.class) { // Double check if (actorSystem == null) { - ActorSystem system = ActorSystem.create("opendaylight-rpc", - ConfigFactory.load().getConfig("odl-cluster"), classLoader); + ActorSystem system = ActorSystem.create("opendaylight-cluster-rpc", + ConfigFactory.load().getConfig("odl-cluster-rpc"), classLoader); actorSystem = system; } } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/resources/application.conf b/opendaylight/md-sal/sal-remoterpc-connector/src/main/resources/application.conf index 6088dd0e0e..daac89c4c8 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/resources/application.conf +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/resources/application.conf @@ -1,4 +1,43 @@ -odl-cluster{ + +odl-cluster-data { + akka { + cluster { + roles = [ + "member-1" + ] + } + actor { + provider = "akka.cluster.ClusterActorRefProvider" + serializers { + java = "akka.serialization.JavaSerializer" + proto = "akka.remote.serialization.ProtobufSerializer" + } + + serialization-bindings { + "com.google.protobuf.Message" = proto + + } + } + remote { + log-remote-lifecycle-events = off + netty.tcp { + hostname = "127.0.0.1" + port = 2550 + maximum-frame-size = 2097152 + send-buffer-size = 52428800 + receive-buffer-size = 52428800 + } + } + + cluster { + seed-nodes = ["akka.tcp://opendaylight-cluster-data@127.0.0.1:2550"] + + auto-down-unreachable-after = 10s + } + } +} + +odl-cluster-rpc { akka { actor { provider = "akka.cluster.ClusterActorRefProvider" @@ -7,15 +46,15 @@ odl-cluster{ remote { log-remote-lifecycle-events = off netty.tcp { - hostname = "192.168.141.141" + hostname = "127.0.0.1" port = 2551 } } cluster { - seed-nodes = ["akka.tcp://opendaylight-rpc@192.168.141.141:2551"] + seed-nodes = ["akka.tcp://opendaylight-cluster-rpc@127.0.0.1:2551"] auto-down-unreachable-after = 10s } } -} \ No newline at end of file +} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.java index ae8e1b05af..93e6a2c0e9 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.java @@ -14,8 +14,6 @@ import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.base.Splitter; import com.google.common.base.Strings; -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import java.io.UnsupportedEncodingException; @@ -86,10 +84,6 @@ public class ControllerContext implements SchemaContextListener { private static final Splitter SLASH_SPLITTER = Splitter.on('/'); - private final BiMap uriToModuleName = HashBiMap. create(); - - private final Map moduleNameToUri = uriToModuleName.inverse(); - private final AtomicReference> qnameToRpc = new AtomicReference<>(Collections.emptyMap()); @@ -279,16 +273,8 @@ public class ControllerContext implements SchemaContextListener { public String findModuleNameByNamespace(final URI namespace) { this.checkPreconditions(); - String moduleName = this.uriToModuleName.get(namespace); - if (moduleName == null) { - final Module module = this.findModuleByNamespace(namespace); - if (module != null) { - moduleName = module.getName(); - this.uriToModuleName.put(namespace, moduleName); - } - } - - return moduleName; + final Module module = this.findModuleByNamespace(namespace); + return module == null ? null : module.getName(); } public String findModuleNameByNamespace(final DOMMountPoint mountPoint, final URI namespace) { @@ -297,16 +283,8 @@ public class ControllerContext implements SchemaContextListener { } public URI findNamespaceByModuleName(final String moduleName) { - URI namespace = this.moduleNameToUri.get(moduleName); - if (namespace == null) { - Module module = this.findModuleByName(moduleName); - if (module != null) { - URI _namespace = module.getNamespace(); - namespace = _namespace; - this.uriToModuleName.put(namespace, moduleName); - } - } - return namespace; + final Module module = this.findModuleByName(moduleName); + return module == null ? null : module.getNamespace(); } public URI findNamespaceByModuleName(final DOMMountPoint mountPoint, final String moduleName) { @@ -326,26 +304,15 @@ public class ControllerContext implements SchemaContextListener { return globalSchema.getModules(); } + private static final CharSequence toRestconfIdentifier(final SchemaContext context, final QName qname) { + final Module schema = context.findModuleByNamespaceAndRevision(qname.getNamespace(), qname.getRevision()); + return schema == null ? null : schema.getName() + ':' + qname.getLocalName(); + } + public CharSequence toRestconfIdentifier(final QName qname) { this.checkPreconditions(); - String module = this.uriToModuleName.get(qname.getNamespace()); - if (module == null) { - final Module moduleSchema = globalSchema.findModuleByNamespaceAndRevision(qname.getNamespace(), - qname.getRevision()); - if (moduleSchema == null) { - return null; - } - - this.uriToModuleName.put(qname.getNamespace(), moduleSchema.getName()); - module = moduleSchema.getName(); - } - - StringBuilder builder = new StringBuilder(); - builder.append(module); - builder.append(":"); - builder.append(qname.getLocalName()); - return builder.toString(); + return toRestconfIdentifier(globalSchema, qname); } public CharSequence toRestconfIdentifier(final DOMMountPoint mountPoint, final QName qname) { @@ -353,19 +320,7 @@ public class ControllerContext implements SchemaContextListener { return null; } - SchemaContext schemaContext = mountPoint.getSchemaContext(); - - final Module moduleSchema = schemaContext.findModuleByNamespaceAndRevision(qname.getNamespace(), - qname.getRevision()); - if (moduleSchema == null) { - return null; - } - - StringBuilder builder = new StringBuilder(); - builder.append(moduleSchema.getName()); - builder.append(":"); - builder.append(qname.getLocalName()); - return builder.toString(); + return toRestconfIdentifier(mountPoint.getSchemaContext(), qname); } public Module getRestconfModule() { @@ -391,7 +346,7 @@ public class ControllerContext implements SchemaContextListener { final GroupingDefinition restconfGrouping = Iterables.getFirst(filteredGroups, null); - List instanceDataChildrenByName = this.findInstanceDataChildrenByName(restconfGrouping, + List instanceDataChildrenByName = findInstanceDataChildrenByName(restconfGrouping, Draft02.RestConfModule.ERRORS_CONTAINER_SCHEMA_NODE); return Iterables.getFirst(instanceDataChildrenByName, null); } @@ -417,38 +372,38 @@ public class ControllerContext implements SchemaContextListener { Iterable filteredGroups = Iterables.filter(groupings, GROUPING_FILTER); final GroupingDefinition restconfGrouping = Iterables.getFirst(filteredGroups, null); - List instanceDataChildrenByName = this.findInstanceDataChildrenByName(restconfGrouping, + List instanceDataChildrenByName = findInstanceDataChildrenByName(restconfGrouping, Draft02.RestConfModule.RESTCONF_CONTAINER_SCHEMA_NODE); final DataSchemaNode restconfContainer = Iterables.getFirst(instanceDataChildrenByName, null); if (Objects.equal(schemaNodeName, Draft02.RestConfModule.OPERATIONS_CONTAINER_SCHEMA_NODE)) { - List instances = this.findInstanceDataChildrenByName( + List instances = findInstanceDataChildrenByName( ((DataNodeContainer) restconfContainer), Draft02.RestConfModule.OPERATIONS_CONTAINER_SCHEMA_NODE); return Iterables.getFirst(instances, null); } else if (Objects.equal(schemaNodeName, Draft02.RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE)) { - List instances = this.findInstanceDataChildrenByName( + List instances = findInstanceDataChildrenByName( ((DataNodeContainer) restconfContainer), Draft02.RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE); return Iterables.getFirst(instances, null); } else if (Objects.equal(schemaNodeName, Draft02.RestConfModule.STREAM_LIST_SCHEMA_NODE)) { - List instances = this.findInstanceDataChildrenByName( + List instances = findInstanceDataChildrenByName( ((DataNodeContainer) restconfContainer), Draft02.RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE); final DataSchemaNode modules = Iterables.getFirst(instances, null); - instances = this.findInstanceDataChildrenByName(((DataNodeContainer) modules), + instances = findInstanceDataChildrenByName(((DataNodeContainer) modules), Draft02.RestConfModule.STREAM_LIST_SCHEMA_NODE); return Iterables.getFirst(instances, null); } else if (Objects.equal(schemaNodeName, Draft02.RestConfModule.MODULES_CONTAINER_SCHEMA_NODE)) { - List instances = this.findInstanceDataChildrenByName( + List instances = findInstanceDataChildrenByName( ((DataNodeContainer) restconfContainer), Draft02.RestConfModule.MODULES_CONTAINER_SCHEMA_NODE); return Iterables.getFirst(instances, null); } else if (Objects.equal(schemaNodeName, Draft02.RestConfModule.MODULE_LIST_SCHEMA_NODE)) { - List instances = this.findInstanceDataChildrenByName( + List instances = findInstanceDataChildrenByName( ((DataNodeContainer) restconfContainer), Draft02.RestConfModule.MODULES_CONTAINER_SCHEMA_NODE); final DataSchemaNode modules = Iterables.getFirst(instances, null); - instances = this.findInstanceDataChildrenByName(((DataNodeContainer) modules), + instances = findInstanceDataChildrenByName(((DataNodeContainer) modules), Draft02.RestConfModule.MODULE_LIST_SCHEMA_NODE); return Iterables.getFirst(instances, null); } else if (Objects.equal(schemaNodeName, Draft02.RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE)) { - List instances = this.findInstanceDataChildrenByName( + List instances = findInstanceDataChildrenByName( ((DataNodeContainer) restconfContainer), Draft02.RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE); return Iterables.getFirst(instances, null); } @@ -602,7 +557,7 @@ public class ControllerContext implements SchemaContextListener { } } - targetNode = this.findInstanceDataChildByNameAndNamespace(parentNode, nodeName, module.getNamespace()); + targetNode = findInstanceDataChildByNameAndNamespace(parentNode, nodeName, module.getNamespace()); if (targetNode == null) { throw new RestconfDocumentedException("URI has bad format. Possible reasons:\n" + " 1. \"" + head + "\" was not found in parent data node.\n" + " 2. \"" + head @@ -610,7 +565,7 @@ public class ControllerContext implements SchemaContextListener { ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); } } else { - final List potentialSchemaNodes = this.findInstanceDataChildrenByName(parentNode, nodeName); + final List potentialSchemaNodes = findInstanceDataChildrenByName(parentNode, nodeName); if (potentialSchemaNodes.size() > 1) { final StringBuilder strBuilder = new StringBuilder(); for (final DataSchemaNode potentialNodeSchema : potentialSchemaNodes) { @@ -680,11 +635,11 @@ public class ControllerContext implements SchemaContextListener { return new InstanceIdWithSchemaNode(builder.toInstance(), targetNode, mountPoint); } - public DataSchemaNode findInstanceDataChildByNameAndNamespace(final DataNodeContainer container, final String name, + public static DataSchemaNode findInstanceDataChildByNameAndNamespace(final DataNodeContainer container, final String name, final URI namespace) { Preconditions. checkNotNull(namespace); - final List potentialSchemaNodes = this.findInstanceDataChildrenByName(container, name); + final List potentialSchemaNodes = findInstanceDataChildrenByName(container, name); Predicate filter = new Predicate() { @Override @@ -697,12 +652,12 @@ public class ControllerContext implements SchemaContextListener { return Iterables.getFirst(result, null); } - public List findInstanceDataChildrenByName(final DataNodeContainer container, final String name) { + public static List findInstanceDataChildrenByName(final DataNodeContainer container, final String name) { Preconditions. checkNotNull(container); Preconditions. checkNotNull(name); List instantiatedDataNodeContainers = new ArrayList(); - this.collectInstanceDataNodeContainers(instantiatedDataNodeContainers, container, name); + collectInstanceDataNodeContainers(instantiatedDataNodeContainers, container, name); return instantiatedDataNodeContainers; } @@ -713,7 +668,7 @@ public class ControllerContext implements SchemaContextListener { } }; - private void collectInstanceDataNodeContainers(final List potentialSchemaNodes, + private static void collectInstanceDataNodeContainers(final List potentialSchemaNodes, final DataNodeContainer container, final String name) { Predicate filter = new Predicate() { @@ -728,7 +683,7 @@ public class ControllerContext implements SchemaContextListener { // Can't combine this loop with the filter above because the filter is // lazily-applied by Iterables.filter. for (final DataSchemaNode potentialNode : nodes) { - if (this.isInstantiatedDataSchema(potentialNode)) { + if (isInstantiatedDataSchema(potentialNode)) { potentialSchemaNodes.add(potentialNode); } } @@ -738,11 +693,11 @@ public class ControllerContext implements SchemaContextListener { final Iterable allCases = Iterables. concat(map); for (final ChoiceCaseNode caze : allCases) { - this.collectInstanceDataNodeContainers(potentialSchemaNodes, caze, name); + collectInstanceDataNodeContainers(potentialSchemaNodes, caze, name); } } - public boolean isInstantiatedDataSchema(final DataSchemaNode node) { + public static boolean isInstantiatedDataSchema(final DataSchemaNode node) { return node instanceof LeafSchemaNode || node instanceof LeafListSchemaNode || node instanceof ContainerSchemaNode || node instanceof ListSchemaNode || node instanceof AnyXmlSchemaNode; @@ -876,11 +831,7 @@ public class ControllerContext implements SchemaContextListener { } private CharSequence convertToRestconfIdentifier(final NodeIdentifier argument, final ContainerSchemaNode node) { - StringBuilder builder = new StringBuilder(); - builder.append("/"); - QName nodeType = argument.getNodeType(); - builder.append(this.toRestconfIdentifier(nodeType)); - return builder.toString(); + return "/" + this.toRestconfIdentifier(argument.getNodeType()); } private CharSequence convertToRestconfIdentifier(final NodeIdentifierWithPredicates argument, @@ -890,9 +841,9 @@ public class ControllerContext implements SchemaContextListener { final Map keyValues = argument.getKeyValues(); StringBuilder builder = new StringBuilder(); - builder.append("/"); + builder.append('/'); builder.append(nodeIdentifier); - builder.append("/"); + builder.append('/'); List keyDefinition = node.getKeyDefinition(); boolean hasElements = false; @@ -900,7 +851,7 @@ public class ControllerContext implements SchemaContextListener { if (!hasElements) { hasElements = true; } else { - builder.append("/"); + builder.append('/'); } try { diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestCodec.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestCodec.java index d61ccfdacf..665fafacc8 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestCodec.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestCodec.java @@ -244,7 +244,7 @@ public class RestCodec { for (int i = 0; i < identities.size(); i++) { IdentityValue identityValue = identities.get(i); URI validNamespace = resolveValidNamespace(identityValue.getNamespace(), mountPoint); - DataSchemaNode node = ControllerContext.getInstance().findInstanceDataChildByNameAndNamespace( + DataSchemaNode node = ControllerContext.findInstanceDataChildByNameAndNamespace( parentContainer, identityValue.getValue(), validNamespace); if (node == null) { logger.info("'{}' node was not found in {}", identityValue, parentContainer.getChildNodes()); @@ -271,7 +271,7 @@ public class RestCodec { Map predicatesMap = new HashMap<>(); for (Predicate predicate : identityValue.getPredicates()) { validNamespace = resolveValidNamespace(predicate.getName().getNamespace(), mountPoint); - DataSchemaNode listKey = ControllerContext.getInstance() + DataSchemaNode listKey = ControllerContext .findInstanceDataChildByNameAndNamespace(listNode, predicate.getName().getValue(), validNamespace); predicatesMap.put(listKey.getQName(), predicate.getValue()); @@ -286,7 +286,7 @@ public class RestCodec { } result.add(pathArgument); if (i < identities.size() - 1) { // last element in instance-identifier can be other than - // DataNodeContainer + // DataNodeContainer if (node instanceof DataNodeContainer) { parentContainer = (DataNodeContainer) node; } else { diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java index 5cb3cc2bae..73ca02c505 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java @@ -15,6 +15,7 @@ import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; + import java.net.URI; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -32,6 +33,7 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriInfo; + import org.apache.commons.lang3.StringUtils; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; @@ -60,12 +62,8 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.composite.node.schema.cnsn.parser.CnSnToNormalizedNodeParserFactory; -import org.opendaylight.yangtools.yang.data.composite.node.schema.cnsn.serializer.CnSnFromNormalizedNodeSerializerFactory; import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode; import org.opendaylight.yangtools.yang.data.impl.NodeFactory; import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode; @@ -358,31 +356,31 @@ public class RestconfImpl implements RestconfService { private CompositeNode toStreamCompositeNode(final String streamName, final DataSchemaNode streamSchemaNode) { final List> streamNodeValues = new ArrayList>(); - List instanceDataChildrenByName = this.controllerContext.findInstanceDataChildrenByName( + List instanceDataChildrenByName = ControllerContext.findInstanceDataChildrenByName( ((DataNodeContainer) streamSchemaNode), "name"); final DataSchemaNode nameSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); streamNodeValues - .add(NodeFactory. createImmutableSimpleNode(nameSchemaNode.getQName(), null, streamName)); + .add(NodeFactory. createImmutableSimpleNode(nameSchemaNode.getQName(), null, streamName)); - instanceDataChildrenByName = this.controllerContext.findInstanceDataChildrenByName( + instanceDataChildrenByName = ControllerContext.findInstanceDataChildrenByName( ((DataNodeContainer) streamSchemaNode), "description"); final DataSchemaNode descriptionSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); streamNodeValues.add(NodeFactory. createImmutableSimpleNode(descriptionSchemaNode.getQName(), null, "DESCRIPTION_PLACEHOLDER")); - instanceDataChildrenByName = this.controllerContext.findInstanceDataChildrenByName( + instanceDataChildrenByName = ControllerContext.findInstanceDataChildrenByName( ((DataNodeContainer) streamSchemaNode), "replay-support"); final DataSchemaNode replaySupportSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); streamNodeValues.add(NodeFactory. createImmutableSimpleNode(replaySupportSchemaNode.getQName(), null, Boolean.valueOf(true))); - instanceDataChildrenByName = this.controllerContext.findInstanceDataChildrenByName( + instanceDataChildrenByName = ControllerContext.findInstanceDataChildrenByName( ((DataNodeContainer) streamSchemaNode), "replay-log-creation-time"); final DataSchemaNode replayLogCreationTimeSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); streamNodeValues.add(NodeFactory. createImmutableSimpleNode(replayLogCreationTimeSchemaNode.getQName(), null, "")); - instanceDataChildrenByName = this.controllerContext.findInstanceDataChildrenByName( + instanceDataChildrenByName = ControllerContext.findInstanceDataChildrenByName( ((DataNodeContainer) streamSchemaNode), "events"); final DataSchemaNode eventsSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); streamNodeValues.add(NodeFactory. createImmutableSimpleNode(eventsSchemaNode.getQName(), null, "")); @@ -392,26 +390,26 @@ public class RestconfImpl implements RestconfService { private CompositeNode toModuleCompositeNode(final Module module, final DataSchemaNode moduleSchemaNode) { final List> moduleNodeValues = new ArrayList>(); - List instanceDataChildrenByName = this.controllerContext.findInstanceDataChildrenByName( + List instanceDataChildrenByName = ControllerContext.findInstanceDataChildrenByName( ((DataNodeContainer) moduleSchemaNode), "name"); final DataSchemaNode nameSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); moduleNodeValues.add(NodeFactory. createImmutableSimpleNode(nameSchemaNode.getQName(), null, module.getName())); - instanceDataChildrenByName = this.controllerContext.findInstanceDataChildrenByName( + instanceDataChildrenByName = ControllerContext.findInstanceDataChildrenByName( ((DataNodeContainer) moduleSchemaNode), "revision"); final DataSchemaNode revisionSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); Date _revision = module.getRevision(); moduleNodeValues.add(NodeFactory. createImmutableSimpleNode(revisionSchemaNode.getQName(), null, REVISION_FORMAT.format(_revision))); - instanceDataChildrenByName = this.controllerContext.findInstanceDataChildrenByName( + instanceDataChildrenByName = ControllerContext.findInstanceDataChildrenByName( ((DataNodeContainer) moduleSchemaNode), "namespace"); final DataSchemaNode namespaceSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); moduleNodeValues.add(NodeFactory. createImmutableSimpleNode(namespaceSchemaNode.getQName(), null, module.getNamespace().toString())); - instanceDataChildrenByName = this.controllerContext.findInstanceDataChildrenByName( + instanceDataChildrenByName = ControllerContext.findInstanceDataChildrenByName( ((DataNodeContainer) moduleSchemaNode), "feature"); final DataSchemaNode featureSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); for (final FeatureDefinition feature : module.getFeatures()) { @@ -830,7 +828,7 @@ public class RestconfImpl implements RestconfService { } String payloadName = this.getName(payload); - final DataSchemaNode schemaNode = this.controllerContext.findInstanceDataChildByNameAndNamespace( + final DataSchemaNode schemaNode = ControllerContext.findInstanceDataChildByNameAndNamespace( parentSchema, payloadName, module.getNamespace()); value = this.normalizeNode(payload, schemaNode, mountPoint); @@ -878,7 +876,7 @@ public class RestconfImpl implements RestconfService { } String payloadName = this.getName(payload); - final DataSchemaNode schemaNode = this.controllerContext.findInstanceDataChildByNameAndNamespace(module, + final DataSchemaNode schemaNode = ControllerContext.findInstanceDataChildByNameAndNamespace(module, payloadName, module.getNamespace()); final CompositeNode value = this.normalizeNode(payload, schemaNode, null); final InstanceIdWithSchemaNode iiWithData = this.addLastIdentifierFromData(null, value, schemaNode); @@ -1102,10 +1100,10 @@ public class RestconfImpl implements RestconfService { private boolean representsMountPointRootData(final Node data) { URI namespace = this.namespace(data); return (SchemaContext.NAME.getNamespace().equals(namespace) /* - * || MOUNT_POINT_MODULE_NAME .equals( namespace . - * toString( ) ) - */) - && SchemaContext.NAME.getLocalName().equals(this.localName(data)); + * || MOUNT_POINT_MODULE_NAME .equals( namespace . + * toString( ) ) + */) + && SchemaContext.NAME.getLocalName().equals(this.localName(data)); } private String addMountPointIdentifier(final String identifier) { @@ -1239,7 +1237,7 @@ public class RestconfImpl implements RestconfService { final List> children = compositeNodeBuilder.getValues(); checkNodeMultiplicityAccordingToSchema(schema, children); for (final NodeWrapper child : children) { - final List potentialSchemaNodes = this.controllerContext.findInstanceDataChildrenByName( + final List potentialSchemaNodes = ControllerContext.findInstanceDataChildrenByName( schema, child.getLocalName()); if (potentialSchemaNodes.size() > 1 && child.getNamespace() == null) { @@ -1334,15 +1332,16 @@ public class RestconfImpl implements RestconfService { } if (nodeBuilder.getNamespace() == null || Objects.equal(nodeBuilder.getNamespace(), validQName.getNamespace()) - || Objects.equal(nodeBuilder.getNamespace().toString(), moduleName) /* - * || Note : this check is wrong - - * can never be true as it compares - * a URI with a String not sure what - * the intention is so commented out - * ... Objects . equal ( nodeBuilder - * . getNamespace ( ) , - * MOUNT_POINT_MODULE_NAME ) - */) { + || Objects.equal(nodeBuilder.getNamespace().toString(), moduleName)) { + /* + * || Note : this check is wrong - + * can never be true as it compares + * a URI with a String not sure what + * the intention is so commented out + * ... Objects . equal ( nodeBuilder + * . getNamespace ( ) , + * MOUNT_POINT_MODULE_NAME ) + */ nodeBuilder.setQname(validQName); } @@ -1411,25 +1410,15 @@ public class RestconfImpl implements RestconfService { } private CompositeNode datastoreNormalizedNodeToCompositeNode(final NormalizedNode dataNode, final DataSchemaNode schema) { - Iterable> nodes = null; + Node nodes = null; if (dataNode == null) { throw new RestconfDocumentedException(new RestconfError(ErrorType.APPLICATION, ErrorTag.DATA_MISSING, "No data was found.")); } - if (schema instanceof ContainerSchemaNode && dataNode instanceof ContainerNode) { - nodes = CnSnFromNormalizedNodeSerializerFactory.getInstance().getContainerNodeSerializer() - .serialize((ContainerSchemaNode) schema, (ContainerNode) dataNode); - } else if (schema instanceof ListSchemaNode && dataNode instanceof MapNode) { - nodes = CnSnFromNormalizedNodeSerializerFactory.getInstance().getMapNodeSerializer() - .serialize((ListSchemaNode) schema, (MapNode) dataNode); - } else if (schema instanceof ListSchemaNode && dataNode instanceof MapEntryNode) { - nodes = CnSnFromNormalizedNodeSerializerFactory.getInstance().getMapEntryNodeSerializer() - .serialize((ListSchemaNode) schema, (MapEntryNode) dataNode); - } + nodes = DataNormalizer.toLegacy(dataNode); if (nodes != null) { - if (nodes.iterator().hasNext()) { - Node nodeOldStruct = nodes.iterator().next(); - return (CompositeNode) nodeOldStruct; + if (nodes instanceof CompositeNode) { + return (CompositeNode) nodes; } else { LOG.error("The node " + dataNode.getNodeType() + " couldn't be transformed to compositenode."); } diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetOperationTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetOperationTest.java index e9d94b1184..539248a147 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetOperationTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetOperationTest.java @@ -64,15 +64,11 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.util.CompositeNodeBuilder; import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; @@ -675,9 +671,7 @@ public class RestGetOperationTest extends JerseyTest { } private NormalizedNode prepareCnDataForSlashesBehindMountPointTest() throws ParseException { - CollectionNodeBuilder lst1 = ImmutableMapNodeBuilder.create(); - lst1.withNodeIdentifier(TestUtils.getNodeIdentifier("lst1", "test:module", "2014-01-09")); - lst1.withChild(ImmutableMapEntryNodeBuilder + return ImmutableMapEntryNodeBuilder .create() .withNodeIdentifier( TestUtils.getNodeIdentifierPredicate("lst1", "test:module", "2014-01-09", "lf11", @@ -685,9 +679,8 @@ public class RestGetOperationTest extends JerseyTest { .withChild( ImmutableLeafNodeBuilder.create() .withNodeIdentifier(TestUtils.getNodeIdentifier("lf11", "test:module", "2014-01-09")) - .withValue("GigabitEthernet0/0/0/0").build()).build()); + .withValue("GigabitEthernet0/0/0/0").build()).build(); - return lst1.build(); } /** diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java index 562cac0bcf..c2b153f02b 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java @@ -62,15 +62,12 @@ import org.opendaylight.yangtools.yang.data.api.CompositeNode; import org.opendaylight.yangtools.yang.data.api.Node; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.composite.node.schema.cnsn.parser.CnSnToNormalizedNodeParserFactory; import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.util.CompositeNodeBuilder; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; @@ -407,9 +404,7 @@ public final class TestUtils { static NormalizedNode prepareNormalizedNodeWithIetfInterfacesInterfacesData() throws ParseException { String ietfInterfacesDate = "2013-07-04"; - CollectionNodeBuilder intface = ImmutableMapNodeBuilder.create(); String namespace = "urn:ietf:params:xml:ns:yang:ietf-interfaces"; - intface.withNodeIdentifier(getNodeIdentifier("interface", namespace, ietfInterfacesDate)); DataContainerNodeAttrBuilder mapEntryNode = ImmutableMapEntryNodeBuilder.create(); Map predicates = new HashMap<>(); @@ -431,8 +426,6 @@ public final class TestUtils { .withNodeIdentifier(getNodeIdentifier("description", namespace, ietfInterfacesDate)) .withValue("some interface").build()); - intface.withChild(mapEntryNode.build()); - - return intface.build(); + return mapEntryNode.build(); } } diff --git a/opendaylight/md-sal/topology-lldp-discovery/pom.xml b/opendaylight/md-sal/topology-lldp-discovery/pom.xml index 2c8571ca64..e01a0d5dcb 100644 --- a/opendaylight/md-sal/topology-lldp-discovery/pom.xml +++ b/opendaylight/md-sal/topology-lldp-discovery/pom.xml @@ -45,10 +45,6 @@ org.opendaylight.controller.model model-flow-base - - org.opendaylight.controller.model - model-flow-management - org.opendaylight.controller.model model-flow-service diff --git a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPusher.java b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPusher.java index eddad8b4c7..fff8d611b7 100644 --- a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPusher.java +++ b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPusher.java @@ -65,9 +65,11 @@ public class ConfigPusher { LinkedHashMap result = new LinkedHashMap<>(); // start pushing snapshots: for (ConfigSnapshotHolder configSnapshotHolder : configs) { - EditAndCommitResponse editAndCommitResponseWithRetries = pushConfigWithConflictingVersionRetries(configSnapshotHolder); - logger.debug("Config snapshot pushed successfully: {}, result: {}", configSnapshotHolder, result); - result.put(configSnapshotHolder, editAndCommitResponseWithRetries); + if(configSnapshotHolder != null) { + EditAndCommitResponse editAndCommitResponseWithRetries = pushConfigWithConflictingVersionRetries(configSnapshotHolder); + logger.debug("Config snapshot pushed successfully: {}, result: {}", configSnapshotHolder, result); + result.put(configSnapshotHolder, editAndCommitResponseWithRetries); + } } logger.debug("All configuration snapshots have been pushed successfully."); return result; diff --git a/opendaylight/netconf/netconf-cli/pom.xml b/opendaylight/netconf/netconf-cli/pom.xml index cd7a1aacf2..55a8715000 100644 --- a/opendaylight/netconf/netconf-cli/pom.xml +++ b/opendaylight/netconf/netconf-cli/pom.xml @@ -52,12 +52,10 @@ org.opendaylight.yangtools yang-data-impl - org.opendaylight.yangtools - yang-data-json - 0.6.2-SNAPSHOT + yang-data-composite-node org.opendaylight.yangtools diff --git a/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/writer/impl/NormalizedNodeWriter.java b/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/writer/impl/NormalizedNodeWriter.java index c101db9ef8..ef29a76fff 100644 --- a/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/writer/impl/NormalizedNodeWriter.java +++ b/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/writer/impl/NormalizedNodeWriter.java @@ -18,7 +18,7 @@ import org.opendaylight.yangtools.yang.data.api.Node; import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; import org.opendaylight.yangtools.yang.data.impl.schema.transform.base.serializer.NodeSerializerDispatcher; import org.opendaylight.yangtools.yang.data.impl.schema.transform.dom.DomUtils; -import org.opendaylight.yangtools.yang.data.json.schema.cnsn.parser.CnSnToNormalizedNodeParserFactory; +import org.opendaylight.yangtools.yang.data.composite.node.schema.cnsn.parser.CnSnToNormalizedNodeParserFactory; import org.opendaylight.yangtools.yang.model.api.AugmentationSchema; import org.opendaylight.yangtools.yang.model.api.ChoiceNode; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; diff --git a/opendaylight/netconf/netconf-it/pom.xml b/opendaylight/netconf/netconf-it/pom.xml index 0e9589d2d2..272b686fc0 100644 --- a/opendaylight/netconf/netconf-it/pom.xml +++ b/opendaylight/netconf/netconf-it/pom.xml @@ -143,34 +143,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - 1 - false - false - - - - default-test - - true - - - - integration-tests - - test - - integration-test - - false - -Dlogback.configurationFile=${maven.test.dest}/logback.xml - - - - org.ops4j.pax.exam maven-paxexam-plugin