From: Tony Tkacik Date: Fri, 1 Aug 2014 07:54:59 +0000 (+0000) Subject: Merge "BUG-190 Simplify reconnect logic in protocol-framework." X-Git-Tag: release/helium~379 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=0eb621d29daaf08979c356e2148e99c48458e169;hp=1d364bf55905f619173d65a4823c6d594c5f29fe Merge "BUG-190 Simplify reconnect logic in protocol-framework." --- diff --git a/features/config/src/main/resources/features.xml b/features/config/src/main/resources/features.xml index e18f844622..de5b198173 100644 --- a/features/config/src/main/resources/features.xml +++ b/features/config/src/main/resources/features.xml @@ -16,7 +16,7 @@ mvn:org.opendaylight.controller/shutdown-api/${project.version} mvn:org.opendaylight.controller/shutdown-impl/${project.version} mvn:org.osgi/org.osgi.core/${osgi.core.version} - wrap:mvn:com.google.guava/guava/${guava.version} + mvn:com.google.guava/guava/${guava.version} mvn:org.javassist/javassist/${javassist.version} diff --git a/features/nsf/pom.xml b/features/nsf/pom.xml new file mode 100644 index 0000000000..224aef1dac --- /dev/null +++ b/features/nsf/pom.xml @@ -0,0 +1,62 @@ + + + 4.0.0 + + org.opendaylight.controller + commons.opendaylight + 1.4.2-SNAPSHOT + ../../opendaylight/commons/opendaylight + + features-nsf + pom + OpenDaylight :: Features :: Network Service Functions + Feature for Network Service Functions + + features.xml + + + + + true + src/main/resources + + + + + org.apache.maven.plugins + maven-resources-plugin + + + filter + + resources + + generate-resources + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${features.file} + xml + features + + + + + + + + + diff --git a/features/nsf/src/main/resources/features.xml b/features/nsf/src/main/resources/features.xml new file mode 100644 index 0000000000..fb61f33fb3 --- /dev/null +++ b/features/nsf/src/main/resources/features.xml @@ -0,0 +1,73 @@ + + + + odl-adsal-all + odl-nsf-managers + odl-adsal-northbound + + + + + base-all + odl-adsal-all + mvn:org.opendaylight.controller/usermanager/${usermanager.version} + mvn:org.opendaylight.controller/usermanager.implementation/${usermanager.version} + + mvn:org.opendaylight.controller/appauth/${appauth.version} + + mvn:org.opendaylight.controller/connectionmanager/${connectionmanager.version} + mvn:org.opendaylight.controller/connectionmanager.implementation/${connectionmanager.version} + + mvn:org.opendaylight.controller/containermanager/${containermanager.version} + mvn:org.opendaylight.controller/containermanager.implementation/${containermanager.version} + + mvn:org.opendaylight.controller/statisticsmanager/${statisticsmanager.version} + mvn:org.opendaylight.controller/statisticsmanager.implementation/${statisticsmanager.implementation.version} + + mvn:org.opendaylight.controller/switchmanager/${switchmanager.api.version} + mvn:org.opendaylight.controller/switchmanager.implementation/${switchmanager.implementation.version} + + mvn:org.opendaylight.controller/forwardingrulesmanager/${forwardingrulesmanager.version} + mvn:org.opendaylight.controller/forwardingrulesmanager.implementation/${forwardingrulesmanager.implementation.version} + + mvn:org.opendaylight.controller/topologymanager/${topologymanager.version} + + mvn:org.opendaylight.controller/networkconfig.neutron/${networkconfig.neutron.version} + mvn:org.opendaylight.controller/networkconfig.neutron.implementation/${networkconfig.neutron.implementation.version} + + mvn:org.opendaylight.controller/hosttracker/${hosttracker.api.version} + mvn:org.opendaylight.controller/hosttracker.implementation/${hosttracker.implementation.version} + + mvn:org.opendaylight.controller/forwarding.staticrouting + + mvn:org.opendaylight.controller.thirdparty/net.sf.jung2/2.0.1 + mvn:org.opendaylight.controller/routing.dijkstra_implementation + + + + base-all + odl-nsf-managers + mvn:org.ow2.asm/asm-all/${asm.version} + + mvn:org.opendaylight.controller/bundlescanner/${bundlescanner.api.version} + mvn:org.opendaylight.controller/bundlescanner.implementation/${bundlescanner.implementation.version} + mvn:org.opendaylight.controller/commons.northbound/${northbound.commons.version} + mvn:org.opendaylight.controller/flowprogrammer.northbound/${flowprogrammer.northbound.version} + mvn:org.opendaylight.controller/hosttracker.northbound/${hosttracker.northbound.version} + mvn:org.opendaylight.controller/networkconfig.bridgedomain.northbound/${networkconfig.bridgedomain.northbound.version} + mvn:org.opendaylight.controller/networkconfig.neutron.northbound/${networkconfig.neutron.northbound.version} + mvn:org.opendaylight.controller/forwarding.staticrouting.northbound/${forwarding.staticrouting.northbound.version} + mvn:org.opendaylight.controller/statistics.northbound/${statistics.northbound.version} + mvn:org.opendaylight.controller/subnets.northbound/${subnets.northbound.version} + mvn:org.opendaylight.controller/switchmanager.northbound/${switchmanager.northbound.version} + mvn:org.opendaylight.controller/topology.northbound/${topology.northbound.version} + mvn:org.opendaylight.controller/usermanager.northbound/${usermanager.northbound.version} + + \ No newline at end of file diff --git a/features/pom.xml b/features/pom.xml index fb40fa93b1..f69190cebd 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -13,6 +13,11 @@ 3.0 + base + controller + adsal + nsf + extras config config-persister config-netty diff --git a/opendaylight/commons/opendaylight/pom.xml b/opendaylight/commons/opendaylight/pom.xml index 163c64ed52..be88e4a505 100644 --- a/opendaylight/commons/opendaylight/pom.xml +++ b/opendaylight/commons/opendaylight/pom.xml @@ -1235,6 +1235,11 @@ sal-rest-connector ${mdsal.version} + + org.opendaylight.controller + sal-rest-connector-config + ${mdsal.version} + org.opendaylight.controller sal-rest-docgen @@ -2081,7 +2086,7 @@ true ${project.basedir} **\/*.java,**\/*.xml,**\/*.ini,**\/*.sh,**\/*.bat - **\/target\/,**\/bin\/,**\/target-ide\/,**\/${jmxGeneratorPath}\/,**\/${salGeneratorPath}\/,**\/xtend-gen\/ + **\/target\/,**\/bin\/,**\/target-ide\/,**\/${jmxGeneratorPath}\/,**\/${salGeneratorPath}\/,**\/xtend-gen\/,**\/protobuff\/ diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/controller/config/yang/protocol/framework/ReconnectImmediatelyStrategyFactoryModule.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/controller/config/yang/protocol/framework/ReconnectImmediatelyStrategyFactoryModule.java index 580a53be94..12b771df80 100644 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/controller/config/yang/protocol/framework/ReconnectImmediatelyStrategyFactoryModule.java +++ b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/controller/config/yang/protocol/framework/ReconnectImmediatelyStrategyFactoryModule.java @@ -32,14 +32,14 @@ public final class ReconnectImmediatelyStrategyFactoryModule extends org.openday @Override protected void customValidation(){ - JmxAttributeValidationException.checkNotNull(getTimeout(), "value is not set.", timeoutJmxAttribute); - JmxAttributeValidationException.checkCondition(getTimeout() >= 0, "value " + getTimeout() + " is less than 0", - timeoutJmxAttribute); + JmxAttributeValidationException.checkNotNull(getReconnectTimeout(), "value is not set.", reconnectTimeoutJmxAttribute); + JmxAttributeValidationException.checkCondition(getReconnectTimeout() >= 0, "value " + getReconnectTimeout() + " is less than 0", + reconnectTimeoutJmxAttribute); } @Override public java.lang.AutoCloseable createInstance() { - return new ReconnectImmediatelyStrategyFactoryCloseable(getExecutorDependency(), getTimeout()); + return new ReconnectImmediatelyStrategyFactoryCloseable(getReconnectExecutorDependency(), getReconnectTimeout()); } private static final class ReconnectImmediatelyStrategyFactoryCloseable implements ReconnectStrategyFactory, AutoCloseable { diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/controller/config/yang/protocol/framework/TimedReconnectStrategyFactoryModule.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/controller/config/yang/protocol/framework/TimedReconnectStrategyFactoryModule.java index b8849c7a1d..0b4a7baf6f 100644 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/controller/config/yang/protocol/framework/TimedReconnectStrategyFactoryModule.java +++ b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/controller/config/yang/protocol/framework/TimedReconnectStrategyFactoryModule.java @@ -49,7 +49,7 @@ public final class TimedReconnectStrategyFactoryModule extends org.opendaylight. @Override public java.lang.AutoCloseable createInstance() { - return new TimedReconnectStrategyFactoryCloseable(getExecutorDependency(), + return new TimedReconnectStrategyFactoryCloseable(getTimedReconnectExecutorDependency(), getConnectTime(), getMinSleep(), getSleepFactor().doubleValue(), getMaxSleep(), getMaxAttempts(), getDeadline()); } diff --git a/opendaylight/commons/protocol-framework/src/main/yang/odl-protocol-framework-cfg.yang b/opendaylight/commons/protocol-framework/src/main/yang/odl-protocol-framework-cfg.yang index 1856369178..cd84d4a95e 100644 --- a/opendaylight/commons/protocol-framework/src/main/yang/odl-protocol-framework-cfg.yang +++ b/opendaylight/commons/protocol-framework/src/main/yang/odl-protocol-framework-cfg.yang @@ -77,12 +77,12 @@ module protocol-framework { case reconnect-immediately-strategy-factory { when "/config:modules/config:module/config:type = 'reconnect-immediately-strategy-factory'"; - leaf timeout { + leaf reconnect-timeout { mandatory true; type int32; } - container executor { + container reconnect-executor { uses config:service-ref { refine type { mandatory true; @@ -138,7 +138,7 @@ module protocol-framework { units "milliseconds"; } - container executor { + container timed-reconnect-executor { uses config:service-ref { refine type { mandatory true; diff --git a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/controller/config/yang/protocol/framework/ReconnectImmediatelyStrategyModuleTest.java b/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/controller/config/yang/protocol/framework/ReconnectImmediatelyStrategyModuleTest.java index 9beadc4dbb..cfdf3bff28 100644 --- a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/controller/config/yang/protocol/framework/ReconnectImmediatelyStrategyModuleTest.java +++ b/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/controller/config/yang/protocol/framework/ReconnectImmediatelyStrategyModuleTest.java @@ -78,7 +78,7 @@ public class ReconnectImmediatelyStrategyModuleTest extends AbstractConfigTest { final ReconnectImmediatelyStrategyFactoryModuleMXBean mxBean = transaction.newMBeanProxy( transaction.lookupConfigBean(FACTORY_NAME, INSTANCE_NAME), ReconnectImmediatelyStrategyFactoryModuleMXBean.class); - mxBean.setTimeout(200); + mxBean.setReconnectTimeout(200); final CommitStatus status = transaction.commit(); assertBeanCount(1, FACTORY_NAME); assertStatus(status, 0, 1, 1); @@ -99,8 +99,8 @@ public class ReconnectImmediatelyStrategyModuleTest extends AbstractConfigTest { final ObjectName nameCreated = transaction.createModule(FACTORY_NAME, INSTANCE_NAME); final ReconnectImmediatelyStrategyFactoryModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated, ReconnectImmediatelyStrategyFactoryModuleMXBean.class); - mxBean.setTimeout(timeout); - mxBean.setExecutor(GlobalEventExecutorUtil.create(transaction)); + mxBean.setReconnectTimeout(timeout); + mxBean.setReconnectExecutor(GlobalEventExecutorUtil.create(transaction)); return nameCreated; } diff --git a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/controller/config/yang/protocol/framework/TimedReconnectStrategyModuleTest.java b/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/controller/config/yang/protocol/framework/TimedReconnectStrategyModuleTest.java index a8cdff7119..1c068a98e7 100644 --- a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/controller/config/yang/protocol/framework/TimedReconnectStrategyModuleTest.java +++ b/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/controller/config/yang/protocol/framework/TimedReconnectStrategyModuleTest.java @@ -7,6 +7,13 @@ */ package org.opendaylight.controller.config.yang.protocol.framework; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.math.BigDecimal; +import javax.management.InstanceAlreadyExistsException; +import javax.management.ObjectName; import org.junit.Before; import org.junit.Test; import org.opendaylight.controller.config.api.ConflictingVersionException; @@ -17,14 +24,6 @@ import org.opendaylight.controller.config.manager.impl.factoriesresolver.Hardcod import org.opendaylight.controller.config.util.ConfigTransactionJMXClient; import org.opendaylight.controller.config.yang.netty.eventexecutor.GlobalEventExecutorModuleFactory; -import javax.management.InstanceAlreadyExistsException; -import javax.management.ObjectName; -import java.math.BigDecimal; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - public class TimedReconnectStrategyModuleTest extends AbstractConfigTest { private static final String INSTANCE_NAME = "timed-reconect-stategy-facotry-impl"; @@ -158,7 +157,7 @@ public class TimedReconnectStrategyModuleTest extends AbstractConfigTest { mxBean.setMaxSleep(maxSleep); mxBean.setMinSleep(minSleep); mxBean.setSleepFactor(sleepFactor); - mxBean.setExecutor(GlobalEventExecutorUtil.create(transaction)); + mxBean.setTimedReconnectExecutor(GlobalEventExecutorUtil.create(transaction)); return nameCreated; } diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/JMXGeneratorTest.java b/opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/JMXGeneratorTest.java index 0fd9720f79..864ebdf954 100644 --- a/opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/JMXGeneratorTest.java +++ b/opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/JMXGeneratorTest.java @@ -7,12 +7,40 @@ */ package org.opendaylight.controller.config.yangjmxgenerator.plugin; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.matchers.JUnitMatchers.containsString; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; + import com.google.common.base.Predicate; import com.google.common.collect.Collections2; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.google.common.io.Files; +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; import org.apache.commons.io.FileUtils; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; @@ -46,35 +74,6 @@ import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import java.io.File; -import java.io.IOException; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.fail; -import static org.junit.matchers.JUnitMatchers.containsString; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doReturn; - //TODO: refactor public class JMXGeneratorTest extends AbstractGeneratorTest { @@ -85,7 +84,7 @@ public class JMXGeneratorTest extends AbstractGeneratorTest { File generatedResourcesDir; private static final List expectedModuleFileNames = ServiceInterfaceEntryTest - .toFileNames("[AbstractAsyncEventBusModule.java, AbstractAsyncEventBusModuleFactory.java, AbstractDynamicThreadPoolModule.java, AbstractDynamicThreadPoolModuleFactory.java, AbstractEventBusModule.java, AbstractEventBusModuleFactory.java, AbstractNamingThreadFactoryModule.java, AbstractNamingThreadFactoryModuleFactory.java, AbstractThreadPoolRegistryImplModule.java, AbstractThreadPoolRegistryImplModuleFactory.java, AsyncEventBusModule.java, AsyncEventBusModuleFactory.java, AsyncEventBusModuleMXBean.java, AsyncEventBusRuntimeMXBean.java, AsyncEventBusRuntimeRegistration.java, AsyncEventBusRuntimeRegistrator.java, DynamicThreadPoolModule.java, DynamicThreadPoolModuleFactory.java, DynamicThreadPoolModuleMXBean.java, DynamicThreadPoolRuntimeMXBean.java, DynamicThreadPoolRuntimeRegistration.java, DynamicThreadPoolRuntimeRegistrator.java, EventBusModule.java, EventBusModuleFactory.java, EventBusModuleMXBean.java, EventRuntimeMXBean.java, EventRuntimeRegistration.java, InnerStreamList.java, NamingThreadFactoryModule.java, NamingThreadFactoryModuleFactory.java, NamingThreadFactoryModuleMXBean.java, NamingThreadFactoryRuntimeMXBean.java, NamingThreadFactoryRuntimeRegistration.java, NamingThreadFactoryRuntimeRegistrator.java, Peer.java, StreamRuntimeMXBean.java, StreamRuntimeRegistration.java, ThreadPoolRegistryImplModule.java, ThreadPoolRegistryImplModuleFactory.java, ThreadPoolRegistryImplModuleMXBean.java, ThreadRuntimeMXBean.java, ThreadRuntimeRegistration.java, ThreadStreamRuntimeMXBean.java, ThreadStreamRuntimeRegistration.java]"); + .toFileNames("[AbstractAsyncEventBusModule.java, AbstractAsyncEventBusModuleFactory.java, AbstractDynamicThreadPoolModule.java, AbstractDynamicThreadPoolModuleFactory.java, AbstractEventBusModule.java, AbstractEventBusModuleFactory.java, AbstractNamingThreadFactoryModule.java, AbstractNamingThreadFactoryModuleFactory.java, AbstractThreadPoolRegistryImplModule.java, AbstractThreadPoolRegistryImplModuleFactory.java, AsyncEventBusModule.java, AsyncEventBusModuleFactory.java, AsyncEventBusModuleMXBean.java, AsyncEventBusRuntimeMXBean.java, AsyncEventBusRuntimeRegistration.java, AsyncEventBusRuntimeRegistrator.java, DynamicThreadPoolModule.java, DynamicThreadPoolModuleFactory.java, DynamicThreadPoolModuleMXBean.java, DynamicThreadPoolRuntimeMXBean.java, DynamicThreadPoolRuntimeRegistration.java, DynamicThreadPoolRuntimeRegistrator.java, EventBusModule.java, EventBusModuleFactory.java, EventBusModuleMXBean.java, EventRuntimeMXBean.java, EventRuntimeRegistration.java, FromGrouping.java, InnerStreamList.java, NamingThreadFactoryModule.java, NamingThreadFactoryModuleFactory.java, NamingThreadFactoryModuleMXBean.java, NamingThreadFactoryRuntimeMXBean.java, NamingThreadFactoryRuntimeRegistration.java, NamingThreadFactoryRuntimeRegistrator.java, Peer.java, StreamRuntimeMXBean.java, StreamRuntimeRegistration.java, ThreadPoolRegistryImplModule.java, ThreadPoolRegistryImplModuleFactory.java, ThreadPoolRegistryImplModuleMXBean.java, ThreadRuntimeMXBean.java, ThreadRuntimeRegistration.java, ThreadStreamRuntimeMXBean.java, ThreadStreamRuntimeRegistration.java]"); private static final List expectedBGPNames = ServiceInterfaceEntryTest .toFileNames("[AbstractBgpListenerImplModule.java, " + "AbstractBgpListenerImplModuleFactory.java, " + @@ -108,7 +107,7 @@ public class JMXGeneratorTest extends AbstractGeneratorTest { "NetconfTestFiles1ImplModuleMXBean.java, NetconfTestFiles1ImplRuntimeMXBean.java, " + "NetconfTestFiles1ImplRuntimeRegistration.java, NetconfTestFiles1ImplRuntimeRegistrator.java, TestFileImplModule.java, TestFileImplModuleFactory.java, TestFileImplModuleMXBean.java, TestFileImplRuntimeMXBean.java, TestFileImplRuntimeRegistration.java, TestFileImplRuntimeRegistrator.java, TestFiles1ImplModule.java, TestFiles1ImplModuleFactory.java, TestFiles1ImplModuleMXBean.java, TestFiles1ImplRuntimeMXBean.java, TestFiles1ImplRuntimeRegistration.java, TestFiles1ImplRuntimeRegistrator.java]"); private static final List expectedAllFileNames = ServiceInterfaceEntryTest - .toFileNames("[AbstractAsyncEventBusModule.java, AbstractAsyncEventBusModuleFactory.java, AbstractBgpListenerImplModule.java, AbstractBgpListenerImplModuleFactory.java, AbstractDynamicThreadPoolModule.java, AbstractDynamicThreadPoolModuleFactory.java, AbstractEventBusModule.java, AbstractEventBusModuleFactory.java, AbstractNamingThreadFactoryModule.java, AbstractNamingThreadFactoryModuleFactory.java, AbstractNetconfTestFileImplModule.java, AbstractNetconfTestFileImplModuleFactory.java, AbstractNetconfTestFiles1ImplModule.java, AbstractNetconfTestFiles1ImplModuleFactory.java, AbstractNetconfTestImplModule.java, AbstractNetconfTestImplModuleFactory.java, AbstractTestFileImplModule.java, AbstractTestFileImplModuleFactory.java, AbstractTestFiles1ImplModule.java, AbstractTestFiles1ImplModuleFactory.java, AbstractTestImplModule.java, AbstractTestImplModuleFactory.java, AbstractThreadPoolRegistryImplModule.java, AbstractThreadPoolRegistryImplModuleFactory.java, AsyncEventBusModule.java, AsyncEventBusModuleFactory.java, AsyncEventBusModuleMXBean.java, AsyncEventBusRuntimeMXBean.java, AsyncEventBusRuntimeRegistration.java, AsyncEventBusRuntimeRegistrator.java, AutoCloseableServiceInterface.java, BgpListenerImplModule.java, BgpListenerImplModuleFactory.java, BgpListenerImplModuleMXBean.java, BgpListenerImplRuntimeMXBean.java, BgpListenerImplRuntimeRegistration.java, BgpListenerImplRuntimeRegistrator.java, ComplexDtoBInner.java, ComplexList.java, Deep.java, DtoA.java, DtoA.java, DtoA.java, DtoA1.java, DtoAInner.java, DtoAInnerInner.java, DtoB.java, DtoC.java, DynamicThreadPoolModule.java, DynamicThreadPoolModuleFactory.java, DynamicThreadPoolModuleMXBean.java, DynamicThreadPoolRuntimeMXBean.java, DynamicThreadPoolRuntimeRegistration.java, DynamicThreadPoolRuntimeRegistrator.java, EventBusModule.java, EventBusModuleFactory.java, EventBusModuleMXBean.java, EventBusServiceInterface.java, EventRuntimeMXBean.java, EventRuntimeRegistration.java, InnerStreamList.java, NamingThreadFactoryModule.java, NamingThreadFactoryModuleFactory.java, NamingThreadFactoryModuleMXBean.java, NamingThreadFactoryRuntimeMXBean.java, NamingThreadFactoryRuntimeRegistration.java, NamingThreadFactoryRuntimeRegistrator.java, NetconfTestFileImplModule.java, NetconfTestFileImplModuleFactory.java, NetconfTestFileImplModuleMXBean.java, NetconfTestFileImplRuntimeMXBean.java, NetconfTestFileImplRuntimeRegistration.java, NetconfTestFileImplRuntimeRegistrator.java, NetconfTestFiles1ImplModule.java, NetconfTestFiles1ImplModuleFactory.java, NetconfTestFiles1ImplModuleMXBean.java, NetconfTestFiles1ImplRuntimeMXBean.java, NetconfTestFiles1ImplRuntimeRegistration.java, NetconfTestFiles1ImplRuntimeRegistrator.java, NetconfTestImplModule.java, NetconfTestImplModuleFactory.java, NetconfTestImplModuleMXBean.java, NetconfTestImplRuntimeMXBean.java, NetconfTestImplRuntimeRegistration.java, NetconfTestImplRuntimeRegistrator.java, Peer.java, Peer.java, PeersRuntimeMXBean.java, PeersRuntimeRegistration.java, ScheduledThreadPoolServiceInterface.java, SimpleList.java, StreamRuntimeMXBean.java, StreamRuntimeRegistration.java, TestFileImplModule.java, TestFileImplModuleFactory.java, TestFileImplModuleMXBean.java, TestFileImplRuntimeMXBean.java, TestFileImplRuntimeRegistration.java, TestFileImplRuntimeRegistrator.java, TestFiles1ImplModule.java, TestFiles1ImplModuleFactory.java, TestFiles1ImplModuleMXBean.java, TestFiles1ImplRuntimeMXBean.java, TestFiles1ImplRuntimeRegistration.java, TestFiles1ImplRuntimeRegistrator.java, TestImplModule.java, TestImplModuleFactory.java, TestImplModuleMXBean.java, TestImplRuntimeMXBean.java, TestImplRuntimeRegistration.java, TestImplRuntimeRegistrator.java, ThreadFactoryServiceInterface.java, ThreadPoolRegistryImplModule.java, ThreadPoolRegistryImplModuleFactory.java, ThreadPoolRegistryImplModuleMXBean.java, ThreadPoolServiceInterface.java, ThreadRuntimeMXBean.java, ThreadRuntimeRegistration.java, ThreadStreamRuntimeMXBean.java, ThreadStreamRuntimeRegistration.java]"); + .toFileNames("[AbstractAsyncEventBusModule.java, AbstractAsyncEventBusModuleFactory.java, AbstractBgpListenerImplModule.java, AbstractBgpListenerImplModuleFactory.java, AbstractDynamicThreadPoolModule.java, AbstractDynamicThreadPoolModuleFactory.java, AbstractEventBusModule.java, AbstractEventBusModuleFactory.java, AbstractNamingThreadFactoryModule.java, AbstractNamingThreadFactoryModuleFactory.java, AbstractNetconfTestFileImplModule.java, AbstractNetconfTestFileImplModuleFactory.java, AbstractNetconfTestFiles1ImplModule.java, AbstractNetconfTestFiles1ImplModuleFactory.java, AbstractNetconfTestImplModule.java, AbstractNetconfTestImplModuleFactory.java, AbstractTestFileImplModule.java, AbstractTestFileImplModuleFactory.java, AbstractTestFiles1ImplModule.java, AbstractTestFiles1ImplModuleFactory.java, AbstractTestImplModule.java, AbstractTestImplModuleFactory.java, AbstractThreadPoolRegistryImplModule.java, AbstractThreadPoolRegistryImplModuleFactory.java, AsyncEventBusModule.java, AsyncEventBusModuleFactory.java, AsyncEventBusModuleMXBean.java, AsyncEventBusRuntimeMXBean.java, AsyncEventBusRuntimeRegistration.java, AsyncEventBusRuntimeRegistrator.java, AutoCloseableServiceInterface.java, BgpListenerImplModule.java, BgpListenerImplModuleFactory.java, BgpListenerImplModuleMXBean.java, BgpListenerImplRuntimeMXBean.java, BgpListenerImplRuntimeRegistration.java, BgpListenerImplRuntimeRegistrator.java, ComplexDtoBInner.java, ComplexList.java, Deep.java, DtoA.java, DtoA.java, DtoA.java, DtoA1.java, DtoAInner.java, DtoAInnerInner.java, DtoB.java, DtoC.java, DynamicThreadPoolModule.java, DynamicThreadPoolModuleFactory.java, DynamicThreadPoolModuleMXBean.java, DynamicThreadPoolRuntimeMXBean.java, DynamicThreadPoolRuntimeRegistration.java, DynamicThreadPoolRuntimeRegistrator.java, EventBusModule.java, EventBusModuleFactory.java, EventBusModuleMXBean.java, EventBusServiceInterface.java, EventRuntimeMXBean.java, EventRuntimeRegistration.java, FromGrouping.java, InnerStreamList.java, NamingThreadFactoryModule.java, NamingThreadFactoryModuleFactory.java, NamingThreadFactoryModuleMXBean.java, NamingThreadFactoryRuntimeMXBean.java, NamingThreadFactoryRuntimeRegistration.java, NamingThreadFactoryRuntimeRegistrator.java, NetconfTestFileImplModule.java, NetconfTestFileImplModuleFactory.java, NetconfTestFileImplModuleMXBean.java, NetconfTestFileImplRuntimeMXBean.java, NetconfTestFileImplRuntimeRegistration.java, NetconfTestFileImplRuntimeRegistrator.java, NetconfTestFiles1ImplModule.java, NetconfTestFiles1ImplModuleFactory.java, NetconfTestFiles1ImplModuleMXBean.java, NetconfTestFiles1ImplRuntimeMXBean.java, NetconfTestFiles1ImplRuntimeRegistration.java, NetconfTestFiles1ImplRuntimeRegistrator.java, NetconfTestImplModule.java, NetconfTestImplModuleFactory.java, NetconfTestImplModuleMXBean.java, NetconfTestImplRuntimeMXBean.java, NetconfTestImplRuntimeRegistration.java, NetconfTestImplRuntimeRegistrator.java, Peer.java, Peer.java, PeersRuntimeMXBean.java, PeersRuntimeRegistration.java, ScheduledThreadPoolServiceInterface.java, SimpleList.java, StreamRuntimeMXBean.java, StreamRuntimeRegistration.java, TestFileImplModule.java, TestFileImplModuleFactory.java, TestFileImplModuleMXBean.java, TestFileImplRuntimeMXBean.java, TestFileImplRuntimeRegistration.java, TestFileImplRuntimeRegistrator.java, TestFiles1ImplModule.java, TestFiles1ImplModuleFactory.java, TestFiles1ImplModuleMXBean.java, TestFiles1ImplRuntimeMXBean.java, TestFiles1ImplRuntimeRegistration.java, TestFiles1ImplRuntimeRegistrator.java, TestImplModule.java, TestImplModuleFactory.java, TestImplModuleMXBean.java, TestImplRuntimeMXBean.java, TestImplRuntimeRegistration.java, TestImplRuntimeRegistrator.java, ThreadFactoryServiceInterface.java, ThreadPoolRegistryImplModule.java, ThreadPoolRegistryImplModuleFactory.java, ThreadPoolRegistryImplModuleMXBean.java, ThreadPoolServiceInterface.java, ThreadRuntimeMXBean.java, ThreadRuntimeRegistration.java, ThreadStreamRuntimeMXBean.java, ThreadStreamRuntimeRegistration.java]"); private static final List expectedGenerateMBEsListNames = ServiceInterfaceEntryTest .toFileNames("[AbstractBgpListenerImplModule.java, AbstractBgpListenerImplModuleFactory.java, BgpListenerImplModule.java, BgpListenerImplModuleFactory.java, BgpListenerImplModuleMXBean.java, BgpListenerImplRuntimeMXBean.java, BgpListenerImplRuntimeRegistration.java, BgpListenerImplRuntimeRegistrator.java, PeersRuntimeMXBean.java, PeersRuntimeRegistration.java]"); @@ -506,8 +505,9 @@ public class JMXGeneratorTest extends AbstractGeneratorTest { + ".threads.java", visitor.packageName); assertEquals("AsyncEventBusModuleMXBean", visitor.type); - assertEquals("Incorrenct number of generated methods", 2, + assertEquals("Incorrenct number of generated methods", 4, visitor.methods.size()); + } private void assertAbstractDynamicThreadPoolModule(MbeASTVisitor visitor) { diff --git a/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/ModuleMXBeanEntryBuilder.java b/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/ModuleMXBeanEntryBuilder.java index 518a11540e..e9f0ac8176 100644 --- a/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/ModuleMXBeanEntryBuilder.java +++ b/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/ModuleMXBeanEntryBuilder.java @@ -38,6 +38,7 @@ import org.opendaylight.controller.config.yangjmxgenerator.attribute.ListAttribu import org.opendaylight.controller.config.yangjmxgenerator.attribute.ListDependenciesAttribute; import org.opendaylight.controller.config.yangjmxgenerator.attribute.TOAttribute; import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.NameConflictException; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServiceRef; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.AugmentationSchema; import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode; @@ -466,7 +467,7 @@ final class ModuleMXBeanEntryBuilder { private Optional extractDependency(final DataNodeContainer dataNodeContainer, final DataSchemaNode attrNode, final Module currentModule, final Map qNamesToSIEs, final SchemaContext schemaContext) { - if (dataNodeContainer.getUses().size() == 1 && getChildNodeSizeWithoutUses(dataNodeContainer) == 0) { + if (isDependencyContainer(dataNodeContainer)) { // reference UsesNode usesNode = dataNodeContainer.getUses().iterator().next(); checkState(usesNode.getRefines().size() == 1, "Unexpected 'refine' child node size of " + dataNodeContainer); @@ -493,6 +494,18 @@ final class ModuleMXBeanEntryBuilder { return Optional.absent(); } + private boolean isDependencyContainer(final DataNodeContainer dataNodeContainer) { + if(dataNodeContainer.getUses().size() != 1) { + return false; + } + UsesNode onlyUses = dataNodeContainer.getUses().iterator().next(); + if(onlyUses.getGroupingPath().getLastComponent().equals(ServiceRef.QNAME) == false) { + return false; + } + + return getChildNodeSizeWithoutUses(dataNodeContainer) == 0; + } + private int getChildNodeSizeWithoutUses(final DataNodeContainer csn) { int result = 0; for (DataSchemaNode dsn : csn.getChildNodes()) { diff --git a/opendaylight/config/yang-jmx-generator/src/test/resources/test-config-threads-java.yang b/opendaylight/config/yang-jmx-generator/src/test/resources/test-config-threads-java.yang index e189ef7d66..a6d2feaf04 100644 --- a/opendaylight/config/yang-jmx-generator/src/test/resources/test-config-threads-java.yang +++ b/opendaylight/config/yang-jmx-generator/src/test/resources/test-config-threads-java.yang @@ -56,6 +56,12 @@ module config-threads-java { } } + grouping async-eventbus-config-attrs { + leaf cfg-attr { + type string; + } + } + augment "/config:modules/config:module/config:configuration" { case async-eventbus { when "/config:modules/config:module/config:type = 'async-eventbus'"; @@ -66,6 +72,10 @@ module config-threads-java { } } } + + container from-grouping { + uses async-eventbus-config-attrs; + } } } augment "/config:modules/config:module/config:state" { diff --git a/opendaylight/distribution/opendaylight-karaf/pom.xml b/opendaylight/distribution/opendaylight-karaf/pom.xml index 06e0a92fa6..977fab1334 100644 --- a/opendaylight/distribution/opendaylight-karaf/pom.xml +++ b/opendaylight/distribution/opendaylight-karaf/pom.xml @@ -69,6 +69,8 @@ xml runtime + + org.opendaylight.controller features-adsal @@ -77,6 +79,16 @@ xml runtime + + org.opendaylight.controller + features-nsf + ${project.version} + features + xml + runtime + + + org.opendaylight.controller mdsal-features diff --git a/opendaylight/distribution/opendaylight/pom.xml b/opendaylight/distribution/opendaylight/pom.xml index d238ee75cc..541c1300f3 100644 --- a/opendaylight/distribution/opendaylight/pom.xml +++ b/opendaylight/distribution/opendaylight/pom.xml @@ -732,6 +732,27 @@ + + org.apache.maven.plugins + maven-dependency-plugin + 2.8 + + + unpack-provided-configs + + unpack-dependencies + + generate-resources + + ${project.build.directory}/configuration + sal-rest-connector-config + **\/*.xml + true + false + + + + maven-assembly-plugin 2.3 @@ -1009,6 +1030,10 @@ org.opendaylight.controller sal-rest-connector + + org.opendaylight.controller + sal-rest-connector-config + org.opendaylight.controller sal-rest-docgen @@ -1285,6 +1310,20 @@ package + + unpack-provided-configs + + unpack-dependencies + + generate-resources + + ${project.build.directory}/configuration + sal-rest-connector-config + **\/*.xml + true + false + + diff --git a/opendaylight/distribution/opendaylight/src/assemble/bin.xml b/opendaylight/distribution/opendaylight/src/assemble/bin.xml index 0ff4c9a83c..e5fc98a863 100644 --- a/opendaylight/distribution/opendaylight/src/assemble/bin.xml +++ b/opendaylight/distribution/opendaylight/src/assemble/bin.xml @@ -75,6 +75,13 @@ opendaylight/ + + ${project.build.directory}/configuration/initial + /opendaylight/configuration/initial + + **/META-INF/** + + diff --git a/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/01-md-sal.xml b/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/01-md-sal.xml index 9534094fa8..f25b7d91bd 100644 --- a/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/01-md-sal.xml +++ b/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/01-md-sal.xml @@ -72,24 +72,14 @@ --> - - + prefix:inmemory-operational-datastore-provider operational-store-service - + dom:schema-service yang-schema-service - + + diff --git a/opendaylight/md-sal/model/model-flow-statistics/src/main/yang/opendaylight-flow-statistics.yang b/opendaylight/md-sal/model/model-flow-statistics/src/main/yang/opendaylight-flow-statistics.yang index e0df924a0e..f7a0652e45 100644 --- a/opendaylight/md-sal/model/model-flow-statistics/src/main/yang/opendaylight-flow-statistics.yang +++ b/opendaylight/md-sal/model/model-flow-statistics/src/main/yang/opendaylight-flow-statistics.yang @@ -25,7 +25,6 @@ module opendaylight-flow-statistics { grouping flow-statistics { container flow-statistics { //config "false"; - uses flow-types:flow; uses stat-types:generic-statistics; } } diff --git a/opendaylight/md-sal/pom.xml b/opendaylight/md-sal/pom.xml index 1cfd5a6639..37da4d2b88 100644 --- a/opendaylight/md-sal/pom.xml +++ b/opendaylight/md-sal/pom.xml @@ -43,6 +43,7 @@ sal-connector-api sal-rest-connector + sal-rest-connector-config sal-netconf-connector inventory-manager @@ -57,14 +58,25 @@ sal-rest-docgen + sal-akka-raft + sal-inmemory-datastore sal-protocolbuffer-encoding + + sal-distributed-datastore + + + sal-dom-xsql + sal-test-model + + + sal-remoterpc-connector diff --git a/opendaylight/md-sal/sal-akka-raft/README-FIRST b/opendaylight/md-sal/sal-akka-raft/README-FIRST new file mode 100644 index 0000000000..d0be2cbcbb --- /dev/null +++ b/opendaylight/md-sal/sal-akka-raft/README-FIRST @@ -0,0 +1,28 @@ +Instructions on generating the protocol buffer Java source files + +These instructions are developers who are planning to generate the protocolbuffer java source files. + +1. We are using protocol buffer version 2.5.0 - you need to install the exact same version on your box. +The download link is https://code.google.com/p/protobuf/downloads/list. Download .tar/zip based on +your OS. + +2. Once downloaded the tar/zip and extracted follow the README instructions to compile protoc on your +machine + +3. Create your .proto (IDL) file in resources folder. Give appropriate package name so that the source + get generation in proper packages. For more information check + https://developers.google.com/protocol-buffers/docs/javatutorial + + For detailed information https://developers.google.com/protocol-buffers/docs/reference/java-generated + +4. To generate the java source files execute in sal-protocolbuffer-encoding directory + just run.sh in sal-protocolbuffer-encoding or execute the following command + + protoc --proto_path=src/main/resources --java_out=src/main/java src/main/resources/*.proto + +5. Run mvn clean install & build the .jar + +6. !!!WARNING!!! - never edit the generated sources files of protocol buffer + +7. !!!NOTE!!! if you are planning to add new .proto file option java_package should begin with + org.opendaylight.controller.protobuff.messages to properly exclude from sonar. diff --git a/opendaylight/md-sal/sal-akka-raft/pom.xml b/opendaylight/md-sal/sal-akka-raft/pom.xml index 50442bda5c..3dcc546426 100644 --- a/opendaylight/md-sal/sal-akka-raft/pom.xml +++ b/opendaylight/md-sal/sal-akka-raft/pom.xml @@ -10,6 +10,11 @@ bundle + + com.google.protobuf + protobuf-java + 2.5.0 + com.google.guava guava @@ -99,6 +104,7 @@ + org.jacoco jacoco-maven-plugin @@ -124,6 +130,15 @@ + + + org.apache.maven.plugins + maven-checkstyle-plugin + + **/protobuff/**/* + + + diff --git a/opendaylight/md-sal/sal-akka-raft/run.sh b/opendaylight/md-sal/sal-akka-raft/run.sh new file mode 100755 index 0000000000..7c588f0922 --- /dev/null +++ b/opendaylight/md-sal/sal-akka-raft/run.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +##################################################################################################### +#Instructions on generating the protocol buffer Java source files +# +#These instructions are developers who are planning to generate the protocolbuffer java source files. +# +#1. We are using protocol buffer version 2.5.0 - you need to install the exact same version on your box. +#The download link is https://code.google.com/p/protobuf/downloads/list. Download .tar/zip based on +#your OS. +# +#2. Once downloaded the tar/zip and extracted follow the README instructions to compile protoc on your +#machine +# +#3. Create your .proto (IDL) file in resources folder. Give appropriate package name so that the source +# get generation in proper packages. For more information check +# https://developers.google.com/protocol-buffers/docs/javatutorial +# +# For detailed information https://developers.google.com/protocol-buffers/docs/reference/java-generated +# +#4. To generate the java source files execute in sal-protocolbuffer-encoding execute ./run.sh i.e. this script +# or run command +# protoc --proto_path=src/main/resources --java_out=src/main/java src/main/resources/*.proto +# +#5. Run mvn clean install & build the .jar +# +#6 !!!WARNING!!!! never edit the source files generated +# +#7. !!!NOTE!!! if you are planning to add new .proto file option java_package should begin with +# 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=src/test/resources --java_out=src/test/java src/test/resources/*.proto + +echo "Done generating Java source files." + +#to remove trailing spaces in the code files +find src/main/java -type f -name '*.java' -exec sed --in-place 's/[[:space:]]\+$//' {} \+ + +find src/test/java -type f -name '*.java' -exec sed --in-place 's/[[:space:]]\+$//' {} \+ diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/ExampleActor.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/ExampleActor.java index 8d4d5e48c8..641ec0582c 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/ExampleActor.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/ExampleActor.java @@ -16,6 +16,7 @@ import org.opendaylight.controller.cluster.example.messages.KeyValueSaved; import org.opendaylight.controller.cluster.example.messages.PrintRole; import org.opendaylight.controller.cluster.example.messages.PrintState; import org.opendaylight.controller.cluster.raft.RaftActor; +import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload; import java.util.HashMap; import java.util.Map; @@ -45,10 +46,9 @@ public class ExampleActor extends RaftActor { @Override public void onReceiveCommand(Object message){ if(message instanceof KeyValue){ - if(isLeader()) { String persistId = Long.toString(persistIdentifier++); - persistData(getSender(), persistId, message); + persistData(getSender(), persistId, (Payload) message); } else { if(getLeader() != null) { getLeader().forward(message, getContext()); @@ -56,12 +56,13 @@ public class ExampleActor extends RaftActor { } } else if (message instanceof PrintState) { - LOG.debug("State of the node:"+getId() + " is="+state.size()); + LOG.debug("State of the node:"+getId() + " has = "+state.size() + " entries"); } else if (message instanceof PrintRole) { LOG.debug(getId() + " = " + getRaftState()); + } else { + super.onReceiveCommand(message); } - super.onReceiveCommand(message); } @Override protected void applyState(ActorRef clientActor, String identifier, diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/TestDriver.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/TestDriver.java index c8a7835334..c2d0b3a6b7 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/TestDriver.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/TestDriver.java @@ -14,7 +14,12 @@ import java.util.Map; import java.util.Random; import java.util.concurrent.ConcurrentHashMap; - +/** + * This is a test driver for testing akka-raft implementation + * Its uses ExampleActors and threads to push content(key-vals) to these actors + * Each ExampleActor can have one or more ClientActors. Each ClientActor spawns + * a thread and starts push logs to the actor its assignged to. + */ public class TestDriver { private static final ActorSystem actorSystem = ActorSystem.create(); diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/messages/KeyValue.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/messages/KeyValue.java index 00cc09ae30..560d5fc194 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/messages/KeyValue.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/messages/KeyValue.java @@ -8,11 +8,21 @@ package org.opendaylight.controller.cluster.example.messages; +import com.google.protobuf.GeneratedMessage; +import org.opendaylight.controller.cluster.example.protobuff.messages.KeyValueMessages; +import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload; +import org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages; + import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +public class KeyValue extends Payload implements Serializable { + private String key; + private String value; -public class KeyValue implements Serializable{ - private final String key; - private final String value; + public KeyValue() { + } public KeyValue(String key, String value){ this.key = key; @@ -27,10 +37,37 @@ public class KeyValue implements Serializable{ return value; } + public void setKey(String key) { + this.key = key; + } + + public void setValue(String value) { + this.value = value; + } + @Override public String toString() { return "KeyValue{" + "key='" + key + '\'' + ", value='" + value + '\'' + '}'; } + + // override this method to return the protobuff related extension fields and their values + @Override public Map encode() { + Map map = new HashMap<>(); + map.put(KeyValueMessages.key, getKey()); + map.put(KeyValueMessages.value, getValue()); + return map; + } + + // override this method to assign the values from protobuff + @Override public Payload decode( + AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload payloadProtoBuff) { + String key = payloadProtoBuff.getExtension(KeyValueMessages.key); + String value = payloadProtoBuff.getExtension(KeyValueMessages.value); + this.setKey(key); + this.setValue(value); + return this; + } + } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/messages/KeyValueSaved.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/messages/KeyValueSaved.java index e10e5a7b43..9b2a2e9e3b 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/messages/KeyValueSaved.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/messages/KeyValueSaved.java @@ -8,5 +8,7 @@ package org.opendaylight.controller.cluster.example.messages; -public class KeyValueSaved { +import java.io.Serializable; + +public class KeyValueSaved implements Serializable { } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/messages/PrintRole.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/messages/PrintRole.java index c9d4bfa72c..a5105f041a 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/messages/PrintRole.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/messages/PrintRole.java @@ -1,7 +1,14 @@ +/* + * 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.example.messages; -/** - * Created by kramesha on 7/17/14. - */ -public class PrintRole { +import java.io.Serializable; + +public class PrintRole implements Serializable { } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/messages/PrintState.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/messages/PrintState.java index dbf863df9a..20ed142d76 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/messages/PrintState.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/messages/PrintState.java @@ -1,7 +1,14 @@ +/* + * 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.example.messages; -/** - * Created by kramesha on 7/17/14. - */ -public class PrintState { +import java.io.Serializable; + +public class PrintState implements Serializable { } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/protobuff/messages/KeyValueMessages.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/protobuff/messages/KeyValueMessages.java new file mode 100644 index 0000000000..c3d4bbfd2b --- /dev/null +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/protobuff/messages/KeyValueMessages.java @@ -0,0 +1,73 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: KeyValueMessages.proto + +package org.opendaylight.controller.cluster.example.protobuff.messages; + +public final class KeyValueMessages { + private KeyValueMessages() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registry.add(org.opendaylight.controller.cluster.example.protobuff.messages.KeyValueMessages.key); + registry.add(org.opendaylight.controller.cluster.example.protobuff.messages.KeyValueMessages.value); + } + public static final int KEY_FIELD_NUMBER = 2; + /** + * extend .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload { ... } + */ + public static final + com.google.protobuf.GeneratedMessage.GeneratedExtension< + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload, + java.lang.String> key = com.google.protobuf.GeneratedMessage + .newFileScopedGeneratedExtension( + java.lang.String.class, + null); + public static final int VALUE_FIELD_NUMBER = 3; + /** + * extend .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload { ... } + */ + public static final + com.google.protobuf.GeneratedMessage.GeneratedExtension< + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload, + java.lang.String> value = com.google.protobuf.GeneratedMessage + .newFileScopedGeneratedExtension( + java.lang.String.class, + null); + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\026KeyValueMessages.proto\022(org.opendaylig" + + "ht.controller.cluster.raft\032\033AppendEntrie" + + "sMessages.proto:_\n\003key\022R.org.opendayligh" + + "t.controller.cluster.raft.AppendEntries." + + "ReplicatedLogEntry.Payload\030\002 \001(\t:a\n\005valu" + + "e\022R.org.opendaylight.controller.cluster." + + "raft.AppendEntries.ReplicatedLogEntry.Pa" + + "yload\030\003 \001(\tBT\n>org.opendaylight.controll" + + "er.cluster.example.protobuff.messagesB\020K" + + "eyValueMessagesH\001" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + key.internalInit(descriptor.getExtensions().get(0)); + value.internalInit(descriptor.getExtensions().get(1)); + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.getDescriptor(), + }, assigner); + } + + // @@protoc_insertion_point(outer_class_scope) +} 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 0ff2341c70..b8e9653bc5 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 @@ -19,6 +19,9 @@ import akka.persistence.SaveSnapshotSuccess; import akka.persistence.SnapshotOffer; import akka.persistence.SnapshotSelectionCriteria; import akka.persistence.UntypedPersistentActor; +import org.opendaylight.controller.cluster.raft.base.messages.ApplySnapshot; +import org.opendaylight.controller.cluster.raft.base.messages.ApplyState; +import org.opendaylight.controller.cluster.raft.base.messages.Replicate; import org.opendaylight.controller.cluster.raft.behaviors.Candidate; import org.opendaylight.controller.cluster.raft.behaviors.Follower; import org.opendaylight.controller.cluster.raft.behaviors.Leader; @@ -26,10 +29,8 @@ import org.opendaylight.controller.cluster.raft.behaviors.RaftActorBehavior; import org.opendaylight.controller.cluster.raft.client.messages.AddRaftPeer; import org.opendaylight.controller.cluster.raft.client.messages.FindLeader; import org.opendaylight.controller.cluster.raft.client.messages.FindLeaderReply; -import org.opendaylight.controller.cluster.raft.internal.messages.ApplySnapshot; import org.opendaylight.controller.cluster.raft.client.messages.RemoveRaftPeer; -import org.opendaylight.controller.cluster.raft.internal.messages.ApplyState; -import org.opendaylight.controller.cluster.raft.internal.messages.Replicate; +import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload; import java.io.Serializable; import java.util.ArrayList; @@ -141,14 +142,17 @@ public abstract class RaftActor extends UntypedPersistentActor { applyState(applyState.getClientActor(), applyState.getIdentifier(), applyState.getReplicatedLogEntry().getData()); + } else if(message instanceof ApplySnapshot ) { applySnapshot(((ApplySnapshot) message).getSnapshot()); + } else if (message instanceof FindLeader) { getSender().tell( new FindLeaderReply( context.getPeerAddress(currentBehavior.getLeaderId())), getSelf() ); + } else if (message instanceof SaveSnapshotSuccess) { SaveSnapshotSuccess success = (SaveSnapshotSuccess) message; @@ -158,7 +162,12 @@ public abstract class RaftActor extends UntypedPersistentActor { } else if (message instanceof SaveSnapshotFailure) { // TODO: Handle failure in saving the snapshot - // Maybe do retries on failure + + } else if (message instanceof FindLeader){ + + getSender().tell(new FindLeaderReply( + context.getPeerAddress(currentBehavior.getLeaderId())), + getSelf()); } else if (message instanceof AddRaftPeer){ @@ -193,7 +202,7 @@ public abstract class RaftActor extends UntypedPersistentActor { * @param data */ protected void persistData(ActorRef clientActor, String identifier, - Object data) { + Payload data) { ReplicatedLogEntry replicatedLogEntry = new ReplicatedLogImplEntry( context.getReplicatedLog().lastIndex() + 1, @@ -241,6 +250,24 @@ public abstract class RaftActor extends UntypedPersistentActor { return currentBehavior.state(); } + /** + * setPeerAddress sets the address of a known peer at a later time. + *

+ * This is to account for situations where a we know that a peer + * exists but we do not know an address up-front. This may also be used in + * situations where a known peer starts off in a different location and we + * need to change it's address + *

+ * Note that if the peerId does not match the list of peers passed to + * this actor during construction an IllegalStateException will be thrown. + * + * @param peerId + * @param peerAddress + */ + protected void setPeerAddress(String peerId, String peerAddress){ + context.setPeerAddress(peerId, peerAddress); + } + /** @@ -442,7 +469,7 @@ public abstract class RaftActor extends UntypedPersistentActor { final String identifier, final ReplicatedLogEntry replicatedLogEntry) { context.getLogger().debug( - "Append log entry and persist " + replicatedLogEntry); + "Append log entry and persist {} ", replicatedLogEntry); // FIXME : By adding the replicated log entry to the in-memory journal we are not truly ensuring durability of the logs journal.add(replicatedLogEntry); @@ -520,39 +547,7 @@ public abstract class RaftActor extends UntypedPersistentActor { } - private static class ReplicatedLogImplEntry implements ReplicatedLogEntry, - Serializable { - - private final long index; - private final long term; - private final Object payload; - public ReplicatedLogImplEntry(long index, long term, Object payload) { - - this.index = index; - this.term = term; - this.payload = payload; - } - - @Override public Object getData() { - return payload; - } - - @Override public long getTerm() { - return term; - } - - @Override public long getIndex() { - return index; - } - - @Override public String toString() { - return "Entry{" + - "index=" + index + - ", term=" + term + - '}'; - } - } private static class DeleteEntries implements Serializable { private final int fromIndex; diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContext.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContext.java index 7150ec0e6e..ae9431a43a 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContext.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContext.java @@ -96,21 +96,27 @@ public interface RaftActorContext { ActorSystem getActorSystem(); /** + * Get the logger to be used for logging messages * * @return */ LoggingAdapter getLogger(); /** - * Get a mapping of peer id's their addresses + * Get a mapping of peerId's to their addresses + * * @return + * */ Map getPeerAddresses(); /** + * Get the address of the peer as a String. This is the same format in + * which a consumer would provide the address * * @param peerId - * @return + * @return The address of the peer or null if the address has not yet been + * resolved */ String getPeerAddress(String peerId); @@ -126,4 +132,27 @@ public interface RaftActorContext { * @param name */ public void removePeer(String name); + + /** + * Given a peerId return the corresponding actor + *

+ * + * + * @param peerId + * @return The actorSelection corresponding to the peer or null if the + * address has not yet been resolved + */ + ActorSelection getPeerActorSelection(String peerId); + + /** + * Set Peer Address can be called at a later time to change the address of + * a known peer. + * + *

+ * Throws an IllegalStateException if the peer is unknown + * + * @param peerId + * @param peerAddress + */ + void setPeerAddress(String peerId, String peerAddress); } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContextImpl.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContextImpl.java index a0f13280c2..833c8a9e8a 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContextImpl.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContextImpl.java @@ -17,6 +17,8 @@ import akka.event.LoggingAdapter; import java.util.Map; +import static com.google.common.base.Preconditions.checkState; + public class RaftActorContextImpl implements RaftActorContext{ private final ActorRef actor; @@ -37,7 +39,6 @@ public class RaftActorContextImpl implements RaftActorContext{ private final LoggingAdapter LOG; - public RaftActorContextImpl(ActorRef actor, UntypedActorContext context, String id, ElectionTerm termInformation, long commitIndex, @@ -110,12 +111,25 @@ public class RaftActorContextImpl implements RaftActorContext{ } @Override public void addToPeers(String name, String address) { - LOG.debug("Kamal--> addToPeer for:"+name); peerAddresses.put(name, address); } @Override public void removePeer(String name) { - LOG.debug("Kamal--> removePeer for:"+name); peerAddresses.remove(name); } + + @Override public ActorSelection getPeerActorSelection(String peerId) { + String peerAddress = getPeerAddress(peerId); + if(peerAddress != null){ + return actorSelection(peerAddress); + } + return null; + } + + @Override public void setPeerAddress(String peerId, String peerAddress) { + LOG.info("Peer address for peer {} set to {}", peerId, peerAddress); + checkState(peerAddresses.containsKey(peerId), peerId + " is unknown"); + + peerAddresses.put(peerId, peerAddress); + } } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLogEntry.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLogEntry.java index 3bbaa22838..f501c4d37f 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLogEntry.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLogEntry.java @@ -8,6 +8,8 @@ package org.opendaylight.controller.cluster.raft; +import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload; + /** * Represents one entry in the replicated log */ @@ -17,7 +19,7 @@ public interface ReplicatedLogEntry { * * @return */ - Object getData(); + Payload getData(); /** * The term stored in that entry diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLogImplEntry.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLogImplEntry.java new file mode 100644 index 0000000000..fc2ec5cff9 --- /dev/null +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLogImplEntry.java @@ -0,0 +1,47 @@ +/* + * 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.raft; + +import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload; + +import java.io.Serializable; + +public class ReplicatedLogImplEntry implements ReplicatedLogEntry, + Serializable { + + private final long index; + private final long term; + private final Payload payload; + + public ReplicatedLogImplEntry(long index, long term, Payload payload) { + + this.index = index; + this.term = term; + this.payload = payload; + } + + @Override public Payload getData() { + return payload; + } + + @Override public long getTerm() { + return term; + } + + @Override public long getIndex() { + return index; + } + + @Override public String toString() { + return "Entry{" + + "index=" + index + + ", term=" + term + + '}'; + } +} diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/SerializationUtils.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/SerializationUtils.java new file mode 100644 index 0000000000..374e0fa9ba --- /dev/null +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/SerializationUtils.java @@ -0,0 +1,22 @@ +/* + * 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.raft; + +import org.opendaylight.controller.cluster.raft.messages.AppendEntries; + +public class SerializationUtils { + + public static Object fromSerializable(Object serializable){ + if(serializable.getClass().equals(AppendEntries.SERIALIZABLE_CLASS)){ + return AppendEntries.fromSerializable(serializable); + } + return serializable; + } + +} diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/ApplySnapshot.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/ApplySnapshot.java similarity index 77% rename from opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/ApplySnapshot.java rename to opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/ApplySnapshot.java index a7172e22c8..9739fb2f1b 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/ApplySnapshot.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/ApplySnapshot.java @@ -6,9 +6,11 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.controller.cluster.raft.internal.messages; +package org.opendaylight.controller.cluster.raft.base.messages; -public class ApplySnapshot { +import java.io.Serializable; + +public class ApplySnapshot implements Serializable { private final Object snapshot; public ApplySnapshot(Object snapshot) { diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/ApplyState.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/ApplyState.java similarity index 87% rename from opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/ApplyState.java rename to opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/ApplyState.java index c9ba26eaad..b904335be3 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/ApplyState.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/ApplyState.java @@ -6,12 +6,14 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.controller.cluster.raft.internal.messages; +package org.opendaylight.controller.cluster.raft.base.messages; import akka.actor.ActorRef; import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry; -public class ApplyState { +import java.io.Serializable; + +public class ApplyState implements Serializable { private final ActorRef clientActor; private final String identifier; private final ReplicatedLogEntry replicatedLogEntry; diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/CommitEntry.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/CommitEntry.java similarity index 71% rename from opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/CommitEntry.java rename to opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/CommitEntry.java index 5afd4925af..07e376fca3 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/CommitEntry.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/CommitEntry.java @@ -6,10 +6,12 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.controller.cluster.raft.internal.messages; +package org.opendaylight.controller.cluster.raft.base.messages; + +import java.io.Serializable; /** * Message sent to commit an entry to the log */ -public class CommitEntry { +public class CommitEntry implements Serializable { } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/SendInstallSnapshot.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/ElectionTimeout.java similarity index 67% rename from opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/SendInstallSnapshot.java rename to opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/ElectionTimeout.java index 0c370aa981..a844849f15 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/SendInstallSnapshot.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/ElectionTimeout.java @@ -6,7 +6,9 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.controller.cluster.raft.internal.messages; +package org.opendaylight.controller.cluster.raft.base.messages; -public class SendInstallSnapshot { +import java.io.Serializable; + +public class ElectionTimeout implements Serializable { } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/PersistEntry.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/PersistEntry.java similarity index 72% rename from opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/PersistEntry.java rename to opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/PersistEntry.java index 7afe0b579b..6a62817e90 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/PersistEntry.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/PersistEntry.java @@ -6,10 +6,12 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.controller.cluster.raft.internal.messages; +package org.opendaylight.controller.cluster.raft.base.messages; + +import java.io.Serializable; /** * Message sent to Persist an entry into the transaction journal */ -public class PersistEntry { +public class PersistEntry implements Serializable { } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/Replicate.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/Replicate.java similarity index 87% rename from opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/Replicate.java rename to opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/Replicate.java index 6ff7cfce5c..9bc737a0e3 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/Replicate.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/Replicate.java @@ -6,12 +6,14 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.controller.cluster.raft.internal.messages; +package org.opendaylight.controller.cluster.raft.base.messages; import akka.actor.ActorRef; import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry; -public class Replicate { +import java.io.Serializable; + +public class Replicate implements Serializable { private final ActorRef clientActor; private final String identifier; private final ReplicatedLogEntry replicatedLogEntry; diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/SaveSnapshot.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/SaveSnapshot.java similarity index 74% rename from opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/SaveSnapshot.java rename to opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/SaveSnapshot.java index 20e5927e6f..861f5ee715 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/SaveSnapshot.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/SaveSnapshot.java @@ -6,11 +6,13 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.controller.cluster.raft.internal.messages; +package org.opendaylight.controller.cluster.raft.base.messages; + +import java.io.Serializable; /** * This message is sent by a RaftActor to itself so that a subclass can process * it and use it to save it's state */ -public class SaveSnapshot { +public class SaveSnapshot implements Serializable { } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/SendHeartBeat.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/SendHeartBeat.java similarity index 75% rename from opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/SendHeartBeat.java rename to opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/SendHeartBeat.java index 5048cbb0b9..3c8c845f5d 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/SendHeartBeat.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/SendHeartBeat.java @@ -6,7 +6,9 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.controller.cluster.raft.internal.messages; +package org.opendaylight.controller.cluster.raft.base.messages; + +import java.io.Serializable; /** * This messages is sent to the Leader to prompt it to send a heartbeat @@ -14,5 +16,5 @@ package org.opendaylight.controller.cluster.raft.internal.messages; * * Typically the Leader to itself on a schedule */ -public class SendHeartBeat { +public class SendHeartBeat implements Serializable { } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/SendInstallSnapshot.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/SendInstallSnapshot.java new file mode 100644 index 0000000000..6c3313f316 --- /dev/null +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/SendInstallSnapshot.java @@ -0,0 +1,14 @@ +/* + * 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.raft.base.messages; + +import java.io.Serializable; + +public class SendInstallSnapshot implements Serializable { +} diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractRaftActorBehavior.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractRaftActorBehavior.java index 1d78bb0227..f7281bb8e3 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractRaftActorBehavior.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractRaftActorBehavior.java @@ -14,8 +14,9 @@ import org.opendaylight.controller.cluster.raft.ClientRequestTracker; import org.opendaylight.controller.cluster.raft.RaftActorContext; import org.opendaylight.controller.cluster.raft.RaftState; import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry; -import org.opendaylight.controller.cluster.raft.internal.messages.ApplyState; -import org.opendaylight.controller.cluster.raft.internal.messages.ElectionTimeout; +import org.opendaylight.controller.cluster.raft.SerializationUtils; +import org.opendaylight.controller.cluster.raft.base.messages.ApplyState; +import org.opendaylight.controller.cluster.raft.base.messages.ElectionTimeout; import org.opendaylight.controller.cluster.raft.messages.AppendEntries; import org.opendaylight.controller.cluster.raft.messages.AppendEntriesReply; import org.opendaylight.controller.cluster.raft.messages.RequestVote; @@ -349,6 +350,10 @@ public abstract class AbstractRaftActorBehavior implements RaftActorBehavior { context.setLastApplied(index); } + protected Object fromSerializableMessage(Object serializable){ + return SerializationUtils.fromSerializable(serializable); + } + @Override public RaftState handleMessage(ActorRef sender, Object message) { if (message instanceof AppendEntries) { diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/Candidate.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/Candidate.java index ecd4901246..c125bd32b6 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/Candidate.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/Candidate.java @@ -12,16 +12,14 @@ import akka.actor.ActorRef; import akka.actor.ActorSelection; import org.opendaylight.controller.cluster.raft.RaftActorContext; import org.opendaylight.controller.cluster.raft.RaftState; -import org.opendaylight.controller.cluster.raft.internal.messages.ElectionTimeout; +import org.opendaylight.controller.cluster.raft.base.messages.ElectionTimeout; import org.opendaylight.controller.cluster.raft.messages.AppendEntries; import org.opendaylight.controller.cluster.raft.messages.AppendEntriesReply; import org.opendaylight.controller.cluster.raft.messages.RaftRPC; import org.opendaylight.controller.cluster.raft.messages.RequestVote; import org.opendaylight.controller.cluster.raft.messages.RequestVoteReply; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; +import java.util.Set; /** * The behavior of a RaftActor when it is in the CandidateState @@ -43,24 +41,20 @@ import java.util.Map; */ public class Candidate extends AbstractRaftActorBehavior { - private final Map peerToActor = new HashMap<>(); - private int voteCount; private final int votesRequired; + private final Set peers; + public Candidate(RaftActorContext context) { super(context); - Collection peerPaths = context.getPeerAddresses().values(); + peers = context.getPeerAddresses().keySet(); - for (String peerPath : peerPaths) { - peerToActor.put(peerPath, - context.actorSelection(peerPath)); - } + context.getLogger().debug("Election:Candidate has following peers:"+ peers); - context.getLogger().debug("Election:Candidate has following peers:"+peerToActor.keySet()); - if(peerPaths.size() > 0) { + if(peers.size() > 0) { // Votes are required from a majority of the peers including self. // The votesRequired field therefore stores a calculated value // of the number of votes required for this candidate to win an @@ -73,7 +67,7 @@ public class Candidate extends AbstractRaftActorBehavior { // 0 peers = 1 votesRequired (0 + 1) / 2 + 1 = 1 // 2 peers = 2 votesRequired (2 + 1) / 2 + 1 = 2 // 4 peers = 3 votesRequired (4 + 1) / 2 + 1 = 3 - int noOfPeers = peerPaths.size(); + int noOfPeers = peers.size(); int self = 1; votesRequired = (noOfPeers + self) / 2 + 1; } else { @@ -87,6 +81,8 @@ public class Candidate extends AbstractRaftActorBehavior { @Override protected RaftState handleAppendEntries(ActorRef sender, AppendEntries appendEntries) { + context.getLogger().info("Candidate: Received {}", appendEntries.toString()); + return state(); } @@ -115,10 +111,16 @@ public class Candidate extends AbstractRaftActorBehavior { } @Override - public RaftState handleMessage(ActorRef sender, Object message) { + public RaftState handleMessage(ActorRef sender, Object originalMessage) { + + Object message = fromSerializableMessage(originalMessage); if (message instanceof RaftRPC) { + RaftRPC rpc = (RaftRPC) message; + + context.getLogger().debug("RaftRPC message received {} my term is {}", rpc.toString(), context.getTermInformation().getCurrentTerm()); + // If RPC request or response contains term T > currentTerm: // set currentTerm = T, convert to follower (§5.1) // This applies to all RPC messages and responses @@ -141,6 +143,7 @@ public class Candidate extends AbstractRaftActorBehavior { scheduleElection(electionDuration()); return state(); } + return super.handleMessage(sender, message); } @@ -153,21 +156,25 @@ public class Candidate extends AbstractRaftActorBehavior { // Increment the election term and vote for self long currentTerm = context.getTermInformation().getCurrentTerm(); - context.getTermInformation().updateAndPersist(currentTerm + 1, context.getId()); + context.getTermInformation().updateAndPersist(currentTerm + 1, + context.getId()); - context.getLogger().debug("Starting new term " + (currentTerm+1)); + context.getLogger().debug("Starting new term " + (currentTerm + 1)); // Request for a vote // TODO: Retry request for vote if replies do not arrive in a reasonable // amount of time TBD - for (ActorSelection peerActor : peerToActor.values()) { - peerActor.tell(new RequestVote( - context.getTermInformation().getCurrentTerm(), - context.getId(), - context.getReplicatedLog().lastIndex(), - context.getReplicatedLog().lastTerm()), - context.getActor() - ); + for (String peerId : peers) { + ActorSelection peerActor = context.getPeerActorSelection(peerId); + if(peerActor != null) { + peerActor.tell(new RequestVote( + context.getTermInformation().getCurrentTerm(), + context.getId(), + context.getReplicatedLog().lastIndex(), + context.getReplicatedLog().lastTerm()), + context.getActor() + ); + } } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/Follower.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/Follower.java index 532201b26e..db62dfc2ac 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/Follower.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/Follower.java @@ -12,8 +12,8 @@ import akka.actor.ActorRef; import org.opendaylight.controller.cluster.raft.RaftActorContext; import org.opendaylight.controller.cluster.raft.RaftState; import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry; -import org.opendaylight.controller.cluster.raft.internal.messages.ApplySnapshot; -import org.opendaylight.controller.cluster.raft.internal.messages.ElectionTimeout; +import org.opendaylight.controller.cluster.raft.base.messages.ApplySnapshot; +import org.opendaylight.controller.cluster.raft.base.messages.ElectionTimeout; import org.opendaylight.controller.cluster.raft.messages.AppendEntries; import org.opendaylight.controller.cluster.raft.messages.AppendEntriesReply; import org.opendaylight.controller.cluster.raft.messages.InstallSnapshot; @@ -40,6 +40,11 @@ public class Follower extends AbstractRaftActorBehavior { @Override protected RaftState handleAppendEntries(ActorRef sender, AppendEntries appendEntries) { + if(appendEntries.getEntries() != null && appendEntries.getEntries().size() > 0) { + context.getLogger() + .info("Follower: Received {}", appendEntries.toString()); + } + // TODO : Refactor this method into a bunch of smaller methods // to make it easier to read. Before refactoring ensure tests // cover the code properly @@ -162,8 +167,9 @@ public class Follower extends AbstractRaftActorBehavior { for (int i = addEntriesFrom; i < appendEntries.getEntries().size(); i++) { - context.getLogger().debug( - "Append entry to log " + appendEntries.getEntries().get(i).getData() + context.getLogger().info( + "Append entry to log " + appendEntries.getEntries().get( + i).getData() .toString() ); context.getReplicatedLog() @@ -214,7 +220,10 @@ public class Follower extends AbstractRaftActorBehavior { return RaftState.Follower; } - @Override public RaftState handleMessage(ActorRef sender, Object message) { + @Override public RaftState handleMessage(ActorRef sender, Object originalMessage) { + + Object message = fromSerializableMessage(originalMessage); + if (message instanceof RaftRPC) { RaftRPC rpc = (RaftRPC) message; // If RPC request or response contains term T > currentTerm: @@ -227,9 +236,10 @@ public class Follower extends AbstractRaftActorBehavior { if (message instanceof ElectionTimeout) { return RaftState.Candidate; + } else if (message instanceof InstallSnapshot) { - InstallSnapshot snapshot = (InstallSnapshot) message; - actor().tell(new ApplySnapshot(snapshot), actor()); + InstallSnapshot installSnapshot = (InstallSnapshot) message; + actor().tell(new ApplySnapshot(installSnapshot.getData()), actor()); } scheduleElection(electionDuration()); 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 fb8be8b891..53e47c2f84 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 @@ -19,10 +19,10 @@ import org.opendaylight.controller.cluster.raft.FollowerLogInformationImpl; import org.opendaylight.controller.cluster.raft.RaftActorContext; import org.opendaylight.controller.cluster.raft.RaftState; import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry; -import org.opendaylight.controller.cluster.raft.internal.messages.ApplyState; -import org.opendaylight.controller.cluster.raft.internal.messages.Replicate; -import org.opendaylight.controller.cluster.raft.internal.messages.SendHeartBeat; -import org.opendaylight.controller.cluster.raft.internal.messages.SendInstallSnapshot; +import org.opendaylight.controller.cluster.raft.base.messages.ApplyState; +import org.opendaylight.controller.cluster.raft.base.messages.Replicate; +import org.opendaylight.controller.cluster.raft.base.messages.SendHeartBeat; +import org.opendaylight.controller.cluster.raft.base.messages.SendInstallSnapshot; import org.opendaylight.controller.cluster.raft.messages.AppendEntries; import org.opendaylight.controller.cluster.raft.messages.AppendEntriesReply; import org.opendaylight.controller.cluster.raft.messages.InstallSnapshot; @@ -36,6 +36,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; @@ -67,7 +68,7 @@ public class Leader extends AbstractRaftActorBehavior { private final Map followerToLog = new HashMap(); - private final Map followerToActor = new HashMap<>(); + private final Set followers; private Cancellable heartbeatSchedule = null; private Cancellable appendEntriesSchedule = null; @@ -84,22 +85,21 @@ public class Leader extends AbstractRaftActorBehavior { context.setCommitIndex(lastIndex()); } - for (String followerId : context.getPeerAddresses().keySet()) { + followers = context.getPeerAddresses().keySet(); + + for (String followerId : followers) { FollowerLogInformation followerLogInformation = new FollowerLogInformationImpl(followerId, new AtomicLong(lastIndex()), new AtomicLong(-1)); - followerToActor.put(followerId, - context.actorSelection(context.getPeerAddress(followerId))); - followerToLog.put(followerId, followerLogInformation); } - context.getLogger().debug("Election:Leader has following peers:"+followerToActor.keySet()); + context.getLogger().debug("Election:Leader has following peers:"+ followers); - if (followerToActor.size() > 0) { - minReplicationCount = (followerToActor.size() + 1) / 2 + 1; + if (followers.size() > 0) { + minReplicationCount = (followers.size() + 1) / 2 + 1; } else { minReplicationCount = 0; } @@ -121,16 +121,29 @@ public class Leader extends AbstractRaftActorBehavior { @Override protected RaftState handleAppendEntries(ActorRef sender, AppendEntries appendEntries) { + context.getLogger().info("Leader: Received {}", appendEntries.toString()); + return state(); } @Override protected RaftState handleAppendEntriesReply(ActorRef sender, AppendEntriesReply appendEntriesReply) { + if(! appendEntriesReply.isSuccess()) { + context.getLogger() + .info("Leader: Received {}", appendEntriesReply.toString()); + } + // Update the FollowerLogInformation String followerId = appendEntriesReply.getFollowerId(); FollowerLogInformation followerLogInformation = followerToLog.get(followerId); + + if(followerLogInformation == null){ + context.getLogger().error("Unknown follower {}", followerId); + return state(); + } + if (appendEntriesReply.isSuccess()) { followerLogInformation .setMatchIndex(appendEntriesReply.getLogLastIndex()); @@ -200,9 +213,11 @@ public class Leader extends AbstractRaftActorBehavior { return RaftState.Leader; } - @Override public RaftState handleMessage(ActorRef sender, Object message) { + @Override public RaftState handleMessage(ActorRef sender, Object originalMessage) { Preconditions.checkNotNull(sender, "sender should not be null"); + Object message = fromSerializableMessage(originalMessage); + if (message instanceof RaftRPC) { RaftRPC rpc = (RaftRPC) message; // If RPC request or response contains term T > currentTerm: @@ -249,7 +264,7 @@ public class Leader extends AbstractRaftActorBehavior { context.getLogger().debug("Replicate message " + logIndex); - if (followerToActor.size() == 0) { + if (followers.size() == 0) { context.setCommitIndex( replicate.getReplicatedLogEntry().getIndex()); @@ -275,35 +290,37 @@ public class Leader extends AbstractRaftActorBehavior { private void sendAppendEntries() { // Send an AppendEntries to all followers - for (String followerId : followerToActor.keySet()) { + for (String followerId : followers) { ActorSelection followerActor = - followerToActor.get(followerId); + context.getPeerActorSelection(followerId); - FollowerLogInformation followerLogInformation = - followerToLog.get(followerId); + if (followerActor != null) { + FollowerLogInformation followerLogInformation = + followerToLog.get(followerId); - long nextIndex = followerLogInformation.getNextIndex().get(); + long nextIndex = followerLogInformation.getNextIndex().get(); - List entries = Collections.emptyList(); + List entries = Collections.emptyList(); - if(context.getReplicatedLog().isPresent(nextIndex)){ - // TODO: Instead of sending all entries from nextIndex - // only send a fixed number of entries to each follower - // This is to avoid the situation where there are a lot of - // entries to install for a fresh follower or to a follower - // that has fallen too far behind with the log but yet is not - // eligible to receive a snapshot - entries = - context.getReplicatedLog().getFrom(nextIndex); - } + if (context.getReplicatedLog().isPresent(nextIndex)) { + // TODO: Instead of sending all entries from nextIndex + // only send a fixed number of entries to each follower + // This is to avoid the situation where there are a lot of + // entries to install for a fresh follower or to a follower + // that has fallen too far behind with the log but yet is not + // eligible to receive a snapshot + entries = + context.getReplicatedLog().getFrom(nextIndex); + } - followerActor.tell( - new AppendEntries(currentTerm(), context.getId(), - prevLogIndex(nextIndex), prevLogTerm(nextIndex), - entries, context.getCommitIndex() - ), - actor() - ); + followerActor.tell( + new AppendEntries(currentTerm(), context.getId(), + prevLogIndex(nextIndex), + prevLogTerm(nextIndex), entries, + context.getCommitIndex()).toSerializable(), + actor() + ); + } } } @@ -313,30 +330,33 @@ public class Leader extends AbstractRaftActorBehavior { * snapshots at every heartbeat. */ private void installSnapshotIfNeeded(){ - for (String followerId : followerToActor.keySet()) { + for (String followerId : followers) { ActorSelection followerActor = - followerToActor.get(followerId); - - FollowerLogInformation followerLogInformation = - followerToLog.get(followerId); - - long nextIndex = followerLogInformation.getNextIndex().get(); - - if(!context.getReplicatedLog().isPresent(nextIndex) && context.getReplicatedLog().isInSnapshot(nextIndex)){ - followerActor.tell( - new InstallSnapshot(currentTerm(), context.getId(), - context.getReplicatedLog().getSnapshotIndex(), - context.getReplicatedLog().getSnapshotTerm(), - context.getReplicatedLog().getSnapshot() - ), - actor() - ); + context.getPeerActorSelection(followerId); + + if(followerActor != null) { + FollowerLogInformation followerLogInformation = + followerToLog.get(followerId); + + long nextIndex = followerLogInformation.getNextIndex().get(); + + if (!context.getReplicatedLog().isPresent(nextIndex) && context + .getReplicatedLog().isInSnapshot(nextIndex)) { + followerActor.tell( + new InstallSnapshot(currentTerm(), context.getId(), + context.getReplicatedLog().getSnapshotIndex(), + context.getReplicatedLog().getSnapshotTerm(), + context.getReplicatedLog().getSnapshot() + ), + actor() + ); + } } } } private RaftState sendHeartBeat() { - if (followerToActor.size() > 0) { + if (followers.size() > 0) { sendAppendEntries(); } return state(); @@ -355,7 +375,7 @@ public class Leader extends AbstractRaftActorBehavior { } private void scheduleHeartBeat(FiniteDuration interval) { - if(followerToActor.keySet().size() == 0){ + if(followers.size() == 0){ // Optimization - do not bother scheduling a heartbeat as there are // no followers return; @@ -377,7 +397,7 @@ public class Leader extends AbstractRaftActorBehavior { private void scheduleInstallSnapshotCheck(FiniteDuration interval) { - if(followerToActor.keySet().size() == 0){ + if(followers.size() == 0){ // Optimization - do not bother scheduling a heartbeat as there are // no followers return; diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AbstractRaftRPC.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AbstractRaftRPC.java index 3cafda9a15..33d8a68686 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AbstractRaftRPC.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AbstractRaftRPC.java @@ -16,9 +16,15 @@ public class AbstractRaftRPC implements RaftRPC { this.term = term; } + // added for testing while serialize-messages=on + public AbstractRaftRPC() { + } + public long getTerm() { return term; } - + public void setTerm(long term) { + this.term = term; + } } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AppendEntries.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AppendEntries.java index 9bb5029548..94366efd5e 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AppendEntries.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AppendEntries.java @@ -8,15 +8,27 @@ package org.opendaylight.controller.cluster.raft.messages; +import com.google.protobuf.GeneratedMessage; import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry; +import org.opendaylight.controller.cluster.raft.ReplicatedLogImplEntry; +import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload; +import org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages; +import java.util.ArrayList; +import java.util.Iterator; import java.util.List; +import java.util.Map; /** * Invoked by leader to replicate log entries (§5.3); also used as * heartbeat (§5.2). */ public class AppendEntries extends AbstractRaftRPC { + + public static final Class SERIALIZABLE_CLASS = AppendEntriesMessages.AppendEntries.class; + + private static final org.slf4j.Logger LOG = org.slf4j.LoggerFactory.getLogger(AppendEntries.class); + // So that follower can redirect clients private final String leaderId; @@ -64,12 +76,88 @@ public class AppendEntries extends AbstractRaftRPC { } @Override public String toString() { - return "AppendEntries{" + - "leaderId='" + leaderId + '\'' + - ", prevLogIndex=" + prevLogIndex + - ", prevLogTerm=" + prevLogTerm + - ", entries=" + entries + - ", leaderCommit=" + leaderCommit + - '}'; + final StringBuilder sb = + new StringBuilder("AppendEntries{"); + sb.append("term=").append(getTerm()); + sb.append("leaderId='").append(leaderId).append('\''); + sb.append(", prevLogIndex=").append(prevLogIndex); + sb.append(", prevLogTerm=").append(prevLogTerm); + sb.append(", entries=").append(entries); + sb.append(", leaderCommit=").append(leaderCommit); + sb.append('}'); + return sb.toString(); + } + + public Object toSerializable(){ + AppendEntriesMessages.AppendEntries.Builder to = AppendEntriesMessages.AppendEntries.newBuilder(); + to.setTerm(this.getTerm()) + .setLeaderId(this.getLeaderId()) + .setPrevLogTerm(this.getPrevLogTerm()) + .setPrevLogIndex(this.getPrevLogIndex()) + .setLeaderCommit(this.getLeaderCommit()); + + for (ReplicatedLogEntry logEntry : this.getEntries()) { + + AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder arBuilder = + AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.newBuilder(); + + AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.Builder arpBuilder = + AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.newBuilder(); + + //get the client specific payload extensions and add them to the payload builder + Map map = logEntry.getData().encode(); + Iterator> iter = map.entrySet().iterator(); + + while (iter.hasNext()) { + Map.Entry entry = iter.next(); + arpBuilder.setExtension(entry.getKey(), entry.getValue()); + } + + arpBuilder.setClientPayloadClassName(logEntry.getData().getClientPayloadClassName()); + + arBuilder.setData(arpBuilder).setIndex(logEntry.getIndex()).setTerm(logEntry.getTerm()); + to.addLogEntries(arBuilder); + } + + return to.build(); + } + + public static AppendEntries fromSerializable(Object o){ + AppendEntriesMessages.AppendEntries from = (AppendEntriesMessages.AppendEntries) o; + + List logEntryList = new ArrayList<>(); + for (AppendEntriesMessages.AppendEntries.ReplicatedLogEntry leProtoBuff : from.getLogEntriesList()) { + + Payload payload = null ; + try { + if(leProtoBuff.getData() != null && leProtoBuff.getData().getClientPayloadClassName() != null) { + String clientPayloadClassName = leProtoBuff.getData().getClientPayloadClassName(); + payload = (Payload)Class.forName(clientPayloadClassName).newInstance(); + payload = payload.decode(leProtoBuff.getData()); + payload.setClientPayloadClassName(clientPayloadClassName); + } else { + LOG.error("Payload is null or payload does not have client payload class name"); + } + + } catch (InstantiationException e) { + LOG.error("InstantiationException when instantiating "+leProtoBuff.getData().getClientPayloadClassName(), e); + } catch (IllegalAccessException e) { + LOG.error("IllegalAccessException when accessing "+leProtoBuff.getData().getClientPayloadClassName(), e); + } catch (ClassNotFoundException e) { + LOG.error("ClassNotFoundException when loading "+leProtoBuff.getData().getClientPayloadClassName(), e); + } + ReplicatedLogEntry logEntry = new ReplicatedLogImplEntry( + leProtoBuff.getIndex(), leProtoBuff.getTerm(), payload); + logEntryList.add(logEntry); + } + + AppendEntries to = new AppendEntries(from.getTerm(), + from.getLeaderId(), + from.getPrevLogIndex(), + from.getPrevLogTerm(), + logEntryList, + from.getLeaderCommit()); + + return to; } } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AppendEntriesReply.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AppendEntriesReply.java index 7524d8f232..b923baa716 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AppendEntriesReply.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AppendEntriesReply.java @@ -11,7 +11,7 @@ package org.opendaylight.controller.cluster.raft.messages; /** * Reply for the AppendEntriesRpc message */ -public class AppendEntriesReply extends AbstractRaftRPC{ +public class AppendEntriesReply extends AbstractRaftRPC { // true if follower contained entry matching // prevLogIndex and prevLogTerm @@ -56,4 +56,16 @@ public class AppendEntriesReply extends AbstractRaftRPC{ public String getFollowerId() { return followerId; } + + @Override public String toString() { + final StringBuilder sb = + new StringBuilder("AppendEntriesReply{"); + sb.append("term=").append(term); + sb.append(", success=").append(success); + sb.append(", logLastIndex=").append(logLastIndex); + sb.append(", logLastTerm=").append(logLastTerm); + sb.append(", followerId='").append(followerId).append('\''); + sb.append('}'); + return sb.toString(); + } } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/RaftRPC.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/RaftRPC.java index a770e54f58..10d99988d8 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/RaftRPC.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/RaftRPC.java @@ -8,6 +8,8 @@ package org.opendaylight.controller.cluster.raft.messages; -public interface RaftRPC { +import java.io.Serializable; + +public interface RaftRPC extends Serializable { public long getTerm(); } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/RequestVote.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/RequestVote.java index 981da17ce1..6ef2a06285 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/RequestVote.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/RequestVote.java @@ -11,16 +11,16 @@ package org.opendaylight.controller.cluster.raft.messages; /** * Invoked by candidates to gather votes (§5.2). */ -public class RequestVote extends AbstractRaftRPC{ +public class RequestVote extends AbstractRaftRPC { // candidate requesting vote - private final String candidateId; + private String candidateId; // index of candidate’s last log entry (§5.4) - private final long lastLogIndex; + private long lastLogIndex; // term of candidate’s last log entry (§5.4) - private final long lastLogTerm; + private long lastLogTerm; public RequestVote(long term, String candidateId, long lastLogIndex, long lastLogTerm) { @@ -30,6 +30,10 @@ public class RequestVote extends AbstractRaftRPC{ this.lastLogTerm = lastLogTerm; } + // added for testing while serialize-messages=on + public RequestVote() { + } + public long getTerm() { return term; } @@ -45,4 +49,27 @@ public class RequestVote extends AbstractRaftRPC{ public long getLastLogTerm() { return lastLogTerm; } + + public void setCandidateId(String candidateId) { + this.candidateId = candidateId; + } + + public void setLastLogIndex(long lastLogIndex) { + this.lastLogIndex = lastLogIndex; + } + + public void setLastLogTerm(long lastLogTerm) { + this.lastLogTerm = lastLogTerm; + } + + @Override public String toString() { + final StringBuilder sb = + new StringBuilder("RequestVote{"); + sb.append("term='").append(getTerm()).append('\''); + sb.append("candidateId='").append(candidateId).append('\''); + sb.append(", lastLogIndex=").append(lastLogIndex); + sb.append(", lastLogTerm=").append(lastLogTerm); + sb.append('}'); + return sb.toString(); + } } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/RequestVoteReply.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/RequestVoteReply.java index 816120cd93..df80b4e5e2 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/RequestVoteReply.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/RequestVoteReply.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.cluster.raft.messages; -public class RequestVoteReply extends AbstractRaftRPC{ +public class RequestVoteReply extends AbstractRaftRPC { // true means candidate received vot private final boolean voteGranted; diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/protobuff/client/messages/Payload.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/protobuff/client/messages/Payload.java new file mode 100644 index 0000000000..9a251cd645 --- /dev/null +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/protobuff/client/messages/Payload.java @@ -0,0 +1,86 @@ +/* + * 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.raft.protobuff.client.messages; + + +import com.google.protobuf.GeneratedMessage; +import org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages; + +import java.util.Map; + +/** + * An instance of a Payload class is meant to be used as the Payload for + * AppendEntries. + *

+ * + * When an actor which is derived from RaftActor attempts to persistData it + * must pass an instance of the Payload class. Similarly when state needs to + * be applied to the derived RaftActor it will be passed an instance of the + * Payload class. + *

+ * + * To define your own payload do the following, + *

    + *
  1. Create your own protocol buffer message which extends the AppendEntries Payload
  2. + *
  3. Extend this Payload class
  4. + *
  5. Implement encode
  6. + *
  7. Implement decode
  8. + *
+ * + * Your own protocol buffer message can be create like so,
+ *
+ * {@code
+ *
+ * import "AppendEntriesMessages.proto";
+ *
+ * package org.opendaylight.controller.cluster.raft;
+ *
+ * option java_package = "org.opendaylight.controller.cluster.raft.protobuff.messages";
+ * option java_outer_classname = "MockPayloadMessages";
+ *
+ * extend AppendEntries.ReplicatedLogEntry.Payload {
+ *      optional string value = 2;
+ * }
+ * }
+ * 
+ * + */ +public abstract class Payload { + private String clientPayloadClassName; + + public String getClientPayloadClassName() { + return this.getClass().getName(); + } + + public void setClientPayloadClassName(String clientPayloadClassName) { + this.clientPayloadClassName = clientPayloadClassName; + } + + /** + * Encode the payload data as a protocol buffer extension. + *

+ * TODO: Add more meat in here + * @param + * @return Map of + */ + public abstract Map encode(); + + /** + * Decode the protocol buffer payload into a specific Payload as defined + * by the class extending RaftActor + * + * @param payload The payload in protocol buffer format + * @return + */ + public abstract Payload decode( + AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload payload); + + + +} diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/protobuff/messages/AppendEntriesMessages.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/protobuff/messages/AppendEntriesMessages.java new file mode 100644 index 0000000000..00aeaf2c88 --- /dev/null +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/protobuff/messages/AppendEntriesMessages.java @@ -0,0 +1,2420 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: AppendEntriesMessages.proto + +package org.opendaylight.controller.cluster.raft.protobuff.messages; + +public final class AppendEntriesMessages { + private AppendEntriesMessages() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + public interface AppendEntriesOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // optional int64 term = 1; + /** + * optional int64 term = 1; + */ + boolean hasTerm(); + /** + * optional int64 term = 1; + */ + long getTerm(); + + // optional string leaderId = 2; + /** + * optional string leaderId = 2; + */ + boolean hasLeaderId(); + /** + * optional string leaderId = 2; + */ + java.lang.String getLeaderId(); + /** + * optional string leaderId = 2; + */ + com.google.protobuf.ByteString + getLeaderIdBytes(); + + // optional int64 prevLogIndex = 3; + /** + * optional int64 prevLogIndex = 3; + */ + boolean hasPrevLogIndex(); + /** + * optional int64 prevLogIndex = 3; + */ + long getPrevLogIndex(); + + // optional int64 prevLogTerm = 4; + /** + * optional int64 prevLogTerm = 4; + */ + boolean hasPrevLogTerm(); + /** + * optional int64 prevLogTerm = 4; + */ + long getPrevLogTerm(); + + // repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + java.util.List + getLogEntriesList(); + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry getLogEntries(int index); + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + int getLogEntriesCount(); + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + java.util.List + getLogEntriesOrBuilderList(); + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder getLogEntriesOrBuilder( + int index); + + // optional int64 leaderCommit = 6; + /** + * optional int64 leaderCommit = 6; + */ + boolean hasLeaderCommit(); + /** + * optional int64 leaderCommit = 6; + */ + long getLeaderCommit(); + } + /** + * Protobuf type {@code org.opendaylight.controller.cluster.raft.AppendEntries} + */ + public static final class AppendEntries extends + com.google.protobuf.GeneratedMessage + implements AppendEntriesOrBuilder { + // Use AppendEntries.newBuilder() to construct. + private AppendEntries(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private AppendEntries(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final AppendEntries defaultInstance; + public static AppendEntries getDefaultInstance() { + return defaultInstance; + } + + public AppendEntries getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private AppendEntries( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + bitField0_ |= 0x00000001; + term_ = input.readInt64(); + break; + } + case 18: { + bitField0_ |= 0x00000002; + leaderId_ = input.readBytes(); + break; + } + case 24: { + bitField0_ |= 0x00000004; + prevLogIndex_ = input.readInt64(); + break; + } + case 32: { + bitField0_ |= 0x00000008; + prevLogTerm_ = input.readInt64(); + break; + } + case 42: { + if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + logEntries_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000010; + } + logEntries_.add(input.readMessage(org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.PARSER, extensionRegistry)); + break; + } + case 48: { + bitField0_ |= 0x00000010; + leaderCommit_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + logEntries_ = java.util.Collections.unmodifiableList(logEntries_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.class, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public AppendEntries parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new AppendEntries(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public interface ReplicatedLogEntryOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // optional int64 term = 1; + /** + * optional int64 term = 1; + */ + boolean hasTerm(); + /** + * optional int64 term = 1; + */ + long getTerm(); + + // optional int64 index = 2; + /** + * optional int64 index = 2; + */ + boolean hasIndex(); + /** + * optional int64 index = 2; + */ + long getIndex(); + + // optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3; + /** + * optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3; + */ + boolean hasData(); + /** + * optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3; + */ + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload getData(); + /** + * optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3; + */ + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.PayloadOrBuilder getDataOrBuilder(); + } + /** + * Protobuf type {@code org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry} + */ + public static final class ReplicatedLogEntry extends + com.google.protobuf.GeneratedMessage + implements ReplicatedLogEntryOrBuilder { + // Use ReplicatedLogEntry.newBuilder() to construct. + private ReplicatedLogEntry(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private ReplicatedLogEntry(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final ReplicatedLogEntry defaultInstance; + public static ReplicatedLogEntry getDefaultInstance() { + return defaultInstance; + } + + public ReplicatedLogEntry getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ReplicatedLogEntry( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + bitField0_ |= 0x00000001; + term_ = input.readInt64(); + break; + } + case 16: { + bitField0_ |= 0x00000002; + index_ = input.readInt64(); + break; + } + case 26: { + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.Builder subBuilder = null; + if (((bitField0_ & 0x00000004) == 0x00000004)) { + subBuilder = data_.toBuilder(); + } + data_ = input.readMessage(org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(data_); + data_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000004; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.class, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public ReplicatedLogEntry parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ReplicatedLogEntry(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public interface PayloadOrBuilder extends + com.google.protobuf.GeneratedMessage. + ExtendableMessageOrBuilder { + + // optional string clientPayloadClassName = 1; + /** + * optional string clientPayloadClassName = 1; + */ + boolean hasClientPayloadClassName(); + /** + * optional string clientPayloadClassName = 1; + */ + java.lang.String getClientPayloadClassName(); + /** + * optional string clientPayloadClassName = 1; + */ + com.google.protobuf.ByteString + getClientPayloadClassNameBytes(); + } + /** + * Protobuf type {@code org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload} + */ + public static final class Payload extends + com.google.protobuf.GeneratedMessage.ExtendableMessage< + Payload> implements PayloadOrBuilder { + // Use Payload.newBuilder() to construct. + private Payload(com.google.protobuf.GeneratedMessage.ExtendableBuilder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private Payload(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final Payload defaultInstance; + public static Payload getDefaultInstance() { + return defaultInstance; + } + + public Payload getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Payload( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + bitField0_ |= 0x00000001; + clientPayloadClassName_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_Payload_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_Payload_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.class, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public Payload parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Payload(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // optional string clientPayloadClassName = 1; + public static final int CLIENTPAYLOADCLASSNAME_FIELD_NUMBER = 1; + private java.lang.Object clientPayloadClassName_; + /** + * optional string clientPayloadClassName = 1; + */ + public boolean hasClientPayloadClassName() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional string clientPayloadClassName = 1; + */ + public java.lang.String getClientPayloadClassName() { + java.lang.Object ref = clientPayloadClassName_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + clientPayloadClassName_ = s; + } + return s; + } + } + /** + * optional string clientPayloadClassName = 1; + */ + public com.google.protobuf.ByteString + getClientPayloadClassNameBytes() { + java.lang.Object ref = clientPayloadClassName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + clientPayloadClassName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private void initFields() { + clientPayloadClassName_ = ""; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!extensionsAreInitialized()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + com.google.protobuf.GeneratedMessage + .ExtendableMessage.ExtensionWriter extensionWriter = + newExtensionWriter(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getClientPayloadClassNameBytes()); + } + extensionWriter.writeUntil(101, output); + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getClientPayloadClassNameBytes()); + } + size += extensionsSerializedSize(); + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.ExtendableBuilder< + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload, Builder> implements org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.PayloadOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_Payload_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_Payload_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.class, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.Builder.class); + } + + // Construct using org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + clientPayloadClassName_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_Payload_descriptor; + } + + public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload getDefaultInstanceForType() { + return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.getDefaultInstance(); + } + + public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload build() { + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload buildPartial() { + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload result = new org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.clientPayloadClassName_ = clientPayloadClassName_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload) { + return mergeFrom((org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload other) { + if (other == org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.getDefaultInstance()) return this; + if (other.hasClientPayloadClassName()) { + bitField0_ |= 0x00000001; + clientPayloadClassName_ = other.clientPayloadClassName_; + onChanged(); + } + this.mergeExtensionFields(other); + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!extensionsAreInitialized()) { + + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // optional string clientPayloadClassName = 1; + private java.lang.Object clientPayloadClassName_ = ""; + /** + * optional string clientPayloadClassName = 1; + */ + public boolean hasClientPayloadClassName() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional string clientPayloadClassName = 1; + */ + public java.lang.String getClientPayloadClassName() { + java.lang.Object ref = clientPayloadClassName_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + clientPayloadClassName_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string clientPayloadClassName = 1; + */ + public com.google.protobuf.ByteString + getClientPayloadClassNameBytes() { + java.lang.Object ref = clientPayloadClassName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + clientPayloadClassName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string clientPayloadClassName = 1; + */ + public Builder setClientPayloadClassName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + clientPayloadClassName_ = value; + onChanged(); + return this; + } + /** + * optional string clientPayloadClassName = 1; + */ + public Builder clearClientPayloadClassName() { + bitField0_ = (bitField0_ & ~0x00000001); + clientPayloadClassName_ = getDefaultInstance().getClientPayloadClassName(); + onChanged(); + return this; + } + /** + * optional string clientPayloadClassName = 1; + */ + public Builder setClientPayloadClassNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + clientPayloadClassName_ = value; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload) + } + + static { + defaultInstance = new Payload(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload) + } + + private int bitField0_; + // optional int64 term = 1; + public static final int TERM_FIELD_NUMBER = 1; + private long term_; + /** + * optional int64 term = 1; + */ + public boolean hasTerm() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional int64 term = 1; + */ + public long getTerm() { + return term_; + } + + // optional int64 index = 2; + public static final int INDEX_FIELD_NUMBER = 2; + private long index_; + /** + * optional int64 index = 2; + */ + public boolean hasIndex() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional int64 index = 2; + */ + public long getIndex() { + return index_; + } + + // optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3; + public static final int DATA_FIELD_NUMBER = 3; + private org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload data_; + /** + * optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3; + */ + public boolean hasData() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3; + */ + public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload getData() { + return data_; + } + /** + * optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3; + */ + public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.PayloadOrBuilder getDataOrBuilder() { + return data_; + } + + private void initFields() { + term_ = 0L; + index_ = 0L; + data_ = org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.getDefaultInstance(); + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (hasData()) { + if (!getData().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeInt64(1, term_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeInt64(2, index_); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeMessage(3, data_); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, term_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, index_); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, data_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.class, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder.class); + } + + // Construct using org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getDataFieldBuilder(); + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + term_ = 0L; + bitField0_ = (bitField0_ & ~0x00000001); + index_ = 0L; + bitField0_ = (bitField0_ & ~0x00000002); + if (dataBuilder_ == null) { + data_ = org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.getDefaultInstance(); + } else { + dataBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000004); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_descriptor; + } + + public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry getDefaultInstanceForType() { + return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.getDefaultInstance(); + } + + public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry build() { + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry buildPartial() { + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry result = new org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.term_ = term_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.index_ = index_; + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000004; + } + if (dataBuilder_ == null) { + result.data_ = data_; + } else { + result.data_ = dataBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry) { + return mergeFrom((org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry other) { + if (other == org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.getDefaultInstance()) return this; + if (other.hasTerm()) { + setTerm(other.getTerm()); + } + if (other.hasIndex()) { + setIndex(other.getIndex()); + } + if (other.hasData()) { + mergeData(other.getData()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (hasData()) { + if (!getData().isInitialized()) { + + return false; + } + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // optional int64 term = 1; + private long term_ ; + /** + * optional int64 term = 1; + */ + public boolean hasTerm() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional int64 term = 1; + */ + public long getTerm() { + return term_; + } + /** + * optional int64 term = 1; + */ + public Builder setTerm(long value) { + bitField0_ |= 0x00000001; + term_ = value; + onChanged(); + return this; + } + /** + * optional int64 term = 1; + */ + public Builder clearTerm() { + bitField0_ = (bitField0_ & ~0x00000001); + term_ = 0L; + onChanged(); + return this; + } + + // optional int64 index = 2; + private long index_ ; + /** + * optional int64 index = 2; + */ + public boolean hasIndex() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional int64 index = 2; + */ + public long getIndex() { + return index_; + } + /** + * optional int64 index = 2; + */ + public Builder setIndex(long value) { + bitField0_ |= 0x00000002; + index_ = value; + onChanged(); + return this; + } + /** + * optional int64 index = 2; + */ + public Builder clearIndex() { + bitField0_ = (bitField0_ & ~0x00000002); + index_ = 0L; + onChanged(); + return this; + } + + // optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3; + private org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload data_ = org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.getDefaultInstance(); + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.Builder, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.PayloadOrBuilder> dataBuilder_; + /** + * optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3; + */ + public boolean hasData() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3; + */ + public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload getData() { + if (dataBuilder_ == null) { + return data_; + } else { + return dataBuilder_.getMessage(); + } + } + /** + * optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3; + */ + public Builder setData(org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload value) { + if (dataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + data_ = value; + onChanged(); + } else { + dataBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + return this; + } + /** + * optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3; + */ + public Builder setData( + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.Builder builderForValue) { + if (dataBuilder_ == null) { + data_ = builderForValue.build(); + onChanged(); + } else { + dataBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + return this; + } + /** + * optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3; + */ + public Builder mergeData(org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload value) { + if (dataBuilder_ == null) { + if (((bitField0_ & 0x00000004) == 0x00000004) && + data_ != org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.getDefaultInstance()) { + data_ = + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.newBuilder(data_).mergeFrom(value).buildPartial(); + } else { + data_ = value; + } + onChanged(); + } else { + dataBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000004; + return this; + } + /** + * optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3; + */ + public Builder clearData() { + if (dataBuilder_ == null) { + data_ = org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.getDefaultInstance(); + onChanged(); + } else { + dataBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000004); + return this; + } + /** + * optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3; + */ + public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.Builder getDataBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getDataFieldBuilder().getBuilder(); + } + /** + * optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3; + */ + public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.PayloadOrBuilder getDataOrBuilder() { + if (dataBuilder_ != null) { + return dataBuilder_.getMessageOrBuilder(); + } else { + return data_; + } + } + /** + * optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.Builder, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.PayloadOrBuilder> + getDataFieldBuilder() { + if (dataBuilder_ == null) { + dataBuilder_ = new com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.Builder, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.PayloadOrBuilder>( + data_, + getParentForChildren(), + isClean()); + data_ = null; + } + return dataBuilder_; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry) + } + + static { + defaultInstance = new ReplicatedLogEntry(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry) + } + + private int bitField0_; + // optional int64 term = 1; + public static final int TERM_FIELD_NUMBER = 1; + private long term_; + /** + * optional int64 term = 1; + */ + public boolean hasTerm() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional int64 term = 1; + */ + public long getTerm() { + return term_; + } + + // optional string leaderId = 2; + public static final int LEADERID_FIELD_NUMBER = 2; + private java.lang.Object leaderId_; + /** + * optional string leaderId = 2; + */ + public boolean hasLeaderId() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional string leaderId = 2; + */ + public java.lang.String getLeaderId() { + java.lang.Object ref = leaderId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + leaderId_ = s; + } + return s; + } + } + /** + * optional string leaderId = 2; + */ + public com.google.protobuf.ByteString + getLeaderIdBytes() { + java.lang.Object ref = leaderId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + leaderId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // optional int64 prevLogIndex = 3; + public static final int PREVLOGINDEX_FIELD_NUMBER = 3; + private long prevLogIndex_; + /** + * optional int64 prevLogIndex = 3; + */ + public boolean hasPrevLogIndex() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional int64 prevLogIndex = 3; + */ + public long getPrevLogIndex() { + return prevLogIndex_; + } + + // optional int64 prevLogTerm = 4; + public static final int PREVLOGTERM_FIELD_NUMBER = 4; + private long prevLogTerm_; + /** + * optional int64 prevLogTerm = 4; + */ + public boolean hasPrevLogTerm() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * optional int64 prevLogTerm = 4; + */ + public long getPrevLogTerm() { + return prevLogTerm_; + } + + // repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + public static final int LOGENTRIES_FIELD_NUMBER = 5; + private java.util.List logEntries_; + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + public java.util.List getLogEntriesList() { + return logEntries_; + } + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + public java.util.List + getLogEntriesOrBuilderList() { + return logEntries_; + } + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + public int getLogEntriesCount() { + return logEntries_.size(); + } + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry getLogEntries(int index) { + return logEntries_.get(index); + } + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder getLogEntriesOrBuilder( + int index) { + return logEntries_.get(index); + } + + // optional int64 leaderCommit = 6; + public static final int LEADERCOMMIT_FIELD_NUMBER = 6; + private long leaderCommit_; + /** + * optional int64 leaderCommit = 6; + */ + public boolean hasLeaderCommit() { + return ((bitField0_ & 0x00000010) == 0x00000010); + } + /** + * optional int64 leaderCommit = 6; + */ + public long getLeaderCommit() { + return leaderCommit_; + } + + private void initFields() { + term_ = 0L; + leaderId_ = ""; + prevLogIndex_ = 0L; + prevLogTerm_ = 0L; + logEntries_ = java.util.Collections.emptyList(); + leaderCommit_ = 0L; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + for (int i = 0; i < getLogEntriesCount(); i++) { + if (!getLogEntries(i).isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeInt64(1, term_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeBytes(2, getLeaderIdBytes()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeInt64(3, prevLogIndex_); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + output.writeInt64(4, prevLogTerm_); + } + for (int i = 0; i < logEntries_.size(); i++) { + output.writeMessage(5, logEntries_.get(i)); + } + if (((bitField0_ & 0x00000010) == 0x00000010)) { + output.writeInt64(6, leaderCommit_); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, term_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, getLeaderIdBytes()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, prevLogIndex_); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, prevLogTerm_); + } + for (int i = 0; i < logEntries_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, logEntries_.get(i)); + } + if (((bitField0_ & 0x00000010) == 0x00000010)) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(6, leaderCommit_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.cluster.raft.AppendEntries} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntriesOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.class, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.Builder.class); + } + + // Construct using org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getLogEntriesFieldBuilder(); + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + term_ = 0L; + bitField0_ = (bitField0_ & ~0x00000001); + leaderId_ = ""; + bitField0_ = (bitField0_ & ~0x00000002); + prevLogIndex_ = 0L; + bitField0_ = (bitField0_ & ~0x00000004); + prevLogTerm_ = 0L; + bitField0_ = (bitField0_ & ~0x00000008); + if (logEntriesBuilder_ == null) { + logEntries_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + } else { + logEntriesBuilder_.clear(); + } + leaderCommit_ = 0L; + bitField0_ = (bitField0_ & ~0x00000020); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_descriptor; + } + + public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries getDefaultInstanceForType() { + return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.getDefaultInstance(); + } + + public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries build() { + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries buildPartial() { + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries result = new org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.term_ = term_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.leaderId_ = leaderId_; + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000004; + } + result.prevLogIndex_ = prevLogIndex_; + if (((from_bitField0_ & 0x00000008) == 0x00000008)) { + to_bitField0_ |= 0x00000008; + } + result.prevLogTerm_ = prevLogTerm_; + if (logEntriesBuilder_ == null) { + if (((bitField0_ & 0x00000010) == 0x00000010)) { + logEntries_ = java.util.Collections.unmodifiableList(logEntries_); + bitField0_ = (bitField0_ & ~0x00000010); + } + result.logEntries_ = logEntries_; + } else { + result.logEntries_ = logEntriesBuilder_.build(); + } + if (((from_bitField0_ & 0x00000020) == 0x00000020)) { + to_bitField0_ |= 0x00000010; + } + result.leaderCommit_ = leaderCommit_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries) { + return mergeFrom((org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries other) { + if (other == org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.getDefaultInstance()) return this; + if (other.hasTerm()) { + setTerm(other.getTerm()); + } + if (other.hasLeaderId()) { + bitField0_ |= 0x00000002; + leaderId_ = other.leaderId_; + onChanged(); + } + if (other.hasPrevLogIndex()) { + setPrevLogIndex(other.getPrevLogIndex()); + } + if (other.hasPrevLogTerm()) { + setPrevLogTerm(other.getPrevLogTerm()); + } + if (logEntriesBuilder_ == null) { + if (!other.logEntries_.isEmpty()) { + if (logEntries_.isEmpty()) { + logEntries_ = other.logEntries_; + bitField0_ = (bitField0_ & ~0x00000010); + } else { + ensureLogEntriesIsMutable(); + logEntries_.addAll(other.logEntries_); + } + onChanged(); + } + } else { + if (!other.logEntries_.isEmpty()) { + if (logEntriesBuilder_.isEmpty()) { + logEntriesBuilder_.dispose(); + logEntriesBuilder_ = null; + logEntries_ = other.logEntries_; + bitField0_ = (bitField0_ & ~0x00000010); + logEntriesBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getLogEntriesFieldBuilder() : null; + } else { + logEntriesBuilder_.addAllMessages(other.logEntries_); + } + } + } + if (other.hasLeaderCommit()) { + setLeaderCommit(other.getLeaderCommit()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + for (int i = 0; i < getLogEntriesCount(); i++) { + if (!getLogEntries(i).isInitialized()) { + + return false; + } + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // optional int64 term = 1; + private long term_ ; + /** + * optional int64 term = 1; + */ + public boolean hasTerm() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional int64 term = 1; + */ + public long getTerm() { + return term_; + } + /** + * optional int64 term = 1; + */ + public Builder setTerm(long value) { + bitField0_ |= 0x00000001; + term_ = value; + onChanged(); + return this; + } + /** + * optional int64 term = 1; + */ + public Builder clearTerm() { + bitField0_ = (bitField0_ & ~0x00000001); + term_ = 0L; + onChanged(); + return this; + } + + // optional string leaderId = 2; + private java.lang.Object leaderId_ = ""; + /** + * optional string leaderId = 2; + */ + public boolean hasLeaderId() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional string leaderId = 2; + */ + public java.lang.String getLeaderId() { + java.lang.Object ref = leaderId_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + leaderId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string leaderId = 2; + */ + public com.google.protobuf.ByteString + getLeaderIdBytes() { + java.lang.Object ref = leaderId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + leaderId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string leaderId = 2; + */ + public Builder setLeaderId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + leaderId_ = value; + onChanged(); + return this; + } + /** + * optional string leaderId = 2; + */ + public Builder clearLeaderId() { + bitField0_ = (bitField0_ & ~0x00000002); + leaderId_ = getDefaultInstance().getLeaderId(); + onChanged(); + return this; + } + /** + * optional string leaderId = 2; + */ + public Builder setLeaderIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + leaderId_ = value; + onChanged(); + return this; + } + + // optional int64 prevLogIndex = 3; + private long prevLogIndex_ ; + /** + * optional int64 prevLogIndex = 3; + */ + public boolean hasPrevLogIndex() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional int64 prevLogIndex = 3; + */ + public long getPrevLogIndex() { + return prevLogIndex_; + } + /** + * optional int64 prevLogIndex = 3; + */ + public Builder setPrevLogIndex(long value) { + bitField0_ |= 0x00000004; + prevLogIndex_ = value; + onChanged(); + return this; + } + /** + * optional int64 prevLogIndex = 3; + */ + public Builder clearPrevLogIndex() { + bitField0_ = (bitField0_ & ~0x00000004); + prevLogIndex_ = 0L; + onChanged(); + return this; + } + + // optional int64 prevLogTerm = 4; + private long prevLogTerm_ ; + /** + * optional int64 prevLogTerm = 4; + */ + public boolean hasPrevLogTerm() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * optional int64 prevLogTerm = 4; + */ + public long getPrevLogTerm() { + return prevLogTerm_; + } + /** + * optional int64 prevLogTerm = 4; + */ + public Builder setPrevLogTerm(long value) { + bitField0_ |= 0x00000008; + prevLogTerm_ = value; + onChanged(); + return this; + } + /** + * optional int64 prevLogTerm = 4; + */ + public Builder clearPrevLogTerm() { + bitField0_ = (bitField0_ & ~0x00000008); + prevLogTerm_ = 0L; + onChanged(); + return this; + } + + // repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + private java.util.List logEntries_ = + java.util.Collections.emptyList(); + private void ensureLogEntriesIsMutable() { + if (!((bitField0_ & 0x00000010) == 0x00000010)) { + logEntries_ = new java.util.ArrayList(logEntries_); + bitField0_ |= 0x00000010; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder> logEntriesBuilder_; + + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + public java.util.List getLogEntriesList() { + if (logEntriesBuilder_ == null) { + return java.util.Collections.unmodifiableList(logEntries_); + } else { + return logEntriesBuilder_.getMessageList(); + } + } + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + public int getLogEntriesCount() { + if (logEntriesBuilder_ == null) { + return logEntries_.size(); + } else { + return logEntriesBuilder_.getCount(); + } + } + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry getLogEntries(int index) { + if (logEntriesBuilder_ == null) { + return logEntries_.get(index); + } else { + return logEntriesBuilder_.getMessage(index); + } + } + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + public Builder setLogEntries( + int index, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry value) { + if (logEntriesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureLogEntriesIsMutable(); + logEntries_.set(index, value); + onChanged(); + } else { + logEntriesBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + public Builder setLogEntries( + int index, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder builderForValue) { + if (logEntriesBuilder_ == null) { + ensureLogEntriesIsMutable(); + logEntries_.set(index, builderForValue.build()); + onChanged(); + } else { + logEntriesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + public Builder addLogEntries(org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry value) { + if (logEntriesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureLogEntriesIsMutable(); + logEntries_.add(value); + onChanged(); + } else { + logEntriesBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + public Builder addLogEntries( + int index, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry value) { + if (logEntriesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureLogEntriesIsMutable(); + logEntries_.add(index, value); + onChanged(); + } else { + logEntriesBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + public Builder addLogEntries( + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder builderForValue) { + if (logEntriesBuilder_ == null) { + ensureLogEntriesIsMutable(); + logEntries_.add(builderForValue.build()); + onChanged(); + } else { + logEntriesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + public Builder addLogEntries( + int index, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder builderForValue) { + if (logEntriesBuilder_ == null) { + ensureLogEntriesIsMutable(); + logEntries_.add(index, builderForValue.build()); + onChanged(); + } else { + logEntriesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + public Builder addAllLogEntries( + java.lang.Iterable values) { + if (logEntriesBuilder_ == null) { + ensureLogEntriesIsMutable(); + super.addAll(values, logEntries_); + onChanged(); + } else { + logEntriesBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + public Builder clearLogEntries() { + if (logEntriesBuilder_ == null) { + logEntries_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + } else { + logEntriesBuilder_.clear(); + } + return this; + } + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + public Builder removeLogEntries(int index) { + if (logEntriesBuilder_ == null) { + ensureLogEntriesIsMutable(); + logEntries_.remove(index); + onChanged(); + } else { + logEntriesBuilder_.remove(index); + } + return this; + } + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder getLogEntriesBuilder( + int index) { + return getLogEntriesFieldBuilder().getBuilder(index); + } + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder getLogEntriesOrBuilder( + int index) { + if (logEntriesBuilder_ == null) { + return logEntries_.get(index); } else { + return logEntriesBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + public java.util.List + getLogEntriesOrBuilderList() { + if (logEntriesBuilder_ != null) { + return logEntriesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(logEntries_); + } + } + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder addLogEntriesBuilder() { + return getLogEntriesFieldBuilder().addBuilder( + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.getDefaultInstance()); + } + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder addLogEntriesBuilder( + int index) { + return getLogEntriesFieldBuilder().addBuilder( + index, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.getDefaultInstance()); + } + /** + * repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5; + */ + public java.util.List + getLogEntriesBuilderList() { + return getLogEntriesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder> + getLogEntriesFieldBuilder() { + if (logEntriesBuilder_ == null) { + logEntriesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder>( + logEntries_, + ((bitField0_ & 0x00000010) == 0x00000010), + getParentForChildren(), + isClean()); + logEntries_ = null; + } + return logEntriesBuilder_; + } + + // optional int64 leaderCommit = 6; + private long leaderCommit_ ; + /** + * optional int64 leaderCommit = 6; + */ + public boolean hasLeaderCommit() { + return ((bitField0_ & 0x00000020) == 0x00000020); + } + /** + * optional int64 leaderCommit = 6; + */ + public long getLeaderCommit() { + return leaderCommit_; + } + /** + * optional int64 leaderCommit = 6; + */ + public Builder setLeaderCommit(long value) { + bitField0_ |= 0x00000020; + leaderCommit_ = value; + onChanged(); + return this; + } + /** + * optional int64 leaderCommit = 6; + */ + public Builder clearLeaderCommit() { + bitField0_ = (bitField0_ & ~0x00000020); + leaderCommit_ = 0L; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.cluster.raft.AppendEntries) + } + + static { + defaultInstance = new AppendEntries(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.cluster.raft.AppendEntries) + } + + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_Payload_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_Payload_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\033AppendEntriesMessages.proto\022(org.opend" + + "aylight.controller.cluster.raft\"\227\003\n\rAppe" + + "ndEntries\022\014\n\004term\030\001 \001(\003\022\020\n\010leaderId\030\002 \001(" + + "\t\022\024\n\014prevLogIndex\030\003 \001(\003\022\023\n\013prevLogTerm\030\004" + + " \001(\003\022^\n\nlogEntries\030\005 \003(\0132J.org.opendayli" + + "ght.controller.cluster.raft.AppendEntrie" + + "s.ReplicatedLogEntry\022\024\n\014leaderCommit\030\006 \001" + + "(\003\032\304\001\n\022ReplicatedLogEntry\022\014\n\004term\030\001 \001(\003\022" + + "\r\n\005index\030\002 \001(\003\022`\n\004data\030\003 \001(\0132R.org.opend" + + "aylight.controller.cluster.raft.AppendEn", + "tries.ReplicatedLogEntry.Payload\032/\n\007Payl" + + "oad\022\036\n\026clientPayloadClassName\030\001 \001(\t*\004\010\002\020" + + "eBV\n;org.opendaylight.controller.cluster" + + ".raft.protobuff.messagesB\025AppendEntriesM" + + "essagesH\001" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_descriptor, + new java.lang.String[] { "Term", "LeaderId", "PrevLogIndex", "PrevLogTerm", "LogEntries", "LeaderCommit", }); + internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_descriptor = + internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_descriptor.getNestedTypes().get(0); + internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_descriptor, + new java.lang.String[] { "Term", "Index", "Data", }); + internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_Payload_descriptor = + internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_descriptor.getNestedTypes().get(0); + internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_Payload_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_Payload_descriptor, + new java.lang.String[] { "ClientPayloadClassName", }); + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/protobuff/messages/VotingMessages.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/protobuff/messages/VotingMessages.java new file mode 100644 index 0000000000..5b3bd2b3a9 --- /dev/null +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/protobuff/messages/VotingMessages.java @@ -0,0 +1,767 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: VotingMessages.proto + +package org.opendaylight.controller.cluster.raft.protobuff.messages; + +public final class VotingMessages { + private VotingMessages() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + public interface RequestVoteOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // optional int64 term = 1; + /** + * optional int64 term = 1; + */ + boolean hasTerm(); + /** + * optional int64 term = 1; + */ + long getTerm(); + + // optional string candidateId = 2; + /** + * optional string candidateId = 2; + */ + boolean hasCandidateId(); + /** + * optional string candidateId = 2; + */ + java.lang.String getCandidateId(); + /** + * optional string candidateId = 2; + */ + com.google.protobuf.ByteString + getCandidateIdBytes(); + + // optional int64 lastLongIndex = 3; + /** + * optional int64 lastLongIndex = 3; + */ + boolean hasLastLongIndex(); + /** + * optional int64 lastLongIndex = 3; + */ + long getLastLongIndex(); + + // optional int64 lastLongTerm = 4; + /** + * optional int64 lastLongTerm = 4; + */ + boolean hasLastLongTerm(); + /** + * optional int64 lastLongTerm = 4; + */ + long getLastLongTerm(); + } + /** + * Protobuf type {@code org.opendaylight.controller.cluster.raft.RequestVote} + */ + public static final class RequestVote extends + com.google.protobuf.GeneratedMessage + implements RequestVoteOrBuilder { + // Use RequestVote.newBuilder() to construct. + private RequestVote(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private RequestVote(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final RequestVote defaultInstance; + public static RequestVote getDefaultInstance() { + return defaultInstance; + } + + public RequestVote getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private RequestVote( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + bitField0_ |= 0x00000001; + term_ = input.readInt64(); + break; + } + case 18: { + bitField0_ |= 0x00000002; + candidateId_ = input.readBytes(); + break; + } + case 24: { + bitField0_ |= 0x00000004; + lastLongIndex_ = input.readInt64(); + break; + } + case 32: { + bitField0_ |= 0x00000008; + lastLongTerm_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.internal_static_org_opendaylight_controller_cluster_raft_RequestVote_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.internal_static_org_opendaylight_controller_cluster_raft_RequestVote_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote.class, org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public RequestVote parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new RequestVote(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // optional int64 term = 1; + public static final int TERM_FIELD_NUMBER = 1; + private long term_; + /** + * optional int64 term = 1; + */ + public boolean hasTerm() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional int64 term = 1; + */ + public long getTerm() { + return term_; + } + + // optional string candidateId = 2; + public static final int CANDIDATEID_FIELD_NUMBER = 2; + private java.lang.Object candidateId_; + /** + * optional string candidateId = 2; + */ + public boolean hasCandidateId() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional string candidateId = 2; + */ + public java.lang.String getCandidateId() { + java.lang.Object ref = candidateId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + candidateId_ = s; + } + return s; + } + } + /** + * optional string candidateId = 2; + */ + public com.google.protobuf.ByteString + getCandidateIdBytes() { + java.lang.Object ref = candidateId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + candidateId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // optional int64 lastLongIndex = 3; + public static final int LASTLONGINDEX_FIELD_NUMBER = 3; + private long lastLongIndex_; + /** + * optional int64 lastLongIndex = 3; + */ + public boolean hasLastLongIndex() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional int64 lastLongIndex = 3; + */ + public long getLastLongIndex() { + return lastLongIndex_; + } + + // optional int64 lastLongTerm = 4; + public static final int LASTLONGTERM_FIELD_NUMBER = 4; + private long lastLongTerm_; + /** + * optional int64 lastLongTerm = 4; + */ + public boolean hasLastLongTerm() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * optional int64 lastLongTerm = 4; + */ + public long getLastLongTerm() { + return lastLongTerm_; + } + + private void initFields() { + term_ = 0L; + candidateId_ = ""; + lastLongIndex_ = 0L; + lastLongTerm_ = 0L; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeInt64(1, term_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeBytes(2, getCandidateIdBytes()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeInt64(3, lastLongIndex_); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + output.writeInt64(4, lastLongTerm_); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, term_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, getCandidateIdBytes()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, lastLongIndex_); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, lastLongTerm_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.cluster.raft.RequestVote} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVoteOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.internal_static_org_opendaylight_controller_cluster_raft_RequestVote_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.internal_static_org_opendaylight_controller_cluster_raft_RequestVote_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote.class, org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote.Builder.class); + } + + // Construct using org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + term_ = 0L; + bitField0_ = (bitField0_ & ~0x00000001); + candidateId_ = ""; + bitField0_ = (bitField0_ & ~0x00000002); + lastLongIndex_ = 0L; + bitField0_ = (bitField0_ & ~0x00000004); + lastLongTerm_ = 0L; + bitField0_ = (bitField0_ & ~0x00000008); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.internal_static_org_opendaylight_controller_cluster_raft_RequestVote_descriptor; + } + + public org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote getDefaultInstanceForType() { + return org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote.getDefaultInstance(); + } + + public org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote build() { + org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote buildPartial() { + org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote result = new org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.term_ = term_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.candidateId_ = candidateId_; + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000004; + } + result.lastLongIndex_ = lastLongIndex_; + if (((from_bitField0_ & 0x00000008) == 0x00000008)) { + to_bitField0_ |= 0x00000008; + } + result.lastLongTerm_ = lastLongTerm_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote) { + return mergeFrom((org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote other) { + if (other == org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote.getDefaultInstance()) return this; + if (other.hasTerm()) { + setTerm(other.getTerm()); + } + if (other.hasCandidateId()) { + bitField0_ |= 0x00000002; + candidateId_ = other.candidateId_; + onChanged(); + } + if (other.hasLastLongIndex()) { + setLastLongIndex(other.getLastLongIndex()); + } + if (other.hasLastLongTerm()) { + setLastLongTerm(other.getLastLongTerm()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // optional int64 term = 1; + private long term_ ; + /** + * optional int64 term = 1; + */ + public boolean hasTerm() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional int64 term = 1; + */ + public long getTerm() { + return term_; + } + /** + * optional int64 term = 1; + */ + public Builder setTerm(long value) { + bitField0_ |= 0x00000001; + term_ = value; + onChanged(); + return this; + } + /** + * optional int64 term = 1; + */ + public Builder clearTerm() { + bitField0_ = (bitField0_ & ~0x00000001); + term_ = 0L; + onChanged(); + return this; + } + + // optional string candidateId = 2; + private java.lang.Object candidateId_ = ""; + /** + * optional string candidateId = 2; + */ + public boolean hasCandidateId() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional string candidateId = 2; + */ + public java.lang.String getCandidateId() { + java.lang.Object ref = candidateId_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + candidateId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string candidateId = 2; + */ + public com.google.protobuf.ByteString + getCandidateIdBytes() { + java.lang.Object ref = candidateId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + candidateId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string candidateId = 2; + */ + public Builder setCandidateId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + candidateId_ = value; + onChanged(); + return this; + } + /** + * optional string candidateId = 2; + */ + public Builder clearCandidateId() { + bitField0_ = (bitField0_ & ~0x00000002); + candidateId_ = getDefaultInstance().getCandidateId(); + onChanged(); + return this; + } + /** + * optional string candidateId = 2; + */ + public Builder setCandidateIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + candidateId_ = value; + onChanged(); + return this; + } + + // optional int64 lastLongIndex = 3; + private long lastLongIndex_ ; + /** + * optional int64 lastLongIndex = 3; + */ + public boolean hasLastLongIndex() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional int64 lastLongIndex = 3; + */ + public long getLastLongIndex() { + return lastLongIndex_; + } + /** + * optional int64 lastLongIndex = 3; + */ + public Builder setLastLongIndex(long value) { + bitField0_ |= 0x00000004; + lastLongIndex_ = value; + onChanged(); + return this; + } + /** + * optional int64 lastLongIndex = 3; + */ + public Builder clearLastLongIndex() { + bitField0_ = (bitField0_ & ~0x00000004); + lastLongIndex_ = 0L; + onChanged(); + return this; + } + + // optional int64 lastLongTerm = 4; + private long lastLongTerm_ ; + /** + * optional int64 lastLongTerm = 4; + */ + public boolean hasLastLongTerm() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * optional int64 lastLongTerm = 4; + */ + public long getLastLongTerm() { + return lastLongTerm_; + } + /** + * optional int64 lastLongTerm = 4; + */ + public Builder setLastLongTerm(long value) { + bitField0_ |= 0x00000008; + lastLongTerm_ = value; + onChanged(); + return this; + } + /** + * optional int64 lastLongTerm = 4; + */ + public Builder clearLastLongTerm() { + bitField0_ = (bitField0_ & ~0x00000008); + lastLongTerm_ = 0L; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.cluster.raft.RequestVote) + } + + static { + defaultInstance = new RequestVote(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.cluster.raft.RequestVote) + } + + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_cluster_raft_RequestVote_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_cluster_raft_RequestVote_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\024VotingMessages.proto\022(org.opendaylight" + + ".controller.cluster.raft\"]\n\013RequestVote\022" + + "\014\n\004term\030\001 \001(\003\022\023\n\013candidateId\030\002 \001(\t\022\025\n\rla" + + "stLongIndex\030\003 \001(\003\022\024\n\014lastLongTerm\030\004 \001(\003B" + + "O\n;org.opendaylight.controller.cluster.r" + + "aft.protobuff.messagesB\016VotingMessagesH\001" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + internal_static_org_opendaylight_controller_cluster_raft_RequestVote_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_org_opendaylight_controller_cluster_raft_RequestVote_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_cluster_raft_RequestVote_descriptor, + new java.lang.String[] { "Term", "CandidateId", "LastLongIndex", "LastLongTerm", }); + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/resources/AppendEntriesMessages.proto b/opendaylight/md-sal/sal-akka-raft/src/main/resources/AppendEntriesMessages.proto new file mode 100644 index 0000000000..ab591ea079 --- /dev/null +++ b/opendaylight/md-sal/sal-akka-raft/src/main/resources/AppendEntriesMessages.proto @@ -0,0 +1,30 @@ +package org.opendaylight.controller.cluster.raft; + +option java_package = "org.opendaylight.controller.cluster.raft.protobuff.messages"; +option java_outer_classname = "AppendEntriesMessages"; +option optimize_for = SPEED; + +message AppendEntries { + optional int64 term = 1; + optional string leaderId = 2; + optional int64 prevLogIndex = 3; + optional int64 prevLogTerm = 4; + + message ReplicatedLogEntry { + optional int64 term = 1; + optional int64 index = 2; + + message Payload { + optional string clientPayloadClassName = 1; + extensions 2 to 100; + } + + optional Payload data = 3; + } + + repeated ReplicatedLogEntry logEntries = 5; + optional int64 leaderCommit = 6; + +} + + diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/resources/KeyValueMessages.proto b/opendaylight/md-sal/sal-akka-raft/src/main/resources/KeyValueMessages.proto new file mode 100644 index 0000000000..7ee0b215ee --- /dev/null +++ b/opendaylight/md-sal/sal-akka-raft/src/main/resources/KeyValueMessages.proto @@ -0,0 +1,13 @@ +package org.opendaylight.controller.cluster.raft; + +import "AppendEntriesMessages.proto"; + +option java_package = "org.opendaylight.controller.cluster.example.protobuff.messages"; +option java_outer_classname = "KeyValueMessages"; +option optimize_for = SPEED; + +// proto file for the payload of Example, extending AppendEntries +extend AppendEntries.ReplicatedLogEntry.Payload { + optional string key = 2; + optional string value = 3; +} diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/resources/VotingMessages.proto b/opendaylight/md-sal/sal-akka-raft/src/main/resources/VotingMessages.proto new file mode 100644 index 0000000000..6a45a2bfc9 --- /dev/null +++ b/opendaylight/md-sal/sal-akka-raft/src/main/resources/VotingMessages.proto @@ -0,0 +1,13 @@ +package org.opendaylight.controller.cluster.raft; + +option java_package = "org.opendaylight.controller.cluster.raft.protobuff.messages"; +option java_outer_classname = "VotingMessages"; +option optimize_for = SPEED; + +message RequestVote { + optional int64 term = 1; + optional string candidateId = 2; + optional int64 lastLongIndex = 3; + optional int64 lastLongTerm = 4; + +} diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/resources/application.conf b/opendaylight/md-sal/sal-akka-raft/src/main/resources/application.conf index 494a99e5d6..9e42a13c6a 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/resources/application.conf +++ b/opendaylight/md-sal/sal-akka-raft/src/main/resources/application.conf @@ -1,12 +1,20 @@ akka { + loglevel = "DEBUG" + actor { + # enable to test serialization only. + # serialize-messages = on + serializers { - java = "akka.serialization.JavaSerializer" + java = "akka.serialization.JavaSerializer" + proto = "akka.remote.serialization.ProtobufSerializer" } serialization-bindings { - "org.opendaylight.controller.cluster.raft.RaftActor$ReplicatedLogImplEntry" = java + "org.opendaylight.controller.cluster.raft.ReplicatedLogImplEntry" = java + "com.google.protobuf.Message" = proto + "com.google.protobuf.GeneratedMessage" = proto } } } 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 77d0071917..2e200cba27 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 @@ -14,7 +14,13 @@ import akka.actor.ActorSystem; import akka.actor.Props; import akka.event.Logging; import akka.event.LoggingAdapter; +import com.google.protobuf.GeneratedMessage; +import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload; +import org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages; +import org.opendaylight.controller.cluster.raft.protobuff.messages.MockPayloadMessages; +import com.google.common.base.Preconditions; +import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -79,7 +85,7 @@ public class MockRaftActorContext implements RaftActorContext { public void initReplicatedLog(){ this.replicatedLog = new SimpleReplicatedLog(); - this.replicatedLog.append(new MockReplicatedLogEntry(1, 1, "")); + this.replicatedLog.append(new MockReplicatedLogEntry(1, 1, new MockPayload(""))); } @Override public ActorRef actorOf(Props props) { @@ -154,6 +160,19 @@ public class MockRaftActorContext implements RaftActorContext { peerAddresses.remove(name); } + @Override public ActorSelection getPeerActorSelection(String peerId) { + String peerAddress = getPeerAddress(peerId); + if(peerAddress != null){ + return actorSelection(peerAddress); + } + return null; + } + + @Override public void setPeerAddress(String peerId, String peerAddress) { + Preconditions.checkState(peerAddresses.containsKey(peerId)); + peerAddresses.put(peerId, peerAddress); + } + public void setPeerAddresses(Map peerAddresses) { this.peerAddresses = peerAddresses; } @@ -255,20 +274,49 @@ public class MockRaftActorContext implements RaftActorContext { } } - public static class MockReplicatedLogEntry implements ReplicatedLogEntry { + public static class MockPayload extends Payload implements Serializable { + private String value = ""; + + public MockPayload(String s) { + this.value = s; + } + + @Override public Map encode() { + Map map = new HashMap(); + map.put(MockPayloadMessages.value, value); + return map; + } + + @Override public Payload decode( + AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload payloadProtoBuff) { + String value = payloadProtoBuff.getExtension(MockPayloadMessages.value); + this.value = value; + return this; + } + + @Override public String getClientPayloadClassName() { + return MockPayload.class.getName(); + } + + public String toString() { + return value; + } + } + + public static class MockReplicatedLogEntry implements ReplicatedLogEntry, Serializable { private final long term; private final long index; - private final Object data; + private final Payload data; - public MockReplicatedLogEntry(long term, long index, Object data){ + public MockReplicatedLogEntry(long term, long index, Payload data){ this.term = term; this.index = index; this.data = data; } - @Override public Object getData() { + @Override public Payload getData() { return data; } diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractRaftActorBehaviorTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractRaftActorBehaviorTest.java index 1a37b921e3..8068dfbcff 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractRaftActorBehaviorTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractRaftActorBehaviorTest.java @@ -9,11 +9,13 @@ import org.opendaylight.controller.cluster.raft.MockRaftActorContext; import org.opendaylight.controller.cluster.raft.RaftActorContext; import org.opendaylight.controller.cluster.raft.RaftState; import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry; +import org.opendaylight.controller.cluster.raft.SerializationUtils; import org.opendaylight.controller.cluster.raft.messages.AppendEntries; import org.opendaylight.controller.cluster.raft.messages.AppendEntriesReply; import org.opendaylight.controller.cluster.raft.messages.RaftRPC; import org.opendaylight.controller.cluster.raft.messages.RequestVote; import org.opendaylight.controller.cluster.raft.messages.RequestVoteReply; +import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload; import org.opendaylight.controller.cluster.raft.utils.DoNothingActor; import java.util.ArrayList; @@ -120,13 +122,13 @@ public abstract class AbstractRaftActorBehaviorTest extends AbstractActorTest { MockRaftActorContext.SimpleReplicatedLog log = new MockRaftActorContext.SimpleReplicatedLog(); log.append( - new MockRaftActorContext.MockReplicatedLogEntry(1, 0, "zero")); + new MockRaftActorContext.MockReplicatedLogEntry(1, 0, new MockRaftActorContext.MockPayload("zero"))); context.setReplicatedLog(log); List entries = new ArrayList<>(); entries.add( - new MockRaftActorContext.MockReplicatedLogEntry(1, 0, "zero")); + new MockRaftActorContext.MockReplicatedLogEntry(1, 0, new MockRaftActorContext.MockPayload("zero"))); AppendEntries appendEntries = new AppendEntries(2, "leader-1", -1, 1, entries, 0); @@ -220,7 +222,7 @@ public abstract class AbstractRaftActorBehaviorTest extends AbstractActorTest { log = new MockRaftActorContext.SimpleReplicatedLog(); log.append( new MockRaftActorContext.MockReplicatedLogEntry(20000, - 1000000, "")); + 1000000, new MockRaftActorContext.MockPayload(""))); ((MockRaftActorContext) actorContext).setReplicatedLog(log); @@ -303,8 +305,9 @@ public abstract class AbstractRaftActorBehaviorTest extends AbstractActorTest { ActorRef actorRef, RaftRPC rpc) { RaftActorContext actorContext = createActorContext(); + Payload p = new MockRaftActorContext.MockPayload(""); setLastLogEntry( - (MockRaftActorContext) actorContext, 0, 0, ""); + (MockRaftActorContext) actorContext, 0, 0, p); RaftState raftState = createBehavior(actorContext) .handleMessage(actorRef, rpc); @@ -313,7 +316,7 @@ public abstract class AbstractRaftActorBehaviorTest extends AbstractActorTest { } protected MockRaftActorContext.SimpleReplicatedLog setLastLogEntry( - MockRaftActorContext actorContext, long term, long index, Object data) { + MockRaftActorContext actorContext, long term, long index, Payload data) { return setLastLogEntry(actorContext, new MockRaftActorContext.MockReplicatedLogEntry(term, index, data)); } @@ -359,6 +362,7 @@ public abstract class AbstractRaftActorBehaviorTest extends AbstractActorTest { return new RequestVoteReply(100, false); } - - + protected Object fromSerializableMessage(Object serializable){ + return SerializationUtils.fromSerializable(serializable); + } } 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 8bcee58afe..c763683705 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 @@ -9,7 +9,7 @@ import org.junit.Test; import org.opendaylight.controller.cluster.raft.MockRaftActorContext; import org.opendaylight.controller.cluster.raft.RaftActorContext; import org.opendaylight.controller.cluster.raft.RaftState; -import org.opendaylight.controller.cluster.raft.internal.messages.ElectionTimeout; +import org.opendaylight.controller.cluster.raft.base.messages.ElectionTimeout; import org.opendaylight.controller.cluster.raft.messages.AppendEntries; import org.opendaylight.controller.cluster.raft.messages.AppendEntriesReply; import org.opendaylight.controller.cluster.raft.messages.RequestVote; 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 b7c371dd39..c015d950c4 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 @@ -9,7 +9,7 @@ import org.opendaylight.controller.cluster.raft.MockRaftActorContext; import org.opendaylight.controller.cluster.raft.RaftActorContext; import org.opendaylight.controller.cluster.raft.RaftState; import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry; -import org.opendaylight.controller.cluster.raft.internal.messages.ElectionTimeout; +import org.opendaylight.controller.cluster.raft.base.messages.ElectionTimeout; import org.opendaylight.controller.cluster.raft.messages.AppendEntries; import org.opendaylight.controller.cluster.raft.messages.AppendEntriesReply; import org.opendaylight.controller.cluster.raft.messages.RequestVote; @@ -157,12 +157,12 @@ public class FollowerTest extends AbstractRaftActorBehaviorTest { createActorContext(); context.setLastApplied(100); - setLastLogEntry((MockRaftActorContext) context, 0, 0, ""); + setLastLogEntry((MockRaftActorContext) context, 0, 0, new MockRaftActorContext.MockPayload("")); List entries = Arrays.asList( (ReplicatedLogEntry) new MockRaftActorContext.MockReplicatedLogEntry(100, 101, - "foo") + new MockRaftActorContext.MockPayload("foo")) ); // The new commitIndex is 101 @@ -198,7 +198,7 @@ public class FollowerTest extends AbstractRaftActorBehaviorTest { // Set the last log entry term for the receiver to be greater than // what we will be sending as the prevLogTerm in AppendEntries MockRaftActorContext.SimpleReplicatedLog mockReplicatedLog = - setLastLogEntry(context, 20, 0, ""); + setLastLogEntry(context, 20, 0, new MockRaftActorContext.MockPayload("")); // AppendEntries is now sent with a bigger term // this will set the receivers term to be the same as the sender's term @@ -259,20 +259,20 @@ public class FollowerTest extends AbstractRaftActorBehaviorTest { MockRaftActorContext.SimpleReplicatedLog log = new MockRaftActorContext.SimpleReplicatedLog(); log.append( - new MockRaftActorContext.MockReplicatedLogEntry(1, 0, "zero")); + new MockRaftActorContext.MockReplicatedLogEntry(1, 0, new MockRaftActorContext.MockPayload("zero"))); log.append( - new MockRaftActorContext.MockReplicatedLogEntry(1, 1, "one")); + new MockRaftActorContext.MockReplicatedLogEntry(1, 1, new MockRaftActorContext.MockPayload("one"))); log.append( - new MockRaftActorContext.MockReplicatedLogEntry(1, 2, "two")); + new MockRaftActorContext.MockReplicatedLogEntry(1, 2, new MockRaftActorContext.MockPayload("two"))); context.setReplicatedLog(log); // Prepare the entries to be sent with AppendEntries List entries = new ArrayList<>(); entries.add( - new MockRaftActorContext.MockReplicatedLogEntry(1, 3, "three")); + new MockRaftActorContext.MockReplicatedLogEntry(1, 3, new MockRaftActorContext.MockPayload("three"))); entries.add( - new MockRaftActorContext.MockReplicatedLogEntry(1, 4, "four")); + new MockRaftActorContext.MockReplicatedLogEntry(1, 4, new MockRaftActorContext.MockPayload("four"))); // Send appendEntries with the same term as was set on the receiver // before the new behavior was created (1 in this case) @@ -339,20 +339,20 @@ public class FollowerTest extends AbstractRaftActorBehaviorTest { MockRaftActorContext.SimpleReplicatedLog log = new MockRaftActorContext.SimpleReplicatedLog(); log.append( - new MockRaftActorContext.MockReplicatedLogEntry(1, 0, "zero")); + new MockRaftActorContext.MockReplicatedLogEntry(1, 0, new MockRaftActorContext.MockPayload("zero"))); log.append( - new MockRaftActorContext.MockReplicatedLogEntry(1, 1, "one")); + new MockRaftActorContext.MockReplicatedLogEntry(1, 1, new MockRaftActorContext.MockPayload("one"))); log.append( - new MockRaftActorContext.MockReplicatedLogEntry(1, 2, "two")); + new MockRaftActorContext.MockReplicatedLogEntry(1, 2, new MockRaftActorContext.MockPayload("two"))); context.setReplicatedLog(log); // Prepare the entries to be sent with AppendEntries List entries = new ArrayList<>(); entries.add( - new MockRaftActorContext.MockReplicatedLogEntry(2, 2, "two-1")); + new MockRaftActorContext.MockReplicatedLogEntry(2, 2, new MockRaftActorContext.MockPayload("two-1"))); entries.add( - new MockRaftActorContext.MockReplicatedLogEntry(2, 3, "three")); + new MockRaftActorContext.MockReplicatedLogEntry(2, 3, new MockRaftActorContext.MockPayload("three"))); // Send appendEntries with the same term as was set on the receiver // before the new behavior was created (1 in this case) @@ -378,13 +378,13 @@ public class FollowerTest extends AbstractRaftActorBehaviorTest { assertEquals(4, log.last().getIndex() + 1); assertNotNull(log.get(2)); - - assertEquals("one", log.get(1).getData()); + assertEquals("one", log.get(1).getData().toString()); // Check that the entry at index 2 has the new data - assertEquals("two-1", log.get(2).getData()); + assertEquals("two-1", log.get(2).getData().toString()); + + assertEquals("three", log.get(3).getData().toString()); - assertEquals("three", log.get(3).getData()); assertNotNull(log.get(3)); // Also expect an AppendEntriesReply to be sent where success is false diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderTest.java index 35bf6f15b4..d33b33925b 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderTest.java @@ -8,9 +8,9 @@ import org.junit.Test; import org.opendaylight.controller.cluster.raft.MockRaftActorContext; import org.opendaylight.controller.cluster.raft.RaftActorContext; import org.opendaylight.controller.cluster.raft.RaftState; -import org.opendaylight.controller.cluster.raft.internal.messages.ApplyState; -import org.opendaylight.controller.cluster.raft.internal.messages.Replicate; -import org.opendaylight.controller.cluster.raft.internal.messages.SendHeartBeat; +import org.opendaylight.controller.cluster.raft.base.messages.ApplyState; +import org.opendaylight.controller.cluster.raft.base.messages.Replicate; +import org.opendaylight.controller.cluster.raft.base.messages.SendHeartBeat; import org.opendaylight.controller.cluster.raft.messages.AppendEntries; import org.opendaylight.controller.cluster.raft.utils.DoNothingActor; @@ -63,13 +63,12 @@ public class LeaderTest extends AbstractRaftActorBehaviorTest { leader.handleMessage(senderActor, new SendHeartBeat()); final String out = - new ExpectMsg(duration("1 seconds"), - "match hint") { + 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 AppendEntries) { - if (((AppendEntries) in).getTerm() - == 0) { + Object msg = fromSerializableMessage(in); + if (msg instanceof AppendEntries) { + if (((AppendEntries)msg).getTerm() == 0) { return "match"; } return null; @@ -112,20 +111,19 @@ public class LeaderTest extends AbstractRaftActorBehaviorTest { .handleMessage(senderActor, new Replicate(null, null, new MockRaftActorContext.MockReplicatedLogEntry(1, 100, - "foo") + new MockRaftActorContext.MockPayload("foo")) )); // State should not change assertEquals(RaftState.Leader, raftState); final String out = - new ExpectMsg(duration("1 seconds"), - "match hint") { + 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 AppendEntries) { - if (((AppendEntries) in).getTerm() - == 0) { + Object msg = fromSerializableMessage(in); + if (msg instanceof AppendEntries) { + if (((AppendEntries)msg).getTerm() == 0) { return "match"; } return null; @@ -161,7 +159,7 @@ public class LeaderTest extends AbstractRaftActorBehaviorTest { .handleMessage(senderActor, new Replicate(null, "state-id", new MockRaftActorContext.MockReplicatedLogEntry(1, 100, - "foo") + new MockRaftActorContext.MockPayload("foo")) )); // State should not change diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/protobuff/messages/MockPayloadMessages.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/protobuff/messages/MockPayloadMessages.java new file mode 100644 index 0000000000..1f618a390c --- /dev/null +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/protobuff/messages/MockPayloadMessages.java @@ -0,0 +1,57 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: MockPayload.proto + +package org.opendaylight.controller.cluster.raft.protobuff.messages; + +public final class MockPayloadMessages { + private MockPayloadMessages() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registry.add(org.opendaylight.controller.cluster.raft.protobuff.messages.MockPayloadMessages.value); + } + public static final int VALUE_FIELD_NUMBER = 2; + /** + * extend .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload { ... } + */ + public static final + com.google.protobuf.GeneratedMessage.GeneratedExtension< + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload, + java.lang.String> value = com.google.protobuf.GeneratedMessage + .newFileScopedGeneratedExtension( + java.lang.String.class, + null); + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\021MockPayload.proto\022(org.opendaylight.co" + + "ntroller.cluster.raft\032\033AppendEntriesMess" + + "ages.proto:a\n\005value\022R.org.opendaylight.c" + + "ontroller.cluster.raft.AppendEntries.Rep" + + "licatedLogEntry.Payload\030\002 \001(\tBR\n;org.ope" + + "ndaylight.controller.cluster.raft.protob" + + "uff.messagesB\023MockPayloadMessages" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + value.internalInit(descriptor.getExtensions().get(0)); + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.getDescriptor(), + }, assigner); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/resources/MockPayload.proto b/opendaylight/md-sal/sal-akka-raft/src/test/resources/MockPayload.proto new file mode 100644 index 0000000000..0e0c604489 --- /dev/null +++ b/opendaylight/md-sal/sal-akka-raft/src/test/resources/MockPayload.proto @@ -0,0 +1,10 @@ +import "AppendEntriesMessages.proto"; + +package org.opendaylight.controller.cluster.raft; + +option java_package = "org.opendaylight.controller.cluster.raft.protobuff.messages"; +option java_outer_classname = "MockPayloadMessages"; + +extend AppendEntries.ReplicatedLogEntry.Payload { + optional string value = 2; +} diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/resources/application.conf b/opendaylight/md-sal/sal-akka-raft/src/test/resources/application.conf index 2647850667..dbe7508cc8 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/resources/application.conf +++ b/opendaylight/md-sal/sal-akka-raft/src/test/resources/application.conf @@ -1,11 +1,20 @@ akka { + + loglevel = "DEBUG" + actor { + # enable to test serialization only. + serialize-messages = on + serializers { - java = "akka.serialization.JavaSerializer" + java = "akka.serialization.JavaSerializer" + proto = "akka.remote.serialization.ProtobufSerializer" } serialization-bindings { - "org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification" = java + "org.opendaylight.controller.cluster.raft.ReplicatedLogImplEntry" = java + "com.google.protobuf.Message" = proto + "com.google.protobuf.GeneratedMessage" = proto } } -} \ No newline at end of file +} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RuntimeMappingModule.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RuntimeMappingModule.java index 0f0ce0dc9d..823a4d9f32 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RuntimeMappingModule.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RuntimeMappingModule.java @@ -19,7 +19,7 @@ import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.RpcService; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService; import org.opendaylight.yangtools.yang.data.impl.codec.CodecRegistry; import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException; @@ -127,13 +127,13 @@ public final class RuntimeMappingModule extends } @Override - public Entry toDataDom( + public Entry toDataDom( Entry, DataObject> entry) { return delegate.toDataDom(entry); } @Override - public InstanceIdentifier toDataDom( + public YangInstanceIdentifier toDataDom( org.opendaylight.yangtools.yang.binding.InstanceIdentifier path) { return delegate.toDataDom(path); } @@ -146,7 +146,7 @@ public final class RuntimeMappingModule extends } @Override - public org.opendaylight.yangtools.yang.binding.InstanceIdentifier fromDataDom(InstanceIdentifier entry) + public org.opendaylight.yangtools.yang.binding.InstanceIdentifier fromDataDom(YangInstanceIdentifier entry) throws DeserializationException { return delegate.fromDataDom(entry); } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedDataBroker.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedDataBroker.java index 58d78a85dc..15e4a466cf 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedDataBroker.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedDataBroker.java @@ -7,11 +7,15 @@ */ package org.opendaylight.controller.md.sal.binding.impl; +import com.google.common.base.Objects; +import com.google.common.base.Optional; + import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -31,6 +35,7 @@ import org.opendaylight.yangtools.concepts.Delegator; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService; import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException; @@ -40,12 +45,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.base.Objects; -import com.google.common.base.Optional; -import com.google.common.collect.Iterables; - -public abstract class AbstractForwardedDataBroker implements Delegator, DomForwardedBroker, - SchemaContextListener, AutoCloseable { +public abstract class AbstractForwardedDataBroker implements Delegator, DomForwardedBroker, SchemaContextListener, AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(AbstractForwardedDataBroker.class); // The Broker to whom we do all forwarding @@ -91,17 +91,17 @@ public abstract class AbstractForwardedDataBroker implements Delegator domRegistration = domDataBroker.registerDataChangeListener(store, domPath, domDataChangeListener, triggeringScope); return new ListenerRegistrationImpl(listener, domRegistration); } protected Map, DataObject> toBinding( - final Map> normalized) { + final Map> normalized) { Map, DataObject> newMap = new HashMap<>(); - for (Map.Entry> entry : sortedEntries(normalized)) { + for (Map.Entry> entry : sortedEntries(normalized)) { try { Optional, DataObject>> potential = getCodec().toBinding( entry); @@ -116,25 +116,43 @@ public abstract class AbstractForwardedDataBroker implements Delegator Iterable> sortedEntries(final Map map) { - ArrayList> entries = new ArrayList<>(map.entrySet()); - Collections.sort(entries, new Comparator>() { + private static final Comparator> MAP_ENTRY_COMPARATOR = new Comparator>() { + @Override + public int compare(final Entry left, + final Entry right) { + final Iterator li = left.getKey().getPathArguments().iterator(); + final Iterator ri = right.getKey().getPathArguments().iterator(); + + // Iterate until left is exhausted... + while (li.hasNext()) { + if (!ri.hasNext()) { + // Left is deeper + return 1; + } - @Override - public int compare(final Entry left, - final Entry right) { - int leftSize = Iterables.size(left.getKey().getPathArguments()); - int rightSize = Iterables.size(right.getKey().getPathArguments()); - return Integer.compare(leftSize, rightSize); + li.next(); + ri.next(); } - }); - return entries; + + // Check if right is exhausted + return ri.hasNext() ? -1 : 0; + } + }; + + private static Iterable> sortedEntries(final Map map) { + if (!map.isEmpty()) { + ArrayList> entries = new ArrayList<>(map.entrySet()); + Collections.sort(entries, MAP_ENTRY_COMPARATOR); + return entries; + } else { + return Collections.emptySet(); + } } protected Set> toBinding( - final Set normalized) { + final Set normalized) { Set> hashSet = new HashSet<>(); - for (org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalizedPath : normalized) { + for (YangInstanceIdentifier normalizedPath : normalized) { try { Optional> potential = getCodec().toBinding(normalizedPath); if (potential.isPresent()) { @@ -176,13 +194,13 @@ public abstract class AbstractForwardedDataBroker implements Delegator> change) { + final AsyncDataChangeEvent> change) { bindingDataChangeListener.onDataChanged(new TranslatedDataChangeEvent(change, path)); } } private class TranslatedDataChangeEvent implements AsyncDataChangeEvent, DataObject> { - private final AsyncDataChangeEvent> domEvent; + private final AsyncDataChangeEvent> domEvent; private final InstanceIdentifier path; private Map, DataObject> createdCache; @@ -193,7 +211,7 @@ public abstract class AbstractForwardedDataBroker implements Delegator updatedDataCache; public TranslatedDataChangeEvent( - final AsyncDataChangeEvent> change, + final AsyncDataChangeEvent> change, final InstanceIdentifier path) { this.domEvent = change; this.path = path; diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedTransaction.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedTransaction.java index a6d20c5c34..e52fcdce23 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedTransaction.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedTransaction.java @@ -13,7 +13,7 @@ import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction; import org.opendaylight.yangtools.concepts.Delegator; import org.opendaylight.yangtools.concepts.Identifiable; import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import com.google.common.base.Optional; @@ -22,7 +22,7 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; -abstract class AbstractForwardedTransaction>> +abstract class AbstractForwardedTransaction>> implements Delegator, Identifiable { private final T delegate; @@ -45,7 +45,7 @@ abstract class AbstractForwardedTransaction>> S getDelegateChecked(final Class txType) { + protected final >> S getDelegateChecked(final Class txType) { Preconditions.checkState(txType.isInstance(delegate)); return (S) delegate; } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractReadWriteTransaction.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractReadWriteTransaction.java index 44be74b424..5ced7bae9f 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractReadWriteTransaction.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractReadWriteTransaction.java @@ -17,7 +17,7 @@ import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizat import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation; import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,7 +34,7 @@ public class AbstractReadWriteTransaction extends AbstractWriteTransaction path) { List currentArguments = new ArrayList<>(); DataNormalizationOperation currentOp = getCodec().getDataNormalizer().getRootOperation(); @@ -47,7 +47,7 @@ public class AbstractReadWriteTransaction extends AbstractWriteTransaction> d; diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractWriteTransaction.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractWriteTransaction.java index f8c56f95b3..65a9c1abeb 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractWriteTransaction.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractWriteTransaction.java @@ -16,7 +16,7 @@ import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.Identifiable; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,7 +43,7 @@ public abstract class AbstractWriteTransaction void put(final LogicalDatastoreType store, final InstanceIdentifier path, final U data, final boolean createParents) { - final Entry> normalized = getCodec() + final Entry> normalized = getCodec() .toNormalizedNode(path, data); if(createParents) { ensureParentsByMerge(store, normalized.getKey(), path); @@ -57,7 +57,7 @@ public abstract class AbstractWriteTransaction void merge(final LogicalDatastoreType store, final InstanceIdentifier path, final U data,final boolean createParents) { - final Entry> normalized = getCodec() + final Entry> normalized = getCodec() .toNormalizedNode(path, data); if(createParents) { @@ -103,9 +103,9 @@ public abstract class AbstractWriteTransaction path, - final Entry> normalized) { + final Entry> normalized) { if(Identifiable.class.isAssignableFrom(path.getTargetType())) { - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier parentMapPath = getParent(normalized.getKey()).get(); + org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier parentMapPath = getParent(normalized.getKey()).get(); NormalizedNode emptyParent = getCodec().getDefaultNodeFor(parentMapPath); getDelegate().merge(store, parentMapPath, emptyParent); } @@ -113,15 +113,15 @@ public abstract class AbstractWriteTransaction getParent( - final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier child) { + protected static Optional getParent( + final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier child) { Iterable mapEntryItemPath = child.getPathArguments(); int parentPathSize = Iterables.size(mapEntryItemPath) - 1; if(parentPathSize > 1) { - return Optional.of(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.create(Iterables.limit(mapEntryItemPath, parentPathSize))); + return Optional.of(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.create(Iterables.limit(mapEntryItemPath, parentPathSize))); } else if(parentPathSize == 0) { - return Optional.of(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.create(Collections.emptyList())); + return Optional.of(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.create(Collections.emptyList())); } else { return Optional.absent(); } @@ -136,11 +136,11 @@ public abstract class AbstractWriteTransaction path); + org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier key, InstanceIdentifier path); protected final void doDelete(final LogicalDatastoreType store, final InstanceIdentifier path) { - final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalized = getCodec().toNormalized(path); + final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier normalized = getCodec().toNormalized(path); getDelegate().delete(store, normalized); } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDataWriteTransactionImpl.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDataWriteTransactionImpl.java index e62b4f736a..f261deb99c 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDataWriteTransactionImpl.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDataWriteTransactionImpl.java @@ -22,7 +22,7 @@ import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; 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.InstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.ListenableFuture; @@ -49,7 +49,7 @@ class BindingDataWriteTransactionImpl extends @Override protected void ensureParentsByMerge(final LogicalDatastoreType store, - final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalizedPath, final InstanceIdentifier path) { + final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier normalizedPath, final InstanceIdentifier path) { List currentArguments = new ArrayList<>(); DataNormalizationOperation currentOp = getCodec().getDataNormalizer().getRootOperation(); Iterator iterator = normalizedPath.getPathArguments().iterator(); @@ -61,7 +61,7 @@ class BindingDataWriteTransactionImpl extends throw new IllegalArgumentException(String.format("Invalid child encountered in path %s", path), e); } currentArguments.add(currentArg); - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier currentPath = org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.create( + org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier currentPath = org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.create( currentArguments); getDelegate().merge(store, currentPath, currentOp.createDefault(currentArg)); diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodec.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodec.java index b4b9e314be..66caaea708 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodec.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodec.java @@ -29,9 +29,9 @@ import org.opendaylight.yangtools.yang.binding.util.BindingReflections; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.QNameModule; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.AugmentationIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; +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.AugmentationNode; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; @@ -67,7 +67,7 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { this.bindingToLegacy = mappingService; } - public org.opendaylight.yangtools.yang.data.api.InstanceIdentifier toNormalized( + public org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier toNormalized( final InstanceIdentifier binding) { // Used instance-identifier codec do not support serialization of last @@ -81,17 +81,17 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { return toNormalizedImpl(binding); } - public Entry> toNormalizedNode( + public Entry> toNormalizedNode( final InstanceIdentifier bindingPath, final DataObject bindingObject) { return toNormalizedNode(toBindingEntry(bindingPath, bindingObject)); } - public Entry> toNormalizedNode( + public Entry> toNormalizedNode( final Entry, DataObject> binding) { - Entry legacyEntry = bindingToLegacy + Entry legacyEntry = bindingToLegacy .toDataDom(binding); - Entry> normalizedEntry = legacyToNormalized + Entry> normalizedEntry = legacyToNormalized .toNormalized(legacyEntry); LOG.trace("Serialization of {}, Legacy Representation: {}, Normalized Representation: {}", binding, legacyEntry, normalizedEntry); @@ -102,7 +102,7 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { if (child instanceof AugmentationNode) { ImmutableList childArgs = ImmutableList. builder() .addAll(normalizedEntry.getKey().getPathArguments()).add(child.getIdentifier()).build(); - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier childPath = org.opendaylight.yangtools.yang.data.api.InstanceIdentifier + org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier childPath = org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier .create(childArgs); return toDOMEntry(childPath, child); } @@ -123,7 +123,7 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { * */ public Optional> toBinding( - final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalized) + final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier normalized) throws DeserializationException { PathArgument lastArgument = Iterables.getLast(normalized.getPathArguments()); @@ -140,7 +140,7 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { } private Optional> toBindingAugmented( - final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalized) + final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier normalized) throws DeserializationException { Optional> potential = toBindingImpl(normalized); // Shorthand check, if codec already supports deserialization @@ -158,7 +158,7 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { // path. LOG.trace("Looking for candidates to match {}", normalized); for (QName child : lastArgument.getPossibleChildNames()) { - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier childPath = normalized.node(child); + org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier childPath = normalized.node(child); try { if (isNotRepresentable(childPath)) { LOG.trace("Path {} is not BI-representable, skipping it", childPath); @@ -190,9 +190,9 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { } private Optional> toBindingImpl( - final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalized) + final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier normalized) throws DeserializationException { - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier legacyPath; + org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier legacyPath; try { if (isNotRepresentable(normalized)) { @@ -207,7 +207,7 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { return Optional.> of(bindingToLegacy.fromDataDom(legacyPath)); } - private boolean isNotRepresentable(final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalized) + private boolean isNotRepresentable(final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier normalized) throws DataNormalizationException { DataNormalizationOperation op = findNormalizationOperation(normalized); if (op.isMixin() && op.getIdentifier() instanceof NodeIdentifier) { @@ -220,7 +220,7 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { } private DataNormalizationOperation findNormalizationOperation( - final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalized) + final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier normalized) throws DataNormalizationException { DataNormalizationOperation current = legacyToNormalized.getRootOperation(); for (PathArgument arg : normalized.getPathArguments()) { @@ -236,9 +236,9 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { key, value); } - private static final Entry> toDOMEntry( - final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier key, final NormalizedNode value) { - return new SimpleEntry>(key, + private static final Entry> toDOMEntry( + final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier key, final NormalizedNode value) { + return new SimpleEntry>(key, value); } @@ -264,7 +264,7 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { } public Optional, DataObject>> toBinding( - final Entry> normalized) + final Entry> normalized) throws DeserializationException { Optional> potentialPath = toBinding(normalized.getKey()); if (potentialPath.isPresent()) { @@ -284,15 +284,15 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { legacyToNormalized = new DataNormalizer(arg0); } - private org.opendaylight.yangtools.yang.data.api.InstanceIdentifier toNormalizedAugmented( + private org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier toNormalizedAugmented( final InstanceIdentifier augPath) { - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier processed = toNormalizedImpl(augPath); + org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier processed = toNormalizedImpl(augPath); // If used instance identifier codec added supports for deserialization // of last AugmentationIdentifier we will just reuse it if (isAugmentationIdentifier(processed)) { return processed; } - Optional additionalSerialized; + Optional additionalSerialized; additionalSerialized = toNormalizedAugmentedUsingChildContainers(augPath, processed); if (additionalSerialized.isPresent()) { @@ -325,9 +325,9 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { * Processed path * @return */ - private Optional toNormalizedAugmentedUsingChildLeafs( + private Optional toNormalizedAugmentedUsingChildLeafs( final InstanceIdentifier augPath, - final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier parentPath) { + final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier parentPath) { try { DataNormalizationOperation parentOp = legacyToNormalized.getOperation(parentPath); if(!parentOp.getDataSchemaNode().isPresent()) { @@ -363,14 +363,14 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { * @return */ @SuppressWarnings("rawtypes") - private Optional toNormalizedAugmentedUsingChildContainers( + private Optional toNormalizedAugmentedUsingChildContainers( final InstanceIdentifier augPath, - final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier parentPath) { + final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier parentPath) { for (Class augChild : BindingReflections.getChildrenClasses(augPath.getTargetType())) { @SuppressWarnings("unchecked") InstanceIdentifier childPath = augPath.child(augChild); - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalized = toNormalizedImpl(childPath); - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier potentialDiscovered = shortenToLastAugmentation( + org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier normalized = toNormalizedImpl(childPath); + org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier potentialDiscovered = shortenToLastAugmentation( normalized, parentPath); if (potentialDiscovered != null) { return Optional.of(potentialDiscovered); @@ -436,9 +436,9 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { && method.getName().startsWith("get") && method.getParameterTypes().length == 0; } - private org.opendaylight.yangtools.yang.data.api.InstanceIdentifier shortenToLastAugmentation( - final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalized, - final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier parentPath) { + private org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier shortenToLastAugmentation( + final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier normalized, + final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier parentPath) { int parentSize = Iterables.size(parentPath.getPathArguments()); int position = 0; int foundPosition = -1; @@ -450,7 +450,7 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { } if (foundPosition > 0 && foundPosition > parentSize) { Iterable shortened = Iterables.limit(normalized.getPathArguments(), foundPosition); - return org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.create(shortened); + return org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.create(shortened); } return null; } @@ -468,11 +468,11 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { return InstanceIdentifier.create(Iterables.limit(binding.getPathArguments(), foundPosition)); } - private org.opendaylight.yangtools.yang.data.api.InstanceIdentifier toNormalizedImpl( + private org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier toNormalizedImpl( final InstanceIdentifier binding) { - final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier legacyPath = bindingToLegacy + final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier legacyPath = bindingToLegacy .toDataDom(binding); - final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalized = legacyToNormalized + final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier normalized = legacyToNormalized .toNormalized(legacyPath); return normalized; } @@ -485,7 +485,7 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { return Augmentation.class.isAssignableFrom(potential.getTargetType()); } - private boolean isAugmentationIdentifier(final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier processed) { + private boolean isAugmentationIdentifier(final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier processed) { return Iterables.getLast(processed.getPathArguments()) instanceof AugmentationIdentifier; } @@ -500,7 +500,7 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { return count; } - private static int getAugmentationCount(final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier potential) { + private static int getAugmentationCount(final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier potential) { int count = 0; for (PathArgument arg : potential.getPathArguments()) { if (arg instanceof AugmentationIdentifier) { @@ -553,7 +553,7 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { * @param path DOM Path * @return Node with defaults set on. */ - public NormalizedNode getDefaultNodeFor(final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier path) { + public NormalizedNode getDefaultNodeFor(final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier path) { Iterator iterator = path.getPathArguments().iterator(); DataNormalizationOperation currentOp = legacyToNormalized.getRootOperation(); while (iterator.hasNext()) { diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentConnector.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentConnector.java index 293a61e0ea..d00d8b7fa8 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentConnector.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentConnector.java @@ -46,7 +46,7 @@ public class BindingIndependentConnector implements // AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(BindingIndependentConnector.class); - private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier ROOT_BI = org.opendaylight.yangtools.yang.data.api.InstanceIdentifier + private static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier ROOT_BI = org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier .builder().toInstance(); private BindingIndependentMappingService mappingService; @@ -88,7 +88,7 @@ public class BindingIndependentConnector implements // @Override public DataObject readOperationalData(final InstanceIdentifier path) { try { - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier biPath = mappingService.toDataDom(path); + org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier biPath = mappingService.toDataDom(path); CompositeNode result = biDataService.readOperationalData(biPath); return potentialAugmentationRead(path, biPath, result); } catch (DeserializationException e) { @@ -97,7 +97,7 @@ public class BindingIndependentConnector implements // } private DataObject potentialAugmentationRead(InstanceIdentifier path, - final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier biPath, final CompositeNode result) + final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier biPath, final CompositeNode result) throws DeserializationException { Class targetType = path.getTargetType(); if (Augmentation.class.isAssignableFrom(targetType)) { @@ -114,7 +114,7 @@ public class BindingIndependentConnector implements // @Override public DataObject readConfigurationData(final InstanceIdentifier path) { try { - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier biPath = mappingService.toDataDom(path); + org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier biPath = mappingService.toDataDom(path); CompositeNode result = biDataService.readConfigurationData(biPath); return potentialAugmentationRead(path, biPath, result); } catch (DeserializationException e) { diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingToDomCommitHandler.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingToDomCommitHandler.java index 7434309387..44198bfc76 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingToDomCommitHandler.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingToDomCommitHandler.java @@ -76,25 +76,25 @@ class BindingToDomCommitHandler implements DataModificationTransaction target = biDataService.beginTransaction(); LOG.debug("Created DOM Transaction {} for {},", target.getIdentifier(), source.getIdentifier()); for (InstanceIdentifier entry : source.getRemovedConfigurationData()) { - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier biEntry = mappingService.toDataDom(entry); + org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier biEntry = mappingService.toDataDom(entry); target.removeConfigurationData(biEntry); LOG.debug("Delete of Binding Configuration Data {} is translated to {}", entry, biEntry); } for (InstanceIdentifier entry : source.getRemovedOperationalData()) { - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier biEntry = mappingService.toDataDom(entry); + org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier biEntry = mappingService.toDataDom(entry); target.removeOperationalData(biEntry); LOG.debug("Delete of Binding Operational Data {} is translated to {}", entry, biEntry); } for (Map.Entry, DataObject> entry : source.getUpdatedConfigurationData() .entrySet()) { - Map.Entry biEntry = mappingService + Map.Entry biEntry = mappingService .toDataDom(entry); target.putConfigurationData(biEntry.getKey(), biEntry.getValue()); LOG.debug("Update of Binding Configuration Data {} is translated to {}", entry, biEntry); } for (Map.Entry, DataObject> entry : source.getUpdatedOperationalData() .entrySet()) { - Map.Entry biEntry = mappingService + Map.Entry biEntry = mappingService .toDataDom(entry); target.putOperationalData(biEntry.getKey(), biEntry.getValue()); LOG.debug("Update of Binding Operational Data {} is translated to {}", entry, biEntry); diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingCommitHandler.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingCommitHandler.java index 88024b9af2..43334f06ac 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingCommitHandler.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingCommitHandler.java @@ -23,7 +23,7 @@ import org.slf4j.LoggerFactory; @Deprecated class DomToBindingCommitHandler implements // RegistrationListener, DataObject>>, // - DataCommitHandler { + DataCommitHandler { private final Logger LOG = LoggerFactory.getLogger(DomToBindingCommitHandler.class); @@ -60,8 +60,8 @@ class DomToBindingCommitHandler implements // } @Override - public org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction requestCommit( - final DataModification domTransaction) { + public org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction requestCommit( + final DataModification domTransaction) { Object identifier = domTransaction.getIdentifier(); /** @@ -82,7 +82,7 @@ class DomToBindingCommitHandler implements // } private org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction createDomToBindingTransaction( - final DataModification source) { + final DataModification source) { if (baDataService == null) { final String msg = "Binding Aware Service is not initialized correctly! DOM to Binding Transaction cannot be created for "; LOG.error(msg + "{}", source); @@ -96,7 +96,7 @@ class DomToBindingCommitHandler implements // org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction target = baDataService .beginTransaction(); - for (org.opendaylight.yangtools.yang.data.api.InstanceIdentifier entry : source.getRemovedConfigurationData()) { + for (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier entry : source.getRemovedConfigurationData()) { try { InstanceIdentifier baEntry = mappingService.fromDataDom(entry); @@ -105,7 +105,7 @@ class DomToBindingCommitHandler implements // LOG.error("Ommiting from BA transaction: {}.", entry, e); } } - for (org.opendaylight.yangtools.yang.data.api.InstanceIdentifier entry : source.getRemovedOperationalData()) { + for (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier entry : source.getRemovedOperationalData()) { try { InstanceIdentifier baEntry = mappingService.fromDataDom(entry); @@ -114,7 +114,7 @@ class DomToBindingCommitHandler implements // LOG.error("Ommiting from BA transaction: {}.", entry, e); } } - for (Map.Entry entry : source + for (Map.Entry entry : source .getUpdatedConfigurationData().entrySet()) { try { InstanceIdentifier baKey = mappingService.fromDataDom(entry.getKey()); @@ -124,7 +124,7 @@ class DomToBindingCommitHandler implements // LOG.error("Ommiting from BA transaction: {}.", entry.getKey(), e); } } - for (Map.Entry entry : source + for (Map.Entry entry : source .getUpdatedOperationalData().entrySet()) { try { diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingRpcForwarder.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingRpcForwarder.java index ffcab597b1..ab6d56c15a 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingRpcForwarder.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingRpcForwarder.java @@ -58,7 +58,7 @@ class DomToBindingRpcForwarder implements RpcImplementation, InvocationHandler { private final RpcProviderRegistry baRpcRegistry; private final RpcProviderRegistryImpl baRpcRegistryImpl; - private final Function, org.opendaylight.yangtools.yang.data.api.InstanceIdentifier> toDOMInstanceIdentifier; + private final Function, org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier> toDOMInstanceIdentifier; private final static Method EQUALS_METHOD; @@ -75,10 +75,10 @@ class DomToBindingRpcForwarder implements RpcImplementation, InvocationHandler { this.rpcServiceType = new WeakReference>(service); this.supportedRpcs = mappingService.getRpcQNamesFor(service); - toDOMInstanceIdentifier = new Function, org.opendaylight.yangtools.yang.data.api.InstanceIdentifier>() { + toDOMInstanceIdentifier = new Function, org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier>() { @Override - public org.opendaylight.yangtools.yang.data.api.InstanceIdentifier apply(final InstanceIdentifier input) { + public org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier apply(final InstanceIdentifier input) { return mappingService.toDataDom(input); } }; @@ -162,7 +162,7 @@ class DomToBindingRpcForwarder implements RpcImplementation, InvocationHandler { public void registerPaths(final Class context, final Class service, final Set> set) { QName ctx = BindingReflections.findQName(context); - for (org.opendaylight.yangtools.yang.data.api.InstanceIdentifier path : FluentIterable.from(set).transform( + for (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier path : FluentIterable.from(set).transform( toDOMInstanceIdentifier)) { for (org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration reg : registrations) { reg.registerPath(ctx, path); @@ -188,7 +188,7 @@ class DomToBindingRpcForwarder implements RpcImplementation, InvocationHandler { public void removePaths(final Class context, final Class service, final Set> set) { QName ctx = BindingReflections.findQName(context); - for (org.opendaylight.yangtools.yang.data.api.InstanceIdentifier path : FluentIterable.from(set).transform( + for (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier path : FluentIterable.from(set).transform( toDOMInstanceIdentifier)) { for (org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration reg : registrations) { reg.unregisterPath(ctx, path); diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingTransaction.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingTransaction.java index cb271a1a91..a5a34dad80 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingTransaction.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingTransaction.java @@ -10,18 +10,18 @@ import org.opendaylight.controller.md.sal.common.api.data.DataModification; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; class DomToBindingTransaction implements - DataCommitHandler.DataCommitTransaction { + DataCommitHandler.DataCommitTransaction { private final org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction backing; - private final DataModification modification; + private final DataModification modification; private final ConcurrentMap bindingOpenedTransactions; public DomToBindingTransaction( final org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction backing, - final DataModification modification, + final DataModification modification, ConcurrentMap bindingOpenedTransactions) { super(); this.backing = backing; @@ -31,7 +31,7 @@ class DomToBindingTransaction implements } @Override - public DataModification getModification() { + public DataModification getModification() { return modification; } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardedBindingBrokerImpl.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardedBindingBrokerImpl.java index e1f8c6c652..92836631a8 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardedBindingBrokerImpl.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardedBindingBrokerImpl.java @@ -33,7 +33,7 @@ public class DomForwardedBindingBrokerImpl extends RootBindingAwareBroker implem private final BindingMountPointForwardingManager bindingForwardingManager = new BindingMountPointForwardingManager(); private ConcurrentMap, BindingIndependentConnector> connectors = new ConcurrentHashMap<>(); - private ConcurrentMap, org.opendaylight.yangtools.yang.data.api.InstanceIdentifier> forwarded = new ConcurrentHashMap<>(); + private ConcurrentMap, org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier> forwarded = new ConcurrentHashMap<>(); private ListenerRegistration domListenerRegistration; private ListenerRegistration baListenerRegistration; @@ -89,8 +89,8 @@ public class DomForwardedBindingBrokerImpl extends RootBindingAwareBroker implem } private void tryToDeployConnector(InstanceIdentifier baPath, - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier biPath) { - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier previous = forwarded.putIfAbsent(baPath, biPath); + org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier biPath) { + org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier previous = forwarded.putIfAbsent(baPath, biPath); if (previous != null) { return; } @@ -111,7 +111,7 @@ public class DomForwardedBindingBrokerImpl extends RootBindingAwareBroker implem return mountConnector; } - public synchronized void tryToDeployDomForwarder(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier domPath) { + public synchronized void tryToDeployDomForwarder(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier domPath) { InstanceIdentifier baPath; try { baPath = connector.getMappingService().fromDataDom(domPath); @@ -130,7 +130,7 @@ public class DomForwardedBindingBrokerImpl extends RootBindingAwareBroker implem if (potentialConnector != null) { return; } - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier domPath = connector.getMappingService().toDataDom(baPath); + org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier domPath = connector.getMappingService().toDataDom(baPath); tryToDeployConnector(baPath, domPath); } @@ -138,19 +138,19 @@ public class DomForwardedBindingBrokerImpl extends RootBindingAwareBroker implem // FIXME: Implement closeMountPoint } - public synchronized void undeployDomForwarder(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier biPath) { + public synchronized void undeployDomForwarder(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier biPath) { // FIXME: Implement closeMountPoint } private class DomMountPointForwardingManager implements MountProvisionListener { @Override - public void onMountPointCreated(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier path) { + public void onMountPointCreated(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier path) { tryToDeployDomForwarder(path); } @Override - public void onMountPointRemoved(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier path) { + public void onMountPointRemoved(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier path) { undeployDomForwarder(path); } } diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/BindingNormalizedCodecTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/BindingNormalizedCodecTest.java index 6b05b1046f..fd0a169694 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/BindingNormalizedCodecTest.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/BindingNormalizedCodecTest.java @@ -14,8 +14,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controll import org.opendaylight.yangtools.sal.binding.generator.impl.RuntimeGeneratedMappingServiceImpl; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.AugmentationIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.model.api.SchemaContext; public class BindingNormalizedCodecTest extends AbstractSchemaAwareTest { diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/compat/MultipleAugmentationPutsTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/compat/MultipleAugmentationPutsTest.java index 6cefd13398..7b67d3b10f 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/compat/MultipleAugmentationPutsTest.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/compat/MultipleAugmentationPutsTest.java @@ -64,8 +64,8 @@ public class MultipleAugmentationPutsTest extends AbstractDataServiceTest implem private static final InstanceIdentifier NODE_INSTANCE_ID_BA = NODES_INSTANCE_ID_BA.child(Node.class, NODE_KEY); - private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier NODE_INSTANCE_ID_BI = // - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() // + private static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier NODE_INSTANCE_ID_BI = // + org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.builder() // .node(Nodes.QNAME) // .nodeWithKey(Node.QNAME, NODE_KEY_BI) // .toInstance(); @@ -158,7 +158,7 @@ public class MultipleAugmentationPutsTest extends AbstractDataServiceTest implem return new AugmentationVerifier(readedNode); } - private void assertBindingIndependentVersion(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier nodeId) { + private void assertBindingIndependentVersion(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier nodeId) { CompositeNode node = biDataService.readOperationalData(nodeId); assertNotNull(node); } diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java index f5e902c775..e82c9d385d 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java @@ -67,7 +67,7 @@ import com.google.common.util.concurrent.ListeningExecutorService; @Beta public class BindingTestContext implements AutoCloseable { - public static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier TREE_ROOT = org.opendaylight.yangtools.yang.data.api.InstanceIdentifier + public static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier TREE_ROOT = org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier .builder().toInstance(); private static final Logger LOG = LoggerFactory.getLogger(BindingTestContext.class); diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/ListProcessingAndOrderingTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/ListProcessingAndOrderingTest.java index cd68559ae5..aa136451a1 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/ListProcessingAndOrderingTest.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/ListProcessingAndOrderingTest.java @@ -56,14 +56,14 @@ import com.google.common.util.concurrent.ListenableFuture; @SuppressWarnings("deprecation") public class ListProcessingAndOrderingTest extends AbstractDataServiceTest { - private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier DOM_UNORDERED_LIST_PATH = org.opendaylight.yangtools.yang.data.api.InstanceIdentifier + private static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier DOM_UNORDERED_LIST_PATH = org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier .builder(Lists.QNAME).node(UnorderedContainer.QNAME).node(UnorderedList.QNAME).build(); - private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier DOM_ORDERED_LIST_PATH = org.opendaylight.yangtools.yang.data.api.InstanceIdentifier + private static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier DOM_ORDERED_LIST_PATH = org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier .builder(Lists.QNAME).node(OrderedContainer.QNAME).node(OrderedList.QNAME).build(); - private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier DOM_UNKEYED_LIST_PATH = org.opendaylight.yangtools.yang.data.api.InstanceIdentifier + private static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier DOM_UNKEYED_LIST_PATH = org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier .builder(Lists.QNAME).node(UnkeyedContainer.QNAME).node(UnkeyedList.QNAME).build(); private static final InstanceIdentifier UNORDERED_CONTAINER_PATH = InstanceIdentifier.builder(Lists.class).child(UnorderedContainer.class).build(); @@ -135,7 +135,7 @@ public class ListProcessingAndOrderingTest extends AbstractDataServiceTest { } private NormalizedNode resolveDataAsserted( - final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier domPath) { + final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier domPath) { try (DOMDataReadOnlyTransaction readTx = testContext.getDomAsyncDataBroker().newReadOnlyTransaction()){ ListenableFuture>> data = readTx.read(LogicalDatastoreType.OPERATIONAL, domPath); @@ -171,7 +171,7 @@ public class ListProcessingAndOrderingTest extends AbstractDataServiceTest { private void assertXmlRepresentation(final InstanceIdentifier containerPath, final String... childNameValues) { - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier domPath = testContext.getBindingToDomMappingService().toDataDom(containerPath); + org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier domPath = testContext.getBindingToDomMappingService().toDataDom(containerPath); CompositeNode compositeNode = testContext.getDomDataBroker().readOperationalData(domPath); assertNotNull(compositeNode); 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 index 0c767f6185..34a71ac0c4 100644 --- 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 @@ -222,7 +222,7 @@ public class DOMCodecBug01Test extends AbstractDataServiceTest { } private void verifyDataAreStoredProperly() { - CompositeNode biFlows = biDataService.readConfigurationData(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.of(Flows.QNAME)); + 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-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug03Test.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug03Test.java index dd8eaa7d5f..c07125a5dc 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug03Test.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug03Test.java @@ -72,16 +72,16 @@ public class DOMCodecBug03Test extends AbstractDataServiceTest implements DataCh .toInstance(); - private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier NODE_INSTANCE_ID_BI = // - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() // + private static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier NODE_INSTANCE_ID_BI = // + org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.builder() // .node(Nodes.QNAME) // .nodeWithKey(Node.QNAME, NODE_KEY_BI) // .toInstance(); private static final QName SUPPORTED_ACTIONS_QNAME = QName.create(FlowCapableNode.QNAME, SupportedActions.QNAME.getLocalName()); - private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier SUPPORTED_ACTIONS_INSTANCE_ID_BI = // - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() // + private static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier SUPPORTED_ACTIONS_INSTANCE_ID_BI = // + org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.builder() // .node(Nodes.QNAME) // .nodeWithKey(Node.QNAME, NODE_KEY_BI) // .node(SUPPORTED_ACTIONS_QNAME) // @@ -206,7 +206,7 @@ public class DOMCodecBug03Test extends AbstractDataServiceTest implements DataCh } private void assertBindingIndependentVersion( - final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier nodeId) { + final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier nodeId) { CompositeNode node = biDataService.readOperationalData(nodeId); assertNotNull(node); } diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DeleteNestedAugmentationListenParentTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DeleteNestedAugmentationListenParentTest.java index fb5fd1fa6c..735138a530 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DeleteNestedAugmentationListenParentTest.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DeleteNestedAugmentationListenParentTest.java @@ -78,13 +78,12 @@ public class DeleteNestedAugmentationListenParentTest extends AbstractDataServic FlowBuilder builder = new FlowBuilder() .setKey(FLOW_KEY) .addAugmentation(FlowStatisticsData.class,new FlowStatisticsDataBuilder() - .setFlowStatistics(new FlowStatisticsBuilder() - .setBarrier(true) - .setMatch(new MatchBuilder() - .build()) - .build()) + .setFlowStatistics(new FlowStatisticsBuilder().build()) .build()) - ;//.build(); + .setBarrier(true) + .setMatch(new MatchBuilder() + .build()) + ; return builder.build(); } diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/PutAugmentationTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/PutAugmentationTest.java index 33a4399cb5..767ccaade3 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/PutAugmentationTest.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/PutAugmentationTest.java @@ -68,8 +68,8 @@ public class PutAugmentationTest extends AbstractDataServiceTest implements Data .augmentation(FlowCapableNode.class) // .build(); - private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier NODE_INSTANCE_ID_BI = // - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() // + private static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier NODE_INSTANCE_ID_BI = // + org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.builder() // .node(Nodes.QNAME) // .nodeWithKey(Node.QNAME, NODE_KEY_BI) // .toInstance(); @@ -216,7 +216,7 @@ public class PutAugmentationTest extends AbstractDataServiceTest implements Data assertNull(node); } - private void assertBindingIndependentVersion(final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier nodeId) { + private void assertBindingIndependentVersion(final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier nodeId) { CompositeNode node = biDataService.readOperationalData(nodeId); assertNotNull(node); } diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/ChangeOriginatedInDomBrokerTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/ChangeOriginatedInDomBrokerTest.java index ae54896c6d..a3b0819501 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/ChangeOriginatedInDomBrokerTest.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/ChangeOriginatedInDomBrokerTest.java @@ -93,8 +93,8 @@ public class ChangeOriginatedInDomBrokerTest extends AbstractDataServiceTest { private static final Map TABLE_KEY_BI = // ImmutableMap. of(TABLE_ID_QNAME, TABLE_ID);; - private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier FLOW_INSTANCE_ID_BI = // - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() // + private static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier FLOW_INSTANCE_ID_BI = // + org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.builder() // .node(Nodes.QNAME) // .nodeWithKey(Node.QNAME, NODE_KEY_BI) // .nodeWithKey(Table.QNAME, TABLE_KEY_BI) // diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerMountPointTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerMountPointTest.java index 804fcc9fbe..a79b0fd53e 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerMountPointTest.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerMountPointTest.java @@ -65,13 +65,13 @@ public class CrossBrokerMountPointTest { private static final QName AUGMENTED_GROUP_STATISTICS = QName.create(NodeGroupStatistics.QNAME, GroupStatistics.QNAME.getLocalName()); - private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier NODE_INSTANCE_ID_BI = // - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() // + private static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier NODE_INSTANCE_ID_BI = // + org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.builder() // .node(Nodes.QNAME) // .nodeWithKey(Node.QNAME, NODE_KEY_BI) // .toInstance(); - private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier GROUP_STATISTICS_ID_BI = org.opendaylight.yangtools.yang.data.api.InstanceIdentifier + private static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier GROUP_STATISTICS_ID_BI = org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier // .builder(NODE_INSTANCE_ID_BI) .nodeWithKey(QName.create(FlowCapableNode.QNAME, "group"), QName.create(FlowCapableNode.QNAME, "group-id"), @@ -112,16 +112,16 @@ public class CrossBrokerMountPointTest { final BigInteger packetCount = BigInteger.valueOf(500L); - DataReader simpleReader = new DataReader() { + DataReader simpleReader = new DataReader() { @Override - public CompositeNode readConfigurationData(final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier arg0) { + public CompositeNode readConfigurationData(final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier arg0) { return null; } @Override - public CompositeNode readOperationalData(final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier arg0) { + public CompositeNode readOperationalData(final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier arg0) { if (arg0.equals(GROUP_STATISTICS_ID_BI)) { ImmutableCompositeNode data = ImmutableCompositeNode .builder() diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerRpcTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerRpcTest.java index 48e1db0e63..4cc3780c6f 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerRpcTest.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerRpcTest.java @@ -72,10 +72,10 @@ public class CrossBrokerRpcTest { public static final InstanceIdentifier BA_NODE_C_ID = createBANodeIdentifier(NODE_C); public static final InstanceIdentifier BA_NODE_D_ID = createBANodeIdentifier(NODE_D); - public static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier BI_NODE_A_ID = createBINodeIdentifier(NODE_A); - public static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier BI_NODE_B_ID = createBINodeIdentifier(NODE_B); - public static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier BI_NODE_C_ID = createBINodeIdentifier(NODE_C); - public static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier BI_NODE_D_ID = createBINodeIdentifier(NODE_D); + public static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier BI_NODE_A_ID = createBINodeIdentifier(NODE_A); + public static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier BI_NODE_B_ID = createBINodeIdentifier(NODE_B); + public static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier BI_NODE_C_ID = createBINodeIdentifier(NODE_C); + public static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier BI_NODE_D_ID = createBINodeIdentifier(NODE_D); @@ -158,8 +158,8 @@ public class CrossBrokerRpcTest { return InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(node)).toInstance(); } - private static org.opendaylight.yangtools.yang.data.api.InstanceIdentifier createBINodeIdentifier(NodeId node) { - return org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder().node(Nodes.QNAME) + private static org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier createBINodeIdentifier(NodeId node) { + return org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.builder().node(Nodes.QNAME) .nodeWithKey(Node.QNAME, NODE_ID_QNAME, node.getValue()).toInstance(); } diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/DOMRpcServiceTestBugfix560.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/DOMRpcServiceTestBugfix560.java index 0c123ebe66..6686a83a2e 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/DOMRpcServiceTestBugfix560.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/DOMRpcServiceTestBugfix560.java @@ -68,7 +68,7 @@ public class DOMRpcServiceTestBugfix560 { private static final QName NODE_ID_QNAME = QName.create(Node.QNAME, "id"); private static final InstanceIdentifier BA_MOUNT_ID = createBANodeIdentifier(MOUNT_NODE); - private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier BI_MOUNT_ID = createBINodeIdentifier(MOUNT_NODE); + private static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier BI_MOUNT_ID = createBINodeIdentifier(MOUNT_NODE); private BindingTestContext testContext; private MountProvisionService domMountPointService; @@ -104,9 +104,9 @@ public class DOMRpcServiceTestBugfix560 { schemaContext = mountSchemaContext; } - private static org.opendaylight.yangtools.yang.data.api.InstanceIdentifier createBINodeIdentifier( + private static org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier createBINodeIdentifier( final NodeId mountNode) { - return org.opendaylight.yangtools.yang.data.api.InstanceIdentifier + return org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier .builder().node(Nodes.QNAME) .nodeWithKey(Node.QNAME, NODE_ID_QNAME, mountNode.getValue()) .toInstance(); diff --git a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationOperation.java b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationOperation.java index 6176977104..b8dfca1604 100644 --- a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationOperation.java +++ b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationOperation.java @@ -21,11 +21,11 @@ import java.util.concurrent.ConcurrentHashMap; import org.opendaylight.yangtools.concepts.Identifiable; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.AugmentationIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeWithValue; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.api.Node; import org.opendaylight.yangtools.yang.data.api.SimpleNode; import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode; diff --git a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizer.java b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizer.java index e2a960a67a..3e14d5e4b7 100644 --- a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizer.java +++ b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizer.java @@ -16,9 +16,9 @@ import java.util.Map; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.AugmentationIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.api.Node; import org.opendaylight.yangtools.yang.data.api.SimpleNode; import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode; @@ -46,7 +46,7 @@ public class DataNormalizer { operation = DataNormalizationOperation.from(ctx); } - public InstanceIdentifier toNormalized(final InstanceIdentifier legacy) { + public YangInstanceIdentifier toNormalized(final YangInstanceIdentifier legacy) { ImmutableList.Builder normalizedArgs = ImmutableList.builder(); DataNormalizationOperation currentOp = operation; @@ -69,10 +69,10 @@ public class DataNormalizer { throw new IllegalArgumentException(String.format("Failed to normalize path %s", legacy), e); } - return InstanceIdentifier.create(normalizedArgs.build()); + return YangInstanceIdentifier.create(normalizedArgs.build()); } - public DataNormalizationOperation getOperation(final InstanceIdentifier legacy) throws DataNormalizationException { + public DataNormalizationOperation getOperation(final YangInstanceIdentifier legacy) throws DataNormalizationException { DataNormalizationOperation currentOp = operation; Iterator arguments = legacy.getPathArguments().iterator(); @@ -82,15 +82,15 @@ public class DataNormalizer { return currentOp; } - public Map.Entry> toNormalized( - final Map.Entry legacy) { + public Map.Entry> toNormalized( + final Map.Entry legacy) { return toNormalized(legacy.getKey(), legacy.getValue()); } - public Map.Entry> toNormalized(final InstanceIdentifier legacyPath, + public Map.Entry> toNormalized(final YangInstanceIdentifier legacyPath, final CompositeNode legacyData) { - InstanceIdentifier normalizedPath = toNormalized(legacyPath); + YangInstanceIdentifier normalizedPath = toNormalized(legacyPath); DataNormalizationOperation currentOp = operation; for (PathArgument arg : normalizedPath.getPathArguments()) { @@ -121,11 +121,11 @@ public class DataNormalizer { Preconditions.checkArgument(currentOp != null, "Instance Identifier %s does not reference correct schema Node.", normalizedPath); - return new AbstractMap.SimpleEntry>(normalizedPath, + return new AbstractMap.SimpleEntry>(normalizedPath, currentOp.normalize(legacyData)); } - public InstanceIdentifier toLegacy(final InstanceIdentifier normalized) throws DataNormalizationException { + public YangInstanceIdentifier toLegacy(final YangInstanceIdentifier normalized) throws DataNormalizationException { ImmutableList.Builder legacyArgs = ImmutableList.builder(); DataNormalizationOperation currentOp = operation; for (PathArgument normalizedArg : normalized.getPathArguments()) { @@ -134,10 +134,10 @@ public class DataNormalizer { legacyArgs.add(normalizedArg); } } - return InstanceIdentifier.create(legacyArgs.build()); + return YangInstanceIdentifier.create(legacyArgs.build()); } - public CompositeNode toLegacy(final InstanceIdentifier normalizedPath, final NormalizedNode normalizedData) { + public CompositeNode toLegacy(final YangInstanceIdentifier normalizedPath, final NormalizedNode normalizedData) { // Preconditions.checkArgument(normalizedData instanceof // DataContainerNode,"Node object %s, %s should be of type DataContainerNode",normalizedPath,normalizedData); if (normalizedData instanceof DataContainerNode) { diff --git a/opendaylight/md-sal/sal-common-impl/src/test/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizerTest.java b/opendaylight/md-sal/sal-common-impl/src/test/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizerTest.java index dcb90a83ba..1595288608 100644 --- a/opendaylight/md-sal/sal-common-impl/src/test/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizerTest.java +++ b/opendaylight/md-sal/sal-common-impl/src/test/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizerTest.java @@ -32,12 +32,12 @@ import java.util.Set; import org.junit.Test; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.AugmentationIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeWithValue; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.api.Node; import org.opendaylight.yangtools.yang.data.api.SimpleNode; import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode; @@ -103,8 +103,8 @@ public class DataNormalizerTest { static final QName NAME_QNAME = QName.create(TEST_QNAME, "name"); static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value"); - static final InstanceIdentifier TEST_PATH = InstanceIdentifier.of(TEST_QNAME); - static final InstanceIdentifier OUTER_LIST_PATH = InstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME) + static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME); + static final YangInstanceIdentifier OUTER_LIST_PATH = YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME) .build(); static final QName ONE_QNAME = QName.create(TEST_QNAME, "one"); static final QName TWO_QNAME = QName.create(TEST_QNAME, "two"); @@ -119,10 +119,10 @@ public class DataNormalizerTest { static final Short OUTER_LIST_ID = (short) 10; - static final InstanceIdentifier OUTER_LIST_PATH_LEGACY = InstanceIdentifier.builder(TEST_QNAME) + static final YangInstanceIdentifier OUTER_LIST_PATH_LEGACY = YangInstanceIdentifier.builder(TEST_QNAME) .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, OUTER_LIST_ID).build(); - static final InstanceIdentifier LEAF_TWO_PATH_LEGACY = InstanceIdentifier.builder(OUTER_LIST_PATH_LEGACY) + static final YangInstanceIdentifier LEAF_TWO_PATH_LEGACY = YangInstanceIdentifier.builder(OUTER_LIST_PATH_LEGACY) .node(TWO_QNAME).build(); static final QName ANY_XML_LEAF_QNAME = QName.create(TEST_QNAME, "leaf");; @@ -141,13 +141,13 @@ public class DataNormalizerTest { SchemaContext testCtx = createTestContext(); DataNormalizer normalizer = new DataNormalizer(testCtx); - InstanceIdentifier normalizedPath = normalizer.toNormalized(LEAF_TWO_PATH_LEGACY); + YangInstanceIdentifier normalizedPath = normalizer.toNormalized(LEAF_TWO_PATH_LEGACY); verifyNormalizedInstanceIdentifier(normalizedPath, TEST_QNAME, OUTER_LIST_QNAME, new Object[] { OUTER_LIST_QNAME, ID_QNAME, OUTER_LIST_ID }, OUTER_CHOICE_QNAME, TWO_QNAME); } - private void verifyNormalizedInstanceIdentifier(final InstanceIdentifier actual, final Object... expPath) { + private void verifyNormalizedInstanceIdentifier(final YangInstanceIdentifier actual, final Object... expPath) { assertNotNull("Actual InstanceIdentifier is null", actual); assertEquals("InstanceIdentifier path length", expPath.length, Iterables.size(actual.getPathArguments())); @@ -181,11 +181,11 @@ public class DataNormalizerTest { DataNormalizer normalizer = new DataNormalizer(createTestContext()); - InstanceIdentifier normalized = InstanceIdentifier.builder().node(TEST_QNAME).node(OUTER_LIST_QNAME) + YangInstanceIdentifier normalized = YangInstanceIdentifier.builder().node(TEST_QNAME).node(OUTER_LIST_QNAME) .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, OUTER_LIST_ID).node(OUTER_CHOICE_QNAME).node(TWO_QNAME) .build(); - InstanceIdentifier legacy = normalizer.toLegacy(normalized); + YangInstanceIdentifier legacy = normalizer.toLegacy(normalized); assertEquals("Legacy InstanceIdentifier", LEAF_TWO_PATH_LEGACY, legacy); } @@ -295,7 +295,7 @@ public class DataNormalizerTest { .withNodeIdentifier(new NodeIdentifier(TEST_QNAME)).withChild(testAnyXmlNode).build(); DataNormalizer normalizer = new DataNormalizer(createTestContext()); - Node legacyNode = normalizer.toLegacy(InstanceIdentifier.builder(TEST_QNAME).build(), testContainerNode); + Node legacyNode = normalizer.toLegacy(YangInstanceIdentifier.builder(TEST_QNAME).build(), testContainerNode); verifyLegacyNode( legacyNode, @@ -332,7 +332,7 @@ public class DataNormalizerTest { DataNormalizer normalizer = new DataNormalizer(createTestContext()); - Node legacyNode = normalizer.toLegacy(InstanceIdentifier.builder(TEST_QNAME).build(), testContainerNode); + Node legacyNode = normalizer.toLegacy(YangInstanceIdentifier.builder(TEST_QNAME).build(), testContainerNode); verifyLegacyNode( legacyNode, @@ -359,7 +359,7 @@ public class DataNormalizerTest { DataNormalizer normalizer = new DataNormalizer(createTestContext()); - Node legacyNode = normalizer.toLegacy(InstanceIdentifier.builder(TEST_QNAME).build(), testContainerNode); + Node legacyNode = normalizer.toLegacy(YangInstanceIdentifier.builder(TEST_QNAME).build(), testContainerNode); verifyLegacyNode( legacyNode, @@ -563,8 +563,8 @@ public class DataNormalizerTest { testBuilder.add(unkeyedListBuilder.toInstance()); } - Entry> normalizedNodeEntry = normalizer - .toNormalized(new AbstractMap.SimpleEntry(InstanceIdentifier.create( + Entry> normalizedNodeEntry = normalizer + .toNormalized(new AbstractMap.SimpleEntry(YangInstanceIdentifier.create( ImmutableList. of(new NodeIdentifier(TEST_QNAME))), testBuilder.toInstance())); verifyNormalizedInstanceIdentifier(normalizedNodeEntry.getKey(), TEST_QNAME); @@ -627,8 +627,8 @@ public class DataNormalizerTest { CompositeNode anyXmlLegacy = anyXmlBuilder.toInstance(); testBuilder.add(anyXmlLegacy); - Entry> normalizedNodeEntry = normalizer - .toNormalized(new AbstractMap.SimpleEntry(InstanceIdentifier.create( + Entry> normalizedNodeEntry = normalizer + .toNormalized(new AbstractMap.SimpleEntry(YangInstanceIdentifier.create( ImmutableList. of(new NodeIdentifier(TEST_QNAME))), testBuilder.toInstance())); verifyNormalizedInstanceIdentifier(normalizedNodeEntry.getKey(), TEST_QNAME); @@ -651,8 +651,8 @@ public class DataNormalizerTest { testBuilder.add(outerContBuilder.toInstance()); - Entry> normalizedNodeEntry = normalizer - .toNormalized(new AbstractMap.SimpleEntry(InstanceIdentifier.create( + Entry> normalizedNodeEntry = normalizer + .toNormalized(new AbstractMap.SimpleEntry(YangInstanceIdentifier.create( ImmutableList. of(new NodeIdentifier(TEST_QNAME))), testBuilder.toInstance())); verifyNormalizedInstanceIdentifier(normalizedNodeEntry.getKey(), TEST_QNAME); @@ -663,8 +663,8 @@ public class DataNormalizerTest { verifyNormalizedNode(normalizedNodeEntry.getValue(), expectContainerNode(TEST_QNAME, expectContainerNode(OUTER_CONTAINER_QNAME, expAugmentation))); - normalizedNodeEntry = normalizer.toNormalized(new AbstractMap.SimpleEntry( - InstanceIdentifier.create(Lists.newArrayList(new NodeIdentifier(TEST_QNAME), new NodeIdentifier( + normalizedNodeEntry = normalizer.toNormalized(new AbstractMap.SimpleEntry( + YangInstanceIdentifier.create(Lists.newArrayList(new NodeIdentifier(TEST_QNAME), new NodeIdentifier( OUTER_CONTAINER_QNAME))), outerContBuilder.toInstance())); verifyNormalizedInstanceIdentifier(normalizedNodeEntry.getKey(), TEST_QNAME, OUTER_CONTAINER_QNAME, @@ -689,8 +689,8 @@ public class DataNormalizerTest { testBuilder.addLeaf(ORDERED_LEAF_LIST_QNAME, "ordered-value" + i); } - Entry> normalizedNodeEntry = normalizer - .toNormalized(new AbstractMap.SimpleEntry(InstanceIdentifier.create( + Entry> normalizedNodeEntry = normalizer + .toNormalized(new AbstractMap.SimpleEntry(YangInstanceIdentifier.create( ImmutableList. of(new NodeIdentifier(TEST_QNAME))), testBuilder.toInstance())); verifyNormalizedInstanceIdentifier(normalizedNodeEntry.getKey(), TEST_QNAME); diff --git a/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/Connector.java b/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/Connector.java index 519d21bf4f..67fb6622d1 100644 --- a/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/Connector.java +++ b/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/Connector.java @@ -11,14 +11,14 @@ import java.util.Set; import org.opendaylight.controller.sal.core.api.RpcImplementation; import org.opendaylight.controller.sal.core.api.notify.NotificationListener; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; public interface Connector extends RpcImplementation, NotificationListener { - Set getConfigurationPrefixes(); - Set getRuntimePrefixes(); + Set getConfigurationPrefixes(); + Set getRuntimePrefixes(); void registerListener(ConnectorListener listener); void unregisterListener(ConnectorListener listener); diff --git a/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/ConnectorListener.java b/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/ConnectorListener.java index ac9c893a0b..935baba7a2 100644 --- a/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/ConnectorListener.java +++ b/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/ConnectorListener.java @@ -9,11 +9,11 @@ package org.opendaylight.controller.sal.connector.api; import java.util.Set; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; public interface ConnectorListener { - void onPrefixesAnnounced(Set prefixes); - void onPrefixesWithdrawn(Set prefixes); + void onPrefixesAnnounced(Set prefixes); + void onPrefixesWithdrawn(Set prefixes); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/pom.xml b/opendaylight/md-sal/sal-distributed-datastore/pom.xml index 5152363ab2..94c895dab3 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/pom.xml +++ b/opendaylight/md-sal/sal-distributed-datastore/pom.xml @@ -118,6 +118,18 @@ scala-library + + org.opendaylight.controller + sal-protocolbuffer-encoding + 1.1-SNAPSHOT + + + + org.opendaylight.controller + sal-akka-raft + 1.1-SNAPSHOT + + junit @@ -153,6 +165,8 @@ !*snappy;!org.jboss.*;* + sal-protocolbuffer-encoding; + sal-akka-raft; !sal*; !*config-api*; !*testkit*; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractUntypedActor.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractUntypedActor.java index 0f10258e9e..ce0516064e 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractUntypedActor.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractUntypedActor.java @@ -27,9 +27,9 @@ public abstract class AbstractUntypedActor extends UntypedActor { } @Override public void onReceive(Object message) throws Exception { - LOG.debug("Received message {}", message); + LOG.debug("Received message {}", message.getClass().getSimpleName()); handleReceive(message); - LOG.debug("Done handling message {}", message); + LOG.debug("Done handling message {}", message.getClass().getSimpleName()); } protected abstract void handleReceive(Object message) throws Exception; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ClusterWrapper.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ClusterWrapper.java new file mode 100644 index 0000000000..2eac2400b5 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ClusterWrapper.java @@ -0,0 +1,16 @@ +/* + * 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; + +public interface ClusterWrapper { + void subscribeToMemberEvents(ActorRef actorRef); + String getCurrentMemberName(); +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ClusterWrapperImpl.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ClusterWrapperImpl.java new file mode 100644 index 0000000000..142aacde65 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ClusterWrapperImpl.java @@ -0,0 +1,35 @@ +/* + * 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.ActorSystem; +import akka.cluster.Cluster; +import akka.cluster.ClusterEvent; + +public class ClusterWrapperImpl implements ClusterWrapper { + private final Cluster cluster; + private final String currentMemberName; + + public ClusterWrapperImpl(ActorSystem actorSystem){ + cluster = Cluster.get(actorSystem); + currentMemberName = (String) cluster.getSelfRoles().toArray()[0]; + + } + + public void subscribeToMemberEvents(ActorRef actorRef){ + cluster.subscribe(actorRef, ClusterEvent.initialStateAsEvents(), + ClusterEvent.MemberEvent.class, + ClusterEvent.UnreachableMember.class); + } + + public String getCurrentMemberName() { + return currentMemberName; + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CompositeModificationPayload.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CompositeModificationPayload.java new file mode 100644 index 0000000000..955e4bbf22 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CompositeModificationPayload.java @@ -0,0 +1,53 @@ +/* + * 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 com.google.common.base.Preconditions; +import com.google.protobuf.GeneratedMessage; +import org.opendaylight.controller.cluster.example.protobuff.messages.KeyValueMessages; +import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload; +import org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages; +import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +public class CompositeModificationPayload extends Payload implements + Serializable { + + private final PersistentMessages.CompositeModification modification; + + public CompositeModificationPayload(){ + modification = null; + } + public CompositeModificationPayload(Object modification){ + this.modification = (PersistentMessages.CompositeModification) modification; + } + + @Override public Map encode() { + Preconditions.checkState(modification!=null); + Map map = new HashMap<>(); + map.put(org.opendaylight.controller.mdsal.CompositeModificationPayload.modification, this.modification); + return map; + } + + @Override public Payload decode( + AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload payload) { + PersistentMessages.CompositeModification modification = payload + .getExtension( + org.opendaylight.controller.mdsal.CompositeModificationPayload.modification); + payload.getExtension(KeyValueMessages.value); + return new CompositeModificationPayload(modification); + } + + public Object getModification(){ + return this.modification; + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Configuration.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Configuration.java new file mode 100644 index 0000000000..34239070a3 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Configuration.java @@ -0,0 +1,55 @@ +/* + * 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 com.google.common.base.Optional; +import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategy; + +import java.util.List; +import java.util.Map; + +public interface Configuration { + + /** + * Given a memberName find all the shards that belong on that member and + * return the names of those shards + * + * @param memberName + * @return + */ + List getMemberShardNames(String memberName); + + /** + * Given a module namespace return the name of a module + * @param nameSpace + * @return + */ + Optional getModuleNameFromNameSpace(String nameSpace); + + /** + * Get a mapping of the module names to it's corresponding ShardStrategy + * @return + */ + Map getModuleNameToShardStrategyMap(); + + /** + * Given a module name find all the shardNames corresponding to it + * @param moduleName + * @return + */ + List getShardNamesFromModuleName(String moduleName); + + /** + * Given a shardName find all the members on which it belongs + * + * @param shardName + * @return + */ + List getMembersFromShardName(String shardName); +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ConfigurationImpl.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ConfigurationImpl.java new file mode 100644 index 0000000000..34590025d5 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ConfigurationImpl.java @@ -0,0 +1,241 @@ +/* + * 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 com.google.common.base.Optional; +import com.typesafe.config.Config; +import com.typesafe.config.ConfigFactory; +import com.typesafe.config.ConfigObject; +import org.opendaylight.controller.cluster.datastore.shardstrategy.DefaultShardStrategy; +import org.opendaylight.controller.cluster.datastore.shardstrategy.ModuleShardStrategy; +import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ConfigurationImpl implements Configuration { + + private final List moduleShards = new ArrayList<>(); + + private final List modules = new ArrayList<>(); + + private static final Logger + LOG = LoggerFactory.getLogger(DistributedDataStore.class); + + + public ConfigurationImpl(String moduleShardsConfigPath, + + String modulesConfigPath){ + + File moduleShardsFile = new File("./configuration/initial/" + moduleShardsConfigPath); + File modulesFile = new File("./configuration/initial/" + modulesConfigPath); + + Config moduleShardsConfig = null; + if(moduleShardsFile.exists()) { + LOG.info("module shards config file exists - reading config from it"); + moduleShardsConfig = ConfigFactory.parseFile(moduleShardsFile); + } else { + LOG.warn("module shards configuration read from resource"); + moduleShardsConfig = ConfigFactory.load(moduleShardsConfigPath); + } + + Config modulesConfig = null; + if(modulesFile.exists()) { + LOG.info("modules config file exists - reading config from it"); + modulesConfig = ConfigFactory.parseFile(modulesFile); + } else { + LOG.warn("modules configuration read from resource"); + modulesConfig = ConfigFactory.load(modulesConfigPath); + } + + readModuleShards(moduleShardsConfig); + + readModules(modulesConfig); + } + + @Override public List getMemberShardNames(String memberName){ + List shards = new ArrayList(); + for(ModuleShard ms : moduleShards){ + for(Shard s : ms.getShards()){ + for(String m : s.getReplicas()){ + if(memberName.equals(m)){ + shards.add(s.getName()); + } + } + } + } + return shards; + + } + + @Override public Optional getModuleNameFromNameSpace(String nameSpace) { + for(Module m : modules){ + if(m.getNameSpace().equals(nameSpace)){ + return Optional.of(m.getName()); + } + } + return Optional.absent(); + } + + @Override public Map getModuleNameToShardStrategyMap() { + Map map = new HashMap<>(); + for(Module m : modules){ + map.put(m.getName(), m.getShardStrategy()); + } + return map; + } + + @Override public List getShardNamesFromModuleName(String moduleName) { + for(ModuleShard m : moduleShards){ + if(m.getModuleName().equals(moduleName)){ + List l = new ArrayList<>(); + for(Shard s : m.getShards()){ + l.add(s.getName()); + } + return l; + } + } + + return Collections.EMPTY_LIST; + } + + @Override public List getMembersFromShardName(String shardName) { + List shards = new ArrayList(); + for(ModuleShard ms : moduleShards){ + for(Shard s : ms.getShards()) { + if(s.getName().equals(shardName)){ + return s.getReplicas(); + } + } + } + return Collections.EMPTY_LIST; + } + + + + private void readModules(Config modulesConfig) { + List modulesConfigObjectList = + modulesConfig.getObjectList("modules"); + + for(ConfigObject o : modulesConfigObjectList){ + ConfigObjectWrapper w = new ConfigObjectWrapper(o); + modules.add(new Module(w.stringValue("name"), w.stringValue( + "namespace"), w.stringValue("shard-strategy"))); + } + } + + private void readModuleShards(Config moduleShardsConfig) { + List moduleShardsConfigObjectList = + moduleShardsConfig.getObjectList("module-shards"); + + for(ConfigObject moduleShardConfigObject : moduleShardsConfigObjectList){ + + String moduleName = moduleShardConfigObject.get("name").unwrapped().toString(); + + List shardsConfigObjectList = + moduleShardConfigObject.toConfig().getObjectList("shards"); + + List shards = new ArrayList<>(); + + for(ConfigObject shard : shardsConfigObjectList){ + String shardName = shard.get("name").unwrapped().toString(); + List replicas = shard.toConfig().getStringList("replicas"); + shards.add(new Shard(shardName, replicas)); + } + + this.moduleShards.add(new ModuleShard(moduleName, shards)); + } + } + + + private class ModuleShard { + private final String moduleName; + private final List shards; + + public ModuleShard(String moduleName, List shards) { + this.moduleName = moduleName; + this.shards = shards; + } + + public String getModuleName() { + return moduleName; + } + + public List getShards() { + return shards; + } + } + + private class Shard { + private final String name; + private final List replicas; + + Shard(String name, List replicas) { + this.name = name; + this.replicas = replicas; + } + + public String getName() { + return name; + } + + public List getReplicas() { + return replicas; + } + } + + private class Module { + + private final String name; + private final String nameSpace; + private final ShardStrategy shardStrategy; + + Module(String name, String nameSpace, String shardStrategy) { + this.name = name; + this.nameSpace = nameSpace; + if(ModuleShardStrategy.NAME.equals(shardStrategy)){ + this.shardStrategy = new ModuleShardStrategy(name, ConfigurationImpl.this); + } else { + this.shardStrategy = new DefaultShardStrategy(); + } + } + + public String getName() { + return name; + } + + public String getNameSpace() { + return nameSpace; + } + + public ShardStrategy getShardStrategy() { + return shardStrategy; + } + } + + + private static class ConfigObjectWrapper{ + + private final ConfigObject configObject; + + ConfigObjectWrapper(ConfigObject configObject){ + this.configObject = configObject; + } + + public String stringValue(String name){ + return configObject.get(name).unwrapped().toString(); + } + } +} 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 fd4f9f75b5..3af6f56a2c 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 @@ -14,36 +14,41 @@ import org.opendaylight.controller.cluster.datastore.messages.DataChanged; import org.opendaylight.controller.cluster.datastore.messages.DataChangedReply; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +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; public class DataChangeListener extends AbstractUntypedActor { - private final AsyncDataChangeListener> listener; + private final AsyncDataChangeListener> listener; + private final SchemaContext schemaContext; + private final YangInstanceIdentifier pathId; - public DataChangeListener( - AsyncDataChangeListener> listener) { + public DataChangeListener(SchemaContext schemaContext, + AsyncDataChangeListener> listener, YangInstanceIdentifier pathId) { this.listener = listener; + this.schemaContext = schemaContext; + this.pathId = pathId; } @Override public void handleReceive(Object message) throws Exception { - if(message instanceof DataChanged){ - DataChanged reply = (DataChanged) message; - AsyncDataChangeEvent> + if(message.getClass().equals(DataChanged.SERIALIZABLE_CLASS)){ + DataChanged reply = DataChanged.fromSerialize(schemaContext,message, pathId); + AsyncDataChangeEvent> change = reply.getChange(); this.listener.onDataChanged(change); if(getSender() != null){ - getSender().tell(new DataChangedReply(), getSelf()); + getSender().tell(new DataChangedReply().toSerializable(), getSelf()); } } } - public static Props props(final AsyncDataChangeListener> listener) { + public static Props props(final SchemaContext schemaContext, final AsyncDataChangeListener> listener, final YangInstanceIdentifier pathId) { return Props.create(new Creator() { @Override public DataChangeListener create() throws Exception { - return new DataChangeListener(listener); + return new DataChangeListener(schemaContext,listener,pathId ); } }); 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 8423b9853d..cd9c330268 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 @@ -12,21 +12,24 @@ import akka.actor.ActorSelection; import org.opendaylight.controller.cluster.datastore.messages.DataChanged; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +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; /** * DataChangeListenerProxy represents a single remote DataChangeListener */ -public class DataChangeListenerProxy implements AsyncDataChangeListener>{ +public class DataChangeListenerProxy implements AsyncDataChangeListener>{ private final ActorSelection dataChangeListenerActor; + private final SchemaContext schemaContext; - public DataChangeListenerProxy(ActorSelection dataChangeListenerActor) { + public DataChangeListenerProxy(SchemaContext schemaContext,ActorSelection dataChangeListenerActor) { this.dataChangeListenerActor = dataChangeListenerActor; + this.schemaContext = schemaContext; } @Override public void onDataChanged( - AsyncDataChangeEvent> change) { - dataChangeListenerActor.tell(new DataChanged(change), null); + AsyncDataChangeEvent> change) { + dataChangeListenerActor.tell(new DataChanged(schemaContext,change).toSerializable(), null); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistration.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistration.java index dca9735487..9e50b5b332 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistration.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistration.java @@ -14,29 +14,29 @@ import akka.japi.Creator; import org.opendaylight.controller.cluster.datastore.messages.CloseDataChangeListenerRegistration; import org.opendaylight.controller.cluster.datastore.messages.CloseDataChangeListenerRegistrationReply; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; public class DataChangeListenerRegistration extends AbstractUntypedActor { - private final org.opendaylight.yangtools.concepts.ListenerRegistration>> + private final org.opendaylight.yangtools.concepts.ListenerRegistration>> registration; public DataChangeListenerRegistration( - org.opendaylight.yangtools.concepts.ListenerRegistration>> registration) { + org.opendaylight.yangtools.concepts.ListenerRegistration>> registration) { this.registration = registration; } @Override public void handleReceive(Object message) throws Exception { - if (message instanceof CloseDataChangeListenerRegistration) { + if (message.getClass().equals(CloseDataChangeListenerRegistration.SERIALIZABLE_CLASS)) { closeListenerRegistration( - (CloseDataChangeListenerRegistration) message); + new CloseDataChangeListenerRegistration()); } } public static Props props( - final org.opendaylight.yangtools.concepts.ListenerRegistration>> registration) { + final org.opendaylight.yangtools.concepts.ListenerRegistration>> registration) { return Props.create(new Creator() { @Override @@ -50,7 +50,7 @@ public class DataChangeListenerRegistration extends AbstractUntypedActor { CloseDataChangeListenerRegistration message) { registration.close(); getSender() - .tell(new CloseDataChangeListenerRegistrationReply(), getSelf()); + .tell(new CloseDataChangeListenerRegistrationReply().toSerializable(), getSelf()); getSelf().tell(PoisonPill.getInstance(), getSelf()); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationProxy.java index 83737cfac5..e3cdbb4ee1 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationProxy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationProxy.java @@ -14,7 +14,7 @@ import akka.actor.PoisonPill; import org.opendaylight.controller.cluster.datastore.messages.CloseDataChangeListenerRegistration; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; /** @@ -29,7 +29,7 @@ public class DataChangeListenerRegistrationProxy implements ListenerRegistration private final AsyncDataChangeListener listener; private final ActorRef dataChangeListenerActor; - public >> + public >> DataChangeListenerRegistrationProxy( ActorSelection listenerRegistrationActor, L listener, ActorRef dataChangeListenerActor) { @@ -45,7 +45,7 @@ public class DataChangeListenerRegistrationProxy implements ListenerRegistration @Override public void close() { - listenerRegistrationActor.tell(new CloseDataChangeListenerRegistration(), null); + listenerRegistrationActor.tell(new CloseDataChangeListenerRegistration().toSerializable(), null); dataChangeListenerActor.tell(PoisonPill.getInstance(), 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 4401104a85..2ef8e5f449 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 @@ -13,6 +13,7 @@ import akka.actor.ActorSystem; import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListener; import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListenerReply; import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext; +import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategyFactory; import org.opendaylight.controller.cluster.datastore.utils.ActorContext; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener; @@ -22,7 +23,7 @@ import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransactio import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain; import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +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 org.opendaylight.yangtools.yang.model.api.SchemaContextListener; @@ -44,6 +45,9 @@ public class DistributedDataStore implements DOMStore, SchemaContextListener, Au private final String type; private final ActorContext actorContext; + private SchemaContext schemaContext; + + /** * Executor used to run FutureTask's @@ -56,8 +60,10 @@ public class DistributedDataStore implements DOMStore, SchemaContextListener, Au private final ExecutorService executor = Executors.newFixedThreadPool(10); - public DistributedDataStore(ActorSystem actorSystem, String type) { - this(new ActorContext(actorSystem, actorSystem.actorOf(ShardManager.props(type), "shardmanager-" + type)), type); + public DistributedDataStore(ActorSystem actorSystem, String type, ClusterWrapper cluster, Configuration configuration) { + this(new ActorContext(actorSystem, actorSystem + .actorOf(ShardManager.props(type, cluster, configuration), + "shardmanager-" + type), cluster, configuration), type); } public DistributedDataStore(ActorContext actorContext, String type) { @@ -67,20 +73,22 @@ public class DistributedDataStore implements DOMStore, SchemaContextListener, Au @Override - public >> ListenerRegistration registerChangeListener( - InstanceIdentifier path, L listener, + public >> ListenerRegistration registerChangeListener( + YangInstanceIdentifier path, L listener, AsyncDataBroker.DataChangeScope scope) { ActorRef dataChangeListenerActor = actorContext.getActorSystem().actorOf( - DataChangeListener.props(listener)); + DataChangeListener.props(schemaContext,listener,path )); + + String shardName = ShardStrategyFactory.getStrategy(path).findShard(path); - Object result = actorContext.executeShardOperation(Shard.DEFAULT_NAME, + Object result = actorContext.executeShardOperation(shardName, new RegisterChangeListener(path, dataChangeListenerActor.path(), - AsyncDataBroker.DataChangeScope.BASE), + scope).toSerializable(), ActorContext.ASK_DURATION ); - RegisterChangeListenerReply reply = (RegisterChangeListenerReply) result; + RegisterChangeListenerReply reply = RegisterChangeListenerReply.fromSerializable(actorContext.getActorSystem(),result); return new DataChangeListenerRegistrationProxy(actorContext.actorSelection(reply.getListenerRegistrationPath()), listener, dataChangeListenerActor); } @@ -88,28 +96,29 @@ public class DistributedDataStore implements DOMStore, SchemaContextListener, Au @Override public DOMStoreTransactionChain createTransactionChain() { - return new TransactionChainProxy(actorContext, executor); + return new TransactionChainProxy(actorContext, executor, schemaContext); } @Override public DOMStoreReadTransaction newReadOnlyTransaction() { return new TransactionProxy(actorContext, TransactionProxy.TransactionType.READ_ONLY, - executor); + executor, schemaContext); } @Override public DOMStoreWriteTransaction newWriteOnlyTransaction() { return new TransactionProxy(actorContext, TransactionProxy.TransactionType.WRITE_ONLY, - executor); + executor, schemaContext); } @Override public DOMStoreReadWriteTransaction newReadWriteTransaction() { return new TransactionProxy(actorContext, TransactionProxy.TransactionType.READ_WRITE, - executor); + executor, schemaContext); } @Override public void onGlobalContextUpdated(SchemaContext schemaContext) { + this.schemaContext = schemaContext; actorContext.getShardManager().tell( new UpdateSchemaContext(schemaContext), null); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreFactory.java index f19cb9284c..692d1b4954 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreFactory.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreFactory.java @@ -8,12 +8,17 @@ package org.opendaylight.controller.cluster.datastore; +import akka.actor.ActorSystem; +import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategyFactory; import org.opendaylight.controller.sal.core.api.model.SchemaService; public class DistributedDataStoreFactory { public static DistributedDataStore createInstance(String name, SchemaService schemaService){ + ActorSystem actorSystem = ActorSystemFactory.getInstance(); + Configuration config = new ConfigurationImpl("module-shards.conf", "modules.conf"); final DistributedDataStore dataStore = - new DistributedDataStore(ActorSystemFactory.getInstance(), name); + new DistributedDataStore(actorSystem, name, new ClusterWrapperImpl(actorSystem),config ); + ShardStrategyFactory.setConfiguration(config); schemaService .registerSchemaServiceListener(dataStore); return dataStore; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/NoOpCohort.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/NoOpCohort.java new file mode 100644 index 0000000000..eb28159025 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/NoOpCohort.java @@ -0,0 +1,40 @@ +/* + * 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.UntypedActor; +import org.opendaylight.controller.cluster.datastore.messages.AbortTransaction; +import org.opendaylight.controller.cluster.datastore.messages.AbortTransactionReply; +import org.opendaylight.controller.cluster.datastore.messages.CanCommitTransaction; +import org.opendaylight.controller.cluster.datastore.messages.CanCommitTransactionReply; +import org.opendaylight.controller.cluster.datastore.messages.CommitTransaction; +import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply; +import org.opendaylight.controller.cluster.datastore.messages.PreCommitTransaction; +import org.opendaylight.controller.cluster.datastore.messages.PreCommitTransactionReply; + +public class NoOpCohort extends UntypedActor { + + @Override public void onReceive(Object message) throws Exception { + if (message.getClass().equals(CanCommitTransaction.SERIALIZABLE_CLASS)) { + getSender().tell(new CanCommitTransactionReply(false).toSerializable(), getSelf()); + } else if (message.getClass().equals(PreCommitTransaction.SERIALIZABLE_CLASS)) { + getSender().tell( + new PreCommitTransactionReply().toSerializable(), + getSelf()); + } else if (message.getClass().equals(CommitTransaction.SERIALIZABLE_CLASS)) { + getSender().tell(new CommitTransactionReply().toSerializable(), getSelf()); + } else if (message.getClass().equals(AbortTransaction.SERIALIZABLE_CLASS)) { + getSender().tell(new AbortTransactionReply().toSerializable(), getSelf()); + } else { + throw new Exception ("Not recognized message received,message="+message); + } + + } +} + 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 3425608d23..999d0f8baf 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 @@ -14,29 +14,33 @@ import akka.actor.Props; import akka.event.Logging; import akka.event.LoggingAdapter; import akka.japi.Creator; -import akka.persistence.Persistent; -import akka.persistence.UntypedProcessor; +import akka.serialization.Serialization; 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; import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction; import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionChain; import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionChainReply; import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionReply; import org.opendaylight.controller.cluster.datastore.messages.ForwardedCommitTransaction; -import org.opendaylight.controller.cluster.datastore.messages.NonPersistent; +import org.opendaylight.controller.cluster.datastore.messages.PeerAddressResolved; import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListener; import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListenerReply; 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.RaftActor; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener; import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; 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.yangtools.yang.data.api.InstanceIdentifier; +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 java.util.HashMap; import java.util.Map; @@ -49,7 +53,7 @@ import java.util.concurrent.Executors; * Our Shard uses InMemoryDataStore as it's internal representation and delegates all requests it *

*/ -public class Shard extends UntypedProcessor { +public class Shard extends RaftActor { public static final String DEFAULT_NAME = "default"; @@ -58,137 +62,208 @@ public class Shard extends UntypedProcessor { private final InMemoryDOMDataStore store; - private final Map + private final Map modificationToCohort = new HashMap<>(); - private final LoggingAdapter log = + private final LoggingAdapter LOG = Logging.getLogger(getContext().system(), this); // By default persistent will be true and can be turned off using the system // property persistent private final boolean persistent; - private Shard(String name) { + private final String name; + + private SchemaContext schemaContext; + + private final ShardStats shardMBean; + + private Shard(String name, Map peerAddresses) { + super(name, peerAddresses); + + this.name = name; String setting = System.getProperty("shard.persistent"); + this.persistent = !"false".equals(setting); - log.info("Creating shard : {} persistent : {}", name , persistent); + LOG.info("Creating shard : {} persistent : {}", name, persistent); store = new InMemoryDOMDataStore(name, storeExecutor); + + shardMBean = ShardMBeanFactory.getShardStatsMBean(name); + } - public static Props props(final String name) { + public static Props props(final String name, final Map peerAddresses) { return Props.create(new Creator() { @Override public Shard create() throws Exception { - return new Shard(name); + return new Shard(name, peerAddresses); } }); } - @Override - public void onReceive(Object message) throws Exception { - log.debug("Received message {}", message); + @Override public void onReceiveCommand(Object message){ + LOG.debug("Received message {} from {}", message.getClass().toString(), getSender()); - if (message instanceof CreateTransactionChain) { - createTransactionChain(); - } else if (message instanceof RegisterChangeListener) { - registerChangeListener((RegisterChangeListener) message); + if (message.getClass().equals(CreateTransactionChain.SERIALIZABLE_CLASS)) { + if(isLeader()) { + createTransactionChain(); + } 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 UpdateSchemaContext) { updateSchemaContext((UpdateSchemaContext) message); } else if (message instanceof ForwardedCommitTransaction) { handleForwardedCommit((ForwardedCommitTransaction) message); - } else if (message instanceof Persistent) { - commit((Modification) ((Persistent) message).payload()); - } else if (message instanceof CreateTransaction) { - createTransaction((CreateTransaction) message); - } else if(message instanceof NonPersistent){ - commit((Modification) ((NonPersistent) message).payload()); + } else if (message.getClass().equals(CreateTransaction.SERIALIZABLE_CLASS)) { + if(isLeader()) { + createTransaction(CreateTransaction.fromSerializable(message)); + } else if(getLeader() != null){ + getLeader().forward(message, getContext()); + } + } else if (message instanceof PeerAddressResolved){ + PeerAddressResolved resolved = (PeerAddressResolved) message; + setPeerAddress(resolved.getPeerId(), resolved.getPeerAddress()); + } else { + super.onReceiveCommand(message); } } 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()), "shard-" + createTransaction.getTransactionId()); + ShardTransaction.props(transaction, getSelf(), schemaContext), transactionId); + getSender() - .tell(new CreateTransactionReply(transactionActor.path(), createTransaction.getTransactionId()), + .tell(new CreateTransactionReply(Serialization.serializedActorPath(transactionActor), createTransaction.getTransactionId()).toSerializable(), getSelf()); } - private void commit(Modification modification) { + private void commit(final ActorRef sender, Object serialized) { + Modification modification = MutableCompositeModification.fromSerializable(serialized, schemaContext); DOMStoreThreePhaseCommitCohort cohort = - modificationToCohort.remove(modification); + modificationToCohort.remove(serialized); if (cohort == null) { - log.error( + LOG.error( "Could not find cohort for modification : " + modification); + LOG.info("Writing modification using a new transaction"); + modification.apply(store.newReadWriteTransaction()); return; } + final ListenableFuture future = cohort.commit(); - final ActorRef sender = getSender(); + shardMBean.incrementCommittedTransactionCount(); final ActorRef self = getSelf(); future.addListener(new Runnable() { @Override public void run() { try { future.get(); - sender.tell(new CommitTransactionReply(), self); + + if(sender != null) { + sender + .tell(new CommitTransactionReply().toSerializable(), + self); + } else { + LOG.error("sender is null ???"); + } } catch (InterruptedException | ExecutionException e) { // FIXME : Handle this properly - log.error(e, "An exception happened when committing"); + LOG.error(e, "An exception happened when committing"); } } }, getContext().dispatcher()); } private void handleForwardedCommit(ForwardedCommitTransaction message) { + Object serializedModification = message.getModification().toSerializable(); + modificationToCohort - .put(message.getModification(), message.getCohort()); + .put(serializedModification , message.getCohort()); + if(persistent) { - getSelf().forward(Persistent.create(message.getModification()), - getContext()); + this.persistData(getSender(), "identifier", new CompositeModificationPayload(serializedModification)); } else { - getSelf().forward(NonPersistent.create(message.getModification()), - getContext()); + this.commit(getSender(), serializedModification); } } private void updateSchemaContext(UpdateSchemaContext message) { + this.schemaContext = message.getSchemaContext(); store.onGlobalContextUpdated(message.getSchemaContext()); } private void registerChangeListener( RegisterChangeListener registerChangeListener) { + LOG.debug("registerDataChangeListener for " + registerChangeListener.getPath()); + + ActorSelection dataChangeListenerPath = getContext() - .system().actorSelection(registerChangeListener.getDataChangeListenerPath()); + .system().actorSelection( + registerChangeListener.getDataChangeListenerPath()); - AsyncDataChangeListener> - listener = new DataChangeListenerProxy(dataChangeListenerPath); + AsyncDataChangeListener> + listener = new DataChangeListenerProxy(schemaContext,dataChangeListenerPath); - org.opendaylight.yangtools.concepts.ListenerRegistration>> + org.opendaylight.yangtools.concepts.ListenerRegistration>> registration = store.registerChangeListener(registerChangeListener.getPath(), listener, registerChangeListener.getScope()); ActorRef listenerRegistration = getContext().actorOf( DataChangeListenerRegistration.props(registration)); + + LOG.debug("registerDataChangeListener sending reply, listenerRegistrationPath = " + listenerRegistration.path().toString()); + getSender() - .tell(new RegisterChangeListenerReply(listenerRegistration.path()), + .tell(new RegisterChangeListenerReply(listenerRegistration.path()).toSerializable(), getSelf()); } private void createTransactionChain() { DOMStoreTransactionChain chain = store.createTransactionChain(); ActorRef transactionChain = - getContext().actorOf(ShardTransactionChain.props(chain)); + getContext().actorOf( + ShardTransactionChain.props(chain, schemaContext)); getSender() - .tell(new CreateTransactionChainReply(transactionChain.path()), + .tell(new CreateTransactionChainReply(transactionChain.path()) + .toSerializable(), getSelf()); } + + @Override protected void applyState(ActorRef clientActor, String identifier, + Object data) { + + if(data instanceof CompositeModificationPayload){ + Object modification = + ((CompositeModificationPayload) data).getModification(); + commit(clientActor, modification); + } else { + LOG.error("Unknown state received {}", data); + } + + } + + @Override protected Object createSnapshot() { + throw new UnsupportedOperationException("createSnapshot"); + } + + @Override protected void applySnapshot(Object snapshot) { + throw new UnsupportedOperationException("applySnapshot"); + } + + @Override public String persistenceId() { + return this.name; + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java index 250ef49e6f..5fbce4cd98 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java @@ -11,14 +11,19 @@ package org.opendaylight.controller.cluster.datastore; import akka.actor.ActorPath; import akka.actor.ActorRef; import akka.actor.Address; +import akka.actor.OneForOneStrategy; import akka.actor.Props; -import akka.event.Logging; -import akka.event.LoggingAdapter; +import akka.actor.SupervisorStrategy; +import akka.cluster.ClusterEvent; import akka.japi.Creator; +import akka.japi.Function; +import com.google.common.base.Preconditions; import org.opendaylight.controller.cluster.datastore.messages.FindPrimary; +import org.opendaylight.controller.cluster.datastore.messages.PeerAddressResolved; import org.opendaylight.controller.cluster.datastore.messages.PrimaryFound; import org.opendaylight.controller.cluster.datastore.messages.PrimaryNotFound; import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext; +import scala.concurrent.duration.Duration; import java.util.HashMap; import java.util.List; @@ -49,54 +54,242 @@ import java.util.Map; */ public class ShardManager extends AbstractUntypedActor { - // Stores a mapping between a shard name and the address of the current primary - private final Map shardNameToPrimaryAddress = new HashMap<>(); - - // Stores a mapping between a member name and the address of the member - private final Map memberNameToAddress = new HashMap<>(); - - // Stores a mapping between the shard name and all the members on which a replica of that shard are available - private final Map> shardNameToMembers = new HashMap<>(); - - private final LoggingAdapter log = Logging.getLogger(getContext().system(), this); - - private final ActorPath defaultShardPath; - - /** - * - * @param type defines the kind of data that goes into shards created by this shard manager. Examples of type would be - * configuration or operational - */ - private ShardManager(String type){ - ActorRef actor = getContext().actorOf(Shard.props("shard-" + Shard.DEFAULT_NAME + "-" + type), "shard-" + Shard.DEFAULT_NAME + "-" + type); - defaultShardPath = actor.path(); - } - - public static Props props(final String type){ - return Props.create(new Creator(){ - - @Override - public ShardManager create() throws Exception { - return new ShardManager(type); - } - }); - } - - @Override - public void handleReceive(Object message) throws Exception { - if (message instanceof FindPrimary) { - FindPrimary msg = ((FindPrimary) message); - String shardName = msg.getShardName(); - if(Shard.DEFAULT_NAME.equals(shardName)){ - getSender().tell(new PrimaryFound(defaultShardPath.toString()), getSelf()); - } else { - getSender().tell(new PrimaryNotFound(shardName), getSelf()); - } - } else if(message instanceof UpdateSchemaContext){ - // FIXME : Notify all local shards of a context change - getContext().system().actorSelection(defaultShardPath).forward(message, getContext()); + // Stores a mapping between a member name and the address of the member + private final Map memberNameToAddress = new HashMap<>(); + + private final Map localShards = new HashMap<>(); + + + private final String type; + + private final ClusterWrapper cluster; + + private final Configuration configuration; + + /** + * @param type defines the kind of data that goes into shards created by this shard manager. Examples of type would be + * configuration or operational + */ + private ShardManager(String type, ClusterWrapper cluster, Configuration configuration) { + + this.type = Preconditions.checkNotNull(type, "type should not be null"); + this.cluster = Preconditions.checkNotNull(cluster, "cluster should not be null"); + this.configuration = Preconditions.checkNotNull(configuration, "configuration should not be null"); + + // Subscribe this actor to cluster member events + cluster.subscribeToMemberEvents(getSelf()); + + // Create all the local Shards and make them a child of the ShardManager + // TODO: This may need to be initiated when we first get the schema context + createLocalShards(); + } + + public static Props props(final String type, + final ClusterWrapper cluster, + final Configuration configuration) { + return Props.create(new Creator() { + + @Override + public ShardManager create() throws Exception { + return new ShardManager(type, cluster, configuration); + } + }); + } + + + @Override + public void handleReceive(Object message) throws Exception { + if (message.getClass().equals(FindPrimary.SERIALIZABLE_CLASS)) { + findPrimary( + FindPrimary.fromSerializable(message)); + + } else if (message instanceof UpdateSchemaContext) { + updateSchemaContext(message); + } else if (message instanceof ClusterEvent.MemberUp){ + memberUp((ClusterEvent.MemberUp) message); + } else if(message instanceof ClusterEvent.MemberRemoved) { + memberRemoved((ClusterEvent.MemberRemoved) message); + } else if(message instanceof ClusterEvent.UnreachableMember) { + ignoreMessage(message); + } else{ + throw new Exception ("Not recognized message received, message="+message); + } + + } + + private void ignoreMessage(Object message){ + LOG.debug("Unhandled message : " + message); + } + + private void memberRemoved(ClusterEvent.MemberRemoved message) { + memberNameToAddress.remove(message.member().roles().head()); + } + + private void memberUp(ClusterEvent.MemberUp message) { + String memberName = message.member().roles().head(); + + memberNameToAddress.put(memberName , message.member().address()); + + for(ShardInformation info : localShards.values()){ + String shardName = info.getShardName(); + info.updatePeerAddress(getShardActorName(memberName, shardName), + getShardActorPath(shardName, memberName)); + } + } + + private void updateSchemaContext(Object message) { + for(ShardInformation info : localShards.values()){ + info.getActor().tell(message,getSelf()); + } + } + + private void findPrimary(FindPrimary message) { + String shardName = message.getShardName(); + + List members = + configuration.getMembersFromShardName(shardName); + + // First see if the there is a local replica for the shard + ShardInformation info = localShards.get(shardName); + if(info != null) { + ActorPath shardPath = info.getActorPath(); + if (shardPath != null) { + getSender() + .tell( + new PrimaryFound(shardPath.toString()).toSerializable(), + getSelf()); + return; + } + } + + if(cluster.getCurrentMemberName() != null) { + members.remove(cluster.getCurrentMemberName()); + } + + // There is no way for us to figure out the primary (for now) so assume + // that one of the remote nodes is a primary + for(String memberName : members) { + Address address = memberNameToAddress.get(memberName); + if(address != null){ + String path = + getShardActorPath(shardName, memberName); + getSender().tell(new PrimaryFound(path).toSerializable(), getSelf()); + return; + } + } + getSender().tell(new PrimaryNotFound(shardName).toSerializable(), getSelf()); + } + + private String + + + getShardActorPath(String shardName, String memberName) { + Address address = memberNameToAddress.get(memberName); + if(address != null) { + return address.toString() + "/user/shardmanager-" + this.type + "/" + + getShardActorName( + memberName, shardName); + } + return null; + } + + private String getShardActorName(String memberName, String shardName){ + return memberName + "-shard-" + shardName + "-" + this.type; } - } + // Create the shards that are local to this member + private void createLocalShards() { + String memberName = this.cluster.getCurrentMemberName(); + List memberShardNames = + this.configuration.getMemberShardNames(memberName); + for(String shardName : memberShardNames){ + String shardActorName = getShardActorName(memberName, shardName); + Map peerAddresses = getPeerAddresses(shardName); + ActorRef actor = getContext() + .actorOf(Shard.props(shardActorName, peerAddresses), + shardActorName); + localShards.put(shardName, new ShardInformation(shardName, actor, peerAddresses)); + } + + } + + private Map getPeerAddresses(String shardName){ + + Map peerAddresses = new HashMap<>(); + + List members = + this.configuration.getMembersFromShardName(shardName); + + String currentMemberName = this.cluster.getCurrentMemberName(); + + for(String memberName : members){ + if(!currentMemberName.equals(memberName)){ + String shardActorName = getShardActorName(memberName, shardName); + String path = + getShardActorPath(shardName, currentMemberName); + peerAddresses.put(shardActorName, path); + } + } + return peerAddresses; + } + + + @Override + public SupervisorStrategy supervisorStrategy() { + return new OneForOneStrategy(10, Duration.create("1 minute"), + new Function() { + @Override + public SupervisorStrategy.Directive apply(Throwable t) { + return SupervisorStrategy.resume(); + } + } + ); + + } + + private class ShardInformation { + private final String shardName; + private final ActorRef actor; + private final ActorPath actorPath; + private final Map peerAddresses; + + private ShardInformation(String shardName, ActorRef actor, + Map peerAddresses) { + this.shardName = shardName; + this.actor = actor; + this.actorPath = actor.path(); + this.peerAddresses = peerAddresses; + } + + public String getShardName() { + return shardName; + } + + public ActorRef getActor(){ + return actor; + } + + public ActorPath getActorPath() { + return actorPath; + } + + public Map getPeerAddresses() { + return peerAddresses; + } + + public void updatePeerAddress(String peerId, String peerAddress){ + LOG.info("updatePeerAddress for peer {} with address {}", peerId, peerAddress); + if(peerAddresses.containsKey(peerId)){ + peerAddresses.put(peerId, peerAddress); + + LOG.info("Sending PeerAddressResolved for peer {} with address {} to {}", peerId, peerAddress, actor.path()); + + actor + .tell(new PeerAddressResolved(peerId, peerAddress), + 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 e3d1e2d9d4..737f57bf5d 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 @@ -37,8 +37,9 @@ import org.opendaylight.controller.cluster.datastore.modification.WriteModificat 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.yangtools.yang.data.api.InstanceIdentifier; +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 java.util.concurrent.ExecutionException; @@ -67,6 +68,7 @@ import java.util.concurrent.ExecutionException; 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 @@ -82,37 +84,38 @@ public class ShardTransaction extends AbstractUntypedActor { Logging.getLogger(getContext().system(), this); public ShardTransaction(DOMStoreReadWriteTransaction transaction, - ActorRef shardActor) { - this(null, transaction, shardActor); + ActorRef shardActor, SchemaContext schemaContext) { + this(null, transaction, shardActor, schemaContext); } public ShardTransaction(DOMStoreTransactionChain transactionChain, DOMStoreReadWriteTransaction transaction, - ActorRef shardActor) { + 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 ActorRef shardActor, final SchemaContext schemaContext) { return Props.create(new Creator() { @Override public ShardTransaction create() throws Exception { - return new ShardTransaction(transaction, shardActor); + return new ShardTransaction(transaction, shardActor, schemaContext); } }); } public static Props props(final DOMStoreTransactionChain transactionChain, final DOMStoreReadWriteTransaction transaction, - final ActorRef shardActor) { + final ActorRef shardActor, final SchemaContext schemaContext) { return Props.create(new Creator() { @Override public ShardTransaction create() throws Exception { - return new ShardTransaction(transactionChain, transaction, shardActor); + return new ShardTransaction(transactionChain, transaction, shardActor, schemaContext); } }); } @@ -120,29 +123,31 @@ public class ShardTransaction extends AbstractUntypedActor { @Override public void handleReceive(Object message) throws Exception { - if (message instanceof ReadData) { - readData((ReadData) message); - } else if (message instanceof WriteData) { - writeData((WriteData) message); - } else if (message instanceof MergeData) { - mergeData((MergeData) message); - } else if (message instanceof DeleteData) { - deleteData((DeleteData) message); - } else if (message instanceof ReadyTransaction) { - readyTransaction((ReadyTransaction) message); - } else if (message instanceof CloseTransaction) { - closeTransaction((CloseTransaction) message); + 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); } } private void readData(ReadData message) { final ActorRef sender = getSender(); final ActorRef self = getSelf(); - final InstanceIdentifier path = message.getPath(); + final YangInstanceIdentifier path = message.getPath(); final ListenableFuture>> future = transaction.read(path); @@ -152,9 +157,9 @@ public class ShardTransaction extends AbstractUntypedActor { try { Optional> optional = future.get(); if (optional.isPresent()) { - sender.tell(new ReadDataReply(optional.get()), self); + sender.tell(new ReadDataReply(schemaContext,optional.get()).toSerializable(), self); } else { - sender.tell(new ReadDataReply(null), self); + sender.tell(new ReadDataReply(schemaContext,null).toSerializable(), self); } } catch (InterruptedException | ExecutionException e) { log.error(e, @@ -169,22 +174,24 @@ public class ShardTransaction extends AbstractUntypedActor { private void writeData(WriteData message) { modification.addModification( - new WriteModification(message.getPath(), message.getData())); + 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(), getSelf()); + getSender().tell(new WriteDataReply().toSerializable(), getSelf()); } private void mergeData(MergeData message) { modification.addModification( - new MergeModification(message.getPath(), message.getData())); + 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(), getSelf()); + 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(), getSelf()); + getSender().tell(new DeleteDataReply().toSerializable(), getSelf()); } private void readyTransaction(ReadyTransaction message) { @@ -192,13 +199,13 @@ public class ShardTransaction extends AbstractUntypedActor { ActorRef cohortActor = getContext().actorOf( ThreePhaseCommitCohort.props(cohort, shardActor, modification), "cohort"); getSender() - .tell(new ReadyTransactionReply(cohortActor.path()), getSelf()); + .tell(new ReadyTransactionReply(cohortActor.path()).toSerializable(), getSelf()); } private void closeTransaction(CloseTransaction message) { transaction.close(); - getSender().tell(new CloseTransactionReply(), getSelf()); + 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/ShardTransactionChain.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionChain.java index 1092e9a793..50042411b1 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 @@ -17,6 +17,7 @@ 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; /** * The ShardTransactionChain Actor represents a remote TransactionChain @@ -24,19 +25,23 @@ import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain; public class ShardTransactionChain extends AbstractUntypedActor { private final DOMStoreTransactionChain chain; + private final SchemaContext schemaContext; - public ShardTransactionChain(DOMStoreTransactionChain chain) { + public ShardTransactionChain(DOMStoreTransactionChain chain, SchemaContext schemaContext) { this.chain = chain; + this.schemaContext = schemaContext; } @Override public void handleReceive(Object message) throws Exception { - if (message instanceof CreateTransaction) { - CreateTransaction createTransaction = (CreateTransaction) message; + if (message.getClass().equals(CreateTransaction.SERIALIZABLE_CLASS)) { + CreateTransaction createTransaction = CreateTransaction.fromSerializable( message); createTransaction(createTransaction); - } else if (message instanceof CloseTransactionChain) { + } else if (message.getClass().equals(CloseTransactionChain.SERIALIZABLE_CLASS)) { chain.close(); - getSender().tell(new CloseTransactionChainReply(), getSelf()); + getSender().tell(new CloseTransactionChainReply().toSerializable(), getSelf()); + }else{ + throw new Exception("Not recognized message recieved="+message); } } @@ -44,18 +49,18 @@ public class ShardTransactionChain extends AbstractUntypedActor { DOMStoreReadWriteTransaction transaction = chain.newReadWriteTransaction(); ActorRef transactionActor = getContext().actorOf(ShardTransaction - .props(chain, transaction, getContext().parent()), "shard-" + createTransaction.getTransactionId()); + .props(chain, transaction, getContext().parent(), schemaContext), "shard-" + createTransaction.getTransactionId()); getSender() - .tell(new CreateTransactionReply(transactionActor.path(), createTransaction.getTransactionId()), + .tell(new CreateTransactionReply(transactionActor.path().toString(),createTransaction.getTransactionId()).toSerializable(), getSelf()); } - public static Props props(final DOMStoreTransactionChain chain) { + public static Props props(final DOMStoreTransactionChain chain, final SchemaContext schemaContext) { return Props.create(new Creator() { @Override public ShardTransactionChain create() throws Exception { - return new ShardTransactionChain(chain); + return new ShardTransactionChain(chain, schemaContext); } }); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohort.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohort.java index 060c9d6b50..a8deb0153a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohort.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohort.java @@ -58,14 +58,16 @@ public class ThreePhaseCommitCohort extends AbstractUntypedActor { @Override public void handleReceive(Object message) throws Exception { - if (message instanceof CanCommitTransaction) { - canCommit((CanCommitTransaction) message); - } else if (message instanceof PreCommitTransaction) { - preCommit((PreCommitTransaction) message); - } else if (message instanceof CommitTransaction) { - commit((CommitTransaction) message); - } else if (message instanceof AbortTransaction) { - abort((AbortTransaction) message); + if (message.getClass().equals(CanCommitTransaction.SERIALIZABLE_CLASS)) { + canCommit(new CanCommitTransaction()); + } else if (message.getClass().equals(PreCommitTransaction.SERIALIZABLE_CLASS)) { + preCommit(new PreCommitTransaction()); + } else if (message.getClass().equals(CommitTransaction.SERIALIZABLE_CLASS)) { + commit(new CommitTransaction()); + } else if (message.getClass().equals(AbortTransaction.SERIALIZABLE_CLASS)) { + abort(new AbortTransaction()); + } else { + throw new Exception ("Not recognized message received,message="+message); } } @@ -79,7 +81,7 @@ public class ThreePhaseCommitCohort extends AbstractUntypedActor { public void run() { try { future.get(); - sender.tell(new AbortTransactionReply(), self); + sender.tell(new AbortTransactionReply().toSerializable(), self); } catch (InterruptedException | ExecutionException e) { log.error(e, "An exception happened when aborting"); } @@ -107,7 +109,7 @@ public class ThreePhaseCommitCohort extends AbstractUntypedActor { public void run() { try { future.get(); - sender.tell(new PreCommitTransactionReply(), self); + sender.tell(new PreCommitTransactionReply().toSerializable(), self); } catch (InterruptedException | ExecutionException e) { log.error(e, "An exception happened when preCommitting"); } @@ -126,7 +128,7 @@ public class ThreePhaseCommitCohort extends AbstractUntypedActor { public void run() { try { Boolean canCommit = future.get(); - sender.tell(new CanCommitTransactionReply(canCommit), self); + sender.tell(new CanCommitTransactionReply(canCommit).toSerializable(), self); } catch (InterruptedException | ExecutionException e) { log.error(e, "An exception happened when aborting"); } 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 279ecba409..b56dc9432f 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 @@ -67,12 +67,12 @@ public class ThreePhaseCommitCohortProxy implements try { Object response = actorContext.executeRemoteOperation(cohort, - new CanCommitTransaction(), + new CanCommitTransaction().toSerializable(), ActorContext.ASK_DURATION); - if (response instanceof CanCommitTransactionReply) { + if (response.getClass().equals(CanCommitTransactionReply.SERIALIZABLE_CLASS)) { CanCommitTransactionReply reply = - (CanCommitTransactionReply) response; + CanCommitTransactionReply.fromSerializable(response); if (!reply.getCanCommit()) { return false; } @@ -97,15 +97,15 @@ public class ThreePhaseCommitCohortProxy implements } @Override public ListenableFuture preCommit() { - return voidOperation(new PreCommitTransaction(), PreCommitTransactionReply.class); + return voidOperation(new PreCommitTransaction().toSerializable(), PreCommitTransactionReply.SERIALIZABLE_CLASS); } @Override public ListenableFuture abort() { - return voidOperation(new AbortTransaction(), AbortTransactionReply.class); + return voidOperation(new AbortTransaction().toSerializable(), AbortTransactionReply.SERIALIZABLE_CLASS); } @Override public ListenableFuture commit() { - return voidOperation(new CommitTransaction(), CommitTransactionReply.class); + return voidOperation(new CommitTransaction().toSerializable(), CommitTransactionReply.SERIALIZABLE_CLASS); } private ListenableFuture voidOperation(final Object message, final Class expectedResponseClass){ diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxy.java index 71b61ffaa0..2e8538d077 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxy.java @@ -13,6 +13,7 @@ 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.DOMStoreTransactionChain; import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; import java.util.concurrent.ExecutorService; @@ -22,28 +23,30 @@ import java.util.concurrent.ExecutorService; public class TransactionChainProxy implements DOMStoreTransactionChain{ private final ActorContext actorContext; private final ExecutorService transactionExecutor; + private final SchemaContext schemaContext; - public TransactionChainProxy(ActorContext actorContext, ExecutorService transactionExecutor) { + public TransactionChainProxy(ActorContext actorContext, ExecutorService transactionExecutor, SchemaContext schemaContext) { this.actorContext = actorContext; this.transactionExecutor = transactionExecutor; + this.schemaContext = schemaContext; } @Override public DOMStoreReadTransaction newReadOnlyTransaction() { return new TransactionProxy(actorContext, - TransactionProxy.TransactionType.READ_ONLY, transactionExecutor); + TransactionProxy.TransactionType.READ_ONLY, transactionExecutor, schemaContext); } @Override public DOMStoreReadWriteTransaction newReadWriteTransaction() { return new TransactionProxy(actorContext, - TransactionProxy.TransactionType.WRITE_ONLY, transactionExecutor); + TransactionProxy.TransactionType.WRITE_ONLY, transactionExecutor, schemaContext); } @Override public DOMStoreWriteTransaction newWriteOnlyTransaction() { return new TransactionProxy(actorContext, - TransactionProxy.TransactionType.READ_WRITE, transactionExecutor); + TransactionProxy.TransactionType.READ_WRITE, transactionExecutor, schemaContext); } @Override 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 74245c4259..c85d32012f 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 @@ -9,10 +9,14 @@ package org.opendaylight.controller.cluster.datastore; import akka.actor.ActorPath; +import akka.actor.ActorRef; import akka.actor.ActorSelection; +import akka.actor.Props; import com.google.common.base.Optional; +import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFutureTask; +import org.opendaylight.controller.cluster.datastore.exceptions.TimeoutException; import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction; import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction; import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionReply; @@ -23,11 +27,15 @@ import org.opendaylight.controller.cluster.datastore.messages.ReadDataReply; import org.opendaylight.controller.cluster.datastore.messages.ReadyTransaction; import org.opendaylight.controller.cluster.datastore.messages.ReadyTransactionReply; import org.opendaylight.controller.cluster.datastore.messages.WriteData; +import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategyFactory; import org.opendaylight.controller.cluster.datastore.utils.ActorContext; import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +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 org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.HashMap; @@ -58,92 +66,77 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction { private static final AtomicLong counter = new AtomicLong(); + private static final Logger + LOG = LoggerFactory.getLogger(TransactionProxy.class); + + private final TransactionType transactionType; private final ActorContext actorContext; - private final Map remoteTransactionPaths = new HashMap<>(); + private final Map remoteTransactionPaths = new HashMap<>(); private final String identifier; private final ExecutorService executor; + private final SchemaContext schemaContext; public TransactionProxy( ActorContext actorContext, TransactionType transactionType, - ExecutorService executor - ) { + ExecutorService executor, + SchemaContext schemaContext + ) { - this.identifier = "txn-" + counter.getAndIncrement(); + this.identifier = actorContext.getCurrentMemberName() + "-txn-" + counter.getAndIncrement(); this.transactionType = transactionType; this.actorContext = actorContext; this.executor = executor; + this.schemaContext = schemaContext; + - Object response = actorContext.executeShardOperation(Shard.DEFAULT_NAME, new CreateTransaction(identifier), ActorContext.ASK_DURATION); - if(response instanceof CreateTransactionReply){ - CreateTransactionReply reply = (CreateTransactionReply) response; - remoteTransactionPaths.put(Shard.DEFAULT_NAME, actorContext.actorSelection(reply.getTransactionPath())); - } } @Override - public ListenableFuture>> read(final InstanceIdentifier path) { - final ActorSelection remoteTransaction = remoteTransactionFromIdentifier(path); - - Callable>> call = new Callable() { - - @Override public Optional> call() throws Exception { - Object response = actorContext - .executeRemoteOperation(remoteTransaction, new ReadData(path), - ActorContext.ASK_DURATION); - if(response instanceof ReadDataReply){ - ReadDataReply reply = (ReadDataReply) response; - if(reply.getNormalizedNode() == null){ - return Optional.absent(); - } - //FIXME : A cast should not be required here ??? - return (Optional>) Optional.of(reply.getNormalizedNode()); - } + public ListenableFuture>> read(final YangInstanceIdentifier path) { - return Optional.absent(); - } - }; + createTransactionIfMissing(actorContext, path); - ListenableFutureTask>> - future = ListenableFutureTask.create(call); - - executor.submit(future); - - return future; + return transactionContext(path).readData(path); } @Override - public void write(InstanceIdentifier path, NormalizedNode data) { - final ActorSelection remoteTransaction = remoteTransactionFromIdentifier(path); - remoteTransaction.tell(new WriteData(path, data), null); + public void write(YangInstanceIdentifier path, NormalizedNode data) { + + createTransactionIfMissing(actorContext, path); + + transactionContext(path).writeData(path, data); } @Override - public void merge(InstanceIdentifier path, NormalizedNode data) { - final ActorSelection remoteTransaction = remoteTransactionFromIdentifier(path); - remoteTransaction.tell(new MergeData(path, data), null); + public void merge(YangInstanceIdentifier path, NormalizedNode data) { + + createTransactionIfMissing(actorContext, path); + + transactionContext(path).mergeData(path, data); } @Override - public void delete(InstanceIdentifier path) { - final ActorSelection remoteTransaction = remoteTransactionFromIdentifier(path); - remoteTransaction.tell(new DeleteData(path), null); + public void delete(YangInstanceIdentifier path) { + + createTransactionIfMissing(actorContext, path); + + transactionContext(path).deleteData(path); } @Override public DOMStoreThreePhaseCommitCohort ready() { List cohortPaths = new ArrayList<>(); - for(ActorSelection remoteTransaction : remoteTransactionPaths.values()) { - Object result = actorContext.executeRemoteOperation(remoteTransaction, - new ReadyTransaction(), - ActorContext.ASK_DURATION - ); + for(TransactionContext transactionContext : remoteTransactionPaths.values()) { + Object result = transactionContext.readyTransaction(); - if(result instanceof ReadyTransactionReply){ - ReadyTransactionReply reply = (ReadyTransactionReply) result; - cohortPaths.add(reply.getCohortPath()); + if(result.getClass().equals(ReadyTransactionReply.SERIALIZABLE_CLASS)){ + ReadyTransactionReply reply = ReadyTransactionReply.fromSerializable(actorContext.getActorSystem(),result); + String resolvedCohortPath = transactionContext + .getResolvedCohortPath(reply.getCohortPath().toString()); + cohortPaths.add(actorContext.actorFor(resolvedCohortPath)); } } @@ -157,17 +150,211 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction { @Override public void close() { - for(ActorSelection remoteTransaction : remoteTransactionPaths.values()) { - remoteTransaction.tell(new CloseTransaction(), null); + for(TransactionContext transactionContext : remoteTransactionPaths.values()) { + transactionContext.closeTransaction(); } } - private ActorSelection remoteTransactionFromIdentifier(InstanceIdentifier path){ + private TransactionContext transactionContext(YangInstanceIdentifier path){ String shardName = shardNameFromIdentifier(path); return remoteTransactionPaths.get(shardName); } - private String shardNameFromIdentifier(InstanceIdentifier path){ - return Shard.DEFAULT_NAME; + private String shardNameFromIdentifier(YangInstanceIdentifier path){ + return ShardStrategyFactory.getStrategy(path).findShard(path); + } + + private void createTransactionIfMissing(ActorContext actorContext, YangInstanceIdentifier path) { + String shardName = ShardStrategyFactory.getStrategy(path).findShard(path); + + TransactionContext transactionContext = + remoteTransactionPaths.get(shardName); + + if(transactionContext != null){ + // A transaction already exists with that shard + return; + } + + try { + Object response = actorContext.executeShardOperation(shardName, + new CreateTransaction(identifier).toSerializable(), + ActorContext.ASK_DURATION); + if (response.getClass() + .equals(CreateTransactionReply.SERIALIZABLE_CLASS)) { + CreateTransactionReply reply = + CreateTransactionReply.fromSerializable(response); + + String transactionPath = reply.getTransactionPath(); + + LOG.info("Received transaction path = {}" , transactionPath ); + + ActorSelection transactionActor = + actorContext.actorSelection(transactionPath); + transactionContext = + new TransactionContextImpl(shardName, transactionPath, + transactionActor); + + remoteTransactionPaths.put(shardName, transactionContext); + } + } catch(TimeoutException e){ + remoteTransactionPaths.put(shardName, new NoOpTransactionContext(shardName)); + } + } + + private interface TransactionContext { + String getShardName(); + + String getResolvedCohortPath(String cohortPath); + + public void closeTransaction(); + + public Object readyTransaction(); + + void deleteData(YangInstanceIdentifier path); + + void mergeData(YangInstanceIdentifier path, NormalizedNode data); + + ListenableFuture>> readData(final YangInstanceIdentifier path); + + void writeData(YangInstanceIdentifier path, NormalizedNode data); + } + + + private class TransactionContextImpl implements TransactionContext{ + private final String shardName; + private final String actorPath; + private final ActorSelection actor; + + + private TransactionContextImpl(String shardName, String actorPath, + ActorSelection actor) { + this.shardName = shardName; + this.actorPath = actorPath; + this.actor = actor; + } + + @Override public String getShardName() { + return shardName; + } + + private ActorSelection getActor() { + return actor; + } + + @Override public String getResolvedCohortPath(String cohortPath){ + return actorContext.resolvePath(actorPath, cohortPath); + } + + @Override public void closeTransaction() { + getActor().tell( + new CloseTransaction().toSerializable(), null); + } + + @Override public Object readyTransaction() { + return actorContext.executeRemoteOperation(getActor(), + new ReadyTransaction().toSerializable(), + ActorContext.ASK_DURATION + ); + + } + + @Override public void deleteData(YangInstanceIdentifier path) { + getActor().tell(new DeleteData(path).toSerializable(), null); + } + + @Override public void mergeData(YangInstanceIdentifier path, NormalizedNode data){ + getActor().tell(new MergeData(path, data, schemaContext).toSerializable(), null); + } + + @Override public ListenableFuture>> readData(final YangInstanceIdentifier path) { + + Callable>> call = new Callable() { + + @Override public Optional> call() throws Exception { + Object response = actorContext + .executeRemoteOperation(getActor(), new ReadData(path).toSerializable(), + ActorContext.ASK_DURATION); + if(response.getClass().equals(ReadDataReply.SERIALIZABLE_CLASS)){ + ReadDataReply reply = ReadDataReply.fromSerializable(schemaContext,path, response); + if(reply.getNormalizedNode() == null){ + return Optional.absent(); + } + //FIXME : A cast should not be required here ??? + return (Optional>) Optional.of(reply.getNormalizedNode()); + } + + return Optional.absent(); + } + }; + + ListenableFutureTask>> + future = ListenableFutureTask.create(call); + + executor.submit(future); + + return future; + } + + @Override public void writeData(YangInstanceIdentifier path, NormalizedNode data) { + getActor().tell(new WriteData(path, data, schemaContext).toSerializable(), null); + } + + } + + private class NoOpTransactionContext implements TransactionContext { + + private final Logger + LOG = LoggerFactory.getLogger(NoOpTransactionContext.class); + + private final String shardName; + + private ActorRef cohort; + + public NoOpTransactionContext(String shardName){ + this.shardName = shardName; + } + @Override public String getShardName() { + return shardName; + + } + + @Override public String getResolvedCohortPath(String cohortPath) { + return cohort.path().toString(); + } + + @Override public void closeTransaction() { + LOG.error("closeTransaction called"); + } + + @Override public Object readyTransaction() { + LOG.error("readyTransaction called"); + cohort = actorContext.getActorSystem().actorOf(Props.create(NoOpCohort.class)); + return new ReadyTransactionReply(cohort.path()).toSerializable(); + } + + @Override public void deleteData(YangInstanceIdentifier path) { + LOG.error("deleteData called path = {}", path); + } + + @Override public void mergeData(YangInstanceIdentifier path, + NormalizedNode data) { + LOG.error("mergeData called path = {}", path); + } + + @Override + public ListenableFuture>> readData( + YangInstanceIdentifier path) { + LOG.error("readData called path = {}", path); + return Futures.immediateFuture( + Optional.>absent()); + } + + @Override public void writeData(YangInstanceIdentifier path, + NormalizedNode data) { + LOG.error("writeData called path = {}", path); + } } + + + } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/PrimaryNotFoundException.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/PrimaryNotFoundException.java index 5a131ade33..7b07053fd9 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/PrimaryNotFoundException.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/PrimaryNotFoundException.java @@ -9,4 +9,7 @@ package org.opendaylight.controller.cluster.datastore.exceptions; public class PrimaryNotFoundException extends RuntimeException { + public PrimaryNotFoundException(String message){ + super(message); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/TimeoutException.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/TimeoutException.java index 4780aaccfb..472cd38734 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/TimeoutException.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/TimeoutException.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.cluster.datastore.exceptions; public class TimeoutException extends RuntimeException { - public TimeoutException(Exception e){ - super(e); + public TimeoutException(String message, Exception e){ + super(message, e); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/AbstractBaseMBean.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/AbstractBaseMBean.java new file mode 100644 index 0000000000..de1ac18533 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/AbstractBaseMBean.java @@ -0,0 +1,138 @@ +/* + * 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.jmx.mbeans; + + +import com.google.common.base.Preconditions; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.management.InstanceNotFoundException; +import javax.management.MBeanRegistrationException; +import javax.management.MBeanServer; +import javax.management.MalformedObjectNameException; +import javax.management.ObjectName; +import java.lang.management.ManagementFactory; + +/** + * All MBeans should extend this class that help in registering and + * unregistering the MBeans. + * + */ + + +public abstract class AbstractBaseMBean { + + + public static String BASE_JMX_PREFIX = "org.opendaylight.controller:"; + public static String JMX_TYPE_DISTRIBUTED_DATASTORE = "DistributedDatastore"; + public static String JMX_CATEGORY_SHARD = "Shard"; + + private static final Logger LOG = LoggerFactory + .getLogger(AbstractBaseMBean.class); + + MBeanServer server = ManagementFactory.getPlatformMBeanServer(); + /** + * gets the MBean ObjectName + * + * @return Object name of the MBean + * @throws MalformedObjectNameException - The bean name does not have the right format. + * @throws NullPointerException - The bean name is null + */ + protected ObjectName getMBeanObjectName() + throws MalformedObjectNameException, NullPointerException { + String name = BASE_JMX_PREFIX + "type="+getMBeanType()+",Category="+ + getMBeanCategory() + ",name="+ + getMBeanName(); + + + return new ObjectName(name); + } + + public boolean registerMBean() { + boolean registered = false; + try { + // Object to identify MBean + final ObjectName mbeanName = this.getMBeanObjectName(); + + Preconditions.checkArgument(mbeanName != null, + "Object name of the MBean cannot be null"); + + LOG.debug("Register MBean {}", mbeanName); + + // unregistered if already registered + if (server.isRegistered(mbeanName)) { + + LOG.debug("MBean {} found to be already registered", mbeanName); + + try { + unregisterMBean(mbeanName); + } catch (Exception e) { + + LOG.warn("unregister mbean {} resulted in exception {} ", mbeanName, + e); + } + } + server.registerMBean(this, mbeanName); + + LOG.debug("MBean {} registered successfully", + mbeanName.getCanonicalName()); + registered = true; + } catch (Exception e) { + + LOG.error("registration failed {}", e); + + } + return registered; + } + + + public boolean unregisterMBean() { + boolean unregister = false; + try { + ObjectName mbeanName = this.getMBeanObjectName(); + unregister = true; + unregisterMBean(mbeanName); + } catch (Exception e) { + + LOG.error("Failed when unregistering MBean {}", e); + } + return unregister; + } + + private void unregisterMBean(ObjectName mbeanName) + throws MBeanRegistrationException, InstanceNotFoundException { + + server.unregisterMBean(mbeanName); + + } + + + /** + * @return name of bean + */ + protected abstract String getMBeanName(); + + /** + * @return type of the MBean + */ + protected abstract String getMBeanType(); + + + /** + * @return Category name of teh bean + */ + protected abstract String getMBeanCategory(); + + //require for test cases + public MBeanServer getMBeanServer() { + return server; + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardMBeanFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardMBeanFactory.java new file mode 100644 index 0000000000..a3359086b6 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardMBeanFactory.java @@ -0,0 +1,26 @@ +package org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author: syedbahm + * Date: 7/16/14 + */ +public class ShardMBeanFactory { + private static Map shardMBeans= new HashMap(); + + public static ShardStats getShardStatsMBean(String shardName){ + if(shardMBeans.containsKey(shardName)){ + return shardMBeans.get(shardName); + }else { + ShardStats shardStatsMBeanImpl = new ShardStats(shardName); + + if(shardStatsMBeanImpl.registerMBean()) { + shardMBeans.put(shardName, shardStatsMBeanImpl); + } + return shardStatsMBeanImpl; + } + } + +} 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 new file mode 100644 index 0000000000..2da6aae85f --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardStats.java @@ -0,0 +1,70 @@ +package org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard; + +import org.opendaylight.controller.cluster.datastore.jmx.mbeans.AbstractBaseMBean; + +/** + * @author: syedbahm + */ +public class ShardStats extends AbstractBaseMBean implements ShardStatsMBean { + private Long committedTransactionsCount; + private Long journalMessagesCount; + final private String shardName; + + ShardStats(String shardName){ + this.shardName = shardName; + committedTransactionsCount =0L; + journalMessagesCount = 0L; + }; + + + @Override + public String getShardName() { + return shardName; + } + + @Override + public Long getCommittedTransactionsCount() { + return committedTransactionsCount; + } + + @Override + public Long getJournalMessagesCount() { + //FIXME: this will be populated once after integration with Raft stuff + return journalMessagesCount; + } + + + public Long incrementCommittedTransactionCount() { + return committedTransactionsCount++; + } + + + public void updateCommittedTransactionsCount(long currentCount){ + committedTransactionsCount = currentCount; + + } + + public void updateJournalMessagesCount(long currentCount){ + journalMessagesCount = currentCount; + + } + + + + @Override + protected String getMBeanName() { + return shardName; + } + + @Override + protected String getMBeanType() { + return JMX_TYPE_DISTRIBUTED_DATASTORE; + } + + @Override + protected String getMBeanCategory() { + return JMX_CATEGORY_SHARD; + } + + +} 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 new file mode 100644 index 0000000000..c107e49e85 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardStatsMBean.java @@ -0,0 +1,11 @@ +package org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard; + +/** + * @author: syedbahm + */ +public interface ShardStatsMBean { + String getShardName(); + Long getCommittedTransactionsCount(); + Long getJournalMessagesCount(); + +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/AbortTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/AbortTransaction.java index 4cf713a0b3..4515bd7042 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/AbortTransaction.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/AbortTransaction.java @@ -8,5 +8,13 @@ package org.opendaylight.controller.cluster.datastore.messages; -public class AbortTransaction { +import org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages; + +public class AbortTransaction implements SerializableMessage { + public static Class SERIALIZABLE_CLASS = ThreePhaseCommitCohortMessages.AbortTransaction.class; + + @Override + public Object toSerializable() { + return ThreePhaseCommitCohortMessages.AbortTransaction.newBuilder().build(); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/AbortTransactionReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/AbortTransactionReply.java index 84234e5807..31a06fe4c5 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/AbortTransactionReply.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/AbortTransactionReply.java @@ -8,5 +8,14 @@ package org.opendaylight.controller.cluster.datastore.messages; -public class AbortTransactionReply { +import org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages; + +public class AbortTransactionReply implements SerializableMessage { + public static Class SERIALIZABLE_CLASS = ThreePhaseCommitCohortMessages.AbortTransactionReply.class; + + + @Override + public Object toSerializable() { + return ThreePhaseCommitCohortMessages.AbortTransactionReply.newBuilder().build(); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CanCommitTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CanCommitTransaction.java index 526d60fc75..2c032aff65 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CanCommitTransaction.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CanCommitTransaction.java @@ -8,5 +8,13 @@ package org.opendaylight.controller.cluster.datastore.messages; -public class CanCommitTransaction { +import org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages; + +public class CanCommitTransaction implements SerializableMessage { + public static Class SERIALIZABLE_CLASS = ThreePhaseCommitCohortMessages.CanCommitTransaction.class; + + @Override + public Object toSerializable() { + return ThreePhaseCommitCohortMessages.CanCommitTransaction.newBuilder().build(); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CanCommitTransactionReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CanCommitTransactionReply.java index d143c14b3b..bbcd4de03f 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CanCommitTransactionReply.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CanCommitTransactionReply.java @@ -8,7 +8,10 @@ package org.opendaylight.controller.cluster.datastore.messages; -public class CanCommitTransactionReply { +import org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages; + +public class CanCommitTransactionReply implements SerializableMessage { + public static Class SERIALIZABLE_CLASS = ThreePhaseCommitCohortMessages.CanCommitTransactionReply.class; private final Boolean canCommit; public CanCommitTransactionReply(Boolean canCommit) { @@ -18,4 +21,14 @@ public class CanCommitTransactionReply { public Boolean getCanCommit() { return canCommit; } + + @Override + public Object toSerializable() { + return ThreePhaseCommitCohortMessages.CanCommitTransactionReply.newBuilder().setCanCommit(canCommit).build(); + } + + + public static CanCommitTransactionReply fromSerializable(Object message) { + return new CanCommitTransactionReply(((ThreePhaseCommitCohortMessages.CanCommitTransactionReply)message).getCanCommit()); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseDataChangeListenerRegistration.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseDataChangeListenerRegistration.java index c3cb00c25f..57237bcbe2 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseDataChangeListenerRegistration.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseDataChangeListenerRegistration.java @@ -8,5 +8,12 @@ package org.opendaylight.controller.cluster.datastore.messages; -public class CloseDataChangeListenerRegistration { +import org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages; + +public class CloseDataChangeListenerRegistration implements SerializableMessage { + public static Class SERIALIZABLE_CLASS = ListenerRegistrationMessages.CloseDataChangeListenerRegistration.class; + @Override + public Object toSerializable() { + return ListenerRegistrationMessages.CloseDataChangeListenerRegistration.newBuilder().build(); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseDataChangeListenerRegistrationReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseDataChangeListenerRegistrationReply.java index d5c75eb68a..faf73c87eb 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseDataChangeListenerRegistrationReply.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseDataChangeListenerRegistrationReply.java @@ -8,5 +8,14 @@ package org.opendaylight.controller.cluster.datastore.messages; -public class CloseDataChangeListenerRegistrationReply { +import org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages; + +public class CloseDataChangeListenerRegistrationReply implements SerializableMessage{ + public static Class SERIALIZABLE_CLASS = ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply.class; + + @Override + public Object toSerializable() { + return ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply.newBuilder().build(); + } + } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransaction.java index 6809f4b135..451e39cf6a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransaction.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransaction.java @@ -8,5 +8,12 @@ package org.opendaylight.controller.cluster.datastore.messages; -public class CloseTransaction { +import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages; + +public class CloseTransaction implements SerializableMessage{ + public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.CloseTransaction.class; + @Override + public Object toSerializable() { + return ShardTransactionMessages.CloseTransaction.newBuilder().build(); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransactionChain.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransactionChain.java index 04c422b68e..efa51fde20 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransactionChain.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransactionChain.java @@ -8,5 +8,12 @@ package org.opendaylight.controller.cluster.datastore.messages; -public class CloseTransactionChain { +import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages; + +public class CloseTransactionChain implements SerializableMessage{ + public static final Class SERIALIZABLE_CLASS = ShardTransactionChainMessages.CloseTransactionChain.class; + @Override + public Object toSerializable() { + return ShardTransactionChainMessages.CloseTransactionChain.newBuilder().build(); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransactionChainReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransactionChainReply.java index 89fa93bf9a..23699b7be6 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransactionChainReply.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransactionChainReply.java @@ -8,5 +8,13 @@ package org.opendaylight.controller.cluster.datastore.messages; -public class CloseTransactionChainReply { +import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages; + +public class CloseTransactionChainReply implements SerializableMessage { + public static final Class SERIALIZABLE_CLASS = ShardTransactionChainMessages.CloseTransactionChainReply.class; + @Override + public Object toSerializable() { + return ShardTransactionChainMessages.CloseTransactionChainReply.newBuilder().build(); + } + } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransactionReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransactionReply.java index 4910a3ea0e..666d182aaf 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransactionReply.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransactionReply.java @@ -8,5 +8,12 @@ package org.opendaylight.controller.cluster.datastore.messages; -public class CloseTransactionReply { +import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages; + +public class CloseTransactionReply implements SerializableMessage { + public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.CloseTransactionReply.class; + @Override + public Object toSerializable() { + return ShardTransactionMessages.CloseTransactionReply.newBuilder().build(); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CommitTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CommitTransaction.java index d7b210fd03..14187139aa 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CommitTransaction.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CommitTransaction.java @@ -8,5 +8,13 @@ package org.opendaylight.controller.cluster.datastore.messages; -public class CommitTransaction { +import org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages; + +public class CommitTransaction implements SerializableMessage { + public static Class SERIALIZABLE_CLASS = ThreePhaseCommitCohortMessages.CommitTransaction.class; + + @Override + public Object toSerializable() { + return ThreePhaseCommitCohortMessages.CommitTransaction.newBuilder().build(); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CommitTransactionReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CommitTransactionReply.java index a0e5e895d2..afeba29879 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CommitTransactionReply.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CommitTransactionReply.java @@ -8,5 +8,14 @@ package org.opendaylight.controller.cluster.datastore.messages; -public class CommitTransactionReply { +import org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages; + +public class CommitTransactionReply implements SerializableMessage { + + public static Class SERIALIZABLE_CLASS = ThreePhaseCommitCohortMessages.CommitTransactionReply.class; + + @Override + public Object toSerializable() { + return ThreePhaseCommitCohortMessages.CommitTransactionReply.newBuilder().build(); + } } 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 6110641696..795131fdbf 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 @@ -8,15 +8,30 @@ package org.opendaylight.controller.cluster.datastore.messages; -public class CreateTransaction { - private final String transactionId; - public CreateTransaction(String transactionId){ +import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages; - this.transactionId = transactionId; - } - public String getTransactionId() { - return transactionId; - } +public class CreateTransaction implements SerializableMessage { + public static Class SERIALIZABLE_CLASS = ShardTransactionMessages.CreateTransaction.class; + private final String transactionId; + + public CreateTransaction(String transactionId){ + + this.transactionId = transactionId; + } + + public String getTransactionId() { + return transactionId; + } + + @Override + public Object toSerializable() { + return ShardTransactionMessages.CreateTransaction.newBuilder().setTransactionId(transactionId).build(); + } + + public static CreateTransaction fromSerializable(Object message){ + return new CreateTransaction(((ShardTransactionMessages.CreateTransaction)message).getTransactionId()); + } + } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransactionChain.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransactionChain.java index cdad3324ab..6339749f7b 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransactionChain.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransactionChain.java @@ -8,6 +8,13 @@ package org.opendaylight.controller.cluster.datastore.messages; -public class CreateTransactionChain { +import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages; +public class CreateTransactionChain implements SerializableMessage{ + public static Class SERIALIZABLE_CLASS = ShardTransactionChainMessages.CreateTransactionChain.class; + + @Override + public Object toSerializable() { + return ShardTransactionChainMessages.CreateTransactionChain.newBuilder().build(); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransactionChainReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransactionChainReply.java index 49dd9b63d2..4a497622fc 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransactionChainReply.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransactionChainReply.java @@ -9,8 +9,11 @@ package org.opendaylight.controller.cluster.datastore.messages; import akka.actor.ActorPath; +import akka.actor.ActorSystem; +import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages; -public class CreateTransactionChainReply { +public class CreateTransactionChainReply implements SerializableMessage { + public static final Class SERIALIZABLE_CLASS = ShardTransactionChainMessages.CreateTransactionChainReply.class; private final ActorPath transactionChainPath; public CreateTransactionChainReply(ActorPath transactionChainPath) { @@ -20,4 +23,17 @@ public class CreateTransactionChainReply { public ActorPath getTransactionChainPath() { return transactionChainPath; } + + @Override + public ShardTransactionChainMessages.CreateTransactionChainReply toSerializable() { + return ShardTransactionChainMessages.CreateTransactionChainReply.newBuilder() + .setTransactionChainPath(transactionChainPath.toString()).build(); + } + + public static CreateTransactionChainReply fromSerializable(ActorSystem actorSystem,Object serializable){ + ShardTransactionChainMessages.CreateTransactionChainReply o = (ShardTransactionChainMessages.CreateTransactionChainReply) serializable; + return new CreateTransactionChainReply( + actorSystem.actorFor(o.getTransactionChainPath()).path()); + } + } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransactionReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransactionReply.java index 46b7194c84..096d131d5a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransactionReply.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransactionReply.java @@ -8,23 +8,38 @@ package org.opendaylight.controller.cluster.datastore.messages; -import akka.actor.ActorPath; +import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages; -public class CreateTransactionReply { - private final ActorPath transactionPath; +public class CreateTransactionReply implements SerializableMessage { + + public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.CreateTransactionReply.class; + private final String transactionPath; private final String transactionId; - public CreateTransactionReply(ActorPath transactionPath, + public CreateTransactionReply(String transactionPath, String transactionId) { this.transactionPath = transactionPath; this.transactionId = transactionId; } - public ActorPath getTransactionPath() { + public String getTransactionPath() { return transactionPath; } public String getTransactionId() { return transactionId; } + + public Object toSerializable(){ + return ShardTransactionMessages.CreateTransactionReply.newBuilder() + .setTransactionActorPath(transactionPath) + .setTransactionId(transactionId) + .build(); + } + + public static CreateTransactionReply fromSerializable(Object serializable){ + ShardTransactionMessages.CreateTransactionReply o = (ShardTransactionMessages.CreateTransactionReply) serializable; + return new CreateTransactionReply(o.getTransactionActorPath(), o.getTransactionId()); + } + } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataChanged.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataChanged.java index c55dae56dd..a8827bebf4 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataChanged.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataChanged.java @@ -8,20 +8,256 @@ package org.opendaylight.controller.cluster.datastore.messages; +import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec; +import org.opendaylight.controller.cluster.datastore.utils.InstanceIdentifierUtils; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages; +import org.opendaylight.controller.protobuff.messages.datachange.notification.DataChangeListenerMessages; +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; -public class DataChanged { - private final AsyncDataChangeEvent> +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class DataChanged implements SerializableMessage { + public static final Class SERIALIZABLE_CLASS = + DataChangeListenerMessages.DataChanged.class; + final private SchemaContext schemaContext; + private final AsyncDataChangeEvent> change; - public DataChanged( - AsyncDataChangeEvent> change) { + + + public DataChanged(SchemaContext schemaContext, + AsyncDataChangeEvent> change) { this.change = change; + this.schemaContext = schemaContext; } - public AsyncDataChangeEvent> getChange() { + + public AsyncDataChangeEvent> getChange() { return change; } + + + private NormalizedNodeMessages.Node convertToNodeTree( + NormalizedNode normalizedNode) { + + return new NormalizedNodeToNodeCodec(schemaContext) + .encode(YangInstanceIdentifier.builder().build(), normalizedNode) + .getNormalizedNode(); + + } + + private Iterable convertToRemovePaths( + Set removedPaths) { + final Set removedPathInstanceIds = new HashSet<>(); + for (YangInstanceIdentifier id : removedPaths) { + removedPathInstanceIds.add(InstanceIdentifierUtils.toSerializable(id)); + } + return new Iterable() { + public Iterator iterator() { + return removedPathInstanceIds.iterator(); + } + }; + + } + + private NormalizedNodeMessages.NodeMap convertToNodeMap( + Map> data) { + NormalizedNodeToNodeCodec normalizedNodeToNodeCodec = + new NormalizedNodeToNodeCodec(schemaContext); + NormalizedNodeMessages.NodeMap.Builder nodeMapBuilder = + NormalizedNodeMessages.NodeMap.newBuilder(); + NormalizedNodeMessages.NodeMapEntry.Builder builder = + NormalizedNodeMessages.NodeMapEntry.newBuilder(); + for (Map.Entry> entry : data + .entrySet()) { + + + NormalizedNodeMessages.InstanceIdentifier instanceIdentifier = + InstanceIdentifierUtils.toSerializable(entry.getKey()); + + builder.setInstanceIdentifierPath(instanceIdentifier) + .setNormalizedNode(normalizedNodeToNodeCodec + .encode(entry.getKey(), entry.getValue()) + .getNormalizedNode()); + nodeMapBuilder.addMapEntries(builder.build()); + } + return nodeMapBuilder.build(); + } + + + @Override + public Object toSerializable() { + return DataChangeListenerMessages.DataChanged.newBuilder() + .addAllRemovedPaths(convertToRemovePaths(change.getRemovedPaths())) + .setCreatedData(convertToNodeMap(change.getCreatedData())) + .setOriginalData(convertToNodeMap(change.getOriginalData())) + .setUpdatedData(convertToNodeMap(change.getUpdatedData())) + .setOriginalSubTree(convertToNodeTree(change.getOriginalSubtree())) + .setUpdatedSubTree(convertToNodeTree(change.getUpdatedSubtree())) + .build(); + } + + public static DataChanged fromSerialize(SchemaContext sc, Object message, + YangInstanceIdentifier pathId) { + DataChangeListenerMessages.DataChanged dataChanged = + (DataChangeListenerMessages.DataChanged) message; + DataChangedEvent event = new DataChangedEvent(sc); + if (dataChanged.getCreatedData() != null && dataChanged.getCreatedData() + .isInitialized()) { + event.setCreatedData(dataChanged.getCreatedData()); + } + if (dataChanged.getOriginalData() != null && dataChanged + .getOriginalData().isInitialized()) { + event.setOriginalData(dataChanged.getOriginalData()); + } + + if (dataChanged.getUpdatedData() != null && dataChanged.getUpdatedData() + .isInitialized()) { + event.setUpdateData(dataChanged.getUpdatedData()); + } + + if (dataChanged.getOriginalSubTree() != null && dataChanged + .getOriginalSubTree().isInitialized()) { + event.setOriginalSubtree(dataChanged.getOriginalSubTree(), pathId); + } + + if (dataChanged.getUpdatedSubTree() != null && dataChanged + .getUpdatedSubTree().isInitialized()) { + event.setUpdatedSubtree(dataChanged.getOriginalSubTree(), pathId); + } + + if (dataChanged.getRemovedPathsList() != null && !dataChanged + .getRemovedPathsList().isEmpty()) { + event.setRemovedPaths(dataChanged.getRemovedPathsList()); + } + + return new DataChanged(sc, event); + + } + + static class DataChangedEvent implements + AsyncDataChangeEvent> { + private final SchemaContext schemaContext; + private Map> createdData; + private final NormalizedNodeToNodeCodec nodeCodec; + private Map> updatedData; + private Map> originalData; + private NormalizedNode originalSubTree; + private NormalizedNode updatedSubTree; + private Set removedPathIds; + + DataChangedEvent(SchemaContext schemaContext) { + this.schemaContext = schemaContext; + nodeCodec = new NormalizedNodeToNodeCodec(schemaContext); + } + + @Override + public Map> getCreatedData() { + if(createdData == null){ + return Collections.emptyMap(); + } + return createdData; + } + + DataChangedEvent setCreatedData( + NormalizedNodeMessages.NodeMap nodeMap) { + this.createdData = convertNodeMapToMap(nodeMap); + return this; + } + + private Map> convertNodeMapToMap( + NormalizedNodeMessages.NodeMap nodeMap) { + Map> mapEntries = + new HashMap>(); + for (NormalizedNodeMessages.NodeMapEntry nodeMapEntry : nodeMap + .getMapEntriesList()) { + YangInstanceIdentifier id = InstanceIdentifierUtils + .fromSerializable(nodeMapEntry.getInstanceIdentifierPath()); + mapEntries.put(id, + nodeCodec.decode(id, nodeMapEntry.getNormalizedNode())); + } + return mapEntries; + } + + + @Override + public Map> getUpdatedData() { + if(updatedData == null){ + return Collections.emptyMap(); + } + return updatedData; + } + + DataChangedEvent setUpdateData(NormalizedNodeMessages.NodeMap nodeMap) { + this.updatedData = convertNodeMapToMap(nodeMap); + return this; + } + + @Override + public Set getRemovedPaths() { + if (removedPathIds == null) { + return Collections.emptySet(); + } + return removedPathIds; + } + + public DataChangedEvent setRemovedPaths(List removedPaths) { + Set removedIds = new HashSet<>(); + for (NormalizedNodeMessages.InstanceIdentifier path : removedPaths) { + removedIds.add(InstanceIdentifierUtils.fromSerializable(path)); + } + this.removedPathIds = removedIds; + return this; + } + + @Override + public Map> getOriginalData() { + if (originalData == null) { + Collections.emptyMap(); + } + return originalData; + } + + DataChangedEvent setOriginalData( + NormalizedNodeMessages.NodeMap nodeMap) { + this.originalData = convertNodeMapToMap(nodeMap); + return this; + } + + @Override + public NormalizedNode getOriginalSubtree() { + return originalSubTree; + } + + DataChangedEvent setOriginalSubtree(NormalizedNodeMessages.Node node, + YangInstanceIdentifier instanceIdentifierPath) { + originalSubTree = nodeCodec.decode(instanceIdentifierPath, node); + return this; + } + + @Override + public NormalizedNode getUpdatedSubtree() { + return updatedSubTree; + } + + DataChangedEvent setUpdatedSubtree(NormalizedNodeMessages.Node node, + YangInstanceIdentifier instanceIdentifierPath) { + updatedSubTree = nodeCodec.decode(instanceIdentifierPath, node); + return this; + } + + + } + + + } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataChangedReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataChangedReply.java index 3531021b94..cffe985d18 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataChangedReply.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataChangedReply.java @@ -8,5 +8,12 @@ package org.opendaylight.controller.cluster.datastore.messages; -public class DataChangedReply { +import org.opendaylight.controller.protobuff.messages.datachange.notification.DataChangeListenerMessages; + +public class DataChangedReply implements SerializableMessage { + public static final Class SERIALIZABLE_CLASS = DataChangeListenerMessages.DataChangedReply.class; + @Override + public Object toSerializable() { + return DataChangeListenerMessages.DataChangedReply.newBuilder().build(); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DeleteData.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DeleteData.java index 384e75ae7e..17861a5a68 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DeleteData.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DeleteData.java @@ -8,16 +8,31 @@ package org.opendaylight.controller.cluster.datastore.messages; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.controller.cluster.datastore.utils.InstanceIdentifierUtils; +import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -public class DeleteData { - private final InstanceIdentifier path; +public class DeleteData implements SerializableMessage { - public DeleteData(InstanceIdentifier path) { - this.path = path; - } + public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.DeleteData.class; - public InstanceIdentifier getPath() { - return path; - } + private final YangInstanceIdentifier path; + + public DeleteData(YangInstanceIdentifier path) { + this.path = path; + } + + public YangInstanceIdentifier getPath() { + return path; + } + + @Override public Object toSerializable() { + return ShardTransactionMessages.DeleteData.newBuilder() + .setInstanceIdentifierPathArguments(InstanceIdentifierUtils.toSerializable(path)).build(); + } + + public static DeleteData fromSerizalizable(Object serializable){ + ShardTransactionMessages.DeleteData o = (ShardTransactionMessages.DeleteData) serializable; + return new DeleteData(InstanceIdentifierUtils.fromSerializable(o.getInstanceIdentifierPathArguments())); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DeleteDataReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DeleteDataReply.java index a3c7305685..8e2a7b7295 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DeleteDataReply.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DeleteDataReply.java @@ -8,5 +8,12 @@ package org.opendaylight.controller.cluster.datastore.messages; -public class DeleteDataReply { +import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages; + +public class DeleteDataReply implements SerializableMessage{ + public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.DeleteDataReply.class; + @Override + public Object toSerializable() { + return ShardTransactionMessages.DeleteDataReply.newBuilder().build(); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/FindPrimary.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/FindPrimary.java index f2497e6517..f584467ee9 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/FindPrimary.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/FindPrimary.java @@ -9,13 +9,14 @@ package org.opendaylight.controller.cluster.datastore.messages; import com.google.common.base.Preconditions; +import org.opendaylight.controller.protobuff.messages.shard.ShardManagerMessages; /** * The FindPrimary message is used to locate the primary of any given shard * - * TODO : Make this serializable */ -public class FindPrimary{ +public class FindPrimary implements SerializableMessage{ + public static final Class SERIALIZABLE_CLASS = ShardManagerMessages.FindPrimary.class; private final String shardName; public FindPrimary(String shardName){ @@ -28,4 +29,13 @@ public class FindPrimary{ public String getShardName() { return shardName; } + + @Override + public Object toSerializable() { + return ShardManagerMessages.FindPrimary.newBuilder().setShardName(shardName).build(); + } + + public static FindPrimary fromSerializable(Object message){ + return new FindPrimary(((ShardManagerMessages.FindPrimary)message).getShardName()); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/MergeData.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/MergeData.java index 75d1e95c1e..ba790816c4 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/MergeData.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/MergeData.java @@ -8,11 +8,41 @@ package org.opendaylight.controller.cluster.datastore.messages; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec; +import org.opendaylight.controller.cluster.datastore.utils.InstanceIdentifierUtils; +import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages; +import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages; +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; -public class MergeData extends ModifyData { - public MergeData(InstanceIdentifier path, NormalizedNode data) { - super(path, data); - } +public class MergeData extends ModifyData{ + + public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.MergeData.class; + + public MergeData(YangInstanceIdentifier path, NormalizedNode data, + SchemaContext context) { + super(path, data, context); + } + + @Override public Object toSerializable() { + + NormalizedNodeMessages.Node normalizedNode = + new NormalizedNodeToNodeCodec(schemaContext).encode(path, data) + .getNormalizedNode(); + return ShardTransactionMessages.MergeData.newBuilder() + .setInstanceIdentifierPathArguments(InstanceIdentifierUtils.toSerializable(path)) + .setNormalizedNode(normalizedNode).build(); + } + + public static MergeData fromSerializable(Object serializable, SchemaContext schemaContext){ + ShardTransactionMessages.MergeData o = (ShardTransactionMessages.MergeData) serializable; + YangInstanceIdentifier identifier = InstanceIdentifierUtils.fromSerializable(o.getInstanceIdentifierPathArguments()); + + NormalizedNode normalizedNode = + new NormalizedNodeToNodeCodec(schemaContext) + .decode(identifier, o.getNormalizedNode()); + + return new MergeData(identifier, normalizedNode, schemaContext); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/MergeDataReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/MergeDataReply.java index 8e90972f87..81b1c3bbb1 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/MergeDataReply.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/MergeDataReply.java @@ -8,5 +8,13 @@ package org.opendaylight.controller.cluster.datastore.messages; -public class MergeDataReply { +import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages; + +public class MergeDataReply implements SerializableMessage{ + public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.MergeDataReply.class; + + @Override + public Object toSerializable() { + return ShardTransactionMessages.MergeDataReply.newBuilder().build(); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ModifyData.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ModifyData.java index da8608876e..b5c39d1c3f 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ModifyData.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ModifyData.java @@ -8,24 +8,33 @@ package org.opendaylight.controller.cluster.datastore.messages; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import com.google.common.base.Preconditions; +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; -public abstract class ModifyData { - private final InstanceIdentifier path; - private final NormalizedNode data; +public abstract class ModifyData implements SerializableMessage { + protected final YangInstanceIdentifier path; + protected final NormalizedNode data; + protected final SchemaContext schemaContext; - public ModifyData(InstanceIdentifier path, NormalizedNode data) { - this.path = path; - this.data = data; - } + public ModifyData(YangInstanceIdentifier path, NormalizedNode data, + SchemaContext context) { + Preconditions.checkNotNull(context, + "Cannot serialize an object which does not have a schema schemaContext"); - public InstanceIdentifier getPath() { - return path; - } - public NormalizedNode getData() { - return data; - } + this.path = path; + this.data = data; + this.schemaContext = context; + } + + public YangInstanceIdentifier getPath() { + return path; + } + + public NormalizedNode getData() { + return data; + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PeerAddressResolved.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PeerAddressResolved.java new file mode 100644 index 0000000000..8c2543e486 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PeerAddressResolved.java @@ -0,0 +1,27 @@ +/* + * 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.messages; + +public class PeerAddressResolved { + private final String peerId; + private final String peerAddress; + + public PeerAddressResolved(String peerId, String peerAddress) { + this.peerId = peerId; + this.peerAddress = peerAddress; + } + + public String getPeerId() { + return peerId; + } + + public String getPeerAddress() { + return peerAddress; + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PreCommitTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PreCommitTransaction.java index 87a9c77a4f..1e5a05329b 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PreCommitTransaction.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PreCommitTransaction.java @@ -8,5 +8,14 @@ package org.opendaylight.controller.cluster.datastore.messages; -public class PreCommitTransaction { +import org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages; + +public class PreCommitTransaction implements SerializableMessage{ + + public static Class SERIALIZABLE_CLASS = ThreePhaseCommitCohortMessages.PreCommitTransaction.class; + + @Override + public Object toSerializable() { + return ThreePhaseCommitCohortMessages.PreCommitTransaction.newBuilder().build(); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PreCommitTransactionReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PreCommitTransactionReply.java index f499c720d2..1aedae3ae7 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PreCommitTransactionReply.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PreCommitTransactionReply.java @@ -8,5 +8,14 @@ package org.opendaylight.controller.cluster.datastore.messages; -public class PreCommitTransactionReply { +import org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages; + +public class PreCommitTransactionReply implements SerializableMessage{ + + public static Class SERIALIZABLE_CLASS = ThreePhaseCommitCohortMessages.PreCommitTransactionReply.class; + + @Override + public Object toSerializable() { + return ThreePhaseCommitCohortMessages.PreCommitTransactionReply.newBuilder().build(); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryFound.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryFound.java index d6aae3786f..69502837bc 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryFound.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryFound.java @@ -8,7 +8,10 @@ package org.opendaylight.controller.cluster.datastore.messages; -public class PrimaryFound { +import org.opendaylight.controller.protobuff.messages.shard.ShardManagerMessages; + +public class PrimaryFound implements SerializableMessage { + public static final Class SERIALIZABLE_CLASS = ShardManagerMessages.PrimaryFound.class; private final String primaryPath; public PrimaryFound(String primaryPath) { @@ -44,4 +47,12 @@ public class PrimaryFound { } + @Override + public Object toSerializable() { + return ShardManagerMessages.PrimaryFound.newBuilder().setPrimaryPath(primaryPath).build(); + } + + public static PrimaryFound fromSerializable(Object message){ + return new PrimaryFound(((ShardManagerMessages.PrimaryFound)message).getPrimaryPath()); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryNotFound.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryNotFound.java index c66e12cb39..057028c469 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryNotFound.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryNotFound.java @@ -9,8 +9,10 @@ package org.opendaylight.controller.cluster.datastore.messages; import com.google.common.base.Preconditions; +import org.opendaylight.controller.protobuff.messages.shard.ShardManagerMessages; -public class PrimaryNotFound { +public class PrimaryNotFound implements SerializableMessage { + public static final Class SERIALIZABLE_CLASS = ShardManagerMessages.PrimaryNotFound.class; private final String shardName; @@ -37,4 +39,13 @@ public class PrimaryNotFound { public int hashCode() { return shardName != null ? shardName.hashCode() : 0; } + + @Override + public Object toSerializable() { + return ShardManagerMessages.PrimaryNotFound.newBuilder().setShardName(shardName).build(); + } + + public static PrimaryNotFound fromSerializable(Object message){ + return new PrimaryNotFound(((ShardManagerMessages.PrimaryNotFound)message).getShardName()); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadData.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadData.java index 2f56a9740b..a698f46347 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadData.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadData.java @@ -8,16 +8,30 @@ package org.opendaylight.controller.cluster.datastore.messages; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.controller.cluster.datastore.utils.InstanceIdentifierUtils; +import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; public class ReadData { - private final InstanceIdentifier path; + public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.ReadData.class; + private final YangInstanceIdentifier path; - public ReadData(InstanceIdentifier path) { + public ReadData(YangInstanceIdentifier path) { this.path = path; } - public InstanceIdentifier getPath() { + public YangInstanceIdentifier getPath() { return path; } + + public Object toSerializable(){ + return ShardTransactionMessages.ReadData.newBuilder() + .setInstanceIdentifierPathArguments(InstanceIdentifierUtils.toSerializable(path)) + .build(); + } + + public static ReadData fromSerializable(Object serializable){ + ShardTransactionMessages.ReadData o = (ShardTransactionMessages.ReadData) serializable; + return new ReadData(InstanceIdentifierUtils.fromSerializable(o.getInstanceIdentifierPathArguments())); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadDataReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadDataReply.java index 52e2c29249..c5498ca228 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadDataReply.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadDataReply.java @@ -8,17 +8,42 @@ package org.opendaylight.controller.cluster.datastore.messages; +import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec; +import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages; +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; -public class ReadDataReply { - private final NormalizedNode normalizedNode; +public class ReadDataReply implements SerializableMessage{ - public ReadDataReply(NormalizedNode normalizedNode){ + private final NormalizedNode normalizedNode; + private final SchemaContext schemaContext; + public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.ReadDataReply.class; + public ReadDataReply(SchemaContext context,NormalizedNode normalizedNode){ this.normalizedNode = normalizedNode; + this.schemaContext = context; } public NormalizedNode getNormalizedNode() { return normalizedNode; } + + public Object toSerializable(){ + if(normalizedNode != null) { + return ShardTransactionMessages.ReadDataReply.newBuilder() + .setNormalizedNode(new NormalizedNodeToNodeCodec(schemaContext) + .encode(YangInstanceIdentifier.builder().build(), normalizedNode).getNormalizedNode() + ).build(); + }else{ + return ShardTransactionMessages.ReadDataReply.newBuilder().build(); + + } + + } + + public static ReadDataReply fromSerializable(SchemaContext schemaContext,YangInstanceIdentifier id,Object serializable){ + ShardTransactionMessages.ReadDataReply o = (ShardTransactionMessages.ReadDataReply) serializable; + return new ReadDataReply(schemaContext,new NormalizedNodeToNodeCodec(schemaContext).decode(id, o.getNormalizedNode())); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadyTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadyTransaction.java index 58eef66fc7..3a51d9850b 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadyTransaction.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadyTransaction.java @@ -8,5 +8,14 @@ package org.opendaylight.controller.cluster.datastore.messages; -public class ReadyTransaction { +import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages; + +public class ReadyTransaction implements SerializableMessage{ + public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.ReadyTransaction.class; + + @Override + public Object toSerializable() { + return ShardTransactionMessages.ReadyTransaction.newBuilder().build(); + } + } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadyTransactionReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadyTransactionReply.java index 32d31bf84d..5273dc2479 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadyTransactionReply.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadyTransactionReply.java @@ -9,8 +9,11 @@ package org.opendaylight.controller.cluster.datastore.messages; import akka.actor.ActorPath; +import akka.actor.ActorSystem; +import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages; -public class ReadyTransactionReply { +public class ReadyTransactionReply implements SerializableMessage { + public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.ReadyTransactionReply.class; private final ActorPath cohortPath; public ReadyTransactionReply(ActorPath cohortPath) { @@ -21,4 +24,16 @@ public class ReadyTransactionReply { public ActorPath getCohortPath() { return cohortPath; } + + @Override + public ShardTransactionMessages.ReadyTransactionReply toSerializable() { + return ShardTransactionMessages.ReadyTransactionReply.newBuilder() + .setActorPath(cohortPath.toString()).build(); + } + + public static ReadyTransactionReply fromSerializable(ActorSystem actorSystem,Object serializable){ + ShardTransactionMessages.ReadyTransactionReply o = (ShardTransactionMessages.ReadyTransactionReply) serializable; + return new ReadyTransactionReply( + actorSystem.actorFor(o.getActorPath()).path()); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterChangeListener.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterChangeListener.java index 7c9e4f0665..c1ec0a87cb 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterChangeListener.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterChangeListener.java @@ -9,16 +9,20 @@ package org.opendaylight.controller.cluster.datastore.messages; import akka.actor.ActorPath; +import akka.actor.ActorSystem; +import org.opendaylight.controller.cluster.datastore.utils.InstanceIdentifierUtils; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -public class RegisterChangeListener { - private final InstanceIdentifier path; +public class RegisterChangeListener implements SerializableMessage { + public static final Class SERIALIZABLE_CLASS = ListenerRegistrationMessages.RegisterChangeListener.class; + private final YangInstanceIdentifier path; private final ActorPath dataChangeListenerPath; private final AsyncDataBroker.DataChangeScope scope; - public RegisterChangeListener(InstanceIdentifier path, + public RegisterChangeListener(YangInstanceIdentifier path, ActorPath dataChangeListenerPath, AsyncDataBroker.DataChangeScope scope) { this.path = path; @@ -26,7 +30,7 @@ public class RegisterChangeListener { this.scope = scope; } - public InstanceIdentifier getPath() { + public YangInstanceIdentifier getPath() { return path; } @@ -38,4 +42,22 @@ public class RegisterChangeListener { public ActorPath getDataChangeListenerPath() { return dataChangeListenerPath; } + + + @Override + public ListenerRegistrationMessages.RegisterChangeListener toSerializable() { + return ListenerRegistrationMessages.RegisterChangeListener.newBuilder() + .setInstanceIdentifierPath(InstanceIdentifierUtils.toSerializable(path)) + .setDataChangeListenerActorPath(dataChangeListenerPath.toString()) + .setDataChangeScope(scope.ordinal()).build(); + } + + public static RegisterChangeListener fromSerializable(ActorSystem actorSystem,Object serializable){ + ListenerRegistrationMessages.RegisterChangeListener o = (ListenerRegistrationMessages.RegisterChangeListener) serializable; + return new RegisterChangeListener(InstanceIdentifierUtils.fromSerializable(o.getInstanceIdentifierPath()), + actorSystem.actorFor(o.getDataChangeListenerActorPath()).path(), + AsyncDataBroker.DataChangeScope.values()[o.getDataChangeScope()]); + } + + } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterChangeListenerReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterChangeListenerReply.java index ae8bbbd75a..8d980d283d 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterChangeListenerReply.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterChangeListenerReply.java @@ -9,8 +9,11 @@ package org.opendaylight.controller.cluster.datastore.messages; import akka.actor.ActorPath; +import akka.actor.ActorSystem; +import org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages; -public class RegisterChangeListenerReply { +public class RegisterChangeListenerReply implements SerializableMessage{ + public static final Class SERIALIZABLE_CLASS = ListenerRegistrationMessages.RegisterChangeListenerReply.class; private final ActorPath listenerRegistrationPath; public RegisterChangeListenerReply(ActorPath listenerRegistrationPath) { @@ -20,4 +23,17 @@ public class RegisterChangeListenerReply { public ActorPath getListenerRegistrationPath() { return listenerRegistrationPath; } + + @Override + public ListenerRegistrationMessages.RegisterChangeListenerReply toSerializable() { + return ListenerRegistrationMessages.RegisterChangeListenerReply.newBuilder() + .setListenerRegistrationPath(listenerRegistrationPath.toString()).build(); + } + + public static RegisterChangeListenerReply fromSerializable(ActorSystem actorSystem,Object serializable){ + ListenerRegistrationMessages.RegisterChangeListenerReply o = (ListenerRegistrationMessages.RegisterChangeListenerReply) serializable; + return new RegisterChangeListenerReply( + actorSystem.actorFor(o.getListenerRegistrationPath()).path() + ); + } } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/ElectionTimeout.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/SerializableMessage.java similarity index 70% rename from opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/ElectionTimeout.java rename to opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/SerializableMessage.java index 0a4b8fa669..d87b903f03 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/internal/messages/ElectionTimeout.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/SerializableMessage.java @@ -6,7 +6,8 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.controller.cluster.raft.internal.messages; +package org.opendaylight.controller.cluster.datastore.messages; -public class ElectionTimeout { +public interface SerializableMessage { + Object toSerializable(); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/WriteData.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/WriteData.java index 1348e65aa3..87fa010b37 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/WriteData.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/WriteData.java @@ -8,12 +8,42 @@ package org.opendaylight.controller.cluster.datastore.messages; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec; +import org.opendaylight.controller.cluster.datastore.utils.InstanceIdentifierUtils; +import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages; +import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages; +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; public class WriteData extends ModifyData{ - public WriteData(InstanceIdentifier path, NormalizedNode data) { - super(path, data); + public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.WriteData.class; + + public WriteData(YangInstanceIdentifier path, NormalizedNode data, SchemaContext schemaContext) { + super(path, data, schemaContext); } + + @Override public Object toSerializable() { + + NormalizedNodeMessages.Node normalizedNode = + new NormalizedNodeToNodeCodec(schemaContext).encode(path, data) + .getNormalizedNode(); + return ShardTransactionMessages.WriteData.newBuilder() + .setInstanceIdentifierPathArguments(InstanceIdentifierUtils.toSerializable(path)) + .setNormalizedNode(normalizedNode).build(); + + } + + public static WriteData fromSerializable(Object serializable, SchemaContext schemaContext){ + ShardTransactionMessages.WriteData o = (ShardTransactionMessages.WriteData) serializable; + YangInstanceIdentifier identifier = InstanceIdentifierUtils.fromSerializable(o.getInstanceIdentifierPathArguments()); + + NormalizedNode normalizedNode = + new NormalizedNodeToNodeCodec(schemaContext) + .decode(identifier, o.getNormalizedNode()); + + return new WriteData(identifier, normalizedNode, schemaContext); + } + } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/WriteDataReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/WriteDataReply.java index 2a2b4ed25d..5404fb6510 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/WriteDataReply.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/WriteDataReply.java @@ -8,5 +8,12 @@ package org.opendaylight.controller.cluster.datastore.messages; -public class WriteDataReply { +import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages; + +public class WriteDataReply implements SerializableMessage{ + public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.WriteDataReply.class; + @Override + public Object toSerializable() { + return ShardTransactionMessages.WriteDataReply.newBuilder().build(); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModification.java index 5d9f96277d..169397bf87 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModification.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModification.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.cluster.datastore.modification; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import java.io.Serializable; @@ -21,9 +21,9 @@ public abstract class AbstractModification implements Modification, private static final long serialVersionUID = 1638042650152084457L; - protected final InstanceIdentifier path; + protected final YangInstanceIdentifier path; - protected AbstractModification(InstanceIdentifier path) { + protected AbstractModification(YangInstanceIdentifier path) { this.path = path; } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java index 063ec3e1fc..593f458afa 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java @@ -8,14 +8,16 @@ package org.opendaylight.controller.cluster.datastore.modification; +import org.opendaylight.controller.cluster.datastore.utils.InstanceIdentifierUtils; +import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages; import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; /** * DeleteModification store all the parameters required to delete a path from the data tree */ public class DeleteModification extends AbstractModification { - public DeleteModification(InstanceIdentifier path) { + public DeleteModification(YangInstanceIdentifier path) { super(path); } @@ -23,4 +25,16 @@ public class DeleteModification extends AbstractModification { public void apply(DOMStoreWriteTransaction transaction) { transaction.delete(path); } + + @Override public Object toSerializable() { + return PersistentMessages.Modification.newBuilder() + .setType(this.getClass().toString()) + .setPath(InstanceIdentifierUtils.toSerializable(this.path)) + .build(); + } + + public static DeleteModification fromSerializable(Object serializable){ + PersistentMessages.Modification o = (PersistentMessages.Modification) serializable; + return new DeleteModification(InstanceIdentifierUtils.fromSerializable(o.getPath())); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/ImmutableCompositeModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/ImmutableCompositeModification.java index 5a15d76d27..2d11500eb7 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/ImmutableCompositeModification.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/ImmutableCompositeModification.java @@ -8,25 +8,39 @@ package org.opendaylight.controller.cluster.datastore.modification; +import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages; import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; import java.util.List; -public class ImmutableCompositeModification implements CompositeModification{ +public class ImmutableCompositeModification implements CompositeModification { - private final CompositeModification modification; + private final CompositeModification modification; - public ImmutableCompositeModification(CompositeModification modification){ - this.modification = modification; - } + public ImmutableCompositeModification(CompositeModification modification) { + this.modification = modification; + } - @Override - public List getModifications() { - return modification.getModifications(); - } + @Override + public List getModifications() { + return modification.getModifications(); + } - @Override - public void apply(DOMStoreWriteTransaction transaction) { - modification.apply(transaction); - } + @Override + public void apply(DOMStoreWriteTransaction transaction) { + modification.apply(transaction); + } + + @Override public Object toSerializable() { + + PersistentMessages.CompositeModification.Builder builder = + PersistentMessages.CompositeModification.newBuilder(); + + for (Modification m : modification.getModifications()) { + builder.addModification( + (PersistentMessages.Modification) m.toSerializable()); + } + + return builder.build(); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MergeModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MergeModification.java index 0457a78280..f06adcf96f 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MergeModification.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MergeModification.java @@ -8,24 +8,58 @@ package org.opendaylight.controller.cluster.datastore.modification; +import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec; +import org.opendaylight.controller.cluster.datastore.utils.InstanceIdentifierUtils; +import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages; +import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages; import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +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; /** * MergeModification stores all the parameters required to merge data into the specified path */ -public class MergeModification extends AbstractModification{ - private final NormalizedNode data; +public class MergeModification extends AbstractModification { + private final NormalizedNode data; + private final SchemaContext schemaContext; - public MergeModification(InstanceIdentifier path, NormalizedNode data) { - super(path); - this.data = data; - } + public MergeModification(YangInstanceIdentifier path, NormalizedNode data, + SchemaContext schemaContext) { + super(path); + this.data = data; + this.schemaContext = schemaContext; + } + + @Override + public void apply(DOMStoreWriteTransaction transaction) { + transaction.merge(path, data); + } + + @Override public Object toSerializable() { + NormalizedNodeMessages.Container encode = + new NormalizedNodeToNodeCodec(schemaContext).encode( + path, data); + + return PersistentMessages.Modification.newBuilder() + .setType(this.getClass().toString()) + .setPath(InstanceIdentifierUtils.toSerializable(this.path)) + .setData(encode.getNormalizedNode()) + .build(); + + } + + public static MergeModification fromSerializable( + Object serializable, + SchemaContext schemaContext) { + PersistentMessages.Modification o = (PersistentMessages.Modification) serializable; + + YangInstanceIdentifier path = InstanceIdentifierUtils.fromSerializable(o.getPath()); + NormalizedNode data = new NormalizedNodeToNodeCodec(schemaContext).decode( + path, o.getData()); + + return new MergeModification(path, data, schemaContext); + } - @Override - public void apply(DOMStoreWriteTransaction transaction) { - transaction.merge(path, data); - } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/Modification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/Modification.java index 60dbf0f4b1..ed9b1fe3b9 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/Modification.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/Modification.java @@ -8,6 +8,7 @@ package org.opendaylight.controller.cluster.datastore.modification; +import org.opendaylight.controller.cluster.datastore.messages.SerializableMessage; import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; /** @@ -24,7 +25,7 @@ import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; * which can then be applied to a write transaction *

*/ -public interface Modification { +public interface Modification extends SerializableMessage { /** * Apply the modification to the specified transaction * @param transaction diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModification.java index 9f37ba42d3..1a005d856e 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModification.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModification.java @@ -8,9 +8,10 @@ package org.opendaylight.controller.cluster.datastore.modification; +import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages; import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -20,7 +21,7 @@ import java.util.List; * CompositeModification {@link org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification#addModification(Modification)} */ public class MutableCompositeModification - implements CompositeModification, Serializable { + implements CompositeModification { private static final long serialVersionUID = 1163377899140186790L; @@ -46,4 +47,33 @@ public class MutableCompositeModification public List getModifications() { return Collections.unmodifiableList(modifications); } + + @Override public Object toSerializable() { + PersistentMessages.CompositeModification.Builder builder = + PersistentMessages.CompositeModification.newBuilder(); + + for (Modification m : modifications) { + builder.addModification( + (PersistentMessages.Modification) m.toSerializable()); + } + + return builder.build(); + } + + public static MutableCompositeModification fromSerializable(Object serializable, SchemaContext schemaContext){ + PersistentMessages.CompositeModification o = (PersistentMessages.CompositeModification) serializable; + MutableCompositeModification compositeModification = new MutableCompositeModification(); + + for(PersistentMessages.Modification m : o.getModificationList()){ + if(m.getType().equals(DeleteModification.class.toString())){ + compositeModification.addModification(DeleteModification.fromSerializable(m)); + } else if(m.getType().equals(WriteModification.class.toString())){ + compositeModification.addModification(WriteModification.fromSerializable(m, schemaContext)); + } else if(m.getType().equals(MergeModification.class.toString())){ + compositeModification.addModification(MergeModification.fromSerializable(m, schemaContext)); + } + } + + return compositeModification; + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/WriteModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/WriteModification.java index 1b2a87f42b..b4a7dd62d0 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/WriteModification.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/WriteModification.java @@ -8,9 +8,14 @@ package org.opendaylight.controller.cluster.datastore.modification; +import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec; +import org.opendaylight.controller.cluster.datastore.utils.InstanceIdentifierUtils; +import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages; +import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages; import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +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; /** * WriteModification stores all the parameters required to write data to the specified path @@ -18,15 +23,42 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; public class WriteModification extends AbstractModification { private final NormalizedNode data; + private final SchemaContext schemaContext; - public WriteModification(InstanceIdentifier path, NormalizedNode data) { + public WriteModification(YangInstanceIdentifier path, NormalizedNode data, SchemaContext schemaContext) { super(path); this.data = data; - } + this.schemaContext = schemaContext; + } @Override public void apply(DOMStoreWriteTransaction transaction) { transaction.write(path, data); } + @Override public Object toSerializable() { + NormalizedNodeMessages.Container encode = + new NormalizedNodeToNodeCodec(schemaContext).encode( + path, data); + + + return PersistentMessages.Modification.newBuilder() + .setType(this.getClass().toString()) + .setPath(InstanceIdentifierUtils.toSerializable(this.path)) + .setData(encode.getNormalizedNode()) + .build(); + + } + + public static WriteModification fromSerializable( + Object serializable, + SchemaContext schemaContext) { + PersistentMessages.Modification o = (PersistentMessages.Modification) serializable; + + YangInstanceIdentifier path = InstanceIdentifierUtils.fromSerializable(o.getPath()); + NormalizedNode data = new NormalizedNodeToNodeCodec(schemaContext).decode( + path, o.getData()); + + return new WriteModification(path, data, schemaContext); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/DefaultShardStrategy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/DefaultShardStrategy.java index a8ab5c4bd3..55c682b860 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/DefaultShardStrategy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/DefaultShardStrategy.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.cluster.datastore.shardstrategy; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; /** * The DefaultShardStrategy basically puts all data into the default Shard @@ -22,7 +22,7 @@ public class DefaultShardStrategy implements ShardStrategy{ public static final String DEFAULT_SHARD = "default"; @Override - public String findShard(InstanceIdentifier path) { + public String findShard(YangInstanceIdentifier path) { return DEFAULT_SHARD; } } 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 new file mode 100644 index 0000000000..6f4b65a6f3 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategy.java @@ -0,0 +1,30 @@ +/* + * 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.shardstrategy; + +import org.opendaylight.controller.cluster.datastore.Configuration; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; + +public class ModuleShardStrategy implements ShardStrategy { + + public static final String NAME = "module"; + + private final String moduleName; + private final Configuration configuration; + + public ModuleShardStrategy(String moduleName, Configuration configuration){ + this.moduleName = moduleName; + + this.configuration = configuration; + } + + @Override public String findShard(YangInstanceIdentifier path) { + return configuration.getShardNamesFromModuleName(moduleName).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 f75eb2d863..2df945edd5 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 @@ -8,7 +8,7 @@ package org.opendaylight.controller.cluster.datastore.shardstrategy; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; /** * The role of ShardStrategy is to figure out which Shards a given piece of data belongs to @@ -20,5 +20,5 @@ public interface ShardStrategy { * @param path The location of the data in the logical tree * @return */ - String findShard(InstanceIdentifier path); + String findShard(YangInstanceIdentifier path); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactory.java index 210537925b..f4ab8fab6f 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactory.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactory.java @@ -8,41 +8,52 @@ package org.opendaylight.controller.cluster.datastore.shardstrategy; +import com.google.common.base.Optional; import com.google.common.base.Preconditions; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.controller.cluster.datastore.Configuration; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class ShardStrategyFactory { - private static final Map moduleNameToStrategyMap = new ConcurrentHashMap(); + private static Map moduleNameToStrategyMap = + new ConcurrentHashMap(); - private static final String UNKNOWN_MODULE_NAME = "unknown"; + private static final String UNKNOWN_MODULE_NAME = "unknown"; + private static Configuration configuration; - public static ShardStrategy getStrategy(InstanceIdentifier path){ - Preconditions.checkNotNull(path, "path should not be null"); - String moduleName = getModuleName(path); - ShardStrategy shardStrategy = moduleNameToStrategyMap.get(moduleName); - if(shardStrategy == null){ - return new DefaultShardStrategy(); + public static void setConfiguration(Configuration configuration){ + ShardStrategyFactory.configuration = configuration; + moduleNameToStrategyMap = configuration.getModuleNameToShardStrategyMap(); } - return shardStrategy; - } + public static ShardStrategy getStrategy(YangInstanceIdentifier path) { + Preconditions.checkState(configuration != null, "configuration should not be missing"); + Preconditions.checkNotNull(path, "path should not be null"); - private static String getModuleName(InstanceIdentifier path){ - return UNKNOWN_MODULE_NAME; - } + String moduleName = getModuleName(path); + ShardStrategy shardStrategy = moduleNameToStrategyMap.get(moduleName); + if (shardStrategy == null) { + return new DefaultShardStrategy(); + } - /** - * This is to be used in the future to register a custom shard strategy - * - * @param moduleName - * @param shardStrategy - */ - public static void registerShardStrategy(String moduleName, ShardStrategy shardStrategy){ - throw new UnsupportedOperationException("registering a custom shard strategy not supported yet"); - } + return shardStrategy; + } + + + private static String getModuleName(YangInstanceIdentifier path) { + String namespace = path.getPathArguments().iterator().next().getNodeType().getNamespace().toASCIIString(); + + Optional optional = + configuration.getModuleNameFromNameSpace(namespace); + + if(!optional.isPresent()){ + return UNKNOWN_MODULE_NAME; + } + + return optional.get(); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java index c97e07db6d..ac0893da5a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java @@ -14,10 +14,13 @@ import akka.actor.ActorSelection; import akka.actor.ActorSystem; import akka.actor.PoisonPill; import akka.util.Timeout; +import org.opendaylight.controller.cluster.datastore.ClusterWrapper; +import org.opendaylight.controller.cluster.datastore.Configuration; import org.opendaylight.controller.cluster.datastore.exceptions.PrimaryNotFoundException; import org.opendaylight.controller.cluster.datastore.exceptions.TimeoutException; import org.opendaylight.controller.cluster.datastore.messages.FindPrimary; import org.opendaylight.controller.cluster.datastore.messages.PrimaryFound; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import scala.concurrent.Await; @@ -39,15 +42,25 @@ public class ActorContext { private static final Logger LOG = LoggerFactory.getLogger(ActorContext.class); - public static final FiniteDuration ASK_DURATION = Duration.create(5, TimeUnit.SECONDS); - public static final Duration AWAIT_DURATION = Duration.create(5, TimeUnit.SECONDS); + public static final FiniteDuration ASK_DURATION = + Duration.create(5, TimeUnit.SECONDS); + public static final Duration AWAIT_DURATION = + Duration.create(5, TimeUnit.SECONDS); private final ActorSystem actorSystem; private final ActorRef shardManager; + private final ClusterWrapper clusterWrapper; + private final Configuration configuration; - public ActorContext(ActorSystem actorSystem, ActorRef shardManager){ + private SchemaContext schemaContext = null; + + public ActorContext(ActorSystem actorSystem, ActorRef shardManager, + ClusterWrapper clusterWrapper, + Configuration configuration) { this.actorSystem = actorSystem; this.shardManager = shardManager; + this.clusterWrapper = clusterWrapper; + this.configuration = configuration; } public ActorSystem getActorSystem() { @@ -58,11 +71,11 @@ public class ActorContext { return shardManager; } - public ActorSelection actorSelection(String actorPath){ + public ActorSelection actorSelection(String actorPath) { return actorSystem.actorSelection(actorPath); } - public ActorSelection actorSelection(ActorPath actorPath){ + public ActorSelection actorSelection(ActorPath actorPath) { return actorSystem.actorSelection(actorPath); } @@ -74,72 +87,84 @@ public class ActorContext { * @return */ public ActorSelection findPrimary(String shardName) { + String path = findPrimaryPath(shardName); + return actorSystem.actorSelection(path); + } + + public String findPrimaryPath(String shardName) { Object result = executeLocalOperation(shardManager, - new FindPrimary(shardName), ASK_DURATION); + new FindPrimary(shardName).toSerializable(), ASK_DURATION); - if(result instanceof PrimaryFound){ - PrimaryFound found = (PrimaryFound) result; + if (result.getClass().equals(PrimaryFound.SERIALIZABLE_CLASS)) { + PrimaryFound found = PrimaryFound.fromSerializable(result); - LOG.error("Primary found {}", found.getPrimaryPath()); + LOG.debug("Primary found {}", found.getPrimaryPath()); - return actorSystem.actorSelection(found.getPrimaryPath()); + return found.getPrimaryPath(); } - throw new PrimaryNotFoundException(); + throw new PrimaryNotFoundException("Could not find primary for shardName " + shardName); } + /** * Executes an operation on a local actor and wait for it's response + * * @param actor * @param message * @param duration * @return The response of the operation */ public Object executeLocalOperation(ActorRef actor, Object message, - FiniteDuration duration){ + FiniteDuration duration) { Future future = ask(actor, message, new Timeout(duration)); try { return Await.result(future, AWAIT_DURATION); } catch (Exception e) { - throw new TimeoutException(e); + throw new TimeoutException("Sending message " + message.getClass().toString() + " to actor " + actor.toString() + " failed" , e); } } /** * Execute an operation on a remote actor and wait for it's response + * * @param actor * @param message * @param duration * @return */ public Object executeRemoteOperation(ActorSelection actor, Object message, - FiniteDuration duration){ + FiniteDuration duration) { + + LOG.debug("Sending remote message {} to {}", message.getClass().toString(), actor.toString()); + Future future = ask(actor, message, new Timeout(duration)); try { return Await.result(future, AWAIT_DURATION); } catch (Exception e) { - throw new TimeoutException(e); + throw new TimeoutException("Sending message " + message.getClass().toString() + " to actor " + actor.toString() + " failed" , e); } } /** * Execute an operation on the primary for a given shard *

- * This method first finds the primary for a given shard ,then sends - * the message to the remote shard and waits for a response + * This method first finds the primary for a given shard ,then sends + * the message to the remote shard and waits for a response *

+ * * @param shardName * @param message * @param duration - * @throws org.opendaylight.controller.cluster.datastore.exceptions.TimeoutException if the message to the remote shard times out - * @throws org.opendaylight.controller.cluster.datastore.exceptions.PrimaryNotFoundException if the primary shard is not found - * * @return + * @throws org.opendaylight.controller.cluster.datastore.exceptions.TimeoutException if the message to the remote shard times out + * @throws org.opendaylight.controller.cluster.datastore.exceptions.PrimaryNotFoundException if the primary shard is not found */ - public Object executeShardOperation(String shardName, Object message, FiniteDuration duration){ + public Object executeShardOperation(String shardName, Object message, + FiniteDuration duration) { ActorSelection primary = findPrimary(shardName); return executeRemoteOperation(primary, message, duration); @@ -149,4 +174,37 @@ public class ActorContext { shardManager.tell(PoisonPill.getInstance(), null); actorSystem.shutdown(); } + + /** + * @deprecated Need to stop using this method. There are ways to send a + * remote ActorRef as a string which should be used instead of this hack + * + * @param primaryPath + * @param localPathOfRemoteActor + * @return + */ + @Deprecated + public String resolvePath(final String primaryPath, + final String localPathOfRemoteActor) { + StringBuilder builder = new StringBuilder(); + String[] primaryPathElements = primaryPath.split("/"); + builder.append(primaryPathElements[0]).append("//") + .append(primaryPathElements[1]).append(primaryPathElements[2]); + String[] remotePathElements = localPathOfRemoteActor.split("/"); + for (int i = 3; i < remotePathElements.length; i++) { + builder.append("/").append(remotePathElements[i]); + } + + return builder.toString(); + + } + + public ActorPath actorFor(String path){ + return actorSystem.actorFor(path).path(); + } + + public String getCurrentMemberName(){ + return clusterWrapper.getCurrentMemberName(); + } + } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/InstanceIdentifierUtils.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/InstanceIdentifierUtils.java new file mode 100644 index 0000000000..20268a6744 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/InstanceIdentifierUtils.java @@ -0,0 +1,72 @@ +package org.opendaylight.controller.cluster.datastore.utils; + +import org.opendaylight.controller.cluster.datastore.node.utils.NodeIdentifierFactory; +import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author: syedbahm + */ +public class InstanceIdentifierUtils { + + protected static final Logger logger = LoggerFactory + .getLogger(InstanceIdentifierUtils.class); + + public static String getParentPath(String currentElementPath) { + String parentPath = ""; + + if (currentElementPath != null) { + String[] parentPaths = currentElementPath.split("/"); + if (parentPaths.length > 2) { + for (int i = 0; i < parentPaths.length - 1; i++) { + if (parentPaths[i].length() > 0) { + parentPath += "/" + parentPaths[i]; + } + } + } + } + return parentPath; + } + + @Deprecated + public static YangInstanceIdentifier from(String path) { + String[] ids = path.split("/"); + + List pathArguments = + new ArrayList<>(); + for (String nodeId : ids) { + if (!"".equals(nodeId)) { + pathArguments + .add(NodeIdentifierFactory.getArgument(nodeId)); + } + } + final YangInstanceIdentifier instanceIdentifier = + YangInstanceIdentifier.create(pathArguments); + return instanceIdentifier; + } + + /** + * @deprecated Use {@link org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils} instead + * @param path + * @return + */ + @Deprecated + public static NormalizedNodeMessages.InstanceIdentifier toSerializable(YangInstanceIdentifier path){ + return org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils.toSerializable(path); + } + + /** + * @deprecated Use {@link org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils} instead + * @param path + * @return + */ + @Deprecated + public static YangInstanceIdentifier fromSerializable(NormalizedNodeMessages.InstanceIdentifier path){ + return org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils.fromSerializable(path); + } +} 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 b56c26b578..76914c2c84 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,3 +1,15 @@ ODLCluster{ +actor { + serializers { + java = "akka.serialization.JavaSerializer" + proto = "akka.remote.serialization.ProtobufSerializer" + } + + serialization-bindings { + "com.google.protobuf.Message" = proto + + } + } + } \ No newline at end of file diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/module-shards.conf b/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/module-shards.conf new file mode 100644 index 0000000000..60dd7754d0 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/module-shards.conf @@ -0,0 +1,25 @@ +module-shards = [ + { + name = "default" + shards = [ + { + name="default", + replicas = [ + "member-1", + ] + } + ] + }, + { + name = "inventory" + shards = [ + { + name="inventory" + replicas = [ + "member-1", + ] + } + ] + } + +] 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 new file mode 100644 index 0000000000..05ef33f759 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/modules.conf @@ -0,0 +1,7 @@ +modules = [ + { + name = "inventory" + namespace = "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test:people" + shard-strategy = "module" + } +] diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractActorTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractActorTest.java index 214b3e9d3d..e23a76b0b2 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractActorTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractActorTest.java @@ -10,22 +10,38 @@ package org.opendaylight.controller.cluster.datastore; import akka.actor.ActorSystem; import akka.testkit.JavaTestKit; +import org.apache.commons.io.FileUtils; import org.junit.AfterClass; import org.junit.BeforeClass; +import java.io.File; +import java.io.IOException; + public abstract class AbstractActorTest { private static ActorSystem system; @BeforeClass - public static void setUpClass() { + public static void setUpClass() throws IOException { + File journal = new File("journal"); + + if(journal.exists()) { + FileUtils.deleteDirectory(journal); + } + System.setProperty("shard.persistent", "false"); system = ActorSystem.create("test"); } @AfterClass - public static void tearDownClass() { + public static void tearDownClass() throws IOException { JavaTestKit.shutdownActorSystem(system); system = null; + + File journal = new File("journal"); + + if(journal.exists()) { + FileUtils.deleteDirectory(journal); + } } protected ActorSystem getSystem() { 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 dfefc5ed57..11ad559744 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,12 +12,10 @@ import akka.actor.ActorPath; import akka.actor.ActorRef; import akka.actor.ActorSelection; import akka.actor.Props; -import akka.actor.Terminated; import akka.testkit.JavaTestKit; import junit.framework.Assert; import org.junit.Test; import org.opendaylight.controller.cluster.datastore.messages.CommitTransaction; -import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply; import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction; import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionChain; import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionChainReply; @@ -35,10 +33,13 @@ import scala.concurrent.Await; import scala.concurrent.Future; import scala.concurrent.duration.FiniteDuration; +import java.util.Collections; + public class BasicIntegrationTest extends AbstractActorTest { @Test public void integrationTest() throws Exception{ + // System.setProperty("shard.persistent", "true"); // This test will // - create a Shard // - initiate a transaction @@ -48,24 +49,33 @@ public class BasicIntegrationTest extends AbstractActorTest { new JavaTestKit(getSystem()) {{ - final Props props = Shard.props("config"); + final Props props = Shard.props("config", Collections.EMPTY_MAP); final ActorRef shard = getSystem().actorOf(props); new Within(duration("5 seconds")) { protected void run() { + shard.tell( new UpdateSchemaContext(TestModel.createTestContext()), getRef()); - shard.tell(new CreateTransactionChain(), getRef()); + + // Wait for Shard to become a Leader + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + // 1. Create a TransactionChain + shard.tell(new CreateTransactionChain().toSerializable(), getRef()); final ActorSelection transactionChain = new ExpectMsg("CreateTransactionChainReply") { protected ActorSelection match(Object in) { - if (in instanceof CreateTransactionChainReply) { + if (in.getClass().equals(CreateTransactionChainReply.SERIALIZABLE_CLASS)) { ActorPath transactionChainPath = - ((CreateTransactionChainReply) in) + CreateTransactionChainReply.fromSerializable(getSystem(),in) .getTransactionChainPath(); return getSystem() .actorSelection(transactionChainPath); @@ -77,17 +87,19 @@ public class BasicIntegrationTest extends AbstractActorTest { Assert.assertNotNull(transactionChain); - transactionChain.tell(new CreateTransaction("txn-1"), getRef()); + System.out.println("Successfully created transaction chain"); + + // 2. Create a Transaction on the TransactionChain + transactionChain.tell(new CreateTransaction("txn-1").toSerializable(), getRef()); final ActorSelection transaction = new ExpectMsg("CreateTransactionReply") { protected ActorSelection match(Object in) { - if (in instanceof CreateTransactionReply) { - ActorPath transactionPath = - ((CreateTransactionReply) in) - .getTransactionPath(); + if (CreateTransactionReply.SERIALIZABLE_CLASS.equals(in.getClass())) { + CreateTransactionReply reply = CreateTransactionReply.fromSerializable(in); return getSystem() - .actorSelection(transactionPath); + .actorSelection(reply + .getTransactionPath()); } else { throw noMatch(); } @@ -96,16 +108,16 @@ public class BasicIntegrationTest extends AbstractActorTest { Assert.assertNotNull(transaction); - // Add a watch on the transaction actor so that we are notified when it dies - final ActorRef transactionActorRef = watchActor(transaction); + System.out.println("Successfully created transaction"); + // 3. Write some data transaction.tell(new WriteData(TestModel.TEST_PATH, - ImmutableNodes.containerNode(TestModel.TEST_QNAME)), + ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext()).toSerializable(), getRef()); Boolean writeDone = new ExpectMsg("WriteDataReply") { protected Boolean match(Object in) { - if (in instanceof WriteDataReply) { + if (in.getClass().equals(WriteDataReply.SERIALIZABLE_CLASS)) { return true; } else { throw noMatch(); @@ -115,14 +127,18 @@ public class BasicIntegrationTest extends AbstractActorTest { Assert.assertTrue(writeDone); - transaction.tell(new ReadyTransaction(), getRef()); + System.out.println("Successfully wrote data"); + + // 4. Ready the transaction for commit + + transaction.tell(new ReadyTransaction().toSerializable(), getRef()); final ActorSelection cohort = new ExpectMsg("ReadyTransactionReply") { protected ActorSelection match(Object in) { - if (in instanceof ReadyTransactionReply) { + if (in.getClass().equals(ReadyTransactionReply.SERIALIZABLE_CLASS)) { ActorPath cohortPath = - ((ReadyTransactionReply) in) + ReadyTransactionReply.fromSerializable(getSystem(),in) .getCohortPath(); return getSystem() .actorSelection(cohortPath); @@ -134,15 +150,16 @@ public class BasicIntegrationTest extends AbstractActorTest { Assert.assertNotNull(cohort); - // Add a watch on the transaction actor so that we are notified when it dies - final ActorRef cohorActorRef = watchActor(cohort); + System.out.println("Successfully readied the transaction"); - cohort.tell(new PreCommitTransaction(), getRef()); + // 5. PreCommit the transaction + + cohort.tell(new PreCommitTransaction().toSerializable(), getRef()); Boolean preCommitDone = new ExpectMsg("PreCommitTransactionReply") { protected Boolean match(Object in) { - if (in instanceof PreCommitTransactionReply) { + if (in.getClass().equals(PreCommitTransactionReply.SERIALIZABLE_CLASS)) { return true; } else { throw noMatch(); @@ -152,52 +169,14 @@ public class BasicIntegrationTest extends AbstractActorTest { Assert.assertTrue(preCommitDone); - // FIXME : When we commit on the cohort it "kills" the Transaction. - // This in turn kills the child of Transaction as well. - // The order in which we receive the terminated event for both - // these actors is not fixed which may cause this test to fail - cohort.tell(new CommitTransaction(), getRef()); - - final Boolean terminatedCohort = - new ExpectMsg("Terminated Cohort") { - protected Boolean match(Object in) { - if (in instanceof Terminated) { - return cohorActorRef.equals(((Terminated) in).actor()); - } else { - throw noMatch(); - } - } - }.get(); // this extracts the received message - - Assert.assertTrue(terminatedCohort); - + System.out.println("Successfully pre-committed the transaction"); - final Boolean terminatedTransaction = - new ExpectMsg("Terminated Transaction") { - protected Boolean match(Object in) { - if (in instanceof Terminated) { - return transactionActorRef.equals(((Terminated) in).actor()); - } else { - throw noMatch(); - } - } - }.get(); // this extracts the received message - - Assert.assertTrue(terminatedTransaction); - - final Boolean commitDone = - new ExpectMsg("CommitTransactionReply") { - protected Boolean match(Object in) { - if (in instanceof CommitTransactionReply) { - return true; - } else { - throw noMatch(); - } - } - }.get(); // this extracts the received message + // 6. Commit the transaction + cohort.tell(new CommitTransaction().toSerializable(), getRef()); - Assert.assertTrue(commitDone); + // FIXME : Add assertions that the commit worked and that the cohort and transaction actors were terminated + System.out.println("TODO : Check Successfully committed the transaction"); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ConfigurationImplTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ConfigurationImplTest.java new file mode 100644 index 0000000000..56fd3c568a --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ConfigurationImplTest.java @@ -0,0 +1,41 @@ +package org.opendaylight.controller.cluster.datastore; + +import com.typesafe.config.ConfigFactory; +import junit.framework.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.io.File; +import java.util.List; + +import static org.junit.Assert.assertTrue; + +public class ConfigurationImplTest { + + private static ConfigurationImpl configuration; + + @BeforeClass + public static void staticSetup(){ + configuration = new ConfigurationImpl("module-shards.conf", "modules.conf"); + } + + @Test + public void testConstructor(){ + Assert.assertNotNull(configuration); + } + + @Test + public void testGetMemberShardNames(){ + List memberShardNames = + configuration.getMemberShardNames("member-1"); + + assertTrue(memberShardNames.contains("people-1")); + assertTrue(memberShardNames.contains("cars-1")); + } + + @Test + public void testReadConfigurationFromFile(){ + File f = new File("./module-shards.conf"); + ConfigFactory.parseFile(f); + } +} 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 a8409a6f85..8c1cbbbba0 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 @@ -1,3 +1,4 @@ + package org.opendaylight.controller.cluster.datastore; import akka.actor.ActorRef; @@ -8,61 +9,79 @@ import org.opendaylight.controller.cluster.datastore.messages.DataChanged; import org.opendaylight.controller.cluster.datastore.utils.ActorContext; import org.opendaylight.controller.cluster.datastore.utils.DoNothingActor; import org.opendaylight.controller.cluster.datastore.utils.MessageCollectorActor; +import org.opendaylight.controller.cluster.datastore.utils.MockClusterWrapper; +import org.opendaylight.controller.cluster.datastore.utils.MockConfiguration; +import org.opendaylight.controller.md.cluster.datastore.model.CompositeModel; +import org.opendaylight.controller.md.cluster.datastore.model.TestModel; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; public class DataChangeListenerProxyTest extends AbstractActorTest { - private static class MockDataChangeEvent implements - AsyncDataChangeEvent> { + private static class MockDataChangedEvent implements AsyncDataChangeEvent> { + Map> createdData = new HashMap(); + Map> updatedData = new HashMap(); + Map> originalData = new HashMap(); + + + + @Override + public Map> getCreatedData() { + createdData.put(YangInstanceIdentifier.builder().build(), CompositeModel.createDocumentOne(CompositeModel.createTestContext())); + return createdData; + } - @Override - public Map> getCreatedData() { - throw new UnsupportedOperationException("getCreatedData"); - } + @Override + public Map> getUpdatedData() { + updatedData.put(YangInstanceIdentifier.builder().build(), CompositeModel.createTestContainer()); + return updatedData; - @Override - public Map> getUpdatedData() { - throw new UnsupportedOperationException("getUpdatedData"); - } + } - @Override public Set getRemovedPaths() { - throw new UnsupportedOperationException("getRemovedPaths"); - } + @Override + public Set getRemovedPaths() { + Setids = new HashSet(); + ids.add( CompositeModel.TEST_PATH); + return ids; + } - @Override - public Map> getOriginalData() { - throw new UnsupportedOperationException("getOriginalData"); - } + @Override + public Map> getOriginalData() { + originalData.put(YangInstanceIdentifier.builder().build(), CompositeModel.createFamily()); + return originalData; + } - @Override public NormalizedNode getOriginalSubtree() { - throw new UnsupportedOperationException("getOriginalSubtree"); - } + @Override public NormalizedNode getOriginalSubtree() { + return CompositeModel.createFamily() ; + } - @Override public NormalizedNode getUpdatedSubtree() { - throw new UnsupportedOperationException("getUpdatedSubtree"); - } + @Override public NormalizedNode getUpdatedSubtree() { + return CompositeModel.createTestContainer(); } + } + - @Test + @Test public void testOnDataChanged() throws Exception { final Props props = Props.create(MessageCollectorActor.class); final ActorRef actorRef = getSystem().actorOf(props); DataChangeListenerProxy dataChangeListenerProxy = - new DataChangeListenerProxy( + new DataChangeListenerProxy(TestModel.createTestContext(), getSystem().actorSelection(actorRef.path())); - dataChangeListenerProxy.onDataChanged(new MockDataChangeEvent()); + dataChangeListenerProxy.onDataChanged(new MockDataChangedEvent()); //Check if it was received by the remote actor ActorContext - testContext = new ActorContext(getSystem(), getSystem().actorOf(Props.create(DoNothingActor.class))); + testContext = new ActorContext(getSystem(), getSystem().actorOf(Props.create(DoNothingActor.class)), new MockClusterWrapper(), new MockConfiguration()); Object messages = testContext .executeLocalOperation(actorRef, "messages", ActorContext.ASK_DURATION); @@ -75,7 +94,7 @@ public class DataChangeListenerProxyTest extends AbstractActorTest { Assert.assertEquals(1, listMessages.size()); - Assert.assertTrue(listMessages.get(0) instanceof DataChanged); + Assert.assertTrue(listMessages.get(0).getClass().equals(DataChanged.SERIALIZABLE_CLASS)); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationProxyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationProxyTest.java index 33b5d95611..c99a7e8c8c 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationProxyTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationProxyTest.java @@ -8,9 +8,11 @@ import org.opendaylight.controller.cluster.datastore.messages.CloseDataChangeLis import org.opendaylight.controller.cluster.datastore.utils.ActorContext; import org.opendaylight.controller.cluster.datastore.utils.DoNothingActor; import org.opendaylight.controller.cluster.datastore.utils.MessageCollectorActor; +import org.opendaylight.controller.cluster.datastore.utils.MockClusterWrapper; +import org.opendaylight.controller.cluster.datastore.utils.MockConfiguration; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import java.util.List; @@ -20,10 +22,10 @@ public class DataChangeListenerRegistrationProxyTest extends AbstractActorTest{ private ActorRef dataChangeListenerActor = getSystem().actorOf(Props.create(DoNothingActor.class)); private static class MockDataChangeListener implements - AsyncDataChangeListener> { + AsyncDataChangeListener> { @Override public void onDataChanged( - AsyncDataChangeEvent> change) { + AsyncDataChangeEvent> change) { throw new UnsupportedOperationException("onDataChanged"); } } @@ -58,7 +60,7 @@ public class DataChangeListenerRegistrationProxyTest extends AbstractActorTest{ //Check if it was received by the remote actor ActorContext - testContext = new ActorContext(getSystem(), getSystem().actorOf(Props.create(DoNothingActor.class))); + testContext = new ActorContext(getSystem(), getSystem().actorOf(Props.create(DoNothingActor.class)),new MockClusterWrapper(), new MockConfiguration()); Object messages = testContext .executeLocalOperation(actorRef, "messages", ActorContext.ASK_DURATION); @@ -71,6 +73,6 @@ public class DataChangeListenerRegistrationProxyTest extends AbstractActorTest{ Assert.assertEquals(1, listMessages.size()); - Assert.assertTrue(listMessages.get(0) instanceof CloseDataChangeListenerRegistration); + Assert.assertTrue(listMessages.get(0).getClass().equals(CloseDataChangeListenerRegistration.SERIALIZABLE_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 23302b504e..8413bac3a7 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 @@ -13,7 +13,7 @@ import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener; import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import static org.junit.Assert.assertEquals; @@ -39,12 +39,12 @@ public class DataChangeListenerRegistrationTest extends AbstractActorTest { new Within(duration("1 seconds")) { protected void run() { - subject.tell(new CloseDataChangeListenerRegistration(), getRef()); + subject.tell(new CloseDataChangeListenerRegistration().toSerializable(), getRef()); final String out = new ExpectMsg("match hint") { // do not put code outside this method, will run afterwards protected String match(Object in) { - if (in instanceof CloseDataChangeListenerRegistrationReply) { + if (in.getClass().equals(CloseDataChangeListenerRegistrationReply.SERIALIZABLE_CLASS)) { return "match"; } else { throw noMatch(); @@ -62,10 +62,10 @@ public class DataChangeListenerRegistrationTest extends AbstractActorTest { }}; } - private AsyncDataChangeListener> noOpDataChangeListener(){ - return new AsyncDataChangeListener>() { + private AsyncDataChangeListener> noOpDataChangeListener(){ + return new AsyncDataChangeListener>() { @Override - public void onDataChanged(AsyncDataChangeEvent> change) { + public void onDataChanged(AsyncDataChangeEvent> change) { } }; 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 6f0816be5c..fd61032220 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 @@ -6,66 +6,90 @@ import akka.testkit.JavaTestKit; import org.junit.Test; import org.opendaylight.controller.cluster.datastore.messages.DataChanged; import org.opendaylight.controller.cluster.datastore.messages.DataChangedReply; +import org.opendaylight.controller.md.cluster.datastore.model.CompositeModel; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Set; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; public class DataChangeListenerTest extends AbstractActorTest { - private static class MockDataChangedEvent implements AsyncDataChangeEvent> { + private static class MockDataChangedEvent implements AsyncDataChangeEvent> { + Map> createdData = new HashMap(); + Map> updatedData = new HashMap(); + Map> originalData = new HashMap(); + + @Override - public Map> getCreatedData() { - throw new UnsupportedOperationException("getCreatedData"); + public Map> getCreatedData() { + createdData.put(CompositeModel.FAMILY_PATH, CompositeModel.createFamily()); + return createdData; } @Override - public Map> getUpdatedData() { - throw new UnsupportedOperationException("getUpdatedData"); + public Map> getUpdatedData() { + updatedData.put(CompositeModel.FAMILY_PATH, CompositeModel.createFamily()); + return updatedData; + } - @Override public Set getRemovedPaths() { - throw new UnsupportedOperationException("getRemovedPaths"); + @Override + public Set getRemovedPaths() { + Setids = new HashSet(); + ids.add( CompositeModel.TEST_PATH); + return ids; } @Override - public Map> getOriginalData() { - throw new UnsupportedOperationException("getOriginalData"); + public Map> getOriginalData() { + originalData.put(CompositeModel.FAMILY_PATH, CompositeModel.createFamily()); + return originalData; } @Override public NormalizedNode getOriginalSubtree() { - throw new UnsupportedOperationException("getOriginalSubtree"); + + + return originalData.put(CompositeModel.FAMILY_PATH, CompositeModel.createFamily()); } @Override public NormalizedNode getUpdatedSubtree() { - throw new UnsupportedOperationException("getUpdatedSubtree"); + + //fixme: need to have some valid data here + return originalData.put(CompositeModel.FAMILY_PATH, CompositeModel.createFamily()); } } - private class MockDataChangeListener implements AsyncDataChangeListener> { + private class MockDataChangeListener implements AsyncDataChangeListener> { private boolean gotIt = false; + private AsyncDataChangeEvent> change; @Override public void onDataChanged( - AsyncDataChangeEvent> change) { - gotIt = true; + AsyncDataChangeEvent> change) { + gotIt = true;this.change=change; } public boolean gotIt() { return gotIt; } + public AsyncDataChangeEvent> getChange(){ + return change; + } } @Test public void testDataChanged(){ new JavaTestKit(getSystem()) {{ final MockDataChangeListener listener = new MockDataChangeListener(); - final Props props = DataChangeListener.props(listener); + final Props props = DataChangeListener.props(CompositeModel.createTestContext(),listener,CompositeModel.FAMILY_PATH ); final ActorRef subject = getSystem().actorOf(props, "testDataChanged"); @@ -73,15 +97,14 @@ public class DataChangeListenerTest extends AbstractActorTest { protected void run() { subject.tell( - new DataChanged(new MockDataChangedEvent()), + new DataChanged(CompositeModel.createTestContext(),new MockDataChangedEvent()).toSerializable(), getRef()); final Boolean out = new ExpectMsg("dataChanged") { // do not put code outside this method, will run afterwards protected Boolean match(Object in) { - if (in instanceof DataChangedReply) { - DataChangedReply reply = - (DataChangedReply) in; + if (in.getClass().equals(DataChangedReply.SERIALIZABLE_CLASS)) { + return true; } else { throw noMatch(); @@ -91,6 +114,7 @@ public class DataChangeListenerTest extends AbstractActorTest { assertTrue(out); assertTrue(listener.gotIt()); + assertNotNull(listener.getChange().getCreatedData()); // Will wait for the rest of the 3 seconds 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 f400e74231..b5e3d24ef6 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,26 +1,59 @@ package org.opendaylight.controller.cluster.datastore; +import akka.actor.ActorSystem; +import akka.testkit.JavaTestKit; import com.google.common.base.Optional; import com.google.common.util.concurrent.ListenableFuture; +import org.junit.After; +import org.junit.Before; import org.junit.Test; +import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategyFactory; +import org.opendaylight.controller.cluster.datastore.utils.MockClusterWrapper; +import org.opendaylight.controller.md.cluster.datastore.model.CarsModel; +import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel; +import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; +import java.util.concurrent.ExecutionException; + import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertTrue; -public class DistributedDataStoreIntegrationTest extends AbstractActorTest { +public class DistributedDataStoreIntegrationTest{ + + private static ActorSystem system; + + @Before + public void setUp() { + System.setProperty("shard.persistent", "false"); + system = ActorSystem.create("test"); + } + + @After + public void tearDown() { + JavaTestKit.shutdownActorSystem(system); + system = null; + } + + protected ActorSystem getSystem() { + return system; + } @Test public void integrationTest() throws Exception { + Configuration configuration = new ConfigurationImpl("module-shards.conf", "modules.conf"); + ShardStrategyFactory.setConfiguration(configuration); DistributedDataStore distributedDataStore = - new DistributedDataStore(getSystem(), "config"); + new DistributedDataStore(getSystem(), "config", new MockClusterWrapper(), configuration); distributedDataStore.onGlobalContextUpdated(TestModel.createTestContext()); + Thread.sleep(1000); + DOMStoreReadWriteTransaction transaction = distributedDataStore.newReadWriteTransaction(); @@ -51,4 +84,41 @@ public class DistributedDataStoreIntegrationTest extends AbstractActorTest { } + + @Test + public void integrationTestWithMultiShardConfiguration() + throws ExecutionException, InterruptedException { + Configuration configuration = new ConfigurationImpl("module-shards.conf", "modules.conf"); + + ShardStrategyFactory.setConfiguration(configuration); + DistributedDataStore distributedDataStore = + new DistributedDataStore(getSystem(), "config", new MockClusterWrapper(), configuration); + + + distributedDataStore.onGlobalContextUpdated(SchemaContextHelper.full()); + + Thread.sleep(1000); + + DOMStoreReadWriteTransaction transaction = + distributedDataStore.newReadWriteTransaction(); + + transaction.write(CarsModel.BASE_PATH, CarsModel.emptyContainer()); + transaction.write(PeopleModel.BASE_PATH, PeopleModel.emptyContainer()); + + DOMStoreThreePhaseCommitCohort ready = transaction.ready(); + + ListenableFuture canCommit = ready.canCommit(); + + assertTrue(canCommit.get()); + + ListenableFuture preCommit = ready.preCommit(); + + preCommit.get(); + + ListenableFuture commit = ready.commit(); + + commit.get(); + + } + } 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 5f82b40140..23a1ed4931 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 @@ -3,20 +3,22 @@ package org.opendaylight.controller.cluster.datastore; import akka.actor.ActorRef; import akka.actor.Props; import junit.framework.Assert; -import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionReply; import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListenerReply; +import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategyFactory; import org.opendaylight.controller.cluster.datastore.utils.DoNothingActor; import org.opendaylight.controller.cluster.datastore.utils.MockActorContext; +import org.opendaylight.controller.cluster.datastore.utils.MockConfiguration; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener; +import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.CreateTransactionReply; 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.DOMStoreTransactionChain; import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; public class DistributedDataStoreTest extends AbstractActorTest{ @@ -27,6 +29,7 @@ public class DistributedDataStoreTest extends AbstractActorTest{ @org.junit.Before public void setUp() throws Exception { + ShardStrategyFactory.setConfiguration(new MockConfiguration()); final Props props = Props.create(DoNothingActor.class); doNothingActorRef = getSystem().actorOf(props); @@ -39,7 +42,10 @@ public class DistributedDataStoreTest extends AbstractActorTest{ // Make CreateTransactionReply as the default response. Will need to be // tuned if a specific test requires some other response mockActorContext.setExecuteShardOperationResponse( - new CreateTransactionReply(doNothingActorRef.path(), "txn-1 ")); + CreateTransactionReply.newBuilder() + .setTransactionActorPath(doNothingActorRef.path().toString()) + .setTransactionId("txn-1 ") + .build()); } @org.junit.After @@ -49,11 +55,11 @@ public class DistributedDataStoreTest extends AbstractActorTest{ @org.junit.Test public void testRegisterChangeListener() throws Exception { - mockActorContext.setExecuteShardOperationResponse(new RegisterChangeListenerReply(doNothingActorRef.path())); + mockActorContext.setExecuteShardOperationResponse(new RegisterChangeListenerReply(doNothingActorRef.path()).toSerializable()); ListenerRegistration registration = - distributedDataStore.registerChangeListener(TestModel.TEST_PATH, new AsyncDataChangeListener>() { + distributedDataStore.registerChangeListener(TestModel.TEST_PATH, new AsyncDataChangeListener>() { @Override - public void onDataChanged(AsyncDataChangeEvent> change) { + public void onDataChanged(AsyncDataChangeEvent> change) { throw new UnsupportedOperationException("onDataChanged"); } }, AsyncDataBroker.DataChangeScope.BASE); 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 fa436c1605..87d257a3f2 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 @@ -4,24 +4,27 @@ import akka.actor.ActorSystem; import akka.actor.Props; import akka.testkit.JavaTestKit; import akka.testkit.TestActorRef; +import junit.framework.Assert; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.controller.cluster.datastore.messages.FindPrimary; import org.opendaylight.controller.cluster.datastore.messages.PrimaryFound; import org.opendaylight.controller.cluster.datastore.messages.PrimaryNotFound; +import org.opendaylight.controller.cluster.datastore.utils.MockClusterWrapper; +import org.opendaylight.controller.cluster.datastore.utils.MockConfiguration; import scala.concurrent.duration.Duration; public class ShardManagerTest { private static ActorSystem system; @BeforeClass - public static void setUp(){ + public static void setUp() { system = ActorSystem.create("test"); } @AfterClass - public static void tearDown(){ + public static void tearDown() { JavaTestKit.shutdownActorSystem(system); system = null; } @@ -30,15 +33,19 @@ public class ShardManagerTest { public void testOnReceiveFindPrimaryForNonExistentShard() throws Exception { new JavaTestKit(system) {{ - final Props props = ShardManager.props("config"); - final TestActorRef subject = TestActorRef.create(system, props); + final Props props = ShardManager + .props("config", new MockClusterWrapper(), + new MockConfiguration()); + final TestActorRef subject = + TestActorRef.create(system, props); new Within(duration("1 seconds")) { protected void run() { - subject.tell(new FindPrimary("inventory"), getRef()); + subject.tell(new FindPrimary("inventory").toSerializable(), getRef()); - expectMsgEquals(Duration.Zero(), new PrimaryNotFound("inventory")); + expectMsgEquals(Duration.Zero(), + new PrimaryNotFound("inventory").toSerializable()); // Will wait for the rest of the 3 seconds expectNoMsg(); @@ -47,24 +54,99 @@ public class ShardManagerTest { }}; } - @Test - public void testOnReceiveFindPrimaryForExistentShard() throws Exception { + @Test + public void testOnReceiveFindPrimaryForExistentShard() throws Exception { + + new JavaTestKit(system) {{ + final Props props = ShardManager + .props("config", new MockClusterWrapper(), + new MockConfiguration()); + final TestActorRef subject = + TestActorRef.create(system, props); + + // the run() method needs to finish within 3 seconds + new Within(duration("1 seconds")) { + protected void run() { + + subject.tell(new FindPrimary(Shard.DEFAULT_NAME).toSerializable(), getRef()); + + expectMsgClass(PrimaryFound.SERIALIZABLE_CLASS); + + expectNoMsg(); + } + }; + }}; + } + + @Test + public void testOnReceiveMemberUp() throws Exception { + + new JavaTestKit(system) {{ + final Props props = ShardManager + .props("config", new MockClusterWrapper(), + new MockConfiguration()); + final TestActorRef subject = + TestActorRef.create(system, props); - new JavaTestKit(system) {{ - final Props props = ShardManager.props("config"); - final TestActorRef subject = TestActorRef.create(system, props); + // the run() method needs to finish within 3 seconds + new Within(duration("1 seconds")) { + protected void run() { + + MockClusterWrapper.sendMemberUp(subject, "member-2", getRef().path().toString()); - // the run() method needs to finish within 3 seconds - new Within(duration("1 seconds")) { - protected void run() { + subject.tell(new FindPrimary("astronauts").toSerializable(), getRef()); - subject.tell(new FindPrimary(Shard.DEFAULT_NAME), getRef()); + final String out = new ExpectMsg("primary found") { + // do not put code outside this method, will run afterwards + protected String match(Object in) { + if (in.getClass().equals(PrimaryFound.SERIALIZABLE_CLASS)) { + PrimaryFound f = PrimaryFound.fromSerializable(in); + return f.getPrimaryPath(); + } else { + throw noMatch(); + } + } + }.get(); // this extracts the received message + + Assert.assertTrue(out, out.contains("member-2-shard-astronauts-config")); + + expectNoMsg(); + } + }; + }}; + } + + @Test + public void testOnReceiveMemberDown() throws Exception { + + new JavaTestKit(system) {{ + final Props props = ShardManager + .props("config", new MockClusterWrapper(), + new MockConfiguration()); + final TestActorRef subject = + TestActorRef.create(system, props); + + // the run() method needs to finish within 3 seconds + new Within(duration("1 seconds")) { + protected void run() { + + MockClusterWrapper.sendMemberUp(subject, "member-2", getRef().path().toString()); + + subject.tell(new FindPrimary("astronauts").toSerializable(), getRef()); + + expectMsgClass(PrimaryFound.SERIALIZABLE_CLASS); + + MockClusterWrapper.sendMemberRemoved(subject, "member-2", getRef().path().toString()); + + subject.tell(new FindPrimary("astronauts").toSerializable(), getRef()); + + expectMsgClass(PrimaryNotFound.SERIALIZABLE_CLASS); + + expectNoMsg(); + } + }; + }}; + } - expectMsgClass(PrimaryFound.class); - expectNoMsg(); - } - }; - }}; - } -} \ No newline at end of file +} 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 ed447e004f..7d57ea8284 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 @@ -7,17 +7,23 @@ import org.junit.Test; import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction; import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionChain; import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionChainReply; -import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionReply; +import org.opendaylight.controller.cluster.datastore.messages.PeerAddressResolved; import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListener; import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListenerReply; import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext; +import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.CreateTransactionReply; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -25,21 +31,29 @@ public class ShardTest extends AbstractActorTest { @Test public void testOnReceiveCreateTransactionChain() throws Exception { new JavaTestKit(getSystem()) {{ - final Props props = Shard.props("config"); + final Props props = Shard.props("config", Collections.EMPTY_MAP); final ActorRef subject = getSystem().actorOf(props, "testCreateTransactionChain"); + + // Wait for Shard to become a Leader + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + new Within(duration("1 seconds")) { protected void run() { - subject.tell(new CreateTransactionChain(), getRef()); + subject.tell(new CreateTransactionChain().toSerializable(), getRef()); final String out = new ExpectMsg("match hint") { // do not put code outside this method, will run afterwards protected String match(Object in) { - if (in instanceof CreateTransactionChainReply) { + if (in.getClass().equals(CreateTransactionChainReply.SERIALIZABLE_CLASS)){ CreateTransactionChainReply reply = - (CreateTransactionChainReply) in; + CreateTransactionChainReply.fromSerializable(getSystem(),in); return reply.getTransactionChainPath() .toString(); } else { @@ -63,7 +77,7 @@ public class ShardTest extends AbstractActorTest { @Test public void testOnReceiveRegisterListener() throws Exception { new JavaTestKit(getSystem()) {{ - final Props props = Shard.props("config"); + final Props props = Shard.props("config", Collections.EMPTY_MAP); final ActorRef subject = getSystem().actorOf(props, "testRegisterChangeListener"); @@ -71,19 +85,19 @@ public class ShardTest extends AbstractActorTest { protected void run() { subject.tell( - new UpdateSchemaContext(TestModel.createTestContext()), + new UpdateSchemaContext(SchemaContextHelper.full()), getRef()); subject.tell(new RegisterChangeListener(TestModel.TEST_PATH, - getRef().path(), AsyncDataBroker.DataChangeScope.BASE), + getRef().path(), AsyncDataBroker.DataChangeScope.BASE).toSerializable(), getRef()); final String out = new ExpectMsg("match hint") { // do not put code outside this method, will run afterwards protected String match(Object in) { - if (in instanceof RegisterChangeListenerReply) { + if (in.getClass().equals(RegisterChangeListenerReply.SERIALIZABLE_CLASS)) { RegisterChangeListenerReply reply = - (RegisterChangeListenerReply) in; + RegisterChangeListenerReply.fromSerializable(getSystem(),in); return reply.getListenerRegistrationPath() .toString(); } else { @@ -106,10 +120,19 @@ public class ShardTest extends AbstractActorTest { @Test public void testCreateTransaction(){ new JavaTestKit(getSystem()) {{ - final Props props = Shard.props("config"); + final Props props = Shard.props("config", Collections.EMPTY_MAP); final ActorRef subject = getSystem().actorOf(props, "testCreateTransaction"); + + // Wait for Shard to become a Leader + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + new Within(duration("1 seconds")) { protected void run() { @@ -117,7 +140,7 @@ public class ShardTest extends AbstractActorTest { new UpdateSchemaContext(TestModel.createTestContext()), getRef()); - subject.tell(new CreateTransaction("txn-1"), + subject.tell(new CreateTransaction("txn-1").toSerializable(), getRef()); final String out = new ExpectMsg("match hint") { @@ -126,7 +149,7 @@ public class ShardTest extends AbstractActorTest { if (in instanceof CreateTransactionReply) { CreateTransactionReply reply = (CreateTransactionReply) in; - return reply.getTransactionPath() + return reply.getTransactionActorPath() .toString(); } else { throw noMatch(); @@ -134,9 +157,8 @@ public class ShardTest extends AbstractActorTest { } }.get(); // this extracts the received message - assertEquals("Unexpected transaction path " + out, - "akka://test/user/testCreateTransaction/shard-txn-1", - out); + assertTrue("Unexpected transaction path " + out, + out.contains("akka://test/user/testCreateTransaction/shard-txn-1")); expectNoMsg(); } @@ -145,13 +167,35 @@ public class ShardTest extends AbstractActorTest { }}; } + @Test + public void testPeerAddressResolved(){ + new JavaTestKit(getSystem()) {{ + Map peerAddresses = new HashMap<>(); + peerAddresses.put("member-2", null); + final Props props = Shard.props("config", peerAddresses); + final ActorRef subject = + getSystem().actorOf(props, "testPeerAddressResolved"); + new Within(duration("1 seconds")) { + protected void run() { + + subject.tell( + new PeerAddressResolved("member-2", "akka://foobar"), + getRef()); + + expectNoMsg(); + } + + + }; + }}; + } - private AsyncDataChangeListener> noOpDataChangeListener() { - return new AsyncDataChangeListener>() { + private AsyncDataChangeListener> noOpDataChangeListener() { + return new AsyncDataChangeListener>() { @Override public void onDataChanged( - AsyncDataChangeEvent> change) { + AsyncDataChangeEvent> change) { } }; 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 b07cbfd87c..6330ad8acc 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 @@ -27,30 +27,30 @@ public class ShardTransactionChainTest extends AbstractActorTest { @Test public void testOnReceiveCreateTransaction() throws Exception { new JavaTestKit(getSystem()) {{ - final Props props = ShardTransactionChain.props(store.createTransactionChain()); + final Props props = ShardTransactionChain.props(store.createTransactionChain(), TestModel.createTestContext()); final ActorRef subject = getSystem().actorOf(props, "testCreateTransaction"); - new Within(duration("1 seconds")) { + new Within(duration("1 seconds")) { protected void run() { - subject.tell(new CreateTransaction("txn-1"), getRef()); + subject.tell(new CreateTransaction("txn-1").toSerializable(), getRef()); final String out = new ExpectMsg("match hint") { // do not put code outside this method, will run afterwards protected String match(Object in) { - if (in instanceof CreateTransactionReply) { - return ((CreateTransactionReply) in).getTransactionPath().toString(); - } else { + if (in.getClass().equals(CreateTransactionReply.SERIALIZABLE_CLASS)) { + return CreateTransactionReply.fromSerializable(in).getTransactionPath(); + }else{ throw noMatch(); } } }.get(); // this extracts the received message - assertEquals("Unexpected transaction path " + out, - "akka://test/user/testCreateTransaction/shard-txn-1", - out); + assertEquals("Unexpected transaction path " + out, + "akka://test/user/testCreateTransaction/shard-txn-1", + out); - // Will wait for the rest of the 3 seconds + // Will wait for the rest of the 3 seconds expectNoMsg(); } @@ -62,18 +62,18 @@ public class ShardTransactionChainTest extends AbstractActorTest { @Test public void testOnReceiveCloseTransactionChain() throws Exception { new JavaTestKit(getSystem()) {{ - final Props props = ShardTransactionChain.props(store.createTransactionChain()); + final Props props = ShardTransactionChain.props(store.createTransactionChain(), TestModel.createTestContext()); final ActorRef subject = getSystem().actorOf(props, "testCloseTransactionChain"); new Within(duration("1 seconds")) { protected void run() { - subject.tell(new CloseTransactionChain(), getRef()); + subject.tell(new CloseTransactionChain().toSerializable(), getRef()); final String out = new ExpectMsg("match hint") { // do not put code outside this method, will run afterwards protected String match(Object in) { - if (in instanceof CloseTransactionChainReply) { + if (in.getClass().equals(CloseTransactionChainReply.SERIALIZABLE_CLASS)) { return "match"; } else { throw noMatch(); 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 2d9ae93d9e..7884eeccda 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 @@ -26,8 +26,11 @@ import org.opendaylight.controller.cluster.datastore.modification.Modification; import org.opendaylight.controller.cluster.datastore.modification.WriteModification; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; + +import java.util.Collections; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -39,31 +42,33 @@ public class ShardTransactionTest extends AbstractActorTest { private static final InMemoryDOMDataStore store = new InMemoryDOMDataStore("OPER", storeExecutor); + private static final SchemaContext testSchemaContext = TestModel.createTestContext(); + static { - store.onGlobalContextUpdated(TestModel.createTestContext()); + store.onGlobalContextUpdated(testSchemaContext); } @Test public void testOnReceiveReadData() throws Exception { new JavaTestKit(getSystem()) {{ - final ActorRef shard = getSystem().actorOf(Shard.props("config")); + final ActorRef shard = getSystem().actorOf(Shard.props("config", Collections.EMPTY_MAP)); final Props props = - ShardTransaction.props(store.newReadWriteTransaction(), shard); + ShardTransaction.props(store.newReadWriteTransaction(), shard, testSchemaContext); final ActorRef subject = getSystem().actorOf(props, "testReadData"); new Within(duration("1 seconds")) { protected void run() { subject.tell( - new ReadData(InstanceIdentifier.builder().build()), + new ReadData(YangInstanceIdentifier.builder().build()).toSerializable(), getRef()); final String out = new ExpectMsg("match hint") { // do not put code outside this method, will run afterwards protected String match(Object in) { - if (in instanceof ReadDataReply) { - if (((ReadDataReply) in).getNormalizedNode() - != null) { + if (in.getClass().equals(ReadDataReply.SERIALIZABLE_CLASS)) { + if (ReadDataReply.fromSerializable(testSchemaContext,YangInstanceIdentifier.builder().build(), in) + .getNormalizedNode()!= null) { return "match"; } return null; @@ -86,23 +91,24 @@ public class ShardTransactionTest extends AbstractActorTest { @Test public void testOnReceiveReadDataWhenDataNotFound() throws Exception { new JavaTestKit(getSystem()) {{ - final ActorRef shard = getSystem().actorOf(Shard.props("config")); + final ActorRef shard = getSystem().actorOf(Shard.props("config", Collections.EMPTY_MAP)); final Props props = - ShardTransaction.props(store.newReadWriteTransaction(), shard); + ShardTransaction.props(store.newReadWriteTransaction(), shard, testSchemaContext); final ActorRef subject = getSystem().actorOf(props, "testReadDataWhenDataNotFound"); new Within(duration("1 seconds")) { protected void run() { subject.tell( - new ReadData(TestModel.TEST_PATH), + new ReadData(TestModel.TEST_PATH).toSerializable(), getRef()); final String out = new ExpectMsg("match hint") { // do not put code outside this method, will run afterwards protected String match(Object in) { - if (in instanceof ReadDataReply) { - if (((ReadDataReply) in).getNormalizedNode() + if (in.getClass().equals(ReadDataReply.SERIALIZABLE_CLASS)) { + if (ReadDataReply.fromSerializable(testSchemaContext,TestModel.TEST_PATH, in) + .getNormalizedNode() == null) { return "match"; } @@ -159,9 +165,9 @@ public class ShardTransactionTest extends AbstractActorTest { @Test public void testOnReceiveWriteData() throws Exception { new JavaTestKit(getSystem()) {{ - final ActorRef shard = getSystem().actorOf(Shard.props("config")); + final ActorRef shard = getSystem().actorOf(Shard.props("config", Collections.EMPTY_MAP)); final Props props = - ShardTransaction.props(store.newReadWriteTransaction(), shard); + ShardTransaction.props(store.newReadWriteTransaction(), shard, TestModel.createTestContext()); final ActorRef subject = getSystem().actorOf(props, "testWriteData"); @@ -169,13 +175,13 @@ public class ShardTransactionTest extends AbstractActorTest { protected void run() { subject.tell(new WriteData(TestModel.TEST_PATH, - ImmutableNodes.containerNode(TestModel.TEST_QNAME)), + ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext()).toSerializable(), getRef()); final String out = new ExpectMsg("match hint") { // do not put code outside this method, will run afterwards protected String match(Object in) { - if (in instanceof WriteDataReply) { + if (in.getClass().equals(WriteDataReply.SERIALIZABLE_CLASS)) { return "match"; } else { throw noMatch(); @@ -197,9 +203,9 @@ public class ShardTransactionTest extends AbstractActorTest { @Test public void testOnReceiveMergeData() throws Exception { new JavaTestKit(getSystem()) {{ - final ActorRef shard = getSystem().actorOf(Shard.props("config")); + final ActorRef shard = getSystem().actorOf(Shard.props("config", Collections.EMPTY_MAP)); final Props props = - ShardTransaction.props(store.newReadWriteTransaction(), shard); + ShardTransaction.props(store.newReadWriteTransaction(), shard, testSchemaContext); final ActorRef subject = getSystem().actorOf(props, "testMergeData"); @@ -207,13 +213,13 @@ public class ShardTransactionTest extends AbstractActorTest { protected void run() { subject.tell(new MergeData(TestModel.TEST_PATH, - ImmutableNodes.containerNode(TestModel.TEST_QNAME)), + ImmutableNodes.containerNode(TestModel.TEST_QNAME), testSchemaContext).toSerializable(), getRef()); - final String out = new ExpectMsg("match hint") { + final String out = new ExpectMsg(duration("500 milliseconds"), "match hint") { // do not put code outside this method, will run afterwards protected String match(Object in) { - if (in instanceof MergeDataReply) { + if (in.getClass().equals(MergeDataReply.SERIALIZABLE_CLASS)) { return "match"; } else { throw noMatch(); @@ -236,21 +242,21 @@ public class ShardTransactionTest extends AbstractActorTest { @Test public void testOnReceiveDeleteData() throws Exception { new JavaTestKit(getSystem()) {{ - final ActorRef shard = getSystem().actorOf(Shard.props("config")); + final ActorRef shard = getSystem().actorOf(Shard.props("config", Collections.EMPTY_MAP)); final Props props = - ShardTransaction.props(store.newReadWriteTransaction(), shard); + ShardTransaction.props(store.newReadWriteTransaction(), shard, TestModel.createTestContext()); final ActorRef subject = getSystem().actorOf(props, "testDeleteData"); new Within(duration("1 seconds")) { protected void run() { - subject.tell(new DeleteData(TestModel.TEST_PATH), getRef()); + subject.tell(new DeleteData(TestModel.TEST_PATH).toSerializable(), getRef()); final String out = new ExpectMsg("match hint") { // do not put code outside this method, will run afterwards protected String match(Object in) { - if (in instanceof DeleteDataReply) { + if (in.getClass().equals(DeleteDataReply.SERIALIZABLE_CLASS)) { return "match"; } else { throw noMatch(); @@ -273,21 +279,21 @@ public class ShardTransactionTest extends AbstractActorTest { @Test public void testOnReceiveReadyTransaction() throws Exception { new JavaTestKit(getSystem()) {{ - final ActorRef shard = getSystem().actorOf(Shard.props("config")); + final ActorRef shard = getSystem().actorOf(Shard.props("config", Collections.EMPTY_MAP)); final Props props = - ShardTransaction.props(store.newReadWriteTransaction(), shard); + ShardTransaction.props(store.newReadWriteTransaction(), shard, TestModel.createTestContext()); final ActorRef subject = getSystem().actorOf(props, "testReadyTransaction"); new Within(duration("1 seconds")) { protected void run() { - subject.tell(new ReadyTransaction(), getRef()); + subject.tell(new ReadyTransaction().toSerializable(), getRef()); final String out = new ExpectMsg("match hint") { // do not put code outside this method, will run afterwards protected String match(Object in) { - if (in instanceof ReadyTransactionReply) { + if (in.getClass().equals(ReadyTransactionReply.SERIALIZABLE_CLASS)) { return "match"; } else { throw noMatch(); @@ -309,9 +315,9 @@ public class ShardTransactionTest extends AbstractActorTest { @Test public void testOnReceiveCloseTransaction() throws Exception { new JavaTestKit(getSystem()) {{ - final ActorRef shard = getSystem().actorOf(Shard.props("config")); + final ActorRef shard = getSystem().actorOf(Shard.props("config", Collections.EMPTY_MAP)); final Props props = - ShardTransaction.props(store.newReadWriteTransaction(), shard); + ShardTransaction.props(store.newReadWriteTransaction(), shard, TestModel.createTestContext()); final ActorRef subject = getSystem().actorOf(props, "testCloseTransaction"); @@ -320,12 +326,12 @@ public class ShardTransactionTest extends AbstractActorTest { new Within(duration("2 seconds")) { protected void run() { - subject.tell(new CloseTransaction(), getRef()); + subject.tell(new CloseTransaction().toSerializable(), getRef()); final String out = new ExpectMsg("match hint") { // do not put code outside this method, will run afterwards protected String match(Object in) { - if (in instanceof CloseTransactionReply) { + if (in.getClass().equals(CloseTransactionReply.SERIALIZABLE_CLASS)) { return "match"; } else { throw noMatch(); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxyTest.java index 8ff785c879..992518e100 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxyTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxyTest.java @@ -41,7 +41,7 @@ public class ThreePhaseCommitCohortProxyTest extends AbstractActorTest { @Test public void testCanCommit() throws Exception { - actorContext.setExecuteRemoteOperationResponse(new CanCommitTransactionReply(true)); + actorContext.setExecuteRemoteOperationResponse(new CanCommitTransactionReply(true).toSerializable()); ListenableFuture future = proxy.canCommit(); @@ -51,7 +51,7 @@ public class ThreePhaseCommitCohortProxyTest extends AbstractActorTest { @Test public void testPreCommit() throws Exception { - actorContext.setExecuteRemoteOperationResponse(new PreCommitTransactionReply()); + actorContext.setExecuteRemoteOperationResponse(new PreCommitTransactionReply().toSerializable()); ListenableFuture future = proxy.preCommit(); @@ -61,7 +61,7 @@ public class ThreePhaseCommitCohortProxyTest extends AbstractActorTest { @Test public void testAbort() throws Exception { - actorContext.setExecuteRemoteOperationResponse(new AbortTransactionReply()); + actorContext.setExecuteRemoteOperationResponse(new AbortTransactionReply().toSerializable()); ListenableFuture future = proxy.abort(); @@ -71,7 +71,7 @@ public class ThreePhaseCommitCohortProxyTest extends AbstractActorTest { @Test public void testCommit() throws Exception { - actorContext.setExecuteRemoteOperationResponse(new CommitTransactionReply()); + actorContext.setExecuteRemoteOperationResponse(new CommitTransactionReply().toSerializable()); ListenableFuture future = proxy.commit(); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java index a8df49f5ca..f654e3aced 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java @@ -5,19 +5,24 @@ import akka.actor.Props; import com.google.common.base.Optional; import com.google.common.util.concurrent.ListenableFuture; import junit.framework.Assert; +import org.junit.Before; import org.junit.Test; import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction; -import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionReply; import org.opendaylight.controller.cluster.datastore.messages.DeleteData; import org.opendaylight.controller.cluster.datastore.messages.MergeData; +import org.opendaylight.controller.cluster.datastore.messages.PrimaryFound; import org.opendaylight.controller.cluster.datastore.messages.ReadDataReply; import org.opendaylight.controller.cluster.datastore.messages.ReadyTransactionReply; import org.opendaylight.controller.cluster.datastore.messages.WriteData; +import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategyFactory; import org.opendaylight.controller.cluster.datastore.utils.ActorContext; import org.opendaylight.controller.cluster.datastore.utils.DoNothingActor; import org.opendaylight.controller.cluster.datastore.utils.MessageCollectorActor; import org.opendaylight.controller.cluster.datastore.utils.MockActorContext; +import org.opendaylight.controller.cluster.datastore.utils.MockClusterWrapper; +import org.opendaylight.controller.cluster.datastore.utils.MockConfiguration; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; +import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.CreateTransactionReply; import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; @@ -28,21 +33,33 @@ import java.util.concurrent.Executors; public class TransactionProxyTest extends AbstractActorTest { + private final Configuration configuration = new MockConfiguration(); + + private final ActorContext testContext = + new ActorContext(getSystem(), getSystem().actorOf(Props.create(DoNothingActor.class)), new MockClusterWrapper(), configuration ); + private ExecutorService transactionExecutor = Executors.newSingleThreadExecutor(); + @Before + public void setUp(){ + ShardStrategyFactory.setConfiguration(configuration); + } + @Test public void testRead() throws Exception { final Props props = Props.create(DoNothingActor.class); final ActorRef actorRef = getSystem().actorOf(props); final MockActorContext actorContext = new MockActorContext(this.getSystem()); + actorContext.setExecuteLocalOperationResponse(createPrimaryFound(actorRef)); actorContext.setExecuteShardOperationResponse(createTransactionReply(actorRef)); actorContext.setExecuteRemoteOperationResponse("message"); + TransactionProxy transactionProxy = new TransactionProxy(actorContext, - TransactionProxy.TransactionType.READ_ONLY, transactionExecutor); + TransactionProxy.TransactionType.READ_ONLY, transactionExecutor, TestModel.createTestContext()); ListenableFuture>> read = @@ -53,7 +70,7 @@ public class TransactionProxyTest extends AbstractActorTest { Assert.assertFalse(normalizedNodeOptional.isPresent()); actorContext.setExecuteRemoteOperationResponse(new ReadDataReply( - ImmutableNodes.containerNode(TestModel.TEST_QNAME))); + TestModel.createTestContext(),ImmutableNodes.containerNode(TestModel.TEST_QNAME)).toSerializable()); read = transactionProxy.read(TestModel.TEST_PATH); @@ -68,12 +85,13 @@ public class TransactionProxyTest extends AbstractActorTest { final ActorRef actorRef = getSystem().actorOf(props); final MockActorContext actorContext = new MockActorContext(this.getSystem()); + actorContext.setExecuteLocalOperationResponse(createPrimaryFound(actorRef)); actorContext.setExecuteShardOperationResponse(createTransactionReply(actorRef)); actorContext.setExecuteRemoteOperationResponse("message"); TransactionProxy transactionProxy = new TransactionProxy(actorContext, - TransactionProxy.TransactionType.READ_ONLY, transactionExecutor); + TransactionProxy.TransactionType.READ_ONLY, transactionExecutor, TestModel.createTestContext()); ListenableFuture>> read = @@ -84,7 +102,7 @@ public class TransactionProxyTest extends AbstractActorTest { Assert.assertFalse(normalizedNodeOptional.isPresent()); actorContext.setExecuteRemoteOperationResponse(new ReadDataReply( - null)); + TestModel.createTestContext(), null).toSerializable()); read = transactionProxy.read(TestModel.TEST_PATH); @@ -99,17 +117,17 @@ public class TransactionProxyTest extends AbstractActorTest { final ActorRef actorRef = getSystem().actorOf(props); final MockActorContext actorContext = new MockActorContext(this.getSystem()); + actorContext.setExecuteLocalOperationResponse(createPrimaryFound(actorRef)); actorContext.setExecuteShardOperationResponse(createTransactionReply(actorRef)); actorContext.setExecuteRemoteOperationResponse("message"); TransactionProxy transactionProxy = new TransactionProxy(actorContext, - TransactionProxy.TransactionType.READ_ONLY, transactionExecutor); + TransactionProxy.TransactionType.READ_ONLY, transactionExecutor, TestModel.createTestContext()); transactionProxy.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.NAME_QNAME)); - ActorContext testContext = new ActorContext(getSystem(), getSystem().actorOf(Props.create(DoNothingActor.class))); Object messages = testContext .executeLocalOperation(actorRef, "messages", ActorContext.ASK_DURATION); @@ -122,7 +140,11 @@ public class TransactionProxyTest extends AbstractActorTest { Assert.assertEquals(1, listMessages.size()); - Assert.assertTrue(listMessages.get(0) instanceof WriteData); + Assert.assertEquals(WriteData.SERIALIZABLE_CLASS, listMessages.get(0).getClass()); + } + + private Object createPrimaryFound(ActorRef actorRef) { + return new PrimaryFound(actorRef.path().toString()).toSerializable(); } @Test @@ -131,17 +153,17 @@ public class TransactionProxyTest extends AbstractActorTest { final ActorRef actorRef = getSystem().actorOf(props); final MockActorContext actorContext = new MockActorContext(this.getSystem()); + actorContext.setExecuteLocalOperationResponse(createPrimaryFound(actorRef)); actorContext.setExecuteShardOperationResponse(createTransactionReply(actorRef)); actorContext.setExecuteRemoteOperationResponse("message"); TransactionProxy transactionProxy = new TransactionProxy(actorContext, - TransactionProxy.TransactionType.READ_ONLY, transactionExecutor); + TransactionProxy.TransactionType.READ_ONLY, transactionExecutor, TestModel.createTestContext()); transactionProxy.merge(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.NAME_QNAME)); - ActorContext testContext = new ActorContext(getSystem(), getSystem().actorOf(Props.create(DoNothingActor.class))); Object messages = testContext .executeLocalOperation(actorRef, "messages", ActorContext.ASK_DURATION); @@ -154,7 +176,7 @@ public class TransactionProxyTest extends AbstractActorTest { Assert.assertEquals(1, listMessages.size()); - Assert.assertTrue(listMessages.get(0) instanceof MergeData); + Assert.assertEquals(MergeData.SERIALIZABLE_CLASS, listMessages.get(0).getClass()); } @Test @@ -163,16 +185,16 @@ public class TransactionProxyTest extends AbstractActorTest { final ActorRef actorRef = getSystem().actorOf(props); final MockActorContext actorContext = new MockActorContext(this.getSystem()); + actorContext.setExecuteLocalOperationResponse(createPrimaryFound(actorRef)); actorContext.setExecuteShardOperationResponse(createTransactionReply(actorRef)); actorContext.setExecuteRemoteOperationResponse("message"); TransactionProxy transactionProxy = new TransactionProxy(actorContext, - TransactionProxy.TransactionType.READ_ONLY, transactionExecutor); + TransactionProxy.TransactionType.READ_ONLY, transactionExecutor, TestModel.createTestContext()); transactionProxy.delete(TestModel.TEST_PATH); - ActorContext testContext = new ActorContext(getSystem(), getSystem().actorOf(Props.create(DoNothingActor.class))); Object messages = testContext .executeLocalOperation(actorRef, "messages", ActorContext.ASK_DURATION); @@ -185,7 +207,7 @@ public class TransactionProxyTest extends AbstractActorTest { Assert.assertEquals(1, listMessages.size()); - Assert.assertTrue(listMessages.get(0) instanceof DeleteData); + Assert.assertEquals(DeleteData.SERIALIZABLE_CLASS, listMessages.get(0).getClass()); } @Test @@ -194,14 +216,17 @@ public class TransactionProxyTest extends AbstractActorTest { final ActorRef doNothingActorRef = getSystem().actorOf(props); final MockActorContext actorContext = new MockActorContext(this.getSystem()); + actorContext.setExecuteLocalOperationResponse(createPrimaryFound(doNothingActorRef)); actorContext.setExecuteShardOperationResponse(createTransactionReply(doNothingActorRef)); - actorContext.setExecuteRemoteOperationResponse(new ReadyTransactionReply(doNothingActorRef.path())); + actorContext.setExecuteRemoteOperationResponse(new ReadyTransactionReply(doNothingActorRef.path()).toSerializable()); TransactionProxy transactionProxy = new TransactionProxy(actorContext, - TransactionProxy.TransactionType.READ_ONLY, transactionExecutor); + TransactionProxy.TransactionType.READ_ONLY, transactionExecutor, TestModel.createTestContext()); + transactionProxy.read(TestModel.TEST_PATH); + DOMStoreThreePhaseCommitCohort ready = transactionProxy.ready(); Assert.assertTrue(ready instanceof ThreePhaseCommitCohortProxy); @@ -222,7 +247,7 @@ public class TransactionProxyTest extends AbstractActorTest { TransactionProxy transactionProxy = new TransactionProxy(actorContext, - TransactionProxy.TransactionType.READ_ONLY, transactionExecutor); + TransactionProxy.TransactionType.READ_ONLY, transactionExecutor, TestModel.createTestContext()); Assert.assertNotNull(transactionProxy.getIdentifier()); } @@ -233,16 +258,18 @@ public class TransactionProxyTest extends AbstractActorTest { final ActorRef actorRef = getSystem().actorOf(props); final MockActorContext actorContext = new MockActorContext(this.getSystem()); + actorContext.setExecuteLocalOperationResponse(createPrimaryFound(actorRef)); actorContext.setExecuteShardOperationResponse(createTransactionReply(actorRef)); actorContext.setExecuteRemoteOperationResponse("message"); TransactionProxy transactionProxy = new TransactionProxy(actorContext, - TransactionProxy.TransactionType.READ_ONLY, transactionExecutor); + TransactionProxy.TransactionType.READ_ONLY, transactionExecutor, TestModel.createTestContext()); + + transactionProxy.read(TestModel.TEST_PATH); transactionProxy.close(); - ActorContext testContext = new ActorContext(getSystem(), getSystem().actorOf(Props.create(DoNothingActor.class))); Object messages = testContext .executeLocalOperation(actorRef, "messages", ActorContext.ASK_DURATION); @@ -255,10 +282,13 @@ public class TransactionProxyTest extends AbstractActorTest { Assert.assertEquals(1, listMessages.size()); - Assert.assertTrue(listMessages.get(0) instanceof CloseTransaction); + Assert.assertTrue(listMessages.get(0).getClass().equals(CloseTransaction.SERIALIZABLE_CLASS)); } private CreateTransactionReply createTransactionReply(ActorRef actorRef){ - return new CreateTransactionReply(actorRef.path(), "txn-1"); + return CreateTransactionReply.newBuilder() + .setTransactionActorPath(actorRef.path().toString()) + .setTransactionId("txn-1") + .build(); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardStatsTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardStatsTest.java new file mode 100644 index 0000000000..f7c467652d --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardStatsTest.java @@ -0,0 +1,55 @@ +package org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.controller.cluster.datastore.jmx.mbeans.AbstractBaseMBean; + +import javax.management.MBeanServer; +import javax.management.ObjectName; + +public class ShardStatsTest { + private MBeanServer mbeanServer; + private ShardStats shardStats; + private ObjectName testMBeanName; + + @Before + public void setUp() throws Exception { + + shardStats = new ShardStats("shard-1"); + shardStats.registerMBean(); + mbeanServer= shardStats.getMBeanServer(); + String objectName = AbstractBaseMBean.BASE_JMX_PREFIX + "type="+shardStats.getMBeanType()+",Category="+ + shardStats.getMBeanCategory() + ",name="+ + shardStats.getMBeanName(); + testMBeanName = new ObjectName(objectName); + } + + @After + public void tearDown() throws Exception { + shardStats.unregisterMBean(); + } + + @Test + public void testGetShardName() throws Exception { + + Object attribute = mbeanServer.getAttribute(testMBeanName,"ShardName"); + Assert.assertEquals((String) attribute, "shard-1"); + + } + + @Test + public void testGetCommittedTransactionsCount() throws Exception { + //let us increment some transactions count and then check + shardStats.incrementCommittedTransactionCount(); + shardStats.incrementCommittedTransactionCount(); + shardStats.incrementCommittedTransactionCount(); + + //now let us get from MBeanServer what is the transaction count. + Object attribute = mbeanServer.getAttribute(testMBeanName,"CommittedTransactionsCount"); + Assert.assertEquals((Long) attribute, (Long)3L); + + + } +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/MergeDataTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/MergeDataTest.java new file mode 100644 index 0000000000..75128e6a25 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/MergeDataTest.java @@ -0,0 +1,47 @@ +package org.opendaylight.controller.cluster.datastore.messages; + +import junit.framework.Assert; +import org.junit.Test; +import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec; +import org.opendaylight.controller.md.cluster.datastore.model.TestModel; +import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; + +public class MergeDataTest { + + @Test + public void testBasic(){ + MergeData mergeData = new MergeData(TestModel.TEST_PATH, ImmutableNodes + .containerNode(TestModel.TEST_QNAME), + TestModel.createTestContext()); + + MergeData output = MergeData + .fromSerializable(mergeData.toSerializable(), + TestModel.createTestContext()); + + } + + @Test + public void testNormalizedNodeEncodeDecode(){ + NormalizedNode expected = + ImmutableNodes.containerNode(TestModel.TEST_QNAME); + + + NormalizedNodeMessages.Container node = + new NormalizedNodeToNodeCodec(TestModel.createTestContext()) + .encode(TestModel.TEST_PATH, + expected); + + String parentPath = node.getParentPath(); + + NormalizedNodeMessages.Node normalizedNode = + node.getNormalizedNode(); + + NormalizedNode actual = new NormalizedNodeToNodeCodec(TestModel.createTestContext()).decode(TestModel.TEST_PATH, + normalizedNode); + + + Assert.assertEquals(expected, actual); + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModificationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModificationTest.java index efaca5d4f6..d9c550a6db 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModificationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModificationTest.java @@ -17,7 +17,7 @@ import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction; import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; public abstract class AbstractModificationTest { @@ -36,7 +36,7 @@ public abstract class AbstractModificationTest { cohort.commit(); } - protected Optional> readData(InstanceIdentifier path) throws Exception{ + protected Optional> readData(YangInstanceIdentifier path) throws Exception{ DOMStoreReadTransaction transaction = store.newReadOnlyTransaction(); ListenableFuture>> future = transaction.read(path); return future.get(); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModificationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModificationTest.java index c1f9f3a631..b33f902929 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModificationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModificationTest.java @@ -15,7 +15,7 @@ public class DeleteModificationTest extends AbstractModificationTest{ public void testApply() throws Exception { //Write something into the datastore DOMStoreReadWriteTransaction writeTransaction = store.newReadWriteTransaction(); - WriteModification writeModification = new WriteModification(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); + WriteModification writeModification = new WriteModification(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext()); writeModification.apply(writeTransaction); commitTransaction(writeTransaction); @@ -32,4 +32,4 @@ public class DeleteModificationTest extends AbstractModificationTest{ data = readData(TestModel.TEST_PATH); Assert.assertFalse(data.isPresent()); } -} \ No newline at end of file +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MergeModificationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MergeModificationTest.java index fd125fb79d..9af3439ae1 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MergeModificationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MergeModificationTest.java @@ -16,7 +16,7 @@ public class MergeModificationTest extends AbstractModificationTest{ //Write something into the datastore DOMStoreReadWriteTransaction writeTransaction = store.newReadWriteTransaction(); - MergeModification writeModification = new MergeModification(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); + MergeModification writeModification = new MergeModification(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext()); writeModification.apply(writeTransaction); commitTransaction(writeTransaction); @@ -25,4 +25,4 @@ public class MergeModificationTest extends AbstractModificationTest{ Assert.assertTrue(data.isPresent()); } -} \ No newline at end of file +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModificationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModificationTest.java index e30936b327..7a21c8cdc5 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModificationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModificationTest.java @@ -14,7 +14,7 @@ public class MutableCompositeModificationTest extends AbstractModificationTest { public void testApply() throws Exception { MutableCompositeModification compositeModification = new MutableCompositeModification(); - compositeModification.addModification(new WriteModification(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME))); + compositeModification.addModification(new WriteModification(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext())); DOMStoreReadWriteTransaction transaction = store.newReadWriteTransaction(); compositeModification.apply(transaction); @@ -25,4 +25,4 @@ public class MutableCompositeModificationTest extends AbstractModificationTest { Assert.assertNotNull(data.get()); Assert.assertEquals(TestModel.TEST_QNAME, data.get().getNodeType()); } -} \ No newline at end of file +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/WriteModificationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/WriteModificationTest.java index e206bf8196..75d8c00db8 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/WriteModificationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/WriteModificationTest.java @@ -14,7 +14,7 @@ public class WriteModificationTest extends AbstractModificationTest{ public void testApply() throws Exception { //Write something into the datastore DOMStoreReadWriteTransaction writeTransaction = store.newReadWriteTransaction(); - WriteModification writeModification = new WriteModification(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); + WriteModification writeModification = new WriteModification(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext()); writeModification.apply(writeTransaction); commitTransaction(writeTransaction); @@ -23,4 +23,4 @@ public class WriteModificationTest extends AbstractModificationTest{ Assert.assertTrue(data.isPresent()); } -} \ No newline at end of file +} 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 new file mode 100644 index 0000000000..88753e4b0a --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategyTest.java @@ -0,0 +1,33 @@ +package org.opendaylight.controller.cluster.datastore.shardstrategy; + +import junit.framework.Assert; +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; +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; + +public class ModuleShardStrategyTest { + @Rule + public ExpectedException expectedEx = ExpectedException.none(); + + private static Configuration configuration; + + @BeforeClass + public static void setUpClass(){ + configuration = new ConfigurationImpl("module-shards.conf", "modules.conf"); + } + + + @Test + public void testFindShard() throws Exception { + ModuleShardStrategy moduleShardStrategy = + new ModuleShardStrategy("cars", configuration); + + String shard = moduleShardStrategy.findShard(CarsModel.BASE_PATH); + + Assert.assertEquals("cars-1", shard); + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactoryTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactoryTest.java index 2cff981b68..ab74ba811a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactoryTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactoryTest.java @@ -1,29 +1,49 @@ package org.opendaylight.controller.cluster.datastore.shardstrategy; +import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.opendaylight.controller.cluster.datastore.ConfigurationImpl; +import org.opendaylight.controller.md.cluster.datastore.model.CarsModel; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import static junit.framework.Assert.assertNotNull; +import static junit.framework.Assert.assertTrue; public class ShardStrategyFactoryTest { - @Rule - public ExpectedException expectedEx = ExpectedException.none(); + @Rule + public ExpectedException expectedEx = ExpectedException.none(); - @Test - public void testGetStrategy(){ - ShardStrategy strategy = ShardStrategyFactory.getStrategy(TestModel.TEST_PATH); - assertNotNull(strategy); - } + @BeforeClass + public static void setUpClass(){ + ShardStrategyFactory.setConfiguration(new ConfigurationImpl("module-shards.conf", "modules.conf")); + } - @Test - public void testGetStrategyNullPointerExceptionWhenPathIsNull(){ - expectedEx.expect(NullPointerException.class); - expectedEx.expectMessage("path should not be null"); + @Test + public void testGetStrategy() { + ShardStrategy strategy = + ShardStrategyFactory.getStrategy(TestModel.TEST_PATH); + assertNotNull(strategy); + } - ShardStrategyFactory.getStrategy(null); - } + @Test + public void testGetStrategyForKnownModuleName() { + ShardStrategy strategy = + ShardStrategyFactory.getStrategy( + YangInstanceIdentifier.of(CarsModel.BASE_QNAME)); + assertTrue(strategy instanceof ModuleShardStrategy); + } -} \ No newline at end of file + + @Test + public void testGetStrategyNullPointerExceptionWhenPathIsNull() { + expectedEx.expect(NullPointerException.class); + expectedEx.expectMessage("path should not be null"); + + ShardStrategyFactory.getStrategy(null); + } + +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java new file mode 100644 index 0000000000..3dd0214e9b --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java @@ -0,0 +1,47 @@ +package org.opendaylight.controller.cluster.datastore.utils; + +import akka.actor.ActorRef; +import akka.actor.ActorSystem; +import org.junit.Test; +import org.opendaylight.controller.cluster.datastore.AbstractActorTest; +import org.opendaylight.controller.cluster.datastore.ClusterWrapper; +import org.opendaylight.controller.cluster.datastore.Configuration; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; + +public class ActorContextTest extends AbstractActorTest{ + @Test + public void testResolvePathForRemoteActor(){ + ActorContext actorContext = + new ActorContext(mock(ActorSystem.class), mock(ActorRef.class),mock( + ClusterWrapper.class), + mock(Configuration.class)); + + String actual = actorContext.resolvePath( + "akka.tcp://system@127.0.0.1:2550/user/shardmanager/shard", + "akka://system/user/shardmanager/shard/transaction"); + + String expected = "akka.tcp://system@127.0.0.1:2550/user/shardmanager/shard/transaction"; + + assertEquals(expected, actual); + } + + @Test + public void testResolvePathForLocalActor(){ + ActorContext actorContext = + new ActorContext(getSystem(), mock(ActorRef.class), mock(ClusterWrapper.class), + mock(Configuration.class)); + + String actual = actorContext.resolvePath( + "akka://system/user/shardmanager/shard", + "akka://system/user/shardmanager/shard/transaction"); + + String expected = "akka://system/user/shardmanager/shard/transaction"; + + assertEquals(expected, actual); + + System.out.println(actorContext + .actorFor("akka://system/user/shardmanager/shard/transaction")); + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockActorContext.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockActorContext.java index fe62516098..1d1e661488 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockActorContext.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockActorContext.java @@ -21,11 +21,11 @@ public class MockActorContext extends ActorContext { private Object executeLocalOperationResponse; public MockActorContext(ActorSystem actorSystem) { - super(actorSystem, null); + super(actorSystem, null, new MockClusterWrapper(), new MockConfiguration()); } public MockActorContext(ActorSystem actorSystem, ActorRef shardManager) { - super(actorSystem, shardManager); + super(actorSystem, shardManager, new MockClusterWrapper(), new MockConfiguration()); } @@ -56,5 +56,8 @@ public class MockActorContext extends ActorContext { this.executeLocalOperationResponse = executeLocalOperationResponse; } - + @Override public Object executeLocalOperation(ActorRef actor, + Object message, FiniteDuration duration) { + return this.executeLocalOperationResponse; + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockClusterWrapper.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockClusterWrapper.java new file mode 100644 index 0000000000..803aa03b7c --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockClusterWrapper.java @@ -0,0 +1,69 @@ +/* + * 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.utils; + +import akka.actor.ActorRef; +import akka.actor.AddressFromURIString; +import akka.cluster.ClusterEvent; +import akka.cluster.MemberStatus; +import akka.cluster.UniqueAddress; +import org.opendaylight.controller.cluster.datastore.ClusterWrapper; +import scala.collection.JavaConversions; + +import java.util.HashSet; +import java.util.Set; + +public class MockClusterWrapper implements ClusterWrapper{ + + @Override public void subscribeToMemberEvents(ActorRef actorRef) { + } + + @Override public String getCurrentMemberName() { + return "member-1"; + } + + public static void sendMemberUp(ActorRef to, String memberName, String address){ + to.tell(createMemberUp(memberName, address), null); + } + + public static void sendMemberRemoved(ActorRef to, String memberName, String address){ + to.tell(createMemberRemoved(memberName, address), null); + } + + private static ClusterEvent.MemberRemoved createMemberRemoved(String memberName, String address) { + akka.cluster.UniqueAddress uniqueAddress = new UniqueAddress( + AddressFromURIString.parse(address), 55); + + Set roles = new HashSet<>(); + + roles.add(memberName); + + akka.cluster.Member member = new akka.cluster.Member(uniqueAddress, 1, MemberStatus + .removed(), + JavaConversions.asScalaSet(roles).toSet()); + + return new ClusterEvent.MemberRemoved(member, MemberStatus.up()); + + } + + + private static ClusterEvent.MemberUp createMemberUp(String memberName, String address) { + akka.cluster.UniqueAddress uniqueAddress = new UniqueAddress( + AddressFromURIString.parse(address), 55); + + Set roles = new HashSet<>(); + + roles.add(memberName); + + akka.cluster.Member member = new akka.cluster.Member(uniqueAddress, 1, MemberStatus.up(), + JavaConversions.asScalaSet(roles).toSet()); + + return new ClusterEvent.MemberUp(member); + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockConfiguration.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockConfiguration.java new file mode 100644 index 0000000000..8d49c6fac3 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockConfiguration.java @@ -0,0 +1,49 @@ +/* + * 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.utils; + +import com.google.common.base.Optional; +import org.opendaylight.controller.cluster.datastore.Configuration; +import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategy; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +public class MockConfiguration implements Configuration{ + @Override public List getMemberShardNames(String memberName) { + return Arrays.asList("default"); + } + + @Override public Optional getModuleNameFromNameSpace( + String nameSpace) { + return Optional.absent(); + } + + @Override + public Map getModuleNameToShardStrategyMap() { + return Collections.EMPTY_MAP; + } + + @Override public List getShardNamesFromModuleName( + String moduleName) { + return Collections.EMPTY_LIST; + } + + @Override public List getMembersFromShardName(String shardName) { + if("default".equals(shardName)) { + return Arrays.asList("member-1", "member-2"); + } else if("astronauts".equals(shardName)){ + return Arrays.asList("member-2", "member-3"); + } + + return Collections.EMPTY_LIST; + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/TestUtils.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/TestUtils.java index bb881d5322..939096e7f3 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/TestUtils.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/TestUtils.java @@ -19,7 +19,7 @@ public class TestUtils { public static void assertFirstSentMessage(ActorSystem actorSystem, ActorRef actorRef, Class clazz){ ActorContext testContext = new ActorContext(actorSystem, actorSystem.actorOf( - Props.create(DoNothingActor.class))); + Props.create(DoNothingActor.class)), new MockClusterWrapper(), new MockConfiguration()); Object messages = testContext .executeLocalOperation(actorRef, "messages", ActorContext.ASK_DURATION); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CarsModel.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CarsModel.java new file mode 100644 index 0000000000..6860872b75 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CarsModel.java @@ -0,0 +1,72 @@ +/* + * 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.cluster.datastore.model; + +import java.math.BigInteger; +import org.opendaylight.yangtools.yang.common.QName; +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.impl.schema.ImmutableNodes; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder; + +public class CarsModel { + public static final QName BASE_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test:cars", "2014-03-13", + "cars"); + + public static final YangInstanceIdentifier BASE_PATH = YangInstanceIdentifier.of(BASE_QNAME); + + public static final QName CARS_QNAME = QName.create(BASE_QNAME, "cars"); + public static final QName CAR_QNAME = QName.create(CARS_QNAME, "car"); + public static final QName CAR_NAME_QNAME = QName.create(CAR_QNAME, "name"); + public static final QName CAR_PRICE_QNAME = QName.create(CAR_QNAME, "price"); + + + public static NormalizedNode create(){ + + // Create a list builder + CollectionNodeBuilder cars = + ImmutableMapNodeBuilder.create().withNodeIdentifier( + new YangInstanceIdentifier.NodeIdentifier( + CAR_QNAME)); + + // Create an entry for the car altima + MapEntryNode altima = + ImmutableNodes.mapEntryBuilder(CAR_QNAME, CAR_NAME_QNAME, "altima") + .withChild(ImmutableNodes.leafNode(CAR_NAME_QNAME, "altima")) + .withChild(ImmutableNodes.leafNode(CAR_PRICE_QNAME, new BigInteger("1000"))) + .build(); + + // Create an entry for the car accord + MapEntryNode honda = + ImmutableNodes.mapEntryBuilder(CAR_QNAME, CAR_NAME_QNAME, "accord") + .withChild(ImmutableNodes.leafNode(CAR_NAME_QNAME, "accord")) + .withChild(ImmutableNodes.leafNode(CAR_PRICE_QNAME, new BigInteger("2000"))) + .build(); + + cars.withChild(altima); + cars.withChild(honda); + + return ImmutableContainerNodeBuilder.create() + .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(BASE_QNAME)) + .withChild(cars.build()) + .build(); + + } + + public static NormalizedNode emptyContainer(){ + return ImmutableContainerNodeBuilder.create() + .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(BASE_QNAME)) + .build(); + } + +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CompositeModel.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CompositeModel.java new file mode 100644 index 0000000000..ece312752d --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CompositeModel.java @@ -0,0 +1,372 @@ +package org.opendaylight.controller.md.cluster.datastore.model; + +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode; +import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; +import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; +import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode; +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.schema.Builders; +import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; +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.api.DataContainerNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder; +import org.opendaylight.yangtools.yang.model.api.Module; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry; +import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder; +import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder; + +public class CompositeModel { + + 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 AUG_QNAME = QName.create( + "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:aug", + "2014-03-13", "name"); + + public static final QName DESC_QNAME = QName.create(TEST_QNAME, "desc"); + 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"); + public static final QName ID_QNAME = QName.create(TEST_QNAME, "id"); + public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name"); + public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value"); + private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang"; + private static final String DATASTORE_AUG_YANG = + "/odl-datastore-augmentation.yang"; + private static final String DATASTORE_TEST_NOTIFICATION_YANG = + "/odl-datastore-test-notification.yang"; + + + public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier + .of(TEST_QNAME); + public static final YangInstanceIdentifier DESC_PATH = YangInstanceIdentifier + .builder(TEST_PATH).node(DESC_QNAME).build(); + 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"); + + private static final Integer ONE_ID = 1; + private static final Integer TWO_ID = 2; + private static final String TWO_ONE_NAME = "one"; + private static final String TWO_TWO_NAME = "two"; + private static final String DESC = "Hello there"; + + // Family specific constants + public static final QName FAMILY_QNAME = + QName + .create( + "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:notification-test", + "2014-04-17", "family"); + public static final QName CHILDREN_QNAME = QName.create(FAMILY_QNAME, + "children"); + public static final QName GRAND_CHILDREN_QNAME = QName.create(FAMILY_QNAME, + "grand-children"); + public static final QName CHILD_NUMBER_QNAME = QName.create(FAMILY_QNAME, + "child-number"); + public static final QName CHILD_NAME_QNAME = QName.create(FAMILY_QNAME, + "child-name"); + public static final QName GRAND_CHILD_NUMBER_QNAME = QName.create( + FAMILY_QNAME, "grand-child-number"); + public static final QName GRAND_CHILD_NAME_QNAME = QName.create(FAMILY_QNAME, + "grand-child-name"); + + public static final YangInstanceIdentifier FAMILY_PATH = YangInstanceIdentifier + .of(FAMILY_QNAME); + public static final YangInstanceIdentifier FAMILY_DESC_PATH = YangInstanceIdentifier + .builder(FAMILY_PATH).node(DESC_QNAME).build(); + public static final YangInstanceIdentifier CHILDREN_PATH = YangInstanceIdentifier + .builder(FAMILY_PATH).node(CHILDREN_QNAME).build(); + + private static final Integer FIRST_CHILD_ID = 1; + private static final Integer SECOND_CHILD_ID = 2; + + private static final String FIRST_CHILD_NAME = "first child"; + private static final String SECOND_CHILD_NAME = "second child"; + + private static final Integer FIRST_GRAND_CHILD_ID = 1; + private static final Integer SECOND_GRAND_CHILD_ID = 2; + + private static final String FIRST_GRAND_CHILD_NAME = "first grand child"; + private static final String SECOND_GRAND_CHILD_NAME = "second grand child"; + + // first child + private static final YangInstanceIdentifier CHILDREN_1_PATH = YangInstanceIdentifier + .builder(CHILDREN_PATH) + .nodeWithKey(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID) // + .build(); + private static final YangInstanceIdentifier CHILDREN_1_NAME_PATH = + YangInstanceIdentifier.builder(CHILDREN_PATH) + .nodeWithKey(CHILDREN_QNAME, CHILD_NAME_QNAME, FIRST_CHILD_NAME) // + .build(); + + private static final YangInstanceIdentifier CHILDREN_2_PATH = YangInstanceIdentifier + .builder(CHILDREN_PATH) + .nodeWithKey(CHILDREN_QNAME, CHILD_NUMBER_QNAME, SECOND_CHILD_ID) // + .build(); + private static final YangInstanceIdentifier CHILDREN_2_NAME_PATH = + YangInstanceIdentifier.builder(CHILDREN_PATH) + .nodeWithKey(CHILDREN_QNAME, CHILD_NAME_QNAME, SECOND_CHILD_NAME) // + .build(); + + + private static final YangInstanceIdentifier GRAND_CHILD_1_PATH = + YangInstanceIdentifier.builder(CHILDREN_1_PATH) + .node(GRAND_CHILDREN_QNAME) + // + .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, + FIRST_GRAND_CHILD_ID) // + .build(); + + private static final YangInstanceIdentifier GRAND_CHILD_1_NAME_PATH = + YangInstanceIdentifier.builder(CHILDREN_1_PATH) + .node(GRAND_CHILDREN_QNAME) + // + .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NAME_QNAME, + FIRST_GRAND_CHILD_NAME) // + .build(); + + private static final YangInstanceIdentifier GRAND_CHILD_2_PATH = + YangInstanceIdentifier.builder(CHILDREN_2_PATH) + .node(GRAND_CHILDREN_QNAME) + // + .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, + SECOND_GRAND_CHILD_ID) // + .build(); + + private static final YangInstanceIdentifier GRAND_CHILD_2_NAME_PATH = + YangInstanceIdentifier.builder(CHILDREN_2_PATH) + .node(GRAND_CHILDREN_QNAME) + // + .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NAME_QNAME, + SECOND_GRAND_CHILD_NAME) // + .build(); + + private static final YangInstanceIdentifier DESC_PATH_ID = YangInstanceIdentifier + .builder(DESC_PATH).build(); + private static final YangInstanceIdentifier OUTER_LIST_1_PATH = + YangInstanceIdentifier.builder(OUTER_LIST_PATH) + .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, ONE_ID) // + .build(); + + private static final YangInstanceIdentifier OUTER_LIST_2_PATH = + YangInstanceIdentifier.builder(OUTER_LIST_PATH) + .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, TWO_ID) // + .build(); + + private static final YangInstanceIdentifier TWO_TWO_PATH = YangInstanceIdentifier + .builder(OUTER_LIST_2_PATH).node(INNER_LIST_QNAME) // + .nodeWithKey(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME) // + .build(); + + private static final YangInstanceIdentifier TWO_TWO_VALUE_PATH = + YangInstanceIdentifier.builder(TWO_TWO_PATH).node(VALUE_QNAME) // + .build(); + + private static final MapEntryNode BAR_NODE = mapEntryBuilder( + OUTER_LIST_QNAME, ID_QNAME, TWO_ID) // + .withChild(mapNodeBuilder(INNER_LIST_QNAME) // + .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_ONE_NAME)) // + .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME)) // + .build()) // + .build(); + + public static final InputStream getDatastoreTestInputStream() { + return getInputStream(DATASTORE_TEST_YANG); + } + + public static final InputStream getDatastoreAugInputStream() { + return getInputStream(DATASTORE_AUG_YANG); + } + + public static final InputStream getDatastoreTestNotificationInputStream() { + return getInputStream(DATASTORE_TEST_NOTIFICATION_YANG); + } + + private static InputStream getInputStream(final String resourceName) { + return TestModel.class.getResourceAsStream(resourceName); + } + + public static SchemaContext createTestContext() { + List inputStreams = new ArrayList<>(); + inputStreams.add(getDatastoreTestInputStream()); + inputStreams.add(getDatastoreAugInputStream()); + inputStreams.add(getDatastoreTestNotificationInputStream()); + + YangParserImpl parser = new YangParserImpl(); + Set modules = parser.parseYangModelsFromStreams(inputStreams); + return parser.resolveSchemaContext(modules); + } + + /** + * Returns a test document + * + *
+   * test
+   *     outer-list
+   *          id 1
+   *     outer-list
+   *          id 2
+   *          inner-list
+   *                  name "one"
+   *          inner-list
+   *                  name "two"
+   *
+   * 
+ * + * @return + */ + public static NormalizedNode createDocumentOne( + SchemaContext schemaContext) { + return ImmutableContainerNodeBuilder + .create() + .withNodeIdentifier( + new YangInstanceIdentifier.NodeIdentifier(schemaContext.getQName())) + .withChild(createTestContainer()).build(); + + } + + public static ContainerNode createTestContainer() { + + + final LeafSetEntryNode nike = + ImmutableLeafSetEntryNodeBuilder + .create() + .withNodeIdentifier( + new YangInstanceIdentifier.NodeWithValue(QName.create(TEST_QNAME, + "shoe"), "nike")).withValue("nike").build(); + final LeafSetEntryNode puma = + ImmutableLeafSetEntryNodeBuilder + .create() + .withNodeIdentifier( + new YangInstanceIdentifier.NodeWithValue(QName.create(TEST_QNAME, + "shoe"), "puma")).withValue("puma").build(); + final LeafSetNode shoes = + ImmutableLeafSetNodeBuilder + .create() + .withNodeIdentifier( + new YangInstanceIdentifier.NodeIdentifier(QName.create(TEST_QNAME, + "shoe"))).withChild(nike).withChild(puma).build(); + + + final LeafSetEntryNode five = + ImmutableLeafSetEntryNodeBuilder + .create() + .withNodeIdentifier( + (new YangInstanceIdentifier.NodeWithValue(QName.create(TEST_QNAME, + "number"), 5))).withValue(5).build(); + final LeafSetEntryNode fifteen = + ImmutableLeafSetEntryNodeBuilder + .create() + .withNodeIdentifier( + (new YangInstanceIdentifier.NodeWithValue(QName.create(TEST_QNAME, + "number"), 15))).withValue(15).build(); + final LeafSetNode numbers = + ImmutableLeafSetNodeBuilder + .create() + .withNodeIdentifier( + new YangInstanceIdentifier.NodeIdentifier(QName.create(TEST_QNAME, + "number"))).withChild(five).withChild(fifteen).build(); + + + Set childAugmentations = new HashSet<>(); + childAugmentations.add(AUG_QNAME); + final YangInstanceIdentifier.AugmentationIdentifier augmentationIdentifier = + new YangInstanceIdentifier.AugmentationIdentifier(null, childAugmentations); + final AugmentationNode augmentationNode = + Builders.augmentationBuilder() + .withNodeIdentifier(augmentationIdentifier) + .withChild(ImmutableNodes.leafNode(AUG_QNAME, "First Test")) + .build(); + return ImmutableContainerNodeBuilder + .create() + .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME)) + .withChild(ImmutableNodes.leafNode(DESC_QNAME, DESC)) + .withChild(augmentationNode) + .withChild(shoes) + .withChild(numbers) + .withChild( + mapNodeBuilder(OUTER_LIST_QNAME) + .withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID)) + .withChild(BAR_NODE).build()).build(); + + } + + + public static ContainerNode createFamily() { + final DataContainerNodeAttrBuilder familyContainerBuilder = + ImmutableContainerNodeBuilder.create().withNodeIdentifier( + new YangInstanceIdentifier.NodeIdentifier(FAMILY_QNAME)); + + final CollectionNodeBuilder childrenBuilder = + mapNodeBuilder(CHILDREN_QNAME); + + final DataContainerNodeBuilder firstChildBuilder = + mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID); + final DataContainerNodeBuilder secondChildBuilder = + mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, SECOND_CHILD_ID); + + final DataContainerNodeBuilder firstGrandChildBuilder = + mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, + FIRST_GRAND_CHILD_ID); + final DataContainerNodeBuilder secondGrandChildBuilder = + mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, + SECOND_GRAND_CHILD_ID); + + firstGrandChildBuilder + .withChild( + ImmutableNodes.leafNode(GRAND_CHILD_NUMBER_QNAME, + FIRST_GRAND_CHILD_ID)).withChild( + ImmutableNodes.leafNode(GRAND_CHILD_NAME_QNAME, + FIRST_GRAND_CHILD_NAME)); + + secondGrandChildBuilder.withChild( + ImmutableNodes + .leafNode(GRAND_CHILD_NUMBER_QNAME, SECOND_GRAND_CHILD_ID)) + .withChild( + ImmutableNodes.leafNode(GRAND_CHILD_NAME_QNAME, + SECOND_GRAND_CHILD_NAME)); + + firstChildBuilder + .withChild(ImmutableNodes.leafNode(CHILD_NUMBER_QNAME, FIRST_CHILD_ID)) + .withChild(ImmutableNodes.leafNode(CHILD_NAME_QNAME, FIRST_CHILD_NAME)) + .withChild( + mapNodeBuilder(GRAND_CHILDREN_QNAME).withChild( + firstGrandChildBuilder.build()).build()); + + + secondChildBuilder + .withChild(ImmutableNodes.leafNode(CHILD_NUMBER_QNAME, SECOND_CHILD_ID)) + .withChild(ImmutableNodes.leafNode(CHILD_NAME_QNAME, SECOND_CHILD_NAME)) + .withChild( + mapNodeBuilder(GRAND_CHILDREN_QNAME).withChild( + firstGrandChildBuilder.build()).build()); + + childrenBuilder.withChild(firstChildBuilder.build()); + childrenBuilder.withChild(secondChildBuilder.build()); + + return familyContainerBuilder.withChild(childrenBuilder.build()).build(); + } + +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/PeopleModel.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/PeopleModel.java new file mode 100644 index 0000000000..e637920e78 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/PeopleModel.java @@ -0,0 +1,72 @@ +/* + * 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.cluster.datastore.model; + +import org.opendaylight.yangtools.yang.common.QName; +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.impl.schema.ImmutableNodes; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder; + +public class PeopleModel { + public static final QName BASE_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test:people", "2014-03-13", + "people"); + + public static final YangInstanceIdentifier BASE_PATH = YangInstanceIdentifier.of(BASE_QNAME); + public static final QName PEOPLE_QNAME = QName.create(BASE_QNAME, "people"); + public static final QName PERSON_QNAME = QName.create(PEOPLE_QNAME, "person"); + public static final QName PERSON_NAME_QNAME = QName.create(PERSON_QNAME, "name"); + public static final QName PERSON_AGE_QNAME = QName.create(PERSON_QNAME, "age"); + + + + public static NormalizedNode create(){ + + // Create a list builder + CollectionNodeBuilder cars = + ImmutableMapNodeBuilder.create().withNodeIdentifier( + new YangInstanceIdentifier.NodeIdentifier( + PERSON_QNAME)); + + // Create an entry for the person jack + MapEntryNode jack = + ImmutableNodes.mapEntryBuilder(PERSON_QNAME, PERSON_NAME_QNAME, "jack") + .withChild(ImmutableNodes.leafNode(PERSON_NAME_QNAME, "jack")) + .withChild(ImmutableNodes.leafNode(PERSON_AGE_QNAME, 100L)) + .build(); + + // Create an entry for the person jill + MapEntryNode jill = + ImmutableNodes.mapEntryBuilder(PERSON_QNAME, PERSON_NAME_QNAME, "jill") + .withChild(ImmutableNodes.leafNode(PERSON_NAME_QNAME, "jill")) + .withChild(ImmutableNodes.leafNode(PERSON_AGE_QNAME, 200L)) + .build(); + + cars.withChild(jack); + cars.withChild(jill); + + return ImmutableContainerNodeBuilder.create() + .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(BASE_QNAME)) + .withChild(cars.build()) + .build(); + + } + + public static NormalizedNode emptyContainer(){ + return ImmutableContainerNodeBuilder.create() + .withNodeIdentifier( + new YangInstanceIdentifier.NodeIdentifier(BASE_QNAME)) + .build(); + } + +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/SampleModelsTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/SampleModelsTest.java new file mode 100644 index 0000000000..be8713c702 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/SampleModelsTest.java @@ -0,0 +1,62 @@ +/* + * 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.cluster.datastore.model; + +import junit.framework.Assert; +import org.junit.Test; +import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec; +import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; + +public class SampleModelsTest { + @Test + public void testPeopleModel(){ + final NormalizedNode expected = PeopleModel.create(); + + + final NormalizedNodeMessages.Container node = + new NormalizedNodeToNodeCodec(SchemaContextHelper.full()) + .encode(YangInstanceIdentifier.of(PeopleModel.BASE_QNAME), + expected); + + final NormalizedNodeMessages.Node normalizedNode = + node.getNormalizedNode(); + + final NormalizedNode actual = new NormalizedNodeToNodeCodec(SchemaContextHelper.full()).decode(YangInstanceIdentifier.of(PeopleModel.BASE_QNAME), + normalizedNode); + + + Assert.assertEquals(expected, actual); + + } + + + @Test + public void testCarsModel(){ + final NormalizedNode expected = CarsModel.create(); + + + final NormalizedNodeMessages.Container node = + new NormalizedNodeToNodeCodec(SchemaContextHelper.full()) + .encode(YangInstanceIdentifier.of(CarsModel.BASE_QNAME), + expected); + + final NormalizedNodeMessages.Node normalizedNode = + node.getNormalizedNode(); + + final NormalizedNode actual = new NormalizedNodeToNodeCodec(SchemaContextHelper.full()).decode( + YangInstanceIdentifier.of(CarsModel.BASE_QNAME), + normalizedNode); + + + Assert.assertEquals(expected, actual); + + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/SchemaContextHelper.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/SchemaContextHelper.java new file mode 100644 index 0000000000..3395738846 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/SchemaContextHelper.java @@ -0,0 +1,37 @@ +/* + * 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.cluster.datastore.model; + +import org.opendaylight.yangtools.yang.model.api.Module; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +public class SchemaContextHelper { + + public static InputStream getInputStream(final String yangFileName) { + return TestModel.class.getResourceAsStream(yangFileName); + } + + public static SchemaContext full(){ + YangParserImpl parser = new YangParserImpl(); + List streams = new ArrayList<>(); + streams.add(getInputStream("/odl-datastore-test.yang")); + streams.add(getInputStream("/people.yang")); + streams.add(getInputStream("/cars.yang")); + + Set modules = parser.parseYangModelsFromStreams(streams); + return parser.resolveSchemaContext(modules); + + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/TestModel.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/TestModel.java index 7a1def9f89..85441eca0d 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/TestModel.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/TestModel.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.md.cluster.datastore.model; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl; @@ -29,8 +29,8 @@ public class TestModel { public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value"); private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang"; - public static final InstanceIdentifier TEST_PATH = InstanceIdentifier.of(TEST_QNAME); - public static final InstanceIdentifier OUTER_LIST_PATH = InstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build(); + public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_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-distributed-datastore/src/test/resources/application.conf b/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/application.conf index 2647850667..aebff27c7d 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,11 +1,14 @@ akka { actor { - serializers { - java = "akka.serialization.JavaSerializer" - } + serializers { + java = "akka.serialization.JavaSerializer" + proto = "akka.remote.serialization.ProtobufSerializer" + } serialization-bindings { "org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification" = java + "com.google.protobuf.Message" = proto + } } -} \ No newline at end of file +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/cars.yang b/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/cars.yang new file mode 100644 index 0000000000..d83135ee64 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/cars.yang @@ -0,0 +1,22 @@ +module cars { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test:cars"; + prefix "cars"; + + revision "2014-03-13" { + description "Initial revision."; + } + + container cars { + list car { + key name; + leaf name { + type string; + } + + leaf price { + type uint64; + } + } + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/module-shards.conf b/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/module-shards.conf new file mode 100644 index 0000000000..b3de998479 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/module-shards.conf @@ -0,0 +1,49 @@ +module-shards = [ + { + name = "default" + shards = [ + { + name="default", + replicas = [ + "member-1", + "member-2", + "member-3" + ] + } + ] + }, + { + name = "people" + shards = [ + { + name="people-1" + replicas = [ + "member-1" + ] + } + ] + }, + { + name = "cars" + shards = [ + { + name="cars-1" + replicas = [ + "member-1" + ] + } + ] + }, + { + name = "test" + shards = [ + { + name="test-1" + replicas = [ + "member-1" + ] + } + ] + } + +] 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 new file mode 100644 index 0000000000..22854cb11a --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/modules.conf @@ -0,0 +1,18 @@ +modules = [ + { + name = "people" + namespace = "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test:people" + shard-strategy = "module" + }, + { + name = "cars" + namespace = "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test:cars" + shard-strategy = "module" + }, + { + name = "test" + namespace = "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test" + shard-strategy = "module" + } + +] diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/odl-datastore-augmentation.yang b/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/odl-datastore-augmentation.yang new file mode 100644 index 0000000000..77d74c47d3 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/odl-datastore-augmentation.yang @@ -0,0 +1,19 @@ +module odl-datastore-augmentation { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:aug"; + prefix "store-aug"; + + import odl-datastore-test {prefix test;revision-date "2014-03-13";} + + revision "2014-03-13" { + description "Initial revision."; + } + + + augment "/test:test" { + leaf name { + type string; + } + } + +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/odl-datastore-test-notification.yang b/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/odl-datastore-test-notification.yang new file mode 100644 index 0000000000..25cc53ab93 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/odl-datastore-test-notification.yang @@ -0,0 +1,33 @@ +module odl-datastore-test-notification { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:notification-test"; + prefix "notification-test-using-family-model"; + + revision "2014-04-17" { + description "Family structure created on "; + } + + container family { + leaf desc { + type string; + } + list children { + key child-number; + leaf child-number { + type uint16; + } + leaf child-name { + type string; + } + list grand-children { + key grand-child-number; + leaf grand-child-number { + type uint16; + } + leaf grand-child-name { + type string; + } + } + } + } +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/people.yang b/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/people.yang new file mode 100644 index 0000000000..7ede0e65cb --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/people.yang @@ -0,0 +1,22 @@ +module people { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test:people"; + prefix "people"; + + revision "2014-03-13" { + description "Initial revision."; + } + + container people { + list person { + key name; + leaf name { + type string; + } + + leaf age { + type uint32; + } + } + } +} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataBroker.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataBroker.java index e85534cdd3..fdb864059f 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataBroker.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataBroker.java @@ -10,7 +10,7 @@ import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker; import org.opendaylight.controller.md.sal.common.api.data.TransactionChainFactory; import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; import org.opendaylight.controller.sal.core.api.BrokerService; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; /** @@ -22,8 +22,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; * */ public interface DOMDataBroker extends - AsyncDataBroker, DOMDataChangeListener>, - TransactionChainFactory>, BrokerService, DOMService { + AsyncDataBroker, DOMDataChangeListener>, + TransactionChainFactory>, BrokerService, DOMService { /** * {@inheritDoc} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataChangeListener.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataChangeListener.java index d1f01760d2..393d1eaafe 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataChangeListener.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataChangeListener.java @@ -8,9 +8,9 @@ package org.opendaylight.controller.md.sal.dom.api; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -public interface DOMDataChangeListener extends AsyncDataChangeListener> { +public interface DOMDataChangeListener extends AsyncDataChangeListener> { } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadOnlyTransaction.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadOnlyTransaction.java index 18fb988661..856272f1f6 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadOnlyTransaction.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadOnlyTransaction.java @@ -1,9 +1,9 @@ package org.opendaylight.controller.md.sal.dom.api; import org.opendaylight.controller.md.sal.common.api.data.AsyncReadOnlyTransaction; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -public interface DOMDataReadOnlyTransaction extends DOMDataReadTransaction, AsyncReadOnlyTransaction> { +public interface DOMDataReadOnlyTransaction extends DOMDataReadTransaction, AsyncReadOnlyTransaction> { } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadTransaction.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadTransaction.java index 0d5e47faee..afa2286d53 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadTransaction.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadTransaction.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.md.sal.dom.api; import org.opendaylight.controller.md.sal.common.api.data.AsyncReadTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import com.google.common.base.Optional; @@ -20,7 +20,7 @@ import com.google.common.util.concurrent.ListenableFuture; *

* For more information on usage and examples, please see the documentation in {@link AsyncReadTransaction}. */ -public interface DOMDataReadTransaction extends AsyncReadTransaction> { +public interface DOMDataReadTransaction extends AsyncReadTransaction> { /** * Reads data from provided logical data store located at the provided path. @@ -42,5 +42,5 @@ public interface DOMDataReadTransaction extends AsyncReadTransaction */ - ListenableFuture>> read(LogicalDatastoreType store,InstanceIdentifier path); + ListenableFuture>> read(LogicalDatastoreType store,YangInstanceIdentifier path); } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadWriteTransaction.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadWriteTransaction.java index 55600b0730..d5fc5c957c 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadWriteTransaction.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadWriteTransaction.java @@ -8,9 +8,9 @@ package org.opendaylight.controller.md.sal.dom.api; import org.opendaylight.controller.md.sal.common.api.data.AsyncReadWriteTransaction; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -public interface DOMDataReadWriteTransaction extends DOMDataReadTransaction, DOMDataWriteTransaction, AsyncReadWriteTransaction> { +public interface DOMDataReadWriteTransaction extends DOMDataReadTransaction, DOMDataWriteTransaction, AsyncReadWriteTransaction> { } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataWriteTransaction.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataWriteTransaction.java index 6a8977154c..b8fe26387b 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataWriteTransaction.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataWriteTransaction.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.md.sal.dom.api; import org.opendaylight.controller.md.sal.common.api.data.AsyncWriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; /** @@ -17,7 +17,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; *

* For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}. */ -public interface DOMDataWriteTransaction extends AsyncWriteTransaction> { +public interface DOMDataWriteTransaction extends AsyncWriteTransaction> { /** * Stores a piece of data at the specified path. This acts as an add / replace @@ -37,7 +37,7 @@ public interface DOMDataWriteTransaction extends AsyncWriteTransaction data); + void put(LogicalDatastoreType store, YangInstanceIdentifier path, NormalizedNode data); /** * Merges a piece of data with the existing data at a specified path. Any pre-existing data @@ -57,5 +57,5 @@ public interface DOMDataWriteTransaction extends AsyncWriteTransaction data); + void merge(LogicalDatastoreType store, YangInstanceIdentifier path, NormalizedNode data); } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMMountPoint.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMMountPoint.java index c0baf19c66..1431155f9f 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMMountPoint.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMMountPoint.java @@ -9,12 +9,12 @@ package org.opendaylight.controller.md.sal.dom.api; import org.opendaylight.yangtools.concepts.Identifiable; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import com.google.common.base.Optional; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -public interface DOMMountPoint extends Identifiable { +public interface DOMMountPoint extends Identifiable { Optional getService(Class cls); diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMMountPointService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMMountPointService.java index 3155bd50ab..6023038b6a 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMMountPointService.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMMountPointService.java @@ -12,7 +12,7 @@ import org.opendaylight.controller.sal.core.api.BrokerService; 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.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import com.google.common.base.Optional; @@ -20,9 +20,9 @@ import com.google.common.base.Optional; public interface DOMMountPointService extends BrokerService { - Optional getMountPoint(InstanceIdentifier path); + Optional getMountPoint(YangInstanceIdentifier path); - DOMMountPointBuilder createMountPoint(InstanceIdentifier path); + DOMMountPointBuilder createMountPoint(YangInstanceIdentifier path); ListenerRegistration registerProvisionListener(MountProvisionListener listener); diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMTransactionChain.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMTransactionChain.java index 73a0c28465..2d2fa48c05 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMTransactionChain.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMTransactionChain.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.md.sal.dom.api; import org.opendaylight.controller.md.sal.common.api.data.TransactionChain; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; /** @@ -21,7 +21,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; *

* This interface is type capture of {@link TransactionChain} for DOM Data Contracts. */ -public interface DOMTransactionChain extends TransactionChain> { +public interface DOMTransactionChain extends TransactionChain> { @Override DOMDataReadOnlyTransaction newReadOnlyTransaction(); diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Broker.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Broker.java index b48f6cb61a..203bd40329 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Broker.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Broker.java @@ -16,7 +16,7 @@ import org.opendaylight.yangtools.concepts.ObjectRegistration; 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.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.osgi.framework.BundleContext; /** @@ -250,6 +250,6 @@ public interface Broker { void close(); } - public interface RoutedRpcRegistration extends RpcRegistration, RoutedRegistration { + public interface RoutedRpcRegistration extends RpcRegistration, RoutedRegistration { } } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RoutedRpcDefaultImplementation.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RoutedRpcDefaultImplementation.java index 4f11ba0661..7a7b144fed 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RoutedRpcDefaultImplementation.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RoutedRpcDefaultImplementation.java @@ -10,12 +10,12 @@ package org.opendaylight.controller.sal.core.api; 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.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import com.google.common.util.concurrent.ListenableFuture; public interface RoutedRpcDefaultImplementation { - ListenableFuture> invokeRpc(QName rpc, InstanceIdentifier identifier, CompositeNode input); + ListenableFuture> invokeRpc(QName rpc, YangInstanceIdentifier identifier, CompositeNode input); } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcProvisionRegistry.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcProvisionRegistry.java index 13a50090c0..050225c5c2 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcProvisionRegistry.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcProvisionRegistry.java @@ -13,9 +13,9 @@ import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration; import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -public interface RpcProvisionRegistry extends RpcImplementation, BrokerService, RouteChangePublisher, DOMService { +public interface RpcProvisionRegistry extends RpcImplementation, BrokerService, RouteChangePublisher, DOMService { /** * Registers an implementation of the rpc. diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataBrokerService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataBrokerService.java index 9c7deaf406..88289b3106 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataBrokerService.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataBrokerService.java @@ -12,7 +12,7 @@ import org.opendaylight.controller.md.sal.common.api.data.DataModificationTransa import org.opendaylight.controller.md.sal.common.api.data.DataReader; import org.opendaylight.controller.sal.core.api.BrokerService; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; /** @@ -27,16 +27,16 @@ import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; @Deprecated public interface DataBrokerService extends BrokerService, // - DataReader, // - DataModificationTransactionFactory, // - DataChangePublisher { + DataReader, // + DataModificationTransactionFactory, // + DataChangePublisher { @Override - public CompositeNode readConfigurationData(InstanceIdentifier path); + public CompositeNode readConfigurationData(YangInstanceIdentifier path); @Override - public CompositeNode readOperationalData(InstanceIdentifier path); + public CompositeNode readOperationalData(YangInstanceIdentifier path); @Override DataModificationTransaction beginTransaction(); diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataChangeListener.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataChangeListener.java index 2bf949d208..47ac2d78af 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataChangeListener.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataChangeListener.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.sal.core.api.data; import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; /** * @@ -18,8 +18,8 @@ import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; @Deprecated public interface DataChangeListener extends - org.opendaylight.controller.md.sal.common.api.data.DataChangeListener { + org.opendaylight.controller.md.sal.common.api.data.DataChangeListener { @Override - public void onDataChanged(DataChangeEvent change); + public void onDataChanged(DataChangeEvent change); } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataModificationTransaction.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataModificationTransaction.java index 82e62255c3..dd5755e33c 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataModificationTransaction.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataModificationTransaction.java @@ -15,7 +15,7 @@ import org.opendaylight.controller.md.sal.common.api.data.DataModification; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; /** * @@ -27,7 +27,7 @@ import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; * */ @Deprecated -public interface DataModificationTransaction extends DataModification { +public interface DataModificationTransaction extends DataModification { /** * Returns transaction identifier diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataProviderService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataProviderService.java index 97b640647a..194da91695 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataProviderService.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataProviderService.java @@ -13,7 +13,7 @@ import org.opendaylight.controller.sal.common.DataStoreIdentifier; import org.opendaylight.controller.sal.core.api.Provider; import org.opendaylight.yangtools.concepts.Registration; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; /** * @@ -23,7 +23,7 @@ import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; @Deprecated public interface DataProviderService extends DataBrokerService, // - DataProvisionService + DataProvisionService { /** @@ -63,9 +63,9 @@ public interface DataProviderService extends void removeRefresher(DataStoreIdentifier store, DataRefresher refresher); - Registration registerConfigurationReader(InstanceIdentifier path, DataReader reader); + Registration registerConfigurationReader(YangInstanceIdentifier path, DataReader reader); - Registration registerOperationalReader(InstanceIdentifier path, DataReader reader); + Registration registerOperationalReader(YangInstanceIdentifier path, DataReader reader); public interface DataRefresher extends Provider.ProviderFunctionality { diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataStore.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataStore.java index 56d2e87c2c..d66d04816b 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataStore.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataStore.java @@ -10,7 +10,7 @@ package org.opendaylight.controller.sal.core.api.data; import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler; import org.opendaylight.controller.md.sal.common.api.data.DataReader; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; /** * @@ -19,14 +19,14 @@ import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; */ @Deprecated public interface DataStore extends // - DataReader, - DataCommitHandler { + DataReader, + DataCommitHandler { - Iterable getStoredConfigurationPaths(); - Iterable getStoredOperationalPaths(); + Iterable getStoredConfigurationPaths(); + Iterable getStoredOperationalPaths(); - boolean containsConfigurationPath(InstanceIdentifier path); - boolean containsOperationalPath(InstanceIdentifier path); + boolean containsConfigurationPath(YangInstanceIdentifier path); + boolean containsOperationalPath(YangInstanceIdentifier path); } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountProvisionListener.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountProvisionListener.java index 64851472e6..1d724e4a8c 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountProvisionListener.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountProvisionListener.java @@ -9,12 +9,12 @@ package org.opendaylight.controller.sal.core.api.mount; import java.util.EventListener; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; public interface MountProvisionListener extends EventListener { - void onMountPointCreated(InstanceIdentifier path); + void onMountPointCreated(YangInstanceIdentifier path); - void onMountPointRemoved(InstanceIdentifier path); + void onMountPointRemoved(YangInstanceIdentifier path); } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountProvisionService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountProvisionService.java index 807b020b72..37c30b6784 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountProvisionService.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountProvisionService.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.sal.core.api.mount; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; /** * @deprecated Use org.opendaylight.controller.md.sal.dom.api.DOMMountPointService instead @@ -17,11 +17,11 @@ import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; public interface MountProvisionService extends MountService { @Override - public MountProvisionInstance getMountPoint(InstanceIdentifier path); + public MountProvisionInstance getMountPoint(YangInstanceIdentifier path); - MountProvisionInstance createMountPoint(InstanceIdentifier path); + MountProvisionInstance createMountPoint(YangInstanceIdentifier path); - MountProvisionInstance createOrGetMountPoint(InstanceIdentifier path); + MountProvisionInstance createOrGetMountPoint(YangInstanceIdentifier path); ListenerRegistration registerProvisionListener(MountProvisionListener listener); diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountService.java index a730203f47..55b74c63d3 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountService.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountService.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.sal.core.api.mount; import org.opendaylight.controller.sal.core.api.BrokerService; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; /** * Client-level interface for interacting with mount points. It provides access @@ -24,5 +24,5 @@ public interface MountService extends BrokerService { * @param path Path at which the instance is registered * @return Reference to the instance, or null if no such instance exists. */ - MountInstance getMountPoint(InstanceIdentifier path); + MountInstance getMountPoint(YangInstanceIdentifier path); } diff --git a/opendaylight/md-sal/sal-dom-broker/pom.xml b/opendaylight/md-sal/sal-dom-broker/pom.xml index 022882fceb..96e353b80e 100644 --- a/opendaylight/md-sal/sal-dom-broker/pom.xml +++ b/opendaylight/md-sal/sal-dom-broker/pom.xml @@ -65,6 +65,12 @@ org.slf4j slf4j-api + + + org.opendaylight.yangtools + mockito-configuration + test + org.slf4j slf4j-simple @@ -84,14 +90,17 @@ ${project.groupId}.${project.artifactId} org.opendaylight.controller.sal.dom.broker.osgi.SchemaServiceActivator - org.opendaylight.controller.sal.dom.broker.spi - org.opendaylight.controller.sal.dom.broker, + org.opendaylight.controller.sal.dom.broker.spi, + + org.opendaylight.controller.sal.dom.broker.impl, org.opendaylight.controller.sal.dom.broker.impl.*, + + org.opendaylight.controller.sal.dom.broker, org.opendaylight.controller.sal.dom.broker.osgi, org.opendaylight.controller.sal.dom.broker.util, org.opendaylight.controller.config.yang.md.sal.dom.impl, - org.opendaylight.controller.config.yang.md.sal.dom.statistics, + org.opendaylight.controller.config.yang.md.sal.dom.statistics,\ org.opendaylight.controller.md.sal.dom.broker.impl, org.opendaylight.controller.md.sal.dom.broker.impl.*, org.opendaylight.yangtools.yang.util, diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomBrokerImplModule.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomBrokerImplModule.java index 998d884b0c..17b78f4ebd 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomBrokerImplModule.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomBrokerImplModule.java @@ -7,8 +7,12 @@ */ package org.opendaylight.controller.config.yang.md.sal.dom.impl; +import com.google.common.collect.ClassToInstanceMap; +import com.google.common.collect.MutableClassToInstanceMap; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; +import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; import org.opendaylight.controller.md.sal.dom.broker.impl.compat.BackwardsCompatibleDataBroker; +import org.opendaylight.controller.md.sal.dom.broker.impl.mount.DOMMountPointServiceImpl; import org.opendaylight.controller.sal.core.api.BrokerService; import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry; import org.opendaylight.controller.sal.core.api.data.DataBrokerService; @@ -17,17 +21,14 @@ import org.opendaylight.controller.sal.core.api.data.DataStore; import org.opendaylight.controller.sal.core.api.model.SchemaService; import org.opendaylight.controller.sal.core.api.mount.MountProvisionService; import org.opendaylight.controller.sal.core.api.mount.MountService; +import org.opendaylight.controller.sal.dom.broker.BackwardsCompatibleMountPointManager; import org.opendaylight.controller.sal.dom.broker.BrokerImpl; import org.opendaylight.controller.sal.dom.broker.DataBrokerImpl; import org.opendaylight.controller.sal.dom.broker.GlobalBundleScanningSchemaServiceImpl; -import org.opendaylight.controller.sal.dom.broker.MountPointManagerImpl; import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareDataStoreAdapter; import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareRpcBroker; import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProviders; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; - -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.MutableClassToInstanceMap; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; /** * @@ -72,16 +73,19 @@ public final class DomBrokerImplModule extends org.opendaylight.controller.confi services.putInstance(DataProviderService.class,legacyData); services.putInstance(DataBrokerService.class, legacyData); + final DOMMountPointService mountService = new DOMMountPointServiceImpl(); + services.putInstance(DOMMountPointService.class, mountService); - MountPointManagerImpl mountService = new MountPointManagerImpl(); - services.putInstance(MountService.class, mountService); - services.putInstance(MountProvisionService.class, mountService); + // TODO remove backwards service, use only new DOMMountPointService + final MountProvisionService backwardsMountService = new BackwardsCompatibleMountPointManager(mountService); + services.putInstance(MountService.class, backwardsMountService); + services.putInstance(MountProvisionService.class, backwardsMountService); return new BrokerImpl(router, services); } private DataProviderService createLegacyDataService(final DataStore legacyStore, final SchemaService schemaService) { - InstanceIdentifier rootPath = InstanceIdentifier.builder().toInstance(); + YangInstanceIdentifier rootPath = YangInstanceIdentifier.builder().toInstance(); DataBrokerImpl dataService = new DataBrokerImpl(); SchemaAwareDataStoreAdapter wrappedStore = new SchemaAwareDataStoreAdapter(); wrappedStore.changeDelegate(legacyStore); diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMForwardedCompositeTransaction.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMForwardedCompositeTransaction.java index 0be4327f7a..d3791a0878 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMForwardedCompositeTransaction.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMForwardedCompositeTransaction.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.md.sal.dom.broker.impl; import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransaction; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import com.google.common.base.Preconditions; @@ -27,7 +27,7 @@ import com.google.common.collect.ImmutableMap; * Subtransaction type */ abstract class AbstractDOMForwardedCompositeTransaction implements - AsyncTransaction> { + AsyncTransaction> { private final ImmutableMap backingTxs; private final Object identifier; diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataBrokerImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataBrokerImpl.java index 7731646a57..d1b9a8f600 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataBrokerImpl.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataBrokerImpl.java @@ -23,7 +23,7 @@ import org.opendaylight.controller.sal.core.spi.data.DOMStore; import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,7 +54,7 @@ public class DOMDataBrokerImpl extends AbstractDOMForwardedTransactionFactory registerDataChangeListener(final LogicalDatastoreType store, - final InstanceIdentifier path, final DOMDataChangeListener listener, final DataChangeScope triggeringScope) { + final YangInstanceIdentifier path, final DOMDataChangeListener listener, final DataChangeScope triggeringScope) { DOMStore potentialStore = getTxFactories().get(store); checkState(potentialStore != null, "Requested logical data store is not available."); diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedReadOnlyTransaction.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedReadOnlyTransaction.java index f207783c29..c8edcbc6e2 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedReadOnlyTransaction.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedReadOnlyTransaction.java @@ -10,7 +10,7 @@ package org.opendaylight.controller.md.sal.dom.broker.impl; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import com.google.common.base.Optional; @@ -22,7 +22,7 @@ import com.google.common.util.concurrent.ListenableFuture; * Read Only Transaction, which is composed of several * {@link DOMStoreReadTransaction} transactions. Subtransaction is selected by * {@link LogicalDatastoreType} type parameter in - * {@link #read(LogicalDatastoreType, InstanceIdentifier)}. + * {@link #read(LogicalDatastoreType, YangInstanceIdentifier)}. */ class DOMForwardedReadOnlyTransaction extends AbstractDOMForwardedCompositeTransaction implements @@ -35,7 +35,7 @@ class DOMForwardedReadOnlyTransaction extends @Override public ListenableFuture>> read(final LogicalDatastoreType store, - final InstanceIdentifier path) { + final YangInstanceIdentifier path) { return getSubtransaction(store).read(path); } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedReadWriteTransaction.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedReadWriteTransaction.java index e1d27e453b..e6521b2377 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedReadWriteTransaction.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedReadWriteTransaction.java @@ -9,7 +9,7 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import com.google.common.base.Optional; @@ -23,10 +23,10 @@ import com.google.common.util.concurrent.ListenableFuture; * {@link LogicalDatastoreType} type parameter in: * *

    - *
  • {@link #read(LogicalDatastoreType, InstanceIdentifier)} - *
  • {@link #put(LogicalDatastoreType, InstanceIdentifier, NormalizedNode)} - *
  • {@link #delete(LogicalDatastoreType, InstanceIdentifier)} - *
  • {@link #merge(LogicalDatastoreType, InstanceIdentifier, NormalizedNode)} + *
  • {@link #read(LogicalDatastoreType, YangInstanceIdentifier)} + *
  • {@link #put(LogicalDatastoreType, YangInstanceIdentifier, NormalizedNode)} + *
  • {@link #delete(LogicalDatastoreType, YangInstanceIdentifier)} + *
  • {@link #merge(LogicalDatastoreType, YangInstanceIdentifier, NormalizedNode)} *
* {@link #commit()} will result in invocation of * {@link DOMDataCommitImplementation#submit(org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction, Iterable)} @@ -46,7 +46,7 @@ class DOMForwardedReadWriteTransaction extends DOMForwardedWriteTransaction>> read(final LogicalDatastoreType store, - final InstanceIdentifier path) { + final YangInstanceIdentifier path) { return getSubtransaction(store).read(path); } } \ No newline at end of file diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedWriteTransaction.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedWriteTransaction.java index 5bddd763fb..5d4ad4d803 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedWriteTransaction.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedWriteTransaction.java @@ -19,7 +19,7 @@ import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import com.google.common.base.Preconditions; @@ -36,9 +36,9 @@ import com.google.common.util.concurrent.ListenableFuture; * {@link LogicalDatastoreType} type parameter in: * *
    - *
  • {@link #put(LogicalDatastoreType, InstanceIdentifier, NormalizedNode)} - *
  • {@link #delete(LogicalDatastoreType, InstanceIdentifier)} - *
  • {@link #merge(LogicalDatastoreType, InstanceIdentifier, NormalizedNode)} + *
  • {@link #put(LogicalDatastoreType, YangInstanceIdentifier, NormalizedNode)} + *
  • {@link #delete(LogicalDatastoreType, YangInstanceIdentifier)} + *
  • {@link #merge(LogicalDatastoreType, YangInstanceIdentifier, NormalizedNode)} *
*

* {@link #commit()} will result in invocation of @@ -86,19 +86,19 @@ class DOMForwardedWriteTransaction extends } @Override - public void put(final LogicalDatastoreType store, final InstanceIdentifier path, final NormalizedNode data) { + public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data) { checkNotReady(); getSubtransaction(store).write(path, data); } @Override - public void delete(final LogicalDatastoreType store, final InstanceIdentifier path) { + public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) { checkNotReady(); getSubtransaction(store).delete(path); } @Override - public void merge(final LogicalDatastoreType store, final InstanceIdentifier path, final NormalizedNode data) { + public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data) { checkNotReady(); getSubtransaction(store).merge(path, data); } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/BackwardsCompatibleDataBroker.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/BackwardsCompatibleDataBroker.java index 8405a78c33..e8f8da53c9 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/BackwardsCompatibleDataBroker.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/BackwardsCompatibleDataBroker.java @@ -18,7 +18,7 @@ import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.concepts.Registration; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener; @@ -36,7 +36,7 @@ public class BackwardsCompatibleDataBroker implements DataProviderService { } @Override - public CompositeNode readConfigurationData(final InstanceIdentifier legacyPath) { + public CompositeNode readConfigurationData(final YangInstanceIdentifier legacyPath) { final BackwardsCompatibleTransaction tx = BackwardsCompatibleTransaction.readOnlyTransaction(backingBroker.newReadOnlyTransaction(),normalizer); try { return tx.readConfigurationData(legacyPath); @@ -46,7 +46,7 @@ public class BackwardsCompatibleDataBroker implements DataProviderService { } @Override - public CompositeNode readOperationalData(final InstanceIdentifier legacyPath) { + public CompositeNode readOperationalData(final YangInstanceIdentifier legacyPath) { final BackwardsCompatibleTransaction tx = BackwardsCompatibleTransaction.readOnlyTransaction(backingBroker.newReadOnlyTransaction(),normalizer); try { return tx.readOperationalData(legacyPath); @@ -61,9 +61,9 @@ public class BackwardsCompatibleDataBroker implements DataProviderService { } @Override - public ListenerRegistration registerDataChangeListener(final InstanceIdentifier legacyPath, + public ListenerRegistration registerDataChangeListener(final YangInstanceIdentifier legacyPath, final DataChangeListener listener) { - final InstanceIdentifier normalizedPath = normalizer.toNormalized(legacyPath); + final YangInstanceIdentifier normalizedPath = normalizer.toNormalized(legacyPath); final TranslatingListenerInvoker translatingCfgListener = TranslatingListenerInvoker.createConfig(listener, normalizer); @@ -78,9 +78,9 @@ public class BackwardsCompatibleDataBroker implements DataProviderService { @Override public Registration registerCommitHandler( - final InstanceIdentifier path, final DataCommitHandler commitHandler) { + final YangInstanceIdentifier path, final DataCommitHandler commitHandler) { // FIXME Do real forwarding - return new AbstractObjectRegistration>(commitHandler) { + return new AbstractObjectRegistration>(commitHandler) { @Override protected void removeRegistration() { // NOOP @@ -89,8 +89,8 @@ public class BackwardsCompatibleDataBroker implements DataProviderService { } @Override - public ListenerRegistration>> registerCommitHandlerListener( - final RegistrationListener> commitHandlerListener) { + public ListenerRegistration>> registerCommitHandlerListener( + final RegistrationListener> commitHandlerListener) { return null; } @@ -118,13 +118,13 @@ public class BackwardsCompatibleDataBroker implements DataProviderService { @Override public Registration registerConfigurationReader( - final InstanceIdentifier path, final DataReader reader) { + final YangInstanceIdentifier path, final DataReader reader) { throw new UnsupportedOperationException("Data Reader contract is not supported."); } @Override public Registration registerOperationalReader( - final InstanceIdentifier path, final DataReader reader) { + final YangInstanceIdentifier path, final DataReader reader) { throw new UnsupportedOperationException("Data Reader contract is not supported."); } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/BackwardsCompatibleTransaction.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/BackwardsCompatibleTransaction.java index f57579858c..70baaae339 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/BackwardsCompatibleTransaction.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/BackwardsCompatibleTransaction.java @@ -33,8 +33,8 @@ import org.opendaylight.yangtools.concepts.Delegator; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -90,9 +90,9 @@ DataModificationTransaction, Delegator { }; @Override - public CompositeNode readConfigurationData(final InstanceIdentifier legacyPath) { + public CompositeNode readConfigurationData(final YangInstanceIdentifier legacyPath) { - InstanceIdentifier normalizedPath = normalizer.toNormalized(legacyPath); + YangInstanceIdentifier normalizedPath = normalizer.toNormalized(legacyPath); ListenableFuture>> normalizedData = asyncTx.read( LogicalDatastoreType.CONFIGURATION, normalizedPath); @@ -105,8 +105,8 @@ DataModificationTransaction, Delegator { } @Override - public CompositeNode readOperationalData(final InstanceIdentifier legacyPath) { - InstanceIdentifier normalizedPath = normalizer.toNormalized(legacyPath); + public CompositeNode readOperationalData(final YangInstanceIdentifier legacyPath) { + YangInstanceIdentifier normalizedPath = normalizer.toNormalized(legacyPath); ListenableFuture>> normalizedData = asyncTx.read( LogicalDatastoreType.OPERATIONAL, normalizedPath); @@ -124,62 +124,62 @@ DataModificationTransaction, Delegator { } @Override - public Map getCreatedConfigurationData() { + public Map getCreatedConfigurationData() { return Collections.emptyMap(); } @Override - public Map getCreatedOperationalData() { + public Map getCreatedOperationalData() { return Collections.emptyMap(); } @Override - public Map getOriginalConfigurationData() { + public Map getOriginalConfigurationData() { return Collections.emptyMap(); } @Override - public Map getOriginalOperationalData() { + public Map getOriginalOperationalData() { return Collections.emptyMap(); } @Override - public Set getRemovedConfigurationData() { + public Set getRemovedConfigurationData() { return Collections.emptySet(); } @Override - public Set getRemovedOperationalData() { + public Set getRemovedOperationalData() { return Collections.emptySet(); } @Override - public Map getUpdatedConfigurationData() { + public Map getUpdatedConfigurationData() { return Collections.emptyMap(); } @Override - public Map getUpdatedOperationalData() { + public Map getUpdatedOperationalData() { return Collections.emptyMap(); } @Override - public void putConfigurationData(final InstanceIdentifier path, final CompositeNode data) { + public void putConfigurationData(final YangInstanceIdentifier path, final CompositeNode data) { throw new UnsupportedOperationException(); } @Override - public void putOperationalData(final InstanceIdentifier path, final CompositeNode data) { + public void putOperationalData(final YangInstanceIdentifier path, final CompositeNode data) { throw new UnsupportedOperationException(); } @Override - public void removeConfigurationData(final InstanceIdentifier path) { + public void removeConfigurationData(final YangInstanceIdentifier path) { throw new UnsupportedOperationException(); } @Override - public void removeOperationalData(final InstanceIdentifier path) { + public void removeOperationalData(final YangInstanceIdentifier path) { throw new UnsupportedOperationException(); } @@ -209,22 +209,22 @@ DataModificationTransaction, Delegator { } @Override - public void putConfigurationData(final InstanceIdentifier legacyPath, final CompositeNode legacyData) { + public void putConfigurationData(final YangInstanceIdentifier legacyPath, final CompositeNode legacyData) { checkNotNull(legacyPath, "Path MUST NOT be null."); checkNotNull(legacyData, "Data for path %s MUST NOT be null",legacyData); - Entry> normalizedData = getNormalizer().toNormalized(legacyPath, legacyData); + Entry> normalizedData = getNormalizer().toNormalized(legacyPath, legacyData); putWithEnsuredParents(LogicalDatastoreType.CONFIGURATION, normalizedData.getKey(), normalizedData.getValue()); } @Override - public void putOperationalData(final InstanceIdentifier legacyPath, final CompositeNode legacyData) { + public void putOperationalData(final YangInstanceIdentifier legacyPath, final CompositeNode legacyData) { checkNotNull(legacyPath, "Path MUST NOT be null."); checkNotNull(legacyData, "Data for path %s MUST NOT be null",legacyData); - Entry> normalizedData = getNormalizer().toNormalized(legacyPath, legacyData); + Entry> normalizedData = getNormalizer().toNormalized(legacyPath, legacyData); putWithEnsuredParents(LogicalDatastoreType.OPERATIONAL, normalizedData.getKey(), normalizedData.getValue()); } - private void putWithEnsuredParents(final LogicalDatastoreType store, final InstanceIdentifier normalizedPath, + private void putWithEnsuredParents(final LogicalDatastoreType store, final YangInstanceIdentifier normalizedPath, final NormalizedNode normalizedData) { LOG.trace("write {}:{} ",store,normalizedPath); @@ -240,7 +240,7 @@ DataModificationTransaction, Delegator { throw new IllegalArgumentException(String.format("Invalid child encountered in path %s", normalizedPath), e); } currentArguments.add(currentArg); - InstanceIdentifier currentPath = InstanceIdentifier.create(currentArguments); + YangInstanceIdentifier currentPath = YangInstanceIdentifier.create(currentArguments); boolean isPresent = getDelegate().read(store, currentPath).get().isPresent(); if(isPresent == false && iterator.hasNext()) { getDelegate().merge(store, currentPath, currentOp.createDefault(currentArg)); @@ -254,13 +254,13 @@ DataModificationTransaction, Delegator { } @Override - public void removeConfigurationData(final InstanceIdentifier legacyPath) { + public void removeConfigurationData(final YangInstanceIdentifier legacyPath) { checkNotNull(legacyPath, "Path MUST NOT be null."); getDelegate().delete(LogicalDatastoreType.CONFIGURATION, getNormalizer().toNormalized(legacyPath)); } @Override - public void removeOperationalData(final InstanceIdentifier legacyPath) { + public void removeOperationalData(final YangInstanceIdentifier legacyPath) { checkNotNull(legacyPath, "Path MUST NOT be null."); getDelegate().delete(LogicalDatastoreType.OPERATIONAL, getNormalizer().toNormalized(legacyPath)); } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/TranslatingDataChangeEvent.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/TranslatingDataChangeEvent.java index 3de07fc2ab..d6d79cd624 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/TranslatingDataChangeEvent.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/TranslatingDataChangeEvent.java @@ -17,64 +17,64 @@ import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent; import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException; import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import com.google.common.collect.Maps; public abstract class TranslatingDataChangeEvent implements -DataChangeEvent { +DataChangeEvent { private TranslatingDataChangeEvent() { } - public static DataChangeEvent createOperational( - final AsyncDataChangeEvent> change, final DataNormalizer normalizer) { + public static DataChangeEvent createOperational( + final AsyncDataChangeEvent> change, final DataNormalizer normalizer) { return new OperationalChangeEvent(change, normalizer); } - public static DataChangeEvent createConfiguration( - final AsyncDataChangeEvent> change, final DataNormalizer normalizer) { + public static DataChangeEvent createConfiguration( + final AsyncDataChangeEvent> change, final DataNormalizer normalizer) { return new ConfigurationChangeEvent(change, normalizer); } @Override - public Map getCreatedOperationalData() { + public Map getCreatedOperationalData() { return Collections.emptyMap(); } @Override - public Map getCreatedConfigurationData() { + public Map getCreatedConfigurationData() { return Collections.emptyMap(); } @Override - public Map getUpdatedOperationalData() { + public Map getUpdatedOperationalData() { return Collections.emptyMap(); } @Override - public Map getUpdatedConfigurationData() { + public Map getUpdatedConfigurationData() { return Collections.emptyMap(); } @Override - public Set getRemovedConfigurationData() { + public Set getRemovedConfigurationData() { return Collections.emptySet(); } @Override - public Set getRemovedOperationalData() { + public Set getRemovedOperationalData() { return Collections.emptySet(); } @Override - public Map getOriginalConfigurationData() { + public Map getOriginalConfigurationData() { return Collections.emptyMap(); } @Override - public Map getOriginalOperationalData() { + public Map getOriginalOperationalData() { return Collections.emptyMap(); } @@ -100,24 +100,24 @@ DataChangeEvent> delegate; + private final AsyncDataChangeEvent> delegate; private final DataNormalizer normalizer; - private Map updatedCache; + private Map updatedCache; - public OperationalChangeEvent(final AsyncDataChangeEvent> change, + public OperationalChangeEvent(final AsyncDataChangeEvent> change, final DataNormalizer normalizer) { this.delegate = change; this.normalizer = normalizer; } @Override - public Map getCreatedOperationalData() { + public Map getCreatedOperationalData() { return transformToLegacy(normalizer, delegate.getCreatedData()); } @Override - public Set getRemovedOperationalData() { + public Set getRemovedOperationalData() { return delegate.getRemovedPaths(); } @@ -134,16 +134,16 @@ DataChangeEvent getOriginalOperationalData() { + public Map getOriginalOperationalData() { return transformToLegacy(normalizer, delegate.getOriginalData()); } @Override - public Map getUpdatedOperationalData() { + public Map getUpdatedOperationalData() { if(updatedCache == null) { - final Map updated = transformToLegacy(normalizer, delegate.getUpdatedData()); - final Map created = getCreatedConfigurationData(); - final HashMap updatedComposite = new HashMap<>(created.size() + updated.size()); + final Map updated = transformToLegacy(normalizer, delegate.getUpdatedData()); + final Map created = getCreatedConfigurationData(); + final HashMap updatedComposite = new HashMap<>(created.size() + updated.size()); updatedComposite.putAll(created); updatedComposite.putAll(updated); updatedCache = Collections.unmodifiableMap(updatedComposite); @@ -158,10 +158,10 @@ DataChangeEvent transformToLegacy(final DataNormalizer normalizer, final Map> nodes) { - final Map legacy = Maps.newHashMap(); + private static Map transformToLegacy(final DataNormalizer normalizer, final Map> nodes) { + final Map legacy = Maps.newHashMap(); - for (final Map.Entry> entry : nodes.entrySet()) { + for (final Map.Entry> entry : nodes.entrySet()) { try { legacy.put(normalizer.toLegacy(entry.getKey()), normalizer.toLegacy(entry.getKey(), entry.getValue())); } catch (final DataNormalizationException e) { @@ -173,24 +173,24 @@ DataChangeEvent> delegate; + private final AsyncDataChangeEvent> delegate; private final DataNormalizer normalizer; - private Map updatedCache; + private Map updatedCache; - public ConfigurationChangeEvent(final AsyncDataChangeEvent> change, + public ConfigurationChangeEvent(final AsyncDataChangeEvent> change, final DataNormalizer normalizer) { this.delegate = change; this.normalizer = normalizer; } @Override - public Map getCreatedConfigurationData() { + public Map getCreatedConfigurationData() { return transformToLegacy(normalizer, delegate.getCreatedData()); } @Override - public Set getRemovedConfigurationData() { + public Set getRemovedConfigurationData() { return delegate.getRemovedPaths(); } @@ -207,16 +207,16 @@ DataChangeEvent getOriginalConfigurationData() { + public Map getOriginalConfigurationData() { return transformToLegacy(normalizer, delegate.getOriginalData()); } @Override - public Map getUpdatedConfigurationData() { + public Map getUpdatedConfigurationData() { if(updatedCache == null) { - final Map updated = transformToLegacy(normalizer, delegate.getUpdatedData()); - final Map created = getCreatedConfigurationData(); - final HashMap updatedComposite = new HashMap<>(created.size() + updated.size()); + final Map updated = transformToLegacy(normalizer, delegate.getUpdatedData()); + final Map created = getCreatedConfigurationData(); + final HashMap updatedComposite = new HashMap<>(created.size() + updated.size()); updatedComposite.putAll(created); updatedComposite.putAll(updated); updatedCache = Collections.unmodifiableMap(updatedComposite); diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/TranslatingListenerInvoker.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/TranslatingListenerInvoker.java index 1ce252df98..b9504e7268 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/TranslatingListenerInvoker.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/TranslatingListenerInvoker.java @@ -18,7 +18,7 @@ import org.opendaylight.controller.sal.core.api.data.DataChangeListener; import org.opendaylight.yangtools.concepts.Delegator; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; abstract class TranslatingListenerInvoker implements AutoCloseable, DOMDataChangeListener, Delegator { @@ -41,19 +41,19 @@ abstract class TranslatingListenerInvoker implements AutoCloseable, DOMDataChang } @Override - public void onDataChanged(final AsyncDataChangeEvent> normalizedChange) { + public void onDataChanged(final AsyncDataChangeEvent> normalizedChange) { delegate.onDataChanged(getLegacyEvent(normalizer, normalizedChange)); } - abstract DataChangeEvent getLegacyEvent(final DataNormalizer normalizer, - final AsyncDataChangeEvent> normalizedChange); + abstract DataChangeEvent getLegacyEvent(final DataNormalizer normalizer, + final AsyncDataChangeEvent> normalizedChange); @Override public DataChangeListener getDelegate() { return delegate; } - abstract void register(final DOMDataBroker backingBroker, final InstanceIdentifier normalizedPath); + abstract void register(final DOMDataBroker backingBroker, final YangInstanceIdentifier normalizedPath); @Override public void close() { @@ -68,12 +68,12 @@ abstract class TranslatingListenerInvoker implements AutoCloseable, DOMDataChang super(listener, normalizer); } - DataChangeEvent getLegacyEvent(final DataNormalizer normalizer, final AsyncDataChangeEvent> normalizedChange) { + DataChangeEvent getLegacyEvent(final DataNormalizer normalizer, final AsyncDataChangeEvent> normalizedChange) { return TranslatingDataChangeEvent.createConfiguration(normalizedChange, normalizer); } @Override - void register(final DOMDataBroker backingBroker, final InstanceIdentifier normalizedPath) { + void register(final DOMDataBroker backingBroker, final YangInstanceIdentifier normalizedPath) { reg = backingBroker.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, normalizedPath, this, AsyncDataBroker.DataChangeScope.SUBTREE); } @@ -85,12 +85,12 @@ abstract class TranslatingListenerInvoker implements AutoCloseable, DOMDataChang super(listener, normalizer); } - DataChangeEvent getLegacyEvent(final DataNormalizer normalizer, final AsyncDataChangeEvent> normalizedChange) { + DataChangeEvent getLegacyEvent(final DataNormalizer normalizer, final AsyncDataChangeEvent> normalizedChange) { return TranslatingDataChangeEvent.createOperational(normalizedChange, normalizer); } @Override - void register(final DOMDataBroker backingBroker, final InstanceIdentifier normalizedPath) { + void register(final DOMDataBroker backingBroker, final YangInstanceIdentifier normalizedPath) { reg = backingBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, normalizedPath, this, AsyncDataBroker.DataChangeScope.SUBTREE); } 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 cdb78fc592..41650666cd 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 @@ -8,9 +8,12 @@ package org.opendaylight.controller.md.sal.dom.broker.impl.mount; +import com.google.common.base.Optional; +import com.google.common.base.Preconditions; +import com.google.common.collect.ClassToInstanceMap; +import com.google.common.collect.MutableClassToInstanceMap; import java.util.HashMap; import java.util.Map; - import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; import org.opendaylight.controller.md.sal.dom.api.DOMService; @@ -19,63 +22,72 @@ 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.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.MutableClassToInstanceMap; - public class DOMMountPointServiceImpl implements DOMMountPointService { - private final Map mountPoints = new HashMap<>(); + private final Map mountPoints = new HashMap<>(); private final ListenerRegistry listeners = ListenerRegistry.create(); @Override - public Optional getMountPoint(final InstanceIdentifier path) { - return Optional.fromNullable(mountPoints.get(path)); + public Optional getMountPoint(final YangInstanceIdentifier path) { + return Optional.fromNullable(mountPoints.get(path)); } @Override - public DOMMountPointBuilder createMountPoint(final InstanceIdentifier path) { + public DOMMountPointBuilder createMountPoint(final YangInstanceIdentifier path) { Preconditions.checkState(!mountPoints.containsKey(path), "Mount point already exists"); return new DOMMountPointBuilderImpl(path); } - public void notifyMountCreated(final InstanceIdentifier identifier) { + public void notifyMountCreated(final YangInstanceIdentifier identifier) { for (final ListenerRegistration listener : listeners .getListeners()) { listener.getInstance().onMountPointCreated(identifier); } } + public void notifyMountRemoved(final YangInstanceIdentifier identifier) { + for (final ListenerRegistration listener : listeners + .getListeners()) { + listener.getInstance().onMountPointRemoved(identifier); + } + } + @Override public ListenerRegistration registerProvisionListener( final MountProvisionListener listener) { return listeners.register(listener); } - public ObjectRegistration registerMountPoint(final SimpleDOMMountPoint mountPoint) { + public ObjectRegistration registerMountPoint(final DOMMountPoint mountPoint) { synchronized (mountPoints) { Preconditions.checkState(!mountPoints.containsKey(mountPoint.getIdentifier()), "Mount point already exists"); mountPoints.put(mountPoint.getIdentifier(), mountPoint); } notifyMountCreated(mountPoint.getIdentifier()); - // FIXME this shouldnt be null - return null; + return new MountRegistration(mountPoint); + } + + public void unregisterMountPoint(final YangInstanceIdentifier mountPointId) { + synchronized (mountPoints) { + Preconditions.checkState(mountPoints.containsKey(mountPointId), "Mount point does not exist"); + mountPoints.remove(mountPointId); + } + notifyMountRemoved(mountPointId); } public class DOMMountPointBuilderImpl implements DOMMountPointBuilder { ClassToInstanceMap services = MutableClassToInstanceMap.create(); private SimpleDOMMountPoint mountPoint; - private final InstanceIdentifier path; + private final YangInstanceIdentifier path; private SchemaContext schemaContext; - public DOMMountPointBuilderImpl(final InstanceIdentifier path) { + public DOMMountPointBuilderImpl(final YangInstanceIdentifier path) { this.path = path; } @@ -98,4 +110,22 @@ public class DOMMountPointServiceImpl implements DOMMountPointService { return registerMountPoint(mountPoint); } } + + private final class MountRegistration implements ObjectRegistration { + private final DOMMountPoint mountPoint; + + public MountRegistration(final DOMMountPoint mountPoint) { + this.mountPoint = mountPoint; + } + + @Override + public DOMMountPoint getInstance() { + return mountPoint; + } + + @Override + public void close() throws Exception { + unregisterMountPoint(mountPoint.getIdentifier()); + } + } } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPoint.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPoint.java new file mode 100644 index 0000000000..d837d75ddc --- /dev/null +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPoint.java @@ -0,0 +1,568 @@ +/* + * 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.dom.broker; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Function; +import com.google.common.base.Optional; +import com.google.common.base.Preconditions; +import com.google.common.util.concurrent.CheckedFuture; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.JdkFutureAdapters; +import com.google.common.util.concurrent.ListenableFuture; +import java.util.List; +import java.util.Map; +import java.util.Set; +import javax.annotation.Nullable; +import org.opendaylight.controller.md.sal.common.api.RegistrationListener; +import org.opendaylight.controller.md.sal.common.api.TransactionStatus; +import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler; +import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandlerRegistration; +import org.opendaylight.controller.md.sal.common.api.data.DataReader; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; +import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener; +import org.opendaylight.controller.md.sal.common.impl.ListenerRegistry; +import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException; +import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; +import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener; +import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; +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.api.DOMMountPoint; +import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; +import org.opendaylight.controller.md.sal.dom.api.DOMService; +import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; +import org.opendaylight.controller.md.sal.dom.broker.impl.compat.BackwardsCompatibleDataBroker; +import org.opendaylight.controller.sal.common.DataStoreIdentifier; +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.RpcProvisionRegistry; +import org.opendaylight.controller.sal.core.api.RpcRegistrationListener; +import org.opendaylight.controller.sal.core.api.RpcRoutingContext; +import org.opendaylight.controller.sal.core.api.data.DataChangeListener; +import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction; +import org.opendaylight.controller.sal.core.api.data.DataProviderService; +import org.opendaylight.controller.sal.core.api.data.DataValidator; +import org.opendaylight.controller.sal.core.api.model.SchemaService; +import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance; +import org.opendaylight.controller.sal.core.api.notify.NotificationListener; +import org.opendaylight.controller.sal.core.api.notify.NotificationPublishService; +import org.opendaylight.controller.sal.dom.broker.impl.NotificationRouterImpl; +import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareRpcBroker; +import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProvider; +import org.opendaylight.controller.sal.dom.broker.spi.NotificationRouter; +import org.opendaylight.controller.sal.dom.broker.util.ProxySchemaContext; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.concepts.Registration; +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.YangInstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.model.api.Module; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener; + +public class BackwardsCompatibleMountPoint implements MountProvisionInstance, SchemaContextProvider, SchemaService { + + private final DataProviderService dataReader; + private final DataReader readWrapper; + + private final YangInstanceIdentifier mountPath; + private final NotificationPublishService notificationPublishService; + private final RpcProvisionRegistry rpcs; + + private final ListenerRegistry schemaListenerRegistry = new ListenerRegistry<>(); + + private SchemaContext schemaContext; + + public BackwardsCompatibleMountPoint(final YangInstanceIdentifier path, final DOMMountPointService.DOMMountPointBuilder mountPointBuilder) { + this.mountPath = Preconditions.checkNotNull(path); + Preconditions.checkNotNull(mountPointBuilder); + + dataReader = new DataBrokerImpl(); + readWrapper = new ReadWrapper(); + notificationPublishService = new DelgatingNotificationPublishService(); + rpcs = new SchemaAwareRpcBroker(path.toString(), this); + + mountPointBuilder.addService(DOMDataBroker.class, new BackwardsCompatibleDomStore(dataReader, this)); + mountPointBuilder.addService(NotificationPublishService.class, notificationPublishService); + mountPointBuilder.addService(RpcProvisionRegistry.class, rpcs); + + mountPointBuilder.addInitialSchemaContext(new ProxySchemaContext(this)); + + mountPointBuilder.register(); + } + + public BackwardsCompatibleMountPoint(final YangInstanceIdentifier path, final DOMMountPoint mount) { + this.mountPath = Preconditions.checkNotNull(path); + Preconditions.checkNotNull(mount); + + final DOMDataBroker domBroker = getServiceWithCheck(mount, DOMDataBroker.class); + + this.schemaContext = mount.getSchemaContext(); + + dataReader = new BackwardsCompatibleDataBroker(domBroker, this); + + // Set schema context to provide it for BackwardsCompatibleDataBroker + if(schemaContext != null) { + setSchemaContext(schemaContext); + } + + readWrapper = new ReadWrapper(); + + notificationPublishService = getServiceWithCheck(mount, NotificationPublishService.class); + rpcs = getServiceWithCheck(mount, RpcProvisionRegistry.class); + } + + private T getServiceWithCheck(final DOMMountPoint mount, final Class type) { + final Optional serviceOptional = mount.getService(type); + Preconditions.checkArgument(serviceOptional.isPresent(), "Service {} has to be set in {}. " + + "Cannot construct backwards compatible mount wrapper without it", type, mount); + return serviceOptional.get(); + } + + @Override + public void addModule(final Module module) { + throw new UnsupportedOperationException(); + } + + @Override + public void removeModule(final Module module) { + throw new UnsupportedOperationException(); + } + + @Override + public SchemaContext getSessionContext() { + return getSchemaContext(); + } + + @Override + public SchemaContext getGlobalContext() { + return getSchemaContext(); + } + + @Override + public ListenerRegistration registerSchemaServiceListener(final SchemaServiceListener listener) { + return schemaListenerRegistry.register(listener); + } + + @Override + public void publish(final CompositeNode notification) { + notificationPublishService.publish(notification); + } + + @Override + public ListenerRegistration addNotificationListener(final QName notification, final NotificationListener listener) { + return notificationPublishService.addNotificationListener(notification, listener); + } + + // TODO Read wrapper is never used ... same in org.opendaylight.controller.sal.dom.broker.MountPointImpl + public DataReader getReadWrapper() { + return readWrapper; + } + + @Override + public CompositeNode readConfigurationData(final YangInstanceIdentifier path) { + return dataReader.readConfigurationData(path); + } + + @Override + public CompositeNode readOperationalData(final YangInstanceIdentifier path) { + return dataReader.readOperationalData(path); + } + + @Override + public Registration registerOperationalReader( + final YangInstanceIdentifier path, final DataReader reader) { + return dataReader.registerOperationalReader(path, reader); + } + + @Override + public Registration registerConfigurationReader( + final YangInstanceIdentifier path, final DataReader reader) { + return dataReader.registerConfigurationReader(path, reader); + } + + @Override + public RoutedRpcRegistration addRoutedRpcImplementation(final QName rpcType, final RpcImplementation implementation) { + return rpcs.addRoutedRpcImplementation(rpcType, implementation); + } + + @Override + public void setRoutedRpcDefaultDelegate(final RoutedRpcDefaultImplementation defaultImplementation) { + rpcs.setRoutedRpcDefaultDelegate(defaultImplementation); + } + + @Override + public RpcRegistration addRpcImplementation(final QName rpcType, final RpcImplementation implementation) + throws IllegalArgumentException { + return rpcs.addRpcImplementation(rpcType, implementation); + } + + @Override + public Set getSupportedRpcs() { + return rpcs.getSupportedRpcs(); + } + + @Override + public ListenableFuture> invokeRpc(final QName rpc, final CompositeNode input) { + return rpcs.invokeRpc(rpc, input); + } + + @Override + public ListenerRegistration addRpcRegistrationListener(final RpcRegistrationListener listener) { + return rpcs.addRpcRegistrationListener(listener); + } + + @Override + public ListenableFuture> rpc(final QName type, final CompositeNode input) { + return rpcs.invokeRpc(type, input); + } + + @Override + public DataModificationTransaction beginTransaction() { + return dataReader.beginTransaction(); + } + + @Override + public ListenerRegistration registerDataChangeListener(final YangInstanceIdentifier path, + final DataChangeListener listener) { + return dataReader.registerDataChangeListener(path, listener); + } + + @Override + public Registration registerCommitHandler( + final YangInstanceIdentifier path, final DataCommitHandler commitHandler) { + return dataReader.registerCommitHandler(path, commitHandler); + } + + @Override + public void removeRefresher(final DataStoreIdentifier store, final DataRefresher refresher) { + // NOOP + } + + @Override + public void addRefresher(final DataStoreIdentifier store, final DataRefresher refresher) { + // NOOP + } + + @Override + public void addValidator(final DataStoreIdentifier store, final DataValidator validator) { + // NOOP + } + @Override + public void removeValidator(final DataStoreIdentifier store, final DataValidator validator) { + // NOOP + } + + @Override + public SchemaContext getSchemaContext() { + return schemaContext; + } + + @Override + public void setSchemaContext(final SchemaContext schemaContext) { + this.schemaContext = schemaContext; + for (ListenerRegistration schemaServiceListenerListenerRegistration : schemaListenerRegistry.getListeners()) { + schemaServiceListenerListenerRegistration.getInstance().onGlobalContextUpdated(schemaContext); + } + } + + class ReadWrapper implements DataReader { + private YangInstanceIdentifier shortenPath(final YangInstanceIdentifier path) { + YangInstanceIdentifier ret = null; + if(mountPath.contains(path)) { + final List newArgs = path.getPath().subList(mountPath.getPath().size(), path.getPath().size()); + ret = YangInstanceIdentifier.create(newArgs); + } + return ret; + } + + @Override + public CompositeNode readConfigurationData(final YangInstanceIdentifier path) { + final YangInstanceIdentifier newPath = shortenPath(path); + if(newPath == null) { + return null; + } + return BackwardsCompatibleMountPoint.this.readConfigurationData(newPath); + } + + @Override + public CompositeNode readOperationalData(final YangInstanceIdentifier path) { + final YangInstanceIdentifier newPath = shortenPath(path); + if(newPath == null) { + return null; + } + return BackwardsCompatibleMountPoint.this.readOperationalData(newPath); + } + } + + @Override + public ListenerRegistration>> registerCommitHandlerListener( + final RegistrationListener> commitHandlerListener) { + return dataReader.registerCommitHandlerListener(commitHandlerListener); + } + + @Override + public > ListenerRegistration registerRouteChangeListener( + final L listener) { + return rpcs.registerRouteChangeListener(listener); + } + + @VisibleForTesting + static final class BackwardsCompatibleDomStore implements DOMDataBroker { + private final DataProviderService dataReader; + private final SchemaContextProvider schemaContextProvider; + + public BackwardsCompatibleDomStore(final DataProviderService dataReader, final SchemaContextProvider schemaContextProvider) { + this.dataReader = dataReader; + this.schemaContextProvider = schemaContextProvider; + } + + @Override + public DOMDataReadOnlyTransaction newReadOnlyTransaction() { + final DataNormalizer dataNormalizer = new DataNormalizer(schemaContextProvider.getSchemaContext()); + return new BackwardsCompatibleReadTransaction(dataReader, dataNormalizer); + } + + @Override + public DOMDataWriteTransaction newWriteOnlyTransaction() { + final DataNormalizer dataNormalizer = new DataNormalizer(schemaContextProvider.getSchemaContext()); + return new BackwardsCompatibleWriteTransaction(dataReader, dataNormalizer); + } + + @Override + public ListenerRegistration registerDataChangeListener(final LogicalDatastoreType store, final YangInstanceIdentifier path, final DOMDataChangeListener listener, final DataChangeScope triggeringScope) { + throw new UnsupportedOperationException("Register data listener not supported for mount point"); + } + + @Override + public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) { + throw new UnsupportedOperationException("Transaction chain not supported for mount point"); + } + + @Override + public DOMDataReadWriteTransaction newReadWriteTransaction() { + final DataNormalizer dataNormalizer = new DataNormalizer(schemaContextProvider.getSchemaContext()); + return new BackwardsCompatibleReadWriteTransaction(dataReader, dataNormalizer); + } + + @VisibleForTesting + static final class BackwardsCompatibleReadTransaction implements DOMDataReadOnlyTransaction { + private final DataProviderService dataReader; + private final DataNormalizer normalizer; + + public BackwardsCompatibleReadTransaction(final DataProviderService dataReader, final DataNormalizer normalizer) { + this.dataReader = dataReader; + this.normalizer = normalizer; + } + + @Override + public Object getIdentifier() { + return this; + } + + @Override + public void close() { + // NOOP + } + + @Override + public ListenableFuture>> read(final LogicalDatastoreType store, final YangInstanceIdentifier path) { + + CompositeNode rawData = null; + + switch (store) { + case CONFIGURATION: { + rawData = dataReader.readConfigurationData(path); + break; + } + case OPERATIONAL: { + rawData = dataReader.readOperationalData(path); + break; + } + } + Preconditions.checkNotNull(rawData, "Unable to read %s data on path %s", store, path); + + final Map.Entry> normalized = normalizer.toNormalized(path, rawData); + final Optional> normalizedNodeOptional = Optional.>fromNullable(normalized.getValue()); + return com.google.common.util.concurrent.Futures.immediateFuture(normalizedNodeOptional); + } + } + + @VisibleForTesting + static final class BackwardsCompatibleWriteTransaction implements DOMDataWriteTransaction { + private DataModificationTransaction oldTx; + private final DataNormalizer dataNormalizer; + + public BackwardsCompatibleWriteTransaction(final DataProviderService dataReader, final DataNormalizer dataNormalizer) { + this.oldTx = dataReader.beginTransaction(); + this.dataNormalizer = dataNormalizer; + } + + @Override + public Object getIdentifier() { + return this; + } + + @Override + public boolean cancel() { + oldTx = null; + return true; + } + + @Override + public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data) { + final CompositeNode legacyData = dataNormalizer.toLegacy(path, data); + try { + final YangInstanceIdentifier legacyPath = dataNormalizer.toLegacy(path); + + switch (store) { + case CONFIGURATION: { + oldTx.putConfigurationData(legacyPath, legacyData); + return; + } + } + + throw new IllegalArgumentException("Cannot put data " + path + " to datastore " + store); + } catch (final DataNormalizationException e) { + throw new IllegalArgumentException(String.format("Cannot transform path %s to legacy format", path), e); + } + } + + @Override + public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data) { + // TODO not supported + throw new UnsupportedOperationException("Merge not supported for mount point"); + } + + @Override + public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) { + try { + final YangInstanceIdentifier legacyPath = dataNormalizer.toLegacy(path); + + switch (store) { + case CONFIGURATION: { + oldTx.removeConfigurationData(legacyPath); + return; + } + } + throw new IllegalArgumentException("Cannot delete data " + path + " from datastore " + store); + } catch (final DataNormalizationException e) { + throw new IllegalArgumentException(String.format("Cannot transform path %s to legacy format", path), e); + } + } + + @Override + public CheckedFuture submit() { + final ListenableFuture commitAsVoid = Futures.transform(commit(), new Function, Void>() { + @Override + public Void apply(@Nullable final RpcResult input) { + return null; + } + }); + + return Futures.makeChecked(commitAsVoid, new Function() { + @Override + public TransactionCommitFailedException apply(@Nullable final Exception input) { + return new TransactionCommitFailedException("Commit failed", input); + } + }); + } + + @Override + public ListenableFuture> commit() { + return JdkFutureAdapters.listenInPoolThread(oldTx.commit()); + } + } + + + @VisibleForTesting + static class BackwardsCompatibleReadWriteTransaction implements DOMDataReadWriteTransaction { + + private final DataProviderService dataReader; + private final DataNormalizer dataNormalizer; + private final BackwardsCompatibleWriteTransaction delegateWriteTx; + + public BackwardsCompatibleReadWriteTransaction(final DataProviderService dataReader, final DataNormalizer dataNormalizer) { + this.dataReader = dataReader; + this.dataNormalizer = dataNormalizer; + this.delegateWriteTx = new BackwardsCompatibleWriteTransaction(dataReader, dataNormalizer); + } + + @Override + public Object getIdentifier() { + return this; + } + + @Override + public ListenableFuture>> read(final LogicalDatastoreType store, final YangInstanceIdentifier path) { + return new BackwardsCompatibleReadTransaction(dataReader, dataNormalizer).read(store, path); + } + + @Override + public boolean cancel() { + return delegateWriteTx.cancel(); + } + + @Override + public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data) { + delegateWriteTx.put(store, path, data); + } + + @Override + public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data) { + delegateWriteTx.merge(store, path, data); + } + + @Override + public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) { + delegateWriteTx.delete(store, path); + } + + @Override + public CheckedFuture submit() { + return delegateWriteTx.submit(); + } + + @Override + public ListenableFuture> commit() { + return delegateWriteTx.commit(); + } + } + } + + private class DelgatingNotificationPublishService implements NotificationPublishService { + private final NotificationRouter notificationRouter; + + public DelgatingNotificationPublishService(final NotificationRouter notificationRouter) { + this.notificationRouter = notificationRouter; + } + + private DelgatingNotificationPublishService() { + this(new NotificationRouterImpl()); + } + + @Override + public void publish(final CompositeNode notification) { + notificationRouter.publish(notification); + } + + @Override + public ListenerRegistration addNotificationListener(final QName notification, final NotificationListener listener) { + return notificationRouter.addNotificationListener(notification, listener); + } + } +} 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 new file mode 100644 index 0000000000..b01db3d515 --- /dev/null +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointManager.java @@ -0,0 +1,97 @@ +/* + * 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.dom.broker; + +import static com.google.common.base.Preconditions.checkState; + +import com.google.common.base.Optional; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; +import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; +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.yang.data.api.YangInstanceIdentifier; + +public class BackwardsCompatibleMountPointManager implements MountProvisionService, MountProvisionListener { + + private final ListenerRegistry listeners = ListenerRegistry.create(); + private final ConcurrentMap mounts = new ConcurrentHashMap<>(); + + private final DOMMountPointService domMountPointService; + + public BackwardsCompatibleMountPointManager(final DOMMountPointService domMountPointService) { + this.domMountPointService = domMountPointService; + } + + @Override + public MountProvisionInstance createMountPoint(final YangInstanceIdentifier path) { + checkState(!mounts.containsKey(path), "Mount already created"); + // Create mount point instance, wrap instance of new API with BackwardsCompatibleMountPoint to preserve backwards comatibility + final BackwardsCompatibleMountPoint mount = new BackwardsCompatibleMountPoint(path, domMountPointService.createMountPoint(path)); + mounts.put(path, mount); + return mount; + } + + public void notifyMountCreated(final YangInstanceIdentifier identifier) { + for (final ListenerRegistration listener : listeners.getListeners()) { + listener.getInstance().onMountPointCreated(identifier); + } + } + + public void notifyMountRemoved(final YangInstanceIdentifier identifier) { + for (final ListenerRegistration listener : listeners.getListeners()) { + listener.getInstance().onMountPointRemoved(identifier); + } + } + + @Override + public MountProvisionInstance createOrGetMountPoint( + final YangInstanceIdentifier path) { + final MountProvisionInstance mount = getMountPoint(path); + if (mount == null) { + return createMountPoint(path); + } + return mount; + } + + @Override + public MountProvisionInstance getMountPoint(final YangInstanceIdentifier path) { + // If the mount point was created here, return directly + if(mounts.containsKey(path)) { + return mounts.get(path); + } + + // If mount was created in underlying DOMMountService, wrap as MountProvisionInstance + final Optional mount = domMountPointService.getMountPoint(path); + if(mount.isPresent()) { + return new BackwardsCompatibleMountPoint(path, mount.get()); + } else { + return null; + } + } + + @Override + public ListenerRegistration registerProvisionListener( + final MountProvisionListener listener) { + return domMountPointService.registerProvisionListener(listener); + } + + @Override + public void onMountPointCreated(final YangInstanceIdentifier path) { + notifyMountCreated(path); + } + + @Override + public void onMountPointRemoved(final YangInstanceIdentifier path) { + notifyMountRemoved(path); + } +} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerImpl.java index 68066778db..a200793fea 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerImpl.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerImpl.java @@ -27,7 +27,7 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration; 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.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.osgi.framework.BundleContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -147,7 +147,7 @@ public class BrokerImpl implements Broker, RpcProvisionRegistry, AutoCloseable { } @Override - public > ListenerRegistration registerRouteChangeListener( + public > ListenerRegistration registerRouteChangeListener( final L listener) { return router.registerRouteChangeListener(listener); } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataBrokerImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataBrokerImpl.java index 32a0ad20ca..27e351c28a 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataBrokerImpl.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataBrokerImpl.java @@ -18,11 +18,11 @@ import org.opendaylight.controller.sal.core.api.data.DataValidator; import org.opendaylight.controller.sal.dom.broker.impl.DataReaderRouter; import org.opendaylight.yangtools.concepts.Registration; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import com.google.common.util.concurrent.MoreExecutors; -public class DataBrokerImpl extends AbstractDataBroker implements +public class DataBrokerImpl extends AbstractDataBroker implements DataProviderService, AutoCloseable { private AtomicLong nextTransaction = new AtomicLong(); @@ -46,13 +46,13 @@ public class DataBrokerImpl extends AbstractDataBroker reader) { + YangInstanceIdentifier path, DataReader reader) { return getDataReadRouter().registerConfigurationReader(path, reader); } @Override public Registration registerOperationalReader( - InstanceIdentifier path, DataReader reader) { + YangInstanceIdentifier path, DataReader reader) { return getDataReadRouter().registerOperationalReader(path, reader); } 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 65aa99deea..f0dd5b921c 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 @@ -13,9 +13,9 @@ 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.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -public class DataTransactionImpl extends AbstractDataTransaction +public class DataTransactionImpl extends AbstractDataTransaction implements DataModificationTransaction { private final ListenerRegistry listeners = new ListenerRegistry(); diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointImpl.java index dd47cb41f7..054c8ea851 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointImpl.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointImpl.java @@ -36,8 +36,8 @@ import org.opendaylight.yangtools.concepts.Registration; 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.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import com.google.common.util.concurrent.ListenableFuture; @@ -48,14 +48,14 @@ public class MountPointImpl implements MountProvisionInstance, SchemaContextProv private final SchemaAwareRpcBroker rpcs; private final DataBrokerImpl dataReader; private final NotificationRouter notificationRouter; - private final DataReader readWrapper; + private final DataReader readWrapper; - private final InstanceIdentifier mountPath; + private final YangInstanceIdentifier mountPath; private SchemaContext schemaContext; - public MountPointImpl(final InstanceIdentifier path) { + public MountPointImpl(final YangInstanceIdentifier path) { this.mountPath = path; rpcs = new SchemaAwareRpcBroker(path.toString(),this); dataReader = new DataBrokerImpl(); @@ -63,11 +63,11 @@ public class MountPointImpl implements MountProvisionInstance, SchemaContextProv readWrapper = new ReadWrapper(); } - public InstanceIdentifier getMountPath() { + public YangInstanceIdentifier getMountPath() { return mountPath; } - public DataReader getReadWrapper() { + public DataReader getReadWrapper() { return readWrapper; } @@ -82,24 +82,24 @@ public class MountPointImpl implements MountProvisionInstance, SchemaContextProv } @Override - public CompositeNode readConfigurationData(final InstanceIdentifier path) { + public CompositeNode readConfigurationData(final YangInstanceIdentifier path) { return dataReader.readConfigurationData(path); } @Override - public CompositeNode readOperationalData(final InstanceIdentifier path) { + public CompositeNode readOperationalData(final YangInstanceIdentifier path) { return dataReader.readOperationalData(path); } @Override public Registration registerOperationalReader( - final InstanceIdentifier path, final DataReader reader) { + final YangInstanceIdentifier path, final DataReader reader) { return dataReader.registerOperationalReader(path, reader); } @Override public Registration registerConfigurationReader( - final InstanceIdentifier path, final DataReader reader) { + final YangInstanceIdentifier path, final DataReader reader) { return dataReader.registerConfigurationReader(path, reader); } @@ -145,14 +145,14 @@ public class MountPointImpl implements MountProvisionInstance, SchemaContextProv } @Override - public ListenerRegistration registerDataChangeListener(final InstanceIdentifier path, + public ListenerRegistration registerDataChangeListener(final YangInstanceIdentifier path, final DataChangeListener listener) { return dataReader.registerDataChangeListener(path, listener); } @Override public Registration registerCommitHandler( - final InstanceIdentifier path, final DataCommitHandler commitHandler) { + final YangInstanceIdentifier path, final DataCommitHandler commitHandler) { return dataReader.registerCommitHandler(path, commitHandler); } @@ -185,19 +185,19 @@ public class MountPointImpl implements MountProvisionInstance, SchemaContextProv this.schemaContext = schemaContext; } - class ReadWrapper implements DataReader { - private InstanceIdentifier shortenPath(final InstanceIdentifier path) { - InstanceIdentifier ret = null; + class ReadWrapper implements DataReader { + private YangInstanceIdentifier shortenPath(final YangInstanceIdentifier path) { + YangInstanceIdentifier ret = null; if(mountPath.contains(path)) { List newArgs = path.getPath().subList(mountPath.getPath().size(), path.getPath().size()); - ret = InstanceIdentifier.create(newArgs); + ret = YangInstanceIdentifier.create(newArgs); } return ret; } @Override - public CompositeNode readConfigurationData(final InstanceIdentifier path) { - InstanceIdentifier newPath = shortenPath(path); + public CompositeNode readConfigurationData(final YangInstanceIdentifier path) { + YangInstanceIdentifier newPath = shortenPath(path); if(newPath == null) { return null; } @@ -205,8 +205,8 @@ public class MountPointImpl implements MountProvisionInstance, SchemaContextProv } @Override - public CompositeNode readOperationalData(final InstanceIdentifier path) { - InstanceIdentifier newPath = shortenPath(path); + public CompositeNode readOperationalData(final YangInstanceIdentifier path) { + YangInstanceIdentifier newPath = shortenPath(path); if(newPath == null) { return null; } @@ -215,13 +215,13 @@ public class MountPointImpl implements MountProvisionInstance, SchemaContextProv } @Override - public ListenerRegistration>> registerCommitHandlerListener( - final RegistrationListener> commitHandlerListener) { + public ListenerRegistration>> registerCommitHandlerListener( + final RegistrationListener> commitHandlerListener) { return dataReader.registerCommitHandlerListener(commitHandlerListener); } @Override - public > ListenerRegistration registerRouteChangeListener( + public > ListenerRegistration registerRouteChangeListener( final L listener) { return rpcs.registerRouteChangeListener(listener); } 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 ac2ab04bbe..d84f1dc031 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 @@ -18,19 +18,19 @@ 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.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; @Deprecated public class MountPointManagerImpl implements MountProvisionService { private final ListenerRegistry listeners = ListenerRegistry.create(); - private final ConcurrentMap mounts = + private final ConcurrentMap mounts = new ConcurrentHashMap<>(); private DataProviderService dataBroker = null; @Override - public MountProvisionInstance createMountPoint(final InstanceIdentifier path) { + public MountProvisionInstance createMountPoint(final YangInstanceIdentifier path) { checkState(!mounts.containsKey(path), "Mount already created"); final MountPointImpl mount = new MountPointImpl(path); registerMountPoint(mount); @@ -39,7 +39,7 @@ public class MountPointManagerImpl implements MountProvisionService { return mount; } - public void notifyMountCreated(final InstanceIdentifier identifier) { + public void notifyMountCreated(final YangInstanceIdentifier identifier) { for (final ListenerRegistration listener : listeners .getListeners()) { listener.getInstance().onMountPointCreated(identifier); @@ -55,7 +55,7 @@ public class MountPointManagerImpl implements MountProvisionService { @Override public MountProvisionInstance createOrGetMountPoint( - final InstanceIdentifier path) { + final YangInstanceIdentifier path) { final MountPointImpl mount = mounts.get(path); if (mount == null) { return createMountPoint(path); @@ -64,7 +64,7 @@ public class MountPointManagerImpl implements MountProvisionService { } @Override - public MountProvisionInstance getMountPoint(final InstanceIdentifier path) { + public MountProvisionInstance getMountPoint(final YangInstanceIdentifier path) { return mounts.get(path); } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/DataReaderRouter.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/DataReaderRouter.java index 4b5b86d0da..4f029bc919 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/DataReaderRouter.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/DataReaderRouter.java @@ -25,9 +25,9 @@ import java.util.Set; import org.opendaylight.controller.md.sal.common.impl.routing.AbstractDataReadRouter; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +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.Node; import org.opendaylight.yangtools.yang.data.api.SimpleNode; import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl; @@ -35,7 +35,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class DataReaderRouter extends -AbstractDataReadRouter { +AbstractDataReadRouter { private final static Logger LOG = LoggerFactory .getLogger(DataReaderRouter.class); private final static URI NETCONF_NAMESPACE = URI @@ -44,7 +44,7 @@ AbstractDataReadRouter { "data"); @Override - protected CompositeNodeTOImpl merge(final InstanceIdentifier path, + protected CompositeNodeTOImpl merge(final YangInstanceIdentifier path, final Iterable data) { PathArgument pathArgument = Iterables.getLast(path.getPathArguments(), null); boolean empty = true; @@ -117,11 +117,11 @@ AbstractDataReadRouter { } public Map> getKeyNodes( - final InstanceIdentifier.PathArgument argument, + final YangInstanceIdentifier.PathArgument argument, final CompositeNode node) { - if (argument instanceof InstanceIdentifier.NodeIdentifierWithPredicates) { + if (argument instanceof YangInstanceIdentifier.NodeIdentifierWithPredicates) { return _getKeyNodes( - (InstanceIdentifier.NodeIdentifierWithPredicates) argument, + (YangInstanceIdentifier.NodeIdentifierWithPredicates) argument, node); } else if (argument != null) { return _getKeyNodes(argument, node); diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/DataStoreStatsWrapper.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/DataStoreStatsWrapper.java index aa4297613e..82c9133279 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/DataStoreStatsWrapper.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/DataStoreStatsWrapper.java @@ -13,7 +13,7 @@ import org.opendaylight.controller.md.sal.common.api.data.DataModification; import org.opendaylight.controller.sal.core.api.data.DataStore; import org.opendaylight.yangtools.concepts.Delegator; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; public class DataStoreStatsWrapper implements Delegator, DataStore { @@ -38,7 +38,7 @@ public class DataStoreStatsWrapper implements Delegator, DataStore { } @Override - public CompositeNode readConfigurationData(InstanceIdentifier path) { + public CompositeNode readConfigurationData(YangInstanceIdentifier path) { cfgReadCount.incrementAndGet(); final long startTime = System.nanoTime(); try { @@ -51,7 +51,7 @@ public class DataStoreStatsWrapper implements Delegator, DataStore { } @Override - public CompositeNode readOperationalData(InstanceIdentifier path) { + public CompositeNode readOperationalData(YangInstanceIdentifier path) { operReadCount.incrementAndGet(); final long startTime = System.nanoTime(); try { @@ -63,8 +63,8 @@ public class DataStoreStatsWrapper implements Delegator, DataStore { } } - public DataCommitTransaction requestCommit( - DataModification modification) { + public DataCommitTransaction requestCommit( + DataModification modification) { requestCommitCount.incrementAndGet(); final long startTime = System.nanoTime(); try { @@ -77,19 +77,19 @@ public class DataStoreStatsWrapper implements Delegator, DataStore { }; @Override - public boolean containsConfigurationPath(InstanceIdentifier path) { + public boolean containsConfigurationPath(YangInstanceIdentifier path) { return delegate.containsConfigurationPath(path); } - public Iterable getStoredConfigurationPaths() { + public Iterable getStoredConfigurationPaths() { return delegate.getStoredConfigurationPaths(); } - public Iterable getStoredOperationalPaths() { + public Iterable getStoredOperationalPaths() { return delegate.getStoredOperationalPaths(); } - public boolean containsOperationalPath(InstanceIdentifier path) { + public boolean containsOperationalPath(YangInstanceIdentifier path) { return delegate.containsOperationalPath(path); } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/HashMapDataStore.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/HashMapDataStore.java index d7309b9ed3..1f82bd71b4 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/HashMapDataStore.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/HashMapDataStore.java @@ -18,7 +18,7 @@ import org.opendaylight.controller.sal.core.api.data.DataStore; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -26,44 +26,44 @@ public final class HashMapDataStore implements DataStore, AutoCloseable { private static final Logger LOG = LoggerFactory .getLogger(HashMapDataStore.class); - private final Map configuration = new ConcurrentHashMap(); - private final Map operational = new ConcurrentHashMap(); + private final Map configuration = new ConcurrentHashMap(); + private final Map operational = new ConcurrentHashMap(); @Override - public boolean containsConfigurationPath(final InstanceIdentifier path) { + public boolean containsConfigurationPath(final YangInstanceIdentifier path) { return configuration.containsKey(path); } @Override - public boolean containsOperationalPath(final InstanceIdentifier path) { + public boolean containsOperationalPath(final YangInstanceIdentifier path) { return operational.containsKey(path); } @Override - public Iterable getStoredConfigurationPaths() { + public Iterable getStoredConfigurationPaths() { return configuration.keySet(); } @Override - public Iterable getStoredOperationalPaths() { + public Iterable getStoredOperationalPaths() { return operational.keySet(); } @Override - public CompositeNode readConfigurationData(final InstanceIdentifier path) { + public CompositeNode readConfigurationData(final YangInstanceIdentifier path) { LOG.trace("Reading configuration path {}", path); return configuration.get(path); } @Override - public CompositeNode readOperationalData(InstanceIdentifier path) { + public CompositeNode readOperationalData(YangInstanceIdentifier path) { LOG.trace("Reading operational path {}", path); return operational.get(path); } @Override - public DataCommitHandler.DataCommitTransaction requestCommit( - final DataModification modification) { + public DataCommitHandler.DataCommitTransaction requestCommit( + final DataModification modification) { return new HashMapDataStoreTransaction(modification, this); } @@ -72,24 +72,24 @@ public final class HashMapDataStore implements DataStore, AutoCloseable { } public RpcResult finish(HashMapDataStoreTransaction transaction) { - final DataModification modification = transaction + final DataModification modification = transaction .getModification(); - for (final InstanceIdentifier removal : modification + for (final YangInstanceIdentifier removal : modification .getRemovedConfigurationData()) { LOG.trace("Removing configuration path {}", removal); remove(configuration, removal); } - for (final InstanceIdentifier removal : modification + for (final YangInstanceIdentifier removal : modification .getRemovedOperationalData()) { LOG.trace("Removing operational path {}", removal); remove(operational, removal); } if (LOG.isTraceEnabled()) { - for (final InstanceIdentifier a : modification + for (final YangInstanceIdentifier a : modification .getUpdatedConfigurationData().keySet()) { LOG.trace("Adding configuration path {}", a); } - for (final InstanceIdentifier a : modification + for (final YangInstanceIdentifier a : modification .getUpdatedOperationalData().keySet()) { LOG.trace("Adding operational path {}", a); } @@ -100,15 +100,15 @@ public final class HashMapDataStore implements DataStore, AutoCloseable { return RpcResultBuilder. success().build(); } - public void remove(final Map map, - final InstanceIdentifier identifier) { - Set affected = new HashSet(); - for (final InstanceIdentifier path : map.keySet()) { + public void remove(final Map map, + final YangInstanceIdentifier identifier) { + Set affected = new HashSet(); + for (final YangInstanceIdentifier path : map.keySet()) { if (identifier.contains(path)) { affected.add(path); } } - for (final InstanceIdentifier pathToRemove : affected) { + for (final YangInstanceIdentifier pathToRemove : affected) { LOG.trace("Removed path {}", pathToRemove); map.remove(pathToRemove); } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/HashMapDataStoreTransaction.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/HashMapDataStoreTransaction.java index bb66594ac9..ee026b6006 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/HashMapDataStoreTransaction.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/HashMapDataStoreTransaction.java @@ -11,15 +11,15 @@ import org.opendaylight.controller.md.sal.common.api.data.DataModification; import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; public class HashMapDataStoreTransaction implements - DataCommitTransaction { - private final DataModification modification; + DataCommitTransaction { + private final DataModification modification; private final HashMapDataStore datastore; HashMapDataStoreTransaction( - final DataModification modify, + final DataModification modify, final HashMapDataStore store) { modification = modify; datastore = store; @@ -31,7 +31,7 @@ public class HashMapDataStoreTransaction implements } @Override - public DataModification getModification() { + public DataModification getModification() { return this.modification; } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/RoutedRpcRegImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/RoutedRpcRegImpl.java index e4f19bbb2a..c2fa82b588 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/RoutedRpcRegImpl.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/RoutedRpcRegImpl.java @@ -11,7 +11,7 @@ import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration; import org.opendaylight.controller.sal.core.api.RpcImplementation; import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; class RoutedRpcRegImpl extends AbstractObjectRegistration implements RoutedRpcRegistration { @@ -26,12 +26,12 @@ class RoutedRpcRegImpl extends AbstractObjectRegistration imp } @Override - public void registerPath(final QName context, final InstanceIdentifier path) { + public void registerPath(final QName context, final YangInstanceIdentifier path) { router.addPath(context, path, this); } @Override - public void unregisterPath(final QName context, final InstanceIdentifier path) { + public void unregisterPath(final QName context, final YangInstanceIdentifier path) { router.removePath(context, path, this); } 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 a22aed7ab1..19ff03b7d2 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 @@ -22,7 +22,7 @@ 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.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.SimpleNode; import com.google.common.collect.ImmutableSet; @@ -33,7 +33,7 @@ class RoutedRpcSelector implements RpcImplementation, AutoCloseable, Identifiabl private final RpcRoutingStrategy strategy; private final Set supportedRpcs; private final RpcRoutingContext identifier; - final ConcurrentMap implementations = new ConcurrentHashMap<>(); + final ConcurrentMap implementations = new ConcurrentHashMap<>(); private final SchemaAwareRpcBroker router; public RoutedRpcSelector(final RpcRoutingStrategy strategy, final SchemaAwareRpcBroker router) { @@ -70,7 +70,7 @@ class RoutedRpcSelector implements RpcImplementation, AutoCloseable, Identifiabl SimpleNode routeContainer = inputContainer.getFirstSimpleByName(strategy.getLeaf()); checkArgument(routeContainer != null, "Leaf %s must be set with value", strategy.getLeaf()); Object route = routeContainer.getValue(); - checkArgument(route instanceof InstanceIdentifier, + checkArgument(route instanceof YangInstanceIdentifier, "The routed node %s is not an instance identifier", route); RpcImplementation potential = null; if (route != null) { @@ -80,13 +80,13 @@ class RoutedRpcSelector implements RpcImplementation, AutoCloseable, Identifiabl } } if (potential == null) { - return router.invokeRpc(rpc, (InstanceIdentifier) route, input); + return router.invokeRpc(rpc, (YangInstanceIdentifier) route, 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 InstanceIdentifier path, final RoutedRpcRegImpl routedRpcRegImpl) { + public void addPath(final QName context, final YangInstanceIdentifier path, final RoutedRpcRegImpl routedRpcRegImpl) { //checkArgument(strategy.getContext().equals(context),"Supplied context is not supported."); RoutedRpcRegImpl previous = implementations.put(path, routedRpcRegImpl); if (previous == null) { @@ -95,7 +95,7 @@ class RoutedRpcSelector implements RpcImplementation, AutoCloseable, Identifiabl } - public void removePath(final QName context, final InstanceIdentifier path, final RoutedRpcRegImpl routedRpcRegImpl) { + public void removePath(final QName context, final YangInstanceIdentifier path, final RoutedRpcRegImpl routedRpcRegImpl) { boolean removed = implementations.remove(path, routedRpcRegImpl); if (removed) { router.notifyPathWithdrawal(context, strategy.getIdentifier(), path); diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareDataStoreAdapter.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareDataStoreAdapter.java index 3cd7ed5e13..94553f5275 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareDataStoreAdapter.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareDataStoreAdapter.java @@ -33,7 +33,7 @@ import org.opendaylight.controller.sal.dom.broker.util.YangSchemaUtils; 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.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.Node; import org.opendaylight.yangtools.yang.data.api.SimpleNode; import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl; @@ -54,10 +54,10 @@ AutoCloseable { private SchemaContext schema = null; private boolean validationEnabled = false; - private final DataReader reader = new MergeFirstLevelReader(); + private final DataReader reader = new MergeFirstLevelReader(); @Override - public boolean containsConfigurationPath(final InstanceIdentifier path) { + public boolean containsConfigurationPath(final YangInstanceIdentifier path) { try { getDelegateReadLock().lock(); return getDelegate().containsConfigurationPath(path); @@ -68,7 +68,7 @@ AutoCloseable { } @Override - public boolean containsOperationalPath(final InstanceIdentifier path) { + public boolean containsOperationalPath(final YangInstanceIdentifier path) { try { getDelegateReadLock().lock(); return getDelegate().containsOperationalPath(path); @@ -79,7 +79,7 @@ AutoCloseable { } @Override - public Iterable getStoredConfigurationPaths() { + public Iterable getStoredConfigurationPaths() { try { getDelegateReadLock().lock(); return getDelegate().getStoredConfigurationPaths(); @@ -90,7 +90,7 @@ AutoCloseable { } @Override - public Iterable getStoredOperationalPaths() { + public Iterable getStoredOperationalPaths() { try { getDelegateReadLock().lock(); return getDelegate().getStoredOperationalPaths(); @@ -101,18 +101,18 @@ AutoCloseable { } @Override - public CompositeNode readConfigurationData(final InstanceIdentifier path) { + public CompositeNode readConfigurationData(final YangInstanceIdentifier path) { return reader.readConfigurationData(path); } @Override - public CompositeNode readOperationalData(final InstanceIdentifier path) { + public CompositeNode readOperationalData(final YangInstanceIdentifier path) { return reader.readOperationalData(path); } @Override - public org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction requestCommit( - final DataModification modification) { + public org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction requestCommit( + final DataModification modification) { validateAgainstSchema(modification); NormalizedDataModification cleanedUp = prepareMergedTransaction(modification); cleanedUp.status = TransactionStatus.SUBMITED; @@ -127,7 +127,7 @@ AutoCloseable { this.validationEnabled = validationEnabled; } - private void validateAgainstSchema(final DataModification modification) { + private void validateAgainstSchema(final DataModification modification) { if (!validationEnabled) { return; } @@ -153,7 +153,7 @@ AutoCloseable { this.schema = null; } - protected CompositeNode mergeData(final InstanceIdentifier path, final CompositeNode stored, final CompositeNode modified, + protected CompositeNode mergeData(final YangInstanceIdentifier path, final CompositeNode stored, final CompositeNode modified, final boolean config) { // long startTime = System.nanoTime(); try { @@ -165,13 +165,13 @@ AutoCloseable { } } - private DataSchemaNode schemaNodeFor(final InstanceIdentifier path) { + private DataSchemaNode schemaNodeFor(final YangInstanceIdentifier path) { checkState(schema != null, "YANG Schema is not available"); return YangSchemaUtils.getSchemaNode(schema, path); } private NormalizedDataModification prepareMergedTransaction( - final DataModification original) { + final DataModification original) { NormalizedDataModification normalized = new NormalizedDataModification(original); LOG.trace("Transaction: {} Removed Configuration {}, Removed Operational {}", original.getIdentifier(), original.getRemovedConfigurationData(), original.getRemovedConfigurationData()); @@ -180,40 +180,40 @@ AutoCloseable { LOG.trace("Transaction: {} Updated Configuration {}, Updated Operational {}", original.getIdentifier(), original.getUpdatedConfigurationData().entrySet(), original.getUpdatedOperationalData().entrySet()); - for (InstanceIdentifier entry : original.getRemovedConfigurationData()) { + for (YangInstanceIdentifier entry : original.getRemovedConfigurationData()) { normalized.deepRemoveConfigurationData(entry); } - for (InstanceIdentifier entry : original.getRemovedOperationalData()) { + for (YangInstanceIdentifier entry : original.getRemovedOperationalData()) { normalized.deepRemoveOperationalData(entry); } - for (Entry entry : original.getUpdatedConfigurationData().entrySet()) { + for (Entry entry : original.getUpdatedConfigurationData().entrySet()) { normalized.putDeepConfigurationData(entry.getKey(), entry.getValue()); } - for (Entry entry : original.getUpdatedOperationalData().entrySet()) { + for (Entry entry : original.getUpdatedOperationalData().entrySet()) { normalized.putDeepOperationalData(entry.getKey(), entry.getValue()); } return normalized; } - private Iterable getConfigurationSubpaths(final InstanceIdentifier entry) { + private Iterable getConfigurationSubpaths(final YangInstanceIdentifier entry) { // FIXME: This should be replaced by index - Iterable paths = getStoredConfigurationPaths(); + Iterable paths = getStoredConfigurationPaths(); return getChildrenPaths(entry, paths); } - public Iterable getOperationalSubpaths(final InstanceIdentifier entry) { + public Iterable getOperationalSubpaths(final YangInstanceIdentifier entry) { // FIXME: This should be indexed - Iterable paths = getStoredOperationalPaths(); + Iterable paths = getStoredOperationalPaths(); return getChildrenPaths(entry, paths); } - private static final Iterable getChildrenPaths(final InstanceIdentifier entry, - final Iterable paths) { - ImmutableSet.Builder children = ImmutableSet.builder(); - for (InstanceIdentifier potential : paths) { + private static final Iterable getChildrenPaths(final YangInstanceIdentifier entry, + final Iterable paths) { + ImmutableSet.Builder children = ImmutableSet.builder(); + for (YangInstanceIdentifier potential : paths) { if (entry.contains(potential)) { children.add(entry); } @@ -221,19 +221,19 @@ AutoCloseable { return children.build(); } - private final Comparator> preparationComparator = new Comparator>() { + private final Comparator> preparationComparator = new Comparator>() { @Override - public int compare(final Entry o1, final Entry o2) { - InstanceIdentifier o1Key = o1.getKey(); - InstanceIdentifier o2Key = o2.getKey(); + public int compare(final Entry o1, final Entry o2) { + YangInstanceIdentifier o1Key = o1.getKey(); + YangInstanceIdentifier o2Key = o2.getKey(); return Integer.compare(o1Key.getPath().size(), o2Key.getPath().size()); } }; - private class MergeFirstLevelReader implements DataReader { + private class MergeFirstLevelReader implements DataReader { @Override - public CompositeNode readConfigurationData(final InstanceIdentifier path) { + public CompositeNode readConfigurationData(final YangInstanceIdentifier path) { getDelegateReadLock().lock(); try { if (Iterables.isEmpty(path.getPathArguments())) { @@ -249,10 +249,10 @@ AutoCloseable { qname = path.getPath().get(path.getPath().size() - 1).getNodeType(); } - FluentIterable directChildren = FluentIterable.from(getStoredConfigurationPaths()) - .filter(new Predicate() { + FluentIterable directChildren = FluentIterable.from(getStoredConfigurationPaths()) + .filter(new Predicate() { @Override - public boolean apply(final InstanceIdentifier input) { + public boolean apply(final YangInstanceIdentifier input) { if (path.contains(input)) { int nesting = input.getPath().size() - path.getPath().size(); if (nesting == 1) { @@ -262,7 +262,7 @@ AutoCloseable { return false; } }); - for (InstanceIdentifier instanceIdentifier : directChildren) { + for (YangInstanceIdentifier instanceIdentifier : directChildren) { childNodes.add(getDelegate().readConfigurationData(instanceIdentifier)); } if (original == null && childNodes.isEmpty()) { @@ -276,7 +276,7 @@ AutoCloseable { } @Override - public CompositeNode readOperationalData(final InstanceIdentifier path) { + public CompositeNode readOperationalData(final YangInstanceIdentifier path) { getDelegateReadLock().lock(); try { if (Iterables.isEmpty(path.getPathArguments())) { @@ -292,10 +292,10 @@ AutoCloseable { qname = path.getPath().get(path.getPath().size() - 1).getNodeType(); } - FluentIterable directChildren = FluentIterable.from(getStoredOperationalPaths()) - .filter(new Predicate() { + FluentIterable directChildren = FluentIterable.from(getStoredOperationalPaths()) + .filter(new Predicate() { @Override - public boolean apply(final InstanceIdentifier input) { + public boolean apply(final YangInstanceIdentifier input) { if (path.contains(input)) { int nesting = input.getPath().size() - path.getPath().size(); if (nesting == 1) { @@ -306,7 +306,7 @@ AutoCloseable { } }); - for (InstanceIdentifier instanceIdentifier : directChildren) { + for (YangInstanceIdentifier instanceIdentifier : directChildren) { childNodes.add(getDelegate().readOperationalData(instanceIdentifier)); } if (original == null && childNodes.isEmpty()) { @@ -320,14 +320,14 @@ AutoCloseable { } } - private class NormalizedDataModification extends AbstractDataModification { + private class NormalizedDataModification extends AbstractDataModification { private final String CONFIGURATIONAL_DATA_STORE_MARKER = "configurational"; private final String OPERATIONAL_DATA_STORE_MARKER = "operational"; private final Object identifier; private TransactionStatus status; - public NormalizedDataModification(final DataModification original) { + public NormalizedDataModification(final DataModification original) { super(getDelegate()); identifier = original; status = TransactionStatus.NEW; @@ -340,27 +340,27 @@ AutoCloseable { * * @param entry */ - public void deepRemoveOperationalData(final InstanceIdentifier entry) { - Iterable paths = getOperationalSubpaths(entry); + public void deepRemoveOperationalData(final YangInstanceIdentifier entry) { + Iterable paths = getOperationalSubpaths(entry); removeOperationalData(entry); - for (InstanceIdentifier potential : paths) { + for (YangInstanceIdentifier potential : paths) { removeOperationalData(potential); } } - public void deepRemoveConfigurationData(final InstanceIdentifier entry) { - Iterable paths = getConfigurationSubpaths(entry); + public void deepRemoveConfigurationData(final YangInstanceIdentifier entry) { + Iterable paths = getConfigurationSubpaths(entry); removeConfigurationData(entry); - for (InstanceIdentifier potential : paths) { + for (YangInstanceIdentifier potential : paths) { removeConfigurationData(potential); } } - public void putDeepConfigurationData(final InstanceIdentifier entryKey, final CompositeNode entryData) { + public void putDeepConfigurationData(final YangInstanceIdentifier entryKey, final CompositeNode entryData) { this.putCompositeNodeData(entryKey, entryData, CONFIGURATIONAL_DATA_STORE_MARKER); } - public void putDeepOperationalData(final InstanceIdentifier entryKey, final CompositeNode entryData) { + public void putDeepOperationalData(final YangInstanceIdentifier entryKey, final CompositeNode entryData) { this.putCompositeNodeData(entryKey, entryData, OPERATIONAL_DATA_STORE_MARKER); } @@ -380,18 +380,18 @@ AutoCloseable { } @Override - protected CompositeNode mergeConfigurationData(final InstanceIdentifier path, final CompositeNode stored, + protected CompositeNode mergeConfigurationData(final YangInstanceIdentifier path, final CompositeNode stored, final CompositeNode modified) { return mergeData(path, stored, modified, true); } @Override - protected CompositeNode mergeOperationalData(final InstanceIdentifier path, final CompositeNode stored, + protected CompositeNode mergeOperationalData(final YangInstanceIdentifier path, final CompositeNode stored, final CompositeNode modified) { return mergeData(path, stored, modified, false); } - private void putData(final InstanceIdentifier entryKey, final CompositeNode entryData, final String dataStoreIdentifier) { + private void putData(final YangInstanceIdentifier entryKey, final CompositeNode entryData, final String dataStoreIdentifier) { if (dataStoreIdentifier != null && entryKey != null && entryData != null) { switch (dataStoreIdentifier) { case (CONFIGURATIONAL_DATA_STORE_MARKER): @@ -408,29 +408,29 @@ AutoCloseable { } } - private void putCompositeNodeData(final InstanceIdentifier entryKey, final CompositeNode entryData, + private void putCompositeNodeData(final YangInstanceIdentifier entryKey, final CompositeNode entryData, final String dataStoreIdentifier) { this.putData(entryKey, entryData, dataStoreIdentifier); for (Node child : entryData.getValue()) { - InstanceIdentifier subEntryId = InstanceIdentifier.builder(entryKey).node(child.getNodeType()) + YangInstanceIdentifier subEntryId = YangInstanceIdentifier.builder(entryKey).node(child.getNodeType()) .toInstance(); if (child instanceof CompositeNode) { DataSchemaNode subSchema = schemaNodeFor(subEntryId); CompositeNode compNode = (CompositeNode) child; - InstanceIdentifier instanceId = null; + YangInstanceIdentifier instanceId = null; if (subSchema instanceof ListSchemaNode) { ListSchemaNode listSubSchema = (ListSchemaNode) subSchema; Map mapOfSubValues = this.getValuesFromListSchema(listSubSchema, (CompositeNode) child); if (mapOfSubValues != null) { - instanceId = InstanceIdentifier.builder(entryKey) + instanceId = YangInstanceIdentifier.builder(entryKey) .nodeWithKey(listSubSchema.getQName(), mapOfSubValues).toInstance(); } } else if (subSchema instanceof ContainerSchemaNode) { ContainerSchemaNode containerSchema = (ContainerSchemaNode) subSchema; - instanceId = InstanceIdentifier.builder(entryKey).node(subSchema.getQName()).toInstance(); + instanceId = YangInstanceIdentifier.builder(entryKey).node(subSchema.getQName()).toInstance(); } if (instanceId != null) { this.putCompositeNodeData(instanceId, compNode, dataStoreIdentifier); 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 7bc827dcb0..44e7abc3aa 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 @@ -31,7 +31,7 @@ import org.opendaylight.yangtools.concepts.util.ListenerRegistry; 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.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.RpcDefinition; import org.opendaylight.yangtools.yang.model.api.SchemaContext; @@ -50,7 +50,7 @@ public class SchemaAwareRpcBroker implements RpcRouter, Identifiable, Ro private final ListenerRegistry rpcRegistrationListeners = new ListenerRegistry<>(); - private final ListenerRegistry> routeChangeListeners = new ListenerRegistry<>(); + private final ListenerRegistry> routeChangeListeners = new ListenerRegistry<>(); private final String identifier; @@ -216,7 +216,7 @@ public class SchemaAwareRpcBroker implements RpcRouter, Identifiable, Ro } @Override - public ListenableFuture> invokeRpc(final QName rpc, final InstanceIdentifier route, final CompositeNode input) { + 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); } @@ -225,10 +225,10 @@ public class SchemaAwareRpcBroker implements RpcRouter, Identifiable, Ro implementations.remove(registration.getType(), registration); } - void notifyPathAnnouncement(final QName context, final QName identifier, final InstanceIdentifier path) { + void notifyPathAnnouncement(final QName context, final QName identifier, final YangInstanceIdentifier path) { RpcRoutingContext contextWrapped = RpcRoutingContext.create(context, identifier); - RouteChange change = RoutingUtils.announcementChange(contextWrapped , path); - for(ListenerRegistration> routeListener : routeChangeListeners) { + RouteChange change = RoutingUtils.announcementChange(contextWrapped , path); + for(ListenerRegistration> routeListener : routeChangeListeners) { try { routeListener.getInstance().onRouteChange(change); } catch (Exception e) { @@ -238,10 +238,10 @@ public class SchemaAwareRpcBroker implements RpcRouter, Identifiable, Ro } - void notifyPathWithdrawal(final QName context,final QName identifier, final InstanceIdentifier path) { + void notifyPathWithdrawal(final QName context,final QName identifier, final YangInstanceIdentifier path) { RpcRoutingContext contextWrapped = RpcRoutingContext.create(context, identifier); - RouteChange change = RoutingUtils.removalChange(contextWrapped , path); - for(ListenerRegistration> routeListener : routeChangeListeners) { + RouteChange change = RoutingUtils.removalChange(contextWrapped , path); + for(ListenerRegistration> routeListener : routeChangeListeners) { try { routeListener.getInstance().onRouteChange(change); } catch (Exception e) { @@ -251,10 +251,10 @@ public class SchemaAwareRpcBroker implements RpcRouter, Identifiable, Ro } @Override - public > ListenerRegistration registerRouteChangeListener( + public > ListenerRegistration registerRouteChangeListener( final L listener) { ListenerRegistration reg = routeChangeListeners.registerWithType(listener); - RouteChange initial = createInitialRouteChange(); + RouteChange initial = createInitialRouteChange(); try { listener.onRouteChange(initial); } catch (Exception e) { @@ -263,15 +263,15 @@ public class SchemaAwareRpcBroker implements RpcRouter, Identifiable, Ro return reg; } - private RouteChange createInitialRouteChange() { + private RouteChange createInitialRouteChange() { FluentIterable rpcSelectors = FluentIterable.from(implementations.values()).filter(RoutedRpcSelector.class); - ImmutableMap.Builder> announcements = ImmutableMap.builder(); - ImmutableMap.Builder> removals = ImmutableMap.builder(); + ImmutableMap.Builder> announcements = ImmutableMap.builder(); + ImmutableMap.Builder> removals = ImmutableMap.builder(); for (RoutedRpcSelector routedRpcSelector : rpcSelectors) { final RpcRoutingContext context = routedRpcSelector.getIdentifier(); - final Set paths = ImmutableSet.copyOf(routedRpcSelector.implementations.keySet()); + final Set paths = ImmutableSet.copyOf(routedRpcSelector.implementations.keySet()); announcements.put(context, paths); } return RoutingUtils.change(announcements.build(), removals.build()); diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DOMDataBrokerProxy.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DOMDataBrokerProxy.java index 4f44f361d5..b539cb948d 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DOMDataBrokerProxy.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DOMDataBrokerProxy.java @@ -9,7 +9,7 @@ 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.api.DOMTransactionChain; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.osgi.framework.ServiceReference; public class DOMDataBrokerProxy extends AbstractBrokerServiceProxy implements DOMDataBroker { @@ -35,7 +35,7 @@ public class DOMDataBrokerProxy extends AbstractBrokerServiceProxy registerDataChangeListener(final LogicalDatastoreType store, - final InstanceIdentifier path, final DOMDataChangeListener listener, + final YangInstanceIdentifier path, final DOMDataChangeListener listener, final org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope triggeringScope) { return getDelegate().registerDataChangeListener(store, path, listener, triggeringScope); } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DOMMountPointServiceProxy.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DOMMountPointServiceProxy.java new file mode 100644 index 0000000000..7a67755b6b --- /dev/null +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DOMMountPointServiceProxy.java @@ -0,0 +1,38 @@ +/* + * 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.dom.broker.osgi; + +import com.google.common.base.Optional; +import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; +import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; +import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.osgi.framework.ServiceReference; + +public class DOMMountPointServiceProxy extends AbstractBrokerServiceProxy implements DOMMountPointService{ + + + public DOMMountPointServiceProxy(final ServiceReference ref, final DOMMountPointService delegate) { + super(ref, delegate); + } + + @Override + public Optional getMountPoint(final YangInstanceIdentifier path) { + return getDelegate().getMountPoint(path); + } + + @Override + public DOMMountPointBuilder createMountPoint(final YangInstanceIdentifier path) { + return getDelegate().createMountPoint(path); + } + + public ListenerRegistration registerProvisionListener(final MountProvisionListener listener) { + return getDelegate().registerProvisionListener(listener); + } +} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DataBrokerServiceProxy.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DataBrokerServiceProxy.java index 30027ec929..94d423e012 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DataBrokerServiceProxy.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DataBrokerServiceProxy.java @@ -12,7 +12,7 @@ import org.opendaylight.controller.sal.core.api.data.DataChangeListener; import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.osgi.framework.ServiceReference; public class DataBrokerServiceProxy extends AbstractBrokerServiceProxy implements DataBrokerService { @@ -21,16 +21,16 @@ public class DataBrokerServiceProxy extends AbstractBrokerServiceProxy registerDataChangeListener(InstanceIdentifier path, + public ListenerRegistration registerDataChangeListener(YangInstanceIdentifier path, DataChangeListener listener) { return addRegistration(getDelegate().registerDataChangeListener(path, listener)); } - public CompositeNode readConfigurationData(InstanceIdentifier path) { + public CompositeNode readConfigurationData(YangInstanceIdentifier path) { return getDelegate().readConfigurationData(path); } - public CompositeNode readOperationalData(InstanceIdentifier path) { + public CompositeNode readOperationalData(YangInstanceIdentifier path) { return getDelegate().readOperationalData(path); } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DataProviderServiceProxy.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DataProviderServiceProxy.java index 5e5b25bdc8..86bfa23ed2 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DataProviderServiceProxy.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DataProviderServiceProxy.java @@ -19,7 +19,7 @@ import org.opendaylight.controller.sal.core.api.data.DataValidator; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.concepts.Registration; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.osgi.framework.ServiceReference; public class DataProviderServiceProxy extends AbstractBrokerServiceProxy implements @@ -29,16 +29,16 @@ public class DataProviderServiceProxy extends AbstractBrokerServiceProxy registerDataChangeListener(InstanceIdentifier path, + public ListenerRegistration registerDataChangeListener(YangInstanceIdentifier path, DataChangeListener listener) { return addRegistration(getDelegate().registerDataChangeListener(path, listener)); } - public CompositeNode readConfigurationData(InstanceIdentifier path) { + public CompositeNode readConfigurationData(YangInstanceIdentifier path) { return getDelegate().readConfigurationData(path); } - public CompositeNode readOperationalData(InstanceIdentifier path) { + public CompositeNode readOperationalData(YangInstanceIdentifier path) { return getDelegate().readOperationalData(path); } @@ -58,19 +58,19 @@ public class DataProviderServiceProxy extends AbstractBrokerServiceProxy commitHandler) { + YangInstanceIdentifier path, DataCommitHandler commitHandler) { return addRegistration(getDelegate().registerCommitHandler(path, commitHandler)); } @Override public Registration registerConfigurationReader( - InstanceIdentifier path, DataReader reader) { + YangInstanceIdentifier path, DataReader reader) { return addRegistration(getDelegate().registerConfigurationReader(path, reader)); } @Override public Registration registerOperationalReader( - InstanceIdentifier path, DataReader reader) { + YangInstanceIdentifier path, DataReader reader) { return addRegistration(getDelegate().registerOperationalReader(path, reader)); } @@ -85,8 +85,8 @@ public class DataProviderServiceProxy extends AbstractBrokerServiceProxy>> registerCommitHandlerListener( - RegistrationListener> commitHandlerListener) { + public ListenerRegistration>> registerCommitHandlerListener( + RegistrationListener> commitHandlerListener) { return addRegistration(getDelegate().registerCommitHandlerListener(commitHandlerListener)); } } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/MountProviderServiceProxy.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/MountProviderServiceProxy.java index 2669f1279e..c807aa0b84 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/MountProviderServiceProxy.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/MountProviderServiceProxy.java @@ -11,7 +11,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.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.osgi.framework.ServiceReference; public class MountProviderServiceProxy extends AbstractBrokerServiceProxy implements MountProvisionService{ @@ -22,17 +22,17 @@ public class MountProviderServiceProxy extends AbstractBrokerServiceProxy) ref), service); } + private static Object _createProxyImpl(final ServiceReference ref, + final DOMMountPointService service) { + + return new DOMMountPointServiceProxy( + ((ServiceReference) ref), service); + } + private static Object _createProxyImpl(final ServiceReference ref, final SchemaService service) { @@ -113,6 +121,8 @@ public class ProxyFactory { return _createProxyImpl(ref, (SchemaService) service); } else if (service instanceof NotificationService) { return _createProxyImpl(ref, (NotificationService) service); + } else if (service instanceof DOMMountPointService) { + return _createProxyImpl(ref, (DOMMountPointService) service); } else if (service != null) { return _createProxyImpl(ref, service); } else { diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/RpcProvisionRegistryProxy.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/RpcProvisionRegistryProxy.java index 7193a53177..3c1901a530 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/RpcProvisionRegistryProxy.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/RpcProvisionRegistryProxy.java @@ -21,7 +21,7 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration; 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.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.osgi.framework.ServiceReference; import com.google.common.util.concurrent.ListenableFuture; @@ -53,7 +53,7 @@ public class RpcProvisionRegistryProxy extends AbstractBrokerServiceProxy> ListenerRegistration registerRouteChangeListener(final L listener) { + public > ListenerRegistration registerRouteChangeListener(final L listener) { return getDelegate().registerRouteChangeListener(listener); } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/spi/RoutedRpcProcessor.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/spi/RoutedRpcProcessor.java index 2976c76ffa..f5e7dc99bd 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/spi/RoutedRpcProcessor.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/spi/RoutedRpcProcessor.java @@ -12,7 +12,7 @@ import java.util.Map; import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration; import org.opendaylight.controller.sal.core.api.RpcImplementation; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; public interface RoutedRpcProcessor extends RpcImplementation { @@ -20,7 +20,7 @@ public interface RoutedRpcProcessor extends RpcImplementation { QName getRpcType(); - Map getRoutes(); + Map getRoutes(); RpcImplementation getDefaultRoute(); diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/ProxySchemaContext.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/ProxySchemaContext.java new file mode 100644 index 0000000000..311055f4b4 --- /dev/null +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/ProxySchemaContext.java @@ -0,0 +1,193 @@ +/* + * 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.dom.broker.util; + +import java.net.URI; +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Set; + +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.model.api.AugmentationSchema; +import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition; +import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; +import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition; +import org.opendaylight.yangtools.yang.model.api.GroupingDefinition; +import org.opendaylight.yangtools.yang.model.api.Module; +import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier; +import org.opendaylight.yangtools.yang.model.api.NotificationDefinition; +import org.opendaylight.yangtools.yang.model.api.RpcDefinition; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider; +import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.Status; +import org.opendaylight.yangtools.yang.model.api.TypeDefinition; +import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; +import org.opendaylight.yangtools.yang.model.api.UsesNode; + +import com.google.common.base.Optional; +import com.google.common.base.Preconditions; + +/** + * ProxySchema Context for SchemaContextProviders + */ +public class ProxySchemaContext implements SchemaContext { + + private final SchemaContextProvider schemaProvider; + + public ProxySchemaContext(final SchemaContextProvider schemaProvider) { + this.schemaProvider = schemaProvider; + } + + private SchemaContext getCurrentSchema() { + Preconditions.checkState(schemaProvider.getSchemaContext() != null, "Schema context unavailable from %s", schemaProvider); + return schemaProvider.getSchemaContext(); + } + + @Override + public Set getDataDefinitions() { + return getCurrentSchema().getDataDefinitions(); + } + + @Override + public Set getModules() { + return getCurrentSchema().getModules(); + } + + @Override + public Set getNotifications() { + return getCurrentSchema().getNotifications(); + } + + @Override + public Set getOperations() { + return getCurrentSchema().getOperations(); + } + + @Override + public Set getExtensions() { + return getCurrentSchema().getExtensions(); + } + + @Override + public Module findModuleByName(final String s, final Date date) { + return getCurrentSchema().findModuleByName(s, date); + } + + @Override + public Set findModuleByNamespace(final URI uri) { + return getCurrentSchema().findModuleByNamespace(uri); + } + + @Override + public Module findModuleByNamespaceAndRevision(final URI uri, final Date date) { + return getCurrentSchema().findModuleByNamespaceAndRevision(uri, date); + } + + @Override + public Optional getModuleSource(final ModuleIdentifier moduleIdentifier) { + return getCurrentSchema().getModuleSource(moduleIdentifier); + } + + @Override + public Set getAllModuleIdentifiers() { + return getCurrentSchema().getAllModuleIdentifiers(); + } + + @Override + public boolean isPresenceContainer() { + return getCurrentSchema().isPresenceContainer(); + } + + @Override + public Set> getTypeDefinitions() { + return getCurrentSchema().getTypeDefinitions(); + } + + @Override + public Collection getChildNodes() { + return getCurrentSchema().getChildNodes(); + } + + @Override + public Set getGroupings() { + return getCurrentSchema().getGroupings(); + } + + @Override + public DataSchemaNode getDataChildByName(final QName qName) { + return getCurrentSchema().getDataChildByName(qName); + } + + @Override + public DataSchemaNode getDataChildByName(final String s) { + return getCurrentSchema().getDataChildByName(s); + } + + @Override + public Set getUses() { + return getCurrentSchema().getUses(); + } + + @Override + public Set getAvailableAugmentations() { + return getCurrentSchema().getAvailableAugmentations(); + } + + @Override + public boolean isAugmenting() { + return getCurrentSchema().isAugmenting(); + } + + @Override + public boolean isAddedByUses() { + return getCurrentSchema().isAddedByUses(); + } + + @Override + public boolean isConfiguration() { + return getCurrentSchema().isConfiguration(); + } + + @Override + public ConstraintDefinition getConstraints() { + return getCurrentSchema().getConstraints(); + } + + @Override + public QName getQName() { + return getCurrentSchema().getQName(); + } + + @Override + public SchemaPath getPath() { + return getCurrentSchema().getPath(); + } + + @Override + public List getUnknownSchemaNodes() { + return getCurrentSchema().getUnknownSchemaNodes(); + } + + @Override + public String getDescription() { + return getCurrentSchema().getDescription(); + } + + @Override + public String getReference() { + return getCurrentSchema().getReference(); + } + + @Override + public Status getStatus() { + return getCurrentSchema().getStatus(); + } +} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangSchemaUtils.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangSchemaUtils.java index cd1a792d67..970bb02899 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangSchemaUtils.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangSchemaUtils.java @@ -18,8 +18,8 @@ import java.util.List; import java.util.Set; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.model.api.AugmentationSchema; import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode; import org.opendaylight.yangtools.yang.model.api.ChoiceNode; @@ -54,7 +54,7 @@ public final class YangSchemaUtils { throw new UnsupportedOperationException("Utility class."); } - public static DataSchemaNode getSchemaNode(final SchemaContext schema,final InstanceIdentifier path) { + public static DataSchemaNode getSchemaNode(final SchemaContext schema,final YangInstanceIdentifier path) { checkArgument(schema != null,"YANG Schema must not be null."); checkArgument(path != null,"Path must not be null."); return getSchemaNode(schema, FluentIterable.from(path.getPathArguments()).transform(QNAME_FROM_PATH_ARGUMENT)); diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerPerformanceTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerPerformanceTest.java index 2dec6f2e4d..181396fc88 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerPerformanceTest.java +++ b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerPerformanceTest.java @@ -18,7 +18,7 @@ import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; 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.yang.data.api.InstanceIdentifier; +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; @@ -40,8 +40,8 @@ public class DOMBrokerPerformanceTest { return ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, i); } - private static InstanceIdentifier outerListPath(final int i) { - return InstanceIdentifier.builder(TestModel.OUTER_LIST_PATH)// + private static YangInstanceIdentifier outerListPath(final int i) { + return YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH)// .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, i) // .build(); } @@ -141,11 +141,11 @@ public class DOMBrokerPerformanceTest { int i = 0; for (DOMDataReadWriteTransaction writeTx :transactions) { // Writes /test/outer-list/i in writeTx - InstanceIdentifier path = InstanceIdentifier.builder(outerListPath(i)) + YangInstanceIdentifier path = YangInstanceIdentifier.builder(outerListPath(i)) .node(TestModel.INNER_LIST_QNAME).build(); writeTx.put(OPERATIONAL, path, ImmutableNodes.mapNodeBuilder(TestModel.INNER_LIST_QNAME).build()); for (int j = 0; j < innerNum; j++) { - InstanceIdentifier innerPath = InstanceIdentifier.builder(path) + YangInstanceIdentifier innerPath = YangInstanceIdentifier.builder(path) .nodeWithKey(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, String.valueOf(j)) .build(); writeTx.put( @@ -205,7 +205,7 @@ public class DOMBrokerPerformanceTest { public Void call() throws Exception { for (int i = 0; i < txNum; i++) { for (int j = 0; j < innerNum; j++) { - InstanceIdentifier path = InstanceIdentifier + YangInstanceIdentifier path = YangInstanceIdentifier .builder(outerListPath(i)) // .node(TestModel.INNER_LIST_QNAME) diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/MountPointServiceTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/MountPointServiceTest.java index 917976b4b4..4d686a9dae 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/MountPointServiceTest.java +++ b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/MountPointServiceTest.java @@ -19,12 +19,12 @@ import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService.DOMMountPointBuilder; import org.opendaylight.controller.md.sal.dom.broker.impl.mount.DOMMountPointServiceImpl; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; public class MountPointServiceTest { private DOMMountPointService mountService; - private static final InstanceIdentifier PATH = InstanceIdentifier.of(QName.create("namespace", "12-12-2012", "top")); + private static final YangInstanceIdentifier PATH = YangInstanceIdentifier.of(QName.create("namespace", "12-12-2012", "top")); @Before public void setup() { 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 91aa57c259..d5ba2a2b9a 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 @@ -8,7 +8,7 @@ package org.opendaylight.controller.md.sal.dom.store.impl; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl; @@ -29,8 +29,8 @@ public class TestModel { public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value"); private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang"; - public static final InstanceIdentifier TEST_PATH = InstanceIdentifier.of(TEST_QNAME); - public static final InstanceIdentifier OUTER_LIST_PATH = InstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build(); + public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_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/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointManagerTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointManagerTest.java new file mode 100644 index 0000000000..4d239a93f7 --- /dev/null +++ b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointManagerTest.java @@ -0,0 +1,138 @@ +/* + * 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.dom.broker; + +import static junit.framework.Assert.fail; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; +import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; +import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; +import org.opendaylight.controller.md.sal.dom.api.DOMService; +import org.opendaylight.controller.md.sal.dom.broker.impl.mount.DOMMountPointServiceImpl; +import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance; +import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener; +import org.opendaylight.yangtools.concepts.ObjectRegistration; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.Optional; + +public class BackwardsCompatibleMountPointManagerTest { + private static final Logger log = LoggerFactory.getLogger(BackwardsCompatibleMountPointManagerTest.class); + + @Mock + private DOMMountPointServiceImpl domMountPointService; + @Mock + private DOMMountPointService.DOMMountPointBuilder mountBuilder; + + private BackwardsCompatibleMountPointManager compatibleMountPointManager; + static final QName qName = QName.create("namespace", "12-12-1212", "mount"); + static final YangInstanceIdentifier id = YangInstanceIdentifier.builder(qName).build(); + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + stubMountService(); + compatibleMountPointManager = new BackwardsCompatibleMountPointManager(domMountPointService); + } + + @Test + public void testCreateMountpointAlreadyCreated() throws Exception { + compatibleMountPointManager.createMountPoint(id); + verify(domMountPointService).createMountPoint(id); + verify(mountBuilder, times(3)).addService(any(Class.class), any(DOMService.class)); + verify(mountBuilder).addInitialSchemaContext(any(SchemaContext.class)); + + try { + compatibleMountPointManager.createMountPoint(id); + } catch (final IllegalStateException e) { + log.debug("", e); + return; + } + fail("Should fail to create duplicate mount"); + } + + @Test + public void testCreateMountpointGetOrCreate() throws Exception { + compatibleMountPointManager = new BackwardsCompatibleMountPointManager(new DOMMountPointServiceImpl()); + + final MountProvisionListener listener = new MountProvisionListener() { + public int createdMounts = 0; + + @Override + public void onMountPointCreated(final YangInstanceIdentifier path) { + if(createdMounts++ > 1 ) { + fail("Only one mount point should have been created"); + } + } + + @Override + public void onMountPointRemoved(final YangInstanceIdentifier path) {} + }; + + compatibleMountPointManager.registerProvisionListener(listener); + + final MountProvisionInstance m1 = compatibleMountPointManager.createOrGetMountPoint(id); + m1.setSchemaContext(mockSchemaContext()); + compatibleMountPointManager.createOrGetMountPoint(id); + compatibleMountPointManager.createOrGetMountPoint(id); + } + + private void stubMountService() { + doReturn(mockMountPointBuilder()).when(domMountPointService).createMountPoint(any(YangInstanceIdentifier.class)); + doReturn(Optional.of(mockMountPoint())).when(domMountPointService).getMountPoint(any(YangInstanceIdentifier.class)); + } + + private DOMMountPoint mockMountPoint() { + final DOMMountPoint mock = mock(DOMMountPoint.class); + doAnswer(new Answer() { + @Override + public Object answer(final InvocationOnMock invocation) throws Throwable { + return Optional.of(mock(((Class) invocation.getArguments()[0]))); + } + }).when(mock).getService(any(Class.class)); + doReturn(mockSchemaContext()).when(mock).getSchemaContext(); + return mock; + } + + static SchemaContext mockSchemaContext() { + final SchemaContext mock = mock(SchemaContext.class); + doReturn(qName).when(mock).getQName(); + doReturn("schema").when(mock).toString(); + doReturn(mock(DataSchemaNode.class)).when(mock).getDataChildByName(any(QName.class)); + return mock; + } + + private DOMMountPointService.DOMMountPointBuilder mockMountPointBuilder() { + doReturn(mountBuilder).when(mountBuilder).addService(any(Class.class), any(DOMService.class)); + doReturn(mockObjectRegistration()).when(mountBuilder).register(); + doReturn(mountBuilder).when(mountBuilder).addInitialSchemaContext(any(SchemaContext.class)); + return mountBuilder; + } + + private ObjectRegistration mockObjectRegistration() { + return mock(ObjectRegistration.class); + } + +} diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointTest.java new file mode 100644 index 0000000000..91ae0c24dd --- /dev/null +++ b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointTest.java @@ -0,0 +1,154 @@ +/* + * 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.dom.broker; + +import static junit.framework.Assert.fail; +import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import com.google.common.base.Optional; +import com.google.common.util.concurrent.ListenableFuture; +import java.util.AbstractMap; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.controller.md.sal.common.api.TransactionStatus; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException; +import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer; +import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction; +import org.opendaylight.controller.sal.core.api.data.DataProviderService; +import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProvider; +import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.data.api.CompositeNode; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class BackwardsCompatibleMountPointTest { + private static final Logger log = LoggerFactory.getLogger(BackwardsCompatibleMountPointManagerTest.class); + + private static final YangInstanceIdentifier id = BackwardsCompatibleMountPointManagerTest.id; + private final NormalizedNode normalizedNode = mockNormalizedNode(); + private final CompositeNode compositeNode = mockCompositeNode(); + + @Mock + private DataProviderService oldBroker; + @Mock + private SchemaContextProvider schemaContextProvider; + @Mock + private DataModificationTransaction mockTx; + + private BackwardsCompatibleMountPoint.BackwardsCompatibleDomStore backwardsCompatibleDomStore; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + stubSchemaProvider(); + stubOldBroker(); + backwardsCompatibleDomStore = new BackwardsCompatibleMountPoint.BackwardsCompatibleDomStore(oldBroker, schemaContextProvider); + } + + private void stubOldBroker() { + doReturn(compositeNode).when(oldBroker).readConfigurationData(id); + doReturn(compositeNode).when(oldBroker).readOperationalData(id); + doReturn(mockTx).when(oldBroker).beginTransaction(); + doNothing().when(mockTx).putConfigurationData(id, compositeNode); + doNothing().when(mockTx).putOperationalData(id, compositeNode); + doReturn(com.google.common.util.concurrent.Futures.immediateFuture(RpcResultBuilder.success(TransactionStatus.COMMITED))).when(mockTx).commit(); + } + + private CompositeNode mockCompositeNode() { + final CompositeNode mock = mock(CompositeNode.class); + doReturn("node").when(mock).toString(); + return mock; + } + + private void stubSchemaProvider() { + doReturn(BackwardsCompatibleMountPointManagerTest.mockSchemaContext()).when(schemaContextProvider).getSchemaContext(); + } + + @Test + public void testBackwardsCompatibleBroker() throws Exception { + backwardsCompatibleDomStore.newReadOnlyTransaction(); + backwardsCompatibleDomStore.newWriteOnlyTransaction(); + backwardsCompatibleDomStore.newReadWriteTransaction(); + } + + @Test + public void testReadTransaction() throws Exception { + final BackwardsCompatibleMountPoint.BackwardsCompatibleDomStore.BackwardsCompatibleReadTransaction tx = + new BackwardsCompatibleMountPoint.BackwardsCompatibleDomStore.BackwardsCompatibleReadTransaction(oldBroker, mockNormalizer()); + + ListenableFuture>> read = tx.read(LogicalDatastoreType.CONFIGURATION, id); + assertEquals(normalizedNode, read.get().get()); + verify(oldBroker).readConfigurationData(id); + + read = tx.read(LogicalDatastoreType.OPERATIONAL, id); + assertEquals(normalizedNode, read.get().get()); + + verify(oldBroker).readOperationalData(id); + } + + @Test + public void testReadWriteTransactionOperational() throws Exception { + final BackwardsCompatibleMountPoint.BackwardsCompatibleDomStore.BackwardsCompatibleWriteTransaction tx = + new BackwardsCompatibleMountPoint.BackwardsCompatibleDomStore.BackwardsCompatibleWriteTransaction(oldBroker, mockNormalizer()); + + verify(oldBroker).beginTransaction(); + + tx.put(LogicalDatastoreType.CONFIGURATION, id, normalizedNode); + verify(mockTx).putConfigurationData(id, compositeNode); + + tx.put(LogicalDatastoreType.CONFIGURATION, id, normalizedNode); + verify(mockTx, times(2)).putConfigurationData(id, compositeNode); + + tx.commit(); + verify(mockTx).commit(); + } + + + @Test + public void testCannotPutOperational() throws Exception { + final BackwardsCompatibleMountPoint.BackwardsCompatibleDomStore.BackwardsCompatibleWriteTransaction tx = + new BackwardsCompatibleMountPoint.BackwardsCompatibleDomStore.BackwardsCompatibleWriteTransaction(oldBroker, mockNormalizer()); + + try { + tx.put(LogicalDatastoreType.OPERATIONAL, id, normalizedNode); + } catch (IllegalArgumentException e) { + // Cannot put operational data + log.debug("", e); + return; + } + + fail("Should fail when putting operational data"); + } + + private DataNormalizer mockNormalizer() throws DataNormalizationException { + final DataNormalizer mock = mock(DataNormalizer.class); + doReturn(new AbstractMap.SimpleEntry>(id, normalizedNode) {}) + .when(mock).toNormalized(any(YangInstanceIdentifier.class), any(CompositeNode.class)); + doReturn(compositeNode).when(mock).toLegacy(any(YangInstanceIdentifier.class), any(NormalizedNode.class)); + doReturn(id).when(mock).toLegacy(any(YangInstanceIdentifier.class)); + return mock; + } + + private NormalizedNode mockNormalizedNode() { + final NormalizedNode mock = mock(NormalizedNode.class); + doReturn("mockNormalizedNode").when(mock).toString(); + return mock; + } +} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/broker/spi/mount/SimpleDOMMountPoint.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/broker/spi/mount/SimpleDOMMountPoint.java index 48a6878327..003da3ea37 100644 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/broker/spi/mount/SimpleDOMMountPoint.java +++ b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/broker/spi/mount/SimpleDOMMountPoint.java @@ -2,7 +2,7 @@ package org.opendaylight.controller.md.sal.dom.broker.spi.mount; import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; import org.opendaylight.controller.md.sal.dom.api.DOMService; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import com.google.common.base.Optional; @@ -11,21 +11,21 @@ import com.google.common.collect.ImmutableClassToInstanceMap; public class SimpleDOMMountPoint implements DOMMountPoint { - private final InstanceIdentifier identifier; + private final YangInstanceIdentifier identifier; private final ClassToInstanceMap services; private final SchemaContext schemaContext; - public static final SimpleDOMMountPoint create(final InstanceIdentifier identifier, final ClassToInstanceMap services, final SchemaContext ctx) { + public static final SimpleDOMMountPoint create(final YangInstanceIdentifier identifier, final ClassToInstanceMap services, final SchemaContext ctx) { return new SimpleDOMMountPoint(identifier, services, ctx); } - private SimpleDOMMountPoint(final InstanceIdentifier identifier, final ClassToInstanceMap services, final SchemaContext ctx) { + private SimpleDOMMountPoint(final YangInstanceIdentifier identifier, final ClassToInstanceMap services, final SchemaContext ctx) { this.identifier = identifier; this.services = ImmutableClassToInstanceMap.copyOf(services); this.schemaContext = ctx; } @Override - public InstanceIdentifier getIdentifier() { + public YangInstanceIdentifier getIdentifier() { return identifier; } diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStore.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStore.java index ab47d1034f..0bab570bd1 100644 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStore.java +++ b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStore.java @@ -10,7 +10,7 @@ package org.opendaylight.controller.sal.core.spi.data; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; /** @@ -48,8 +48,8 @@ public interface DOMStore extends DOMStoreTransactionFactory { * registration / interest on receiving data changes. * */ - >> ListenerRegistration registerChangeListener( - InstanceIdentifier path, L listener, DataChangeScope scope); + >> ListenerRegistration registerChangeListener( + YangInstanceIdentifier path, L listener, DataChangeScope scope); /** * diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreReadTransaction.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreReadTransaction.java index b546f2e77d..ae1b3ee2aa 100644 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreReadTransaction.java +++ b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreReadTransaction.java @@ -7,7 +7,7 @@ */ package org.opendaylight.controller.sal.core.spi.data; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import com.google.common.base.Optional; @@ -31,5 +31,5 @@ public interface DOMStoreReadTransaction extends DOMStoreTransaction { * {@link java.util.concurrent.Future#get()} returns {@link Optional#absent()}. * */ - ListenableFuture>> read(InstanceIdentifier path); + ListenableFuture>> read(YangInstanceIdentifier path); } diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreWriteTransaction.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreWriteTransaction.java index 19bb0538c2..0a090520f2 100644 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreWriteTransaction.java +++ b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreWriteTransaction.java @@ -7,7 +7,7 @@ */ package org.opendaylight.controller.sal.core.spi.data; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; public interface DOMStoreWriteTransaction extends DOMStoreTransaction { @@ -29,7 +29,7 @@ public interface DOMStoreWriteTransaction extends DOMStoreTransaction { * if the client code already sealed transaction and invoked * {@link #ready()} */ - void write(InstanceIdentifier path, NormalizedNode data); + void write(YangInstanceIdentifier path, NormalizedNode data); /** * Store a provided data at specified path. This acts as a add / replace @@ -48,7 +48,7 @@ public interface DOMStoreWriteTransaction extends DOMStoreTransaction { * if the client code already sealed transaction and invoked * {@link #ready()} */ - void merge(InstanceIdentifier path, NormalizedNode data); + void merge(YangInstanceIdentifier path, NormalizedNode data); /** * @@ -60,7 +60,7 @@ public interface DOMStoreWriteTransaction extends DOMStoreTransaction { * if the client code already sealed transaction and invoked * {@link #ready()} */ - void delete(InstanceIdentifier path); + void delete(YangInstanceIdentifier path); /** * diff --git a/opendaylight/md-sal/sal-dom-xsql/.checkstyle b/opendaylight/md-sal/sal-dom-xsql/.checkstyle new file mode 100644 index 0000000000..48e02b8bba --- /dev/null +++ b/opendaylight/md-sal/sal-dom-xsql/.checkstyle @@ -0,0 +1,7 @@ + + + + + + + diff --git a/opendaylight/md-sal/sal-dom-xsql/.gitignore b/opendaylight/md-sal/sal-dom-xsql/.gitignore new file mode 100644 index 0000000000..a48e45b9df --- /dev/null +++ b/opendaylight/md-sal/sal-dom-xsql/.gitignore @@ -0,0 +1 @@ +/target-ide diff --git a/opendaylight/md-sal/sal-dom-xsql/pom.xml b/opendaylight/md-sal/sal-dom-xsql/pom.xml new file mode 100644 index 0000000000..2ab80daf3b --- /dev/null +++ b/opendaylight/md-sal/sal-dom-xsql/pom.xml @@ -0,0 +1,102 @@ + + + 4.0.0 + + org.opendaylight.controller + sal-parent + 1.1-SNAPSHOT + + sal-dom-xsql + bundle + sal-dom-xsql + XSQL language + + + + org.opendaylight.controller + config-api + + + org.opendaylight.controller + sal-binding-api + + + org.opendaylight.controller + sal-binding-config + + + org.opendaylight.controller + sal-common-util + + + org.opendaylight.controller + sal-core-api + + + org.opendaylight.controller + yang-jmx-generator-plugin + ${config.version} + + + org.opendaylight.yangtools + yang-binding + + + org.opendaylight.yangtools + yang-common + + + org.osgi + org.osgi.core + + + + + + org.apache.felix + maven-bundle-plugin + + + org.opendaylight.yangtools + yang-maven-plugin + + + org.opendaylight.yangtools + maven-sal-api-gen-plugin + ${yangtools.version} + jar + + + + + + generate-sources + + + src/main/yang + + + org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + ${jmxGeneratorPath} + + urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang + + + + org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl + ${salGeneratorPath} + + + true + + + + + + + https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL:XSQL + + Sharon Aicler + https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL:XSQL + + diff --git a/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/TablesResultSet.java b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/TablesResultSet.java new file mode 100644 index 0000000000..2f28052758 --- /dev/null +++ b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/TablesResultSet.java @@ -0,0 +1,1241 @@ +package org.opendaylight.controller.md.sal.dom.xsql; + +import java.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; +import java.net.URL; +import java.sql.Array; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.Date; +import java.sql.NClob; +import java.sql.Ref; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.RowId; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.SQLXML; +import java.sql.Statement; +import java.sql.Time; +import java.sql.Timestamp; +import java.util.Calendar; +import java.util.Map; + +public class TablesResultSet implements ResultSet { + + private String tables[] = null; + private int pos = -1; + + public TablesResultSet(XSQLBluePrint cache) { + //tables = cache.getInterfaceNames(); + } + + @Override + public T unwrap(Class iface) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean next() throws SQLException { + if (tables == null) { + return false; + } + pos++; + if (pos >= tables.length) { + return false; + } + return true; + } + + @Override + public void close() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public boolean wasNull() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public String getString(int columnIndex) throws SQLException { + return tables[pos]; + } + + @Override + public boolean getBoolean(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public byte getByte(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public short getShort(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getInt(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public long getLong(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public float getFloat(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public double getDouble(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public BigDecimal getBigDecimal(int columnIndex, int scale) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public byte[] getBytes(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Date getDate(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Time getTime(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Timestamp getTimestamp(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public InputStream getAsciiStream(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public InputStream getUnicodeStream(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public InputStream getBinaryStream(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getString(String columnLabel) throws SQLException { + return tables[pos]; + } + + @Override + public boolean getBoolean(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public byte getByte(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public short getShort(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getInt(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public long getLong(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public float getFloat(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public double getDouble(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public BigDecimal getBigDecimal(String columnLabel, int scale) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public byte[] getBytes(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Date getDate(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Time getTime(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Timestamp getTimestamp(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public InputStream getAsciiStream(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public InputStream getUnicodeStream(String columnLabel) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public InputStream getBinaryStream(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public SQLWarning getWarnings() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public void clearWarnings() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public String getCursorName() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultSetMetaData getMetaData() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object getObject(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object getObject(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public int findColumn(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public Reader getCharacterStream(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Reader getCharacterStream(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public BigDecimal getBigDecimal(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public BigDecimal getBigDecimal(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean isBeforeFirst() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isAfterLast() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isFirst() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isLast() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public void beforeFirst() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void afterLast() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public boolean first() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean last() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public int getRow() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public boolean absolute(int row) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean relative(int rows) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean previous() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public void setFetchDirection(int direction) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public int getFetchDirection() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public void setFetchSize(int rows) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public int getFetchSize() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getType() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getConcurrency() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public boolean rowUpdated() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean rowInserted() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean rowDeleted() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public void updateNull(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBoolean(int columnIndex, boolean x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateByte(int columnIndex, byte x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateShort(int columnIndex, short x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateInt(int columnIndex, int x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateLong(int columnIndex, long x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateFloat(int columnIndex, float x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateDouble(int columnIndex, double x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBigDecimal(int columnIndex, BigDecimal x) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateString(int columnIndex, String x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBytes(int columnIndex, byte[] x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateDate(int columnIndex, Date x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateTime(int columnIndex, Time x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateTimestamp(int columnIndex, Timestamp x) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x, int length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x, int length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x, int length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateObject(int columnIndex, Object x, int scaleOrLength) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateObject(int columnIndex, Object x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateNull(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBoolean(String columnLabel, boolean x) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateByte(String columnLabel, byte x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateShort(String columnLabel, short x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateInt(String columnLabel, int x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateLong(String columnLabel, long x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateFloat(String columnLabel, float x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateDouble(String columnLabel, double x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBigDecimal(String columnLabel, BigDecimal x) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateString(String columnLabel, String x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBytes(String columnLabel, byte[] x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateDate(String columnLabel, Date x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateTime(String columnLabel, Time x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateTimestamp(String columnLabel, Timestamp x) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x, int length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x, + int length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader, + int length) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateObject(String columnLabel, Object x, int scaleOrLength) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateObject(String columnLabel, Object x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void insertRow() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateRow() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void deleteRow() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void refreshRow() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void cancelRowUpdates() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void moveToInsertRow() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void moveToCurrentRow() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public Statement getStatement() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object getObject(int columnIndex, Map> map) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Ref getRef(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Blob getBlob(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Clob getClob(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Array getArray(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object getObject(String columnLabel, Map> map) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Ref getRef(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Blob getBlob(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Clob getClob(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Array getArray(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Date getDate(int columnIndex, Calendar cal) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Date getDate(String columnLabel, Calendar cal) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Time getTime(int columnIndex, Calendar cal) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Time getTime(String columnLabel, Calendar cal) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Timestamp getTimestamp(int columnIndex, Calendar cal) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Timestamp getTimestamp(String columnLabel, Calendar cal) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public URL getURL(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public URL getURL(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public void updateRef(int columnIndex, Ref x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateRef(String columnLabel, Ref x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBlob(int columnIndex, Blob x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBlob(String columnLabel, Blob x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateClob(int columnIndex, Clob x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateClob(String columnLabel, Clob x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateArray(int columnIndex, Array x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateArray(String columnLabel, Array x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public RowId getRowId(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public RowId getRowId(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public void updateRowId(int columnIndex, RowId x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateRowId(String columnLabel, RowId x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public int getHoldability() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public boolean isClosed() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public void updateNString(int columnIndex, String nString) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateNString(String columnLabel, String nString) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateNClob(int columnIndex, NClob nClob) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateNClob(String columnLabel, NClob nClob) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public NClob getNClob(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public NClob getNClob(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public SQLXML getSQLXML(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public SQLXML getSQLXML(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public void updateSQLXML(int columnIndex, SQLXML xmlObject) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateSQLXML(String columnLabel, SQLXML xmlObject) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public String getNString(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getNString(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Reader getNCharacterStream(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Reader getNCharacterStream(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public void updateNCharacterStream(int columnIndex, Reader x, long length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateNCharacterStream(String columnLabel, Reader reader, + long length) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x, long length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x, long length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x, long length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x, + long length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x, + long length) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader, + long length) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBlob(int columnIndex, InputStream inputStream, + long length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBlob(String columnLabel, InputStream inputStream, + long length) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateClob(int columnIndex, Reader reader, long length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateClob(String columnLabel, Reader reader, long length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateNClob(int columnIndex, Reader reader, long length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateNClob(String columnLabel, Reader reader, long length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateNCharacterStream(int columnIndex, Reader x) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateNCharacterStream(String columnLabel, Reader reader) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBlob(int columnIndex, InputStream inputStream) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBlob(String columnLabel, InputStream inputStream) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateClob(int columnIndex, Reader reader) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateClob(String columnLabel, Reader reader) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateNClob(int columnIndex, Reader reader) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateNClob(String columnLabel, Reader reader) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public T getObject(int columnIndex, Class type) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public T getObject(String columnLabel, Class type) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + +} + diff --git a/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLAdapter.java b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLAdapter.java new file mode 100644 index 0000000000..6d4400fe20 --- /dev/null +++ b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLAdapter.java @@ -0,0 +1,531 @@ +package org.opendaylight.controller.md.sal.dom.xsql; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.PrintStream; +import java.net.ServerSocket; +import java.net.Socket; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; +import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction; +import org.opendaylight.controller.md.sal.dom.xsql.jdbc.JDBCResultSet; +import org.opendaylight.controller.md.sal.dom.xsql.jdbc.JDBCServer; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.model.api.Module; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; + +public class XSQLAdapter extends Thread implements SchemaContextListener { + + private static final int SLEEP = 10000; + private static XSQLAdapter a = new XSQLAdapter(); + private static PrintStream l = null; + public boolean stopped = false; + private List elementHosts = new ArrayList(); + private String username; + private String password; + private String transport = "tcp"; + private int reconnectTimeout; + private int nThreads; + private int qsize; + private String applicationName = "NQL Adapter"; + private Map elements = new ConcurrentHashMap(); + private StringBuffer lastInputString = new StringBuffer(); + private XSQLBluePrint bluePrint = new XSQLBluePrint(); + private boolean toCsv = false; + private String exportToFileName = null; + private XSQLThreadPool threadPool = new XSQLThreadPool(1, "Tasks", 2000); + private JDBCServer jdbcServer = new JDBCServer(this); + private String pinningFile; + private ServerSocket serverSocket = null; + private DOMDataBroker domDataBroker = null; + + private XSQLAdapter() { + XSQLAdapter.log("Starting Adapter"); + this.setDaemon(true); + try { + serverSocket = new ServerSocket(34343); + } catch (Exception err) { + XSQLAdapter.log(err); + } + this.start(); + XSQLAdapter.log("Adapter Started!"); + + } + + public static XSQLAdapter getInstance() { + return a; + } + + public static void main(String args[]) { + XSQLAdapter adapter = new XSQLAdapter(); + adapter.start(); + } + + public static void log(String str) { + try { + if (l == null) { + synchronized (XSQLAdapter.class) { + if (l == null) { + l = new PrintStream( + new FileOutputStream("/tmp/xql.log")); + } + } + } + l.print(Calendar.getInstance().getTime()); + l.print(" - "); + l.println(str); + } catch (Exception err) { + err.printStackTrace(); + } + } + + public static void log(Exception e) { + try { + if (l == null) { + synchronized (XSQLAdapter.class) { + if (l == null) { + l = new PrintStream( + new FileOutputStream("/tmp/xql.log")); + } + } + } + l.print(Calendar.getInstance().getTime()); + l.print(" - "); + e.printStackTrace(l); + } catch (Exception err) { + err.printStackTrace(); + } + } + + @Override + public void onGlobalContextUpdated(SchemaContext context) { + Set modules = context.getModules(); + for (Module m : modules) { + if (XSQLODLUtils.createOpenDaylightCache(this.bluePrint, m)) { + this.addRootElement(m); + } + } + } + + public void setDataBroker(DOMDataBroker ddb) { + this.domDataBroker = ddb; + } + + public XSQLBluePrint getBluePrint() { + return this.bluePrint; + } + + public List collectModuleRoots(XSQLBluePrintNode table) { + if (table.getParent().isModule()) { + try { + List result = new LinkedList(); + YangInstanceIdentifier instanceIdentifier = YangInstanceIdentifier + .builder() + .node(XSQLODLUtils.getPath(table.getODLNode()).get(0)) + .toInstance(); + DOMDataReadTransaction t = this.domDataBroker + .newReadOnlyTransaction(); + Object node = t.read(LogicalDatastoreType.OPERATIONAL, + instanceIdentifier).get(); + node = XSQLODLUtils.get(node, "reference"); + if (node == null) { + return result; + } + + // XSQLAdapter.log(""+node); + Map children = XSQLODLUtils.getChildren(node); + for (Object c : children.values()) { + Map sons = XSQLODLUtils.getChildren(c); + for (Object child : sons.values()) { + result.add(child); + } + } + + return result; + } catch (Exception err) { + XSQLAdapter.log(err); + } + } else { + return collectModuleRoots(table.getParent()); + } + return null; + } + + public void execute(JDBCResultSet rs) { + List tables = rs.getTables(); + List roots = collectModuleRoots(tables.get(0)); + XSQLBluePrintNode main = rs.getMainTable(); + List tasks = new LinkedList(); + + for (Object entry : roots) { + NETask task = new NETask(rs, entry, main, bluePrint); + rs.numberOfTasks++; + tasks.add(task); + } + for (NETask task : tasks) { + threadPool.addTask(task); + } + } + + public void run() { + while (!stopped) { + try { + Socket s = serverSocket.accept(); + new TelnetConnection(s); + } catch (Exception err) { + err.printStackTrace(); + try { + Thread.sleep(20000); + } catch (Exception err2) { + } + stopped = true; + } + } + } + + public void addRootElement(Object o) { + NEEntry entry = new NEEntry(o); + elements.put(o.toString(), entry); + + } + + protected void processCommand(StringBuffer inputString, PrintStream sout, + TelnetConnection tc) { + if (inputString.toString().trim().equals("r")) { + sout.println(lastInputString); + inputString = lastInputString; + } + lastInputString = inputString; + String input = inputString.toString().trim(); + if (input.startsWith("setExcel")) { + String substr = input.substring("setExcel".length()).trim(); + if (!substr.equals("")) { + // excelPath01 = substr; + } + // sout.println("Excel Path="+excelPath01); + } else if (input.startsWith("list vrel")) { + String substr = input.substring("list vrel".length()).trim(); + XSQLBluePrintNode node = bluePrint + .getBluePrintNodeByTableName(substr); + if (node == null) { + sout.println("Unknown Interface " + substr); + return; + } + List fld = new ArrayList(); + for (XSQLBluePrintRelation r : node.getRelations()) { + fld.add(r.toString()); + } + String p[] = (String[]) fld.toArray(new String[fld.size()]); + Arrays.sort(p); + for (int i = 0; i < p.length; i++) { + sout.println(p[i]); + } + } else if (input.startsWith("list vfields")) { + String substr = input.substring("list vfields".length()).trim(); + XSQLBluePrintNode node = bluePrint + .getBluePrintNodeByTableName(substr); + if (node == null) { + sout.println("Unknown Interface " + substr); + return; + } + List fld = new ArrayList(); + for (XSQLColumn c : node.getColumns()) { + fld.add(c.getName()); + } + String p[] = (String[]) fld.toArray(new String[fld.size()]); + Arrays.sort(p); + for (int i = 0; i < p.length; i++) { + sout.println(p[i]); + } + } else if (input.startsWith("jdbc")) { + String addr = input.substring(5).trim(); + jdbcServer.connectToClient(addr); + sout.println("Connected To " + addr); + } else if (input.startsWith("fetch")) { + // fetchSize = Integer.parseInt(input.substring(6).trim()); + } else if (input.startsWith("list vtables")) { + + String iNames[] = bluePrint.getAllTableNames().toArray( + new String[0]); + Arrays.sort(iNames); + sout.println(); + for (int i = 0; i < iNames.length; i++) { + sout.println(iNames[i]); + } + } else if (input.startsWith("cd sid")) { + String substr = input.substring("cd sid".length()).trim(); + for (NEEntry e : elements.values()) { + if (((Module) e.ne).getName().equals(substr)) { + tc.currentModule = (Module) e.ne; + } + } + } else if (input.equals("list sid")) { + String arr[] = new String[elements.size()]; + + int i = 0; + for (NEEntry entry : elements.values()) { + arr[i] = entry.toString(); + i++; + } + Arrays.sort(arr); + for (String s : arr) { + sout.println(s); + } + } else if (input.equals("help") || input.equals("?")) { + // sout.println(getLongDescription()); + } else if (input.equals("avmdata")) { + try { + // myConnection.getManagedData(); + } catch (Exception err) { + } + } else if (input.equals("innerjoin")) { + // innerJoin = !innerJoin; + // sout.println("Inner Join set to "+innerJoin); + } else if (input.equals("exit")) { + try { + sout.close(); + } catch (Exception err) { + } + } else if (input.equals("tocsv")) { + toCsv = !toCsv; + sout.println("to csv file is " + toCsv); + } else if (input.indexOf("filename") != -1) { + exportToFileName = input.substring(input.indexOf(" ")).trim(); + sout.println("Exporting to file:" + exportToFileName); + } else if (!input.equals("")) { + if (toCsv) { + if (exportToFileName != null) { + try { + PrintStream o = new PrintStream(new File( + exportToFileName)); + executeSql(inputString.toString(), o); + o.close(); + } catch (Exception err) { + err.printStackTrace(); + } + } else { + try { + String fName = "export-" + System.currentTimeMillis() + + ".csv"; + PrintStream o = new PrintStream(new File(fName)); + executeSql(inputString.toString(), o); + o.close(); + sout.println("Exported to file " + fName); + } catch (Exception err) { + err.printStackTrace(); + } + + } + } else { + executeSql(inputString.toString(), sout); + } + } + sout.println(); + } + + public void executeSql(String sql, PrintStream out) { + JDBCResultSet rs = new JDBCResultSet(sql); + try { + int count = 0; + jdbcServer.execute(rs, this); + boolean isFirst = true; + int loc = rs.getFields().size() - 1; + int totalWidth = 0; + for (XSQLColumn c : rs.getFields()) { + if (isFirst) { + isFirst = false; + if (toCsv) { + out.print("\""); + } + } + + if (!toCsv) { + out.print("|"); + } + + out.print(c.getName()); + + if (!toCsv) { + int cw = c.getCharWidth(); + int cnw = c.getName().length(); + if (cnw > cw) { + c.setCharWidth(cnw); + } + int gap = cw - cnw; + for (int i = 0; i < gap; i++) { + out.print(" "); + } + } + + totalWidth += c.getCharWidth() + 1; + + if (loc > 0) { + if (toCsv) { + out.print("\",\""); + } + } + loc--; + } + + if (toCsv) { + out.println("\""); + } else { + totalWidth++; + out.println("|"); + for (int i = 0; i < totalWidth; i++) { + out.print("-"); + } + out.println(); + } + + while (rs.next()) { + isFirst = true; + loc = rs.getFields().size() - 1; + for (XSQLColumn c : rs.getFields()) { + if (isFirst) { + isFirst = false; + if (toCsv) { + out.print("\""); + } + } + + if (!toCsv) { + out.print("|"); + } + + Object sValue = rs.getObject(c.toString()); + if (sValue == null) { + sValue = ""; + } + out.print(sValue); + + int cw = c.getCharWidth(); + int vw = sValue.toString().length(); + int gap = cw - vw; + for (int i = 0; i < gap; i++) { + out.print(" "); + } + + if (loc > 0) { + if (toCsv) { + out.print("\",\""); + } + } + loc--; + } + if (toCsv) { + out.println("\""); + } else { + out.println("|"); + } + count++; + } + out.println("Total Number Of Records=" + count); + } catch (Exception err) { + err.printStackTrace(out); + } + } + + public static class NETask implements Runnable { + + private JDBCResultSet rs = null; + private Object modelRoot = null; + private XSQLBluePrintNode main = null; + private XSQLBluePrint bluePrint = null; + + public NETask(JDBCResultSet _rs, Object _modelRoot, + XSQLBluePrintNode _main, XSQLBluePrint _bluePrint) { + this.rs = _rs; + this.modelRoot = _modelRoot; + this.main = _main; + this.bluePrint = _bluePrint; + } + + public void run() { + rs.addRecords(modelRoot, main, true, main.getBluePrintNodeName(), + bluePrint); + synchronized (rs) { + rs.numberOfTasks--; + if (rs.numberOfTasks == 0) { + rs.setFinished(true); + rs.notifyAll(); + } + } + } + } + + private static class NEEntry { + private Object ne = null; + + public NEEntry(Object _ne) { + this.ne = _ne; + } + + public String toString() { + Module m = (Module) ne; + return m.getName() + " [" + m.getNamespace().toString() + "]"; + } + } + + private class TelnetConnection extends Thread { + + private Socket socket = null; + private InputStream in = null; + private PrintStream out = null; + private Module currentModule = null; + + public TelnetConnection(Socket s) { + this.socket = s; + try { + this.in = s.getInputStream(); + this.out = new PrintStream(s.getOutputStream()); + this.start(); + } catch (Exception err) { + XSQLAdapter.log(err); + } + } + + public void run() { + StringBuffer inputString = new StringBuffer(); + String prompt = "XSQL>"; + try { + while (!stopped) { + if (currentModule != null) { + prompt = "XQL/" + currentModule.getName() + ">"; + } + out.print(prompt); + char c = 0; + byte data[] = new byte[1]; + while (c != '\n') { + try { + in.read(data); + c = (char) data[0]; + inputString.append(c); + } catch (Exception err) { + err.printStackTrace(out); + } + } + + processCommand(inputString, out, this); + inputString = new StringBuffer(); + } + } catch (Exception err) { + try { + socket.close(); + } catch (Exception err2) { + } + } + } + } +} diff --git a/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLBluePrint.java b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLBluePrint.java new file mode 100644 index 0000000000..1a31662020 --- /dev/null +++ b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLBluePrint.java @@ -0,0 +1,1314 @@ +package org.opendaylight.controller.md.sal.dom.xsql; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Proxy; +import java.lang.reflect.Type; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.sql.RowIdLifetime; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class XSQLBluePrint implements DatabaseMetaData { + + public static final String CACHE_FILE_NAME = "BluePrintCache.dat"; + + private Map tableNameToBluePrint = new HashMap(); + private Map> odlNameToBluePrint = new HashMap>(); + + private boolean cacheLoadedSuccessfuly = false; + private DatabaseMetaData myProxy = null; + + public static final String replaceAll(String source, String toReplace, + String withThis) { + int index = source.indexOf(toReplace); + int index2 = 0; + StringBuffer result = new StringBuffer(); + while (index != -1) { + result.append(source.substring(index2, index)); + result.append(withThis); + index2 = index + toReplace.length(); + index = source.indexOf(toReplace, index2); + } + if (index2 < source.length()) { + result.append(source.substring(index2)); + } + return result.toString(); + } + + public XSQLBluePrint() { + } + + private class NQLBluePrintProxy implements InvocationHandler { + public Object invoke(Object proxy, Method method, Object[] args) + throws Throwable { + System.out.println("Method " + method); + return method.invoke(XSQLBluePrint.this, args); + } + } + + public DatabaseMetaData getProxy() { + if (myProxy == null) { + try { + myProxy = (DatabaseMetaData) Proxy + .newProxyInstance(getClass().getClassLoader(), + new Class[] {DatabaseMetaData.class}, + new NQLBluePrintProxy()); + } catch (Exception err) { + err.printStackTrace(); + } + } + return myProxy; + } + + /* + public void loadBluePrintCache(String hostName) { + try { + ObjectInputStream in = new ObjectInputStream( + new FileInputStream(hostName + "-" + CACHE_FILE_NAME)); + cache = (Map) in.readObject(); + in.close(); + cacheLoadedSuccessfuly = true; + } catch (Exception err) { + //err.printStackTrace(); + } + }*/ + + public XSQLBluePrintNode[] getBluePrintNodeByODLTableName(String odlTableName) { + Map map = this.odlNameToBluePrint.get(odlTableName); + if(map==null) return null; + return map.values().toArray(new XSQLBluePrintNode[map.size()]); + } + + public XSQLBluePrintNode getBluePrintNodeByTableName(String tableName) { + if (tableName.indexOf(".") != -1) { + tableName = tableName.substring(tableName.lastIndexOf(".") + 1); + } + + XSQLBluePrintNode node = tableNameToBluePrint.get(tableName); + + if (node != null) { + return node; + } + + for (XSQLBluePrintNode n : tableNameToBluePrint.values()) { + if (n.getBluePrintNodeName().endsWith(tableName)) { + return n; + } + } + + for (XSQLBluePrintNode n : tableNameToBluePrint.values()) { + if (n.getBluePrintNodeName().toLowerCase().endsWith(tableName.toLowerCase())) { + return n; + } + } + + for (XSQLBluePrintNode n : tableNameToBluePrint.values()) { + if (n.getBluePrintNodeName().toLowerCase().equals(tableName.toLowerCase())) { + return n; + } + } + + for (XSQLBluePrintNode n : tableNameToBluePrint.values()) { + if (n.getBluePrintNodeName().toLowerCase().indexOf(tableName.toLowerCase())!= -1) { + return n; + } + } + return null; + } + + + public boolean isCacheLoaded() { + return cacheLoadedSuccessfuly; + } + + private static Map> superClassMap = new HashMap>(); + + public static Set getInheritance(Class myObjectClass, + Class returnType) { + + if (returnType != null && myObjectClass.equals(returnType)) { + return new HashSet(); + } + Set result = superClassMap.get(myObjectClass); + if (result != null) { + return result; + } + result = new HashSet(); + superClassMap.put(myObjectClass, result); + if (returnType != null) { + if (!returnType.equals(myObjectClass)) { + Class mySuperClass = myObjectClass.getSuperclass(); + while (mySuperClass != null) { + result.add(mySuperClass); + mySuperClass = mySuperClass.getSuperclass(); + } + result.addAll(collectInterfaces(myObjectClass)); + } + } + return result; + } + + public static Set collectInterfaces(Class cls) { + Set result = new HashSet(); + Class myInterfaces[] = cls.getInterfaces(); + if (myInterfaces != null) { + for (Class in : myInterfaces) { + result.add(in); + result.addAll(collectInterfaces(in)); + } + } + return result; + } + + public void addToBluePrintCache(XSQLBluePrintNode blNode) { + this.tableNameToBluePrint.put(blNode.getBluePrintNodeName(), blNode); + Map map = this.odlNameToBluePrint.get(blNode.getODLTableName()); + if(map==null){ + map = new HashMap(); + this.odlNameToBluePrint.put(blNode.getODLTableName(),map); + } + map.put(blNode.getBluePrintNodeName(), blNode); + } + + public Class getGenericType(ParameterizedType type) { + Type[] typeArguments = type.getActualTypeArguments(); + for (Type typeArgument : typeArguments) { + if (typeArgument instanceof ParameterizedType) { + ParameterizedType pType = (ParameterizedType) typeArgument; + return (Class) pType.getRawType(); + } else if (typeArgument instanceof Class) { + return (Class) typeArgument; + } + } + return null; + } + + public Class getMethodReturnTypeFromGeneric(Method m) { + Type rType = m.getGenericReturnType(); + if (rType instanceof ParameterizedType) { + return getGenericType((ParameterizedType) rType); + } + return null; + } + + public List getAllTableNames() { + List names = new ArrayList(); + for (XSQLBluePrintNode n : this.tableNameToBluePrint.values()) { + if (!n.isModule() && !n.getColumns().isEmpty()) { + names.add(n.getBluePrintNodeName()); + } + } + return names; + + } + + public List getInterfaceNames(XSQLBluePrintNode node) { + Set children = node.getChildren(); + List names = new ArrayList(); + for (XSQLBluePrintNode n : children) { + if (!n.isModule() && !n.getColumns().isEmpty()) { + names.add(n.toString()); + } + names.addAll(getInterfaceNames(n)); + } + return names; + } + + @Override + public boolean allProceduresAreCallable() throws SQLException { + return false; + } + + @Override + public boolean allTablesAreSelectable() throws SQLException { + return true; + } + + @Override + public boolean autoCommitFailureClosesAllResultSets() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean dataDefinitionCausesTransactionCommit() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean dataDefinitionIgnoredInTransactions() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean deletesAreDetected(int type) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean doesMaxRowSizeIncludeBlobs() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public ResultSet getAttributes(String catalog, String schemaPattern, + String typeNamePattern, String attributeNamePattern) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultSet getBestRowIdentifier(String catalog, String schema, + String table, int scope, boolean nullable) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultSet getCatalogs() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getCatalogSeparator() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getCatalogTerm() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultSet getClientInfoProperties() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultSet getColumnPrivileges(String catalog, String schema, + String table, String columnNamePattern) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultSet getColumns(String catalog, String schemaPattern, + String tableNamePattern, String columnNamePattern) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Connection getConnection() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultSet getCrossReference(String parentCatalog, + String parentSchema, String parentTable, String foreignCatalog, + String foreignSchema, String foreignTable) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public int getDatabaseMajorVersion() throws SQLException { + return 0; + } + + @Override + public int getDatabaseMinorVersion() throws SQLException { + // TODO Auto-generated method stub + return 1; + } + + @Override + public String getDatabaseProductName() throws SQLException { + return "VNE Query Language"; + } + + @Override + public String getDatabaseProductVersion() throws SQLException { + return "0.1"; + } + + @Override + public int getDefaultTransactionIsolation() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getDriverMajorVersion() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getDriverMinorVersion() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public String getDriverName() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getDriverVersion() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultSet getExportedKeys(String catalog, String schema, + String table) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getExtraNameCharacters() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultSet getFunctionColumns(String catalog, String schemaPattern, + String functionNamePattern, String columnNamePattern) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultSet getFunctions(String catalog, String schemaPattern, + String functionNamePattern) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getIdentifierQuoteString() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultSet getImportedKeys(String catalog, String schema, + String table) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultSet getIndexInfo(String catalog, String schema, String table, + boolean unique, boolean approximate) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public int getJDBCMajorVersion() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getJDBCMinorVersion() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxBinaryLiteralLength() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxCatalogNameLength() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxCharLiteralLength() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxColumnNameLength() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxColumnsInGroupBy() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxColumnsInIndex() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxColumnsInOrderBy() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxColumnsInSelect() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxColumnsInTable() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxConnections() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxCursorNameLength() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxIndexLength() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxProcedureNameLength() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxRowSize() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxSchemaNameLength() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxStatementLength() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxStatements() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxTableNameLength() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxTablesInSelect() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxUserNameLength() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public String getNumericFunctions() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultSet getPrimaryKeys(String catalog, String schema, String table) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultSet getProcedureColumns(String catalog, String schemaPattern, + String procedureNamePattern, String columnNamePattern) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultSet getProcedures(String catalog, String schemaPattern, + String procedureNamePattern) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getProcedureTerm() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public int getResultSetHoldability() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public RowIdLifetime getRowIdLifetime() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultSet getSchemas() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultSet getSchemas(String catalog, String schemaPattern) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getSchemaTerm() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getSearchStringEscape() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getSQLKeywords() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public int getSQLStateType() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public String getStringFunctions() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultSet getSuperTables(String catalog, String schemaPattern, + String tableNamePattern) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultSet getSuperTypes(String catalog, String schemaPattern, + String typeNamePattern) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getSystemFunctions() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultSet getTablePrivileges(String catalog, String schemaPattern, + String tableNamePattern) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultSet getTables(String catalog, String schemaPattern, + String tableNamePattern, String[] types) throws SQLException { + return new TablesResultSet(this); + } + + @Override + public ResultSet getTableTypes() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getTimeDateFunctions() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultSet getTypeInfo() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultSet getUDTs(String catalog, String schemaPattern, + String typeNamePattern, int[] types) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getURL() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getUserName() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultSet getVersionColumns(String catalog, String schema, + String table) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean insertsAreDetected(int type) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isCatalogAtStart() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isReadOnly() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean locatorsUpdateCopy() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean nullPlusNonNullIsNull() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean nullsAreSortedAtEnd() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean nullsAreSortedAtStart() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean nullsAreSortedHigh() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean nullsAreSortedLow() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean othersDeletesAreVisible(int type) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean othersInsertsAreVisible(int type) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean othersUpdatesAreVisible(int type) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean ownDeletesAreVisible(int type) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean ownInsertsAreVisible(int type) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean ownUpdatesAreVisible(int type) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean storesLowerCaseIdentifiers() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean storesLowerCaseQuotedIdentifiers() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean storesMixedCaseIdentifiers() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean storesMixedCaseQuotedIdentifiers() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean storesUpperCaseIdentifiers() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean storesUpperCaseQuotedIdentifiers() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsAlterTableWithAddColumn() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsAlterTableWithDropColumn() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsANSI92EntryLevelSQL() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsANSI92FullSQL() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsANSI92IntermediateSQL() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsBatchUpdates() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsCatalogsInDataManipulation() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsCatalogsInIndexDefinitions() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsCatalogsInPrivilegeDefinitions() + throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsCatalogsInProcedureCalls() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsCatalogsInTableDefinitions() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsColumnAliasing() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsConvert() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsConvert(int fromType, int toType) + throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsCoreSQLGrammar() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsCorrelatedSubqueries() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsDataDefinitionAndDataManipulationTransactions() + throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsDataManipulationTransactionsOnly() + throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsDifferentTableCorrelationNames() + throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsExpressionsInOrderBy() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsExtendedSQLGrammar() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsFullOuterJoins() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsGetGeneratedKeys() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsGroupBy() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsGroupByBeyondSelect() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsGroupByUnrelated() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsIntegrityEnhancementFacility() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsLikeEscapeClause() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsLimitedOuterJoins() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsMinimumSQLGrammar() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsMixedCaseIdentifiers() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsMultipleOpenResults() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsMultipleResultSets() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsMultipleTransactions() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsNamedParameters() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsNonNullableColumns() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsOpenCursorsAcrossCommit() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsOpenCursorsAcrossRollback() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsOpenStatementsAcrossCommit() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsOpenStatementsAcrossRollback() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsOrderByUnrelated() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsOuterJoins() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsPositionedDelete() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsPositionedUpdate() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsResultSetConcurrency(int type, int concurrency) + throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsResultSetHoldability(int holdability) + throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsResultSetType(int type) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsSavepoints() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsSchemasInDataManipulation() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsSchemasInIndexDefinitions() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsSchemasInProcedureCalls() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsSchemasInTableDefinitions() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsSelectForUpdate() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsStatementPooling() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsStoredFunctionsUsingCallSyntax() + throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsStoredProcedures() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsSubqueriesInComparisons() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsSubqueriesInExists() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsSubqueriesInIns() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsSubqueriesInQuantifieds() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsTableCorrelationNames() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsTransactionIsolationLevel(int level) + throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsTransactions() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsUnion() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean supportsUnionAll() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean updatesAreDetected(int type) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean usesLocalFilePerTable() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean usesLocalFiles() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public T unwrap(Class iface) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultSet getPseudoColumns(String catalog, String schemaPattern, + String tableNamePattern, String columnNamePattern) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean generatedKeyAlwaysReturned() throws SQLException { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLBluePrintNode.java b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLBluePrintNode.java new file mode 100644 index 0000000000..fbd818e632 --- /dev/null +++ b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLBluePrintNode.java @@ -0,0 +1,236 @@ +package org.opendaylight.controller.md.sal.dom.xsql; + +import java.io.Serializable; +import java.sql.SQLException; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +public class XSQLBluePrintNode implements Serializable { + + private static final long serialVersionUID = 1L; + private Class myInterface = null; + private String myInterfaceString = null; + private Set relations = + new HashSet(); + private Set inheritingNodes = + new HashSet(); + private Set children = new HashSet(); + private XSQLBluePrintNode parent = null; + + private int level = -1; + private transient Set parentHierarchySet = null; + private String myInterfaceName = null; + private Set columns = new HashSet(); + + private transient Object odlNode = null; + private boolean module = false; + private String bluePrintTableName = null; + private String odlTableName = null; + + public XSQLBluePrintNode(Class _myInterface, int _level) { + this.myInterface = _myInterface; + this.myInterfaceString = _myInterface.getName(); + this.myInterfaceName = myInterface.getSimpleName(); + this.level = _level; + } + + public XSQLBluePrintNode(Object _odlNode, int _level,XSQLBluePrintNode _parent) { + this.odlNode = _odlNode; + this.level = _level; + this.module = XSQLODLUtils.isModule(_odlNode); + this.parent = _parent; + this.bluePrintTableName = XSQLODLUtils.getBluePrintName(_odlNode); + + } + + public String getBluePrintNodeName(){ + return this.bluePrintTableName; + } + + public boolean isModule() { + return this.module; + } + + public Set getChildren() { + return this.children; + } + + public String getODLTableName() { + if (this.odlTableName == null) { + this.odlTableName = XSQLODLUtils.getODLNodeName(this.odlNode); + } + return this.odlTableName; + } + + public Object getODLNode() { + return this.odlNode; + } + + public void AddChild(XSQLBluePrintNode ch) { + this.children.add(ch); + } + + public boolean isModelChild(Class p) { + if (this.relations.size() == 0) { + return false; + } + for (XSQLBluePrintRelation parentRelation : this.relations) { + if (parentRelation.getParent().getInterface().equals(p)) { + return true; + } + } + for (XSQLBluePrintRelation dtr : this.relations) { + XSQLBluePrintNode parent = dtr.getParent(); + if (!parent.getInterface().equals(this.getInterface()) && !parent + .getInterface().isAssignableFrom(this.getInterface()) && + this.getInterface().isAssignableFrom(parent.getInterface()) + && parent.isModelChild(p)) { + return true; + } + } + return false; + } + + public Set getRelations() { + return this.relations; + } + + public String getClassName() { + return this.myInterfaceString; + } + + public void addInheritingNode(XSQLBluePrintNode node) { + this.inheritingNodes.add(node); + } + + public Set getInheritingNodes() { + return this.inheritingNodes; + } + + public void addColumn(Object node, String tableName) { + XSQLColumn c = new XSQLColumn(node,getBluePrintNodeName(), this); + this.columns.add(c); + } + + public void addColumn(String methodName) { + if (methodName.startsWith("get")) { + methodName = methodName.substring(3); + } else if (methodName.startsWith("is")) { + methodName = methodName.substring(2); + } + XSQLColumn c = new XSQLColumn(methodName, myInterfaceName, null); + this.columns.add(c); + } + + public Collection getColumns() { + return this.columns; + } + + public XSQLColumn findColumnByName(String name) throws SQLException { + + XSQLColumn exactMatch = null; + XSQLColumn indexOfMatch = null; + XSQLColumn exactLowercaseMatch = null; + XSQLColumn indexOfLowerCaseMatch = null; + + for (XSQLColumn col : columns) { + if (col.getName().equals(name)) { + exactMatch = col; + } + if (col.getName().indexOf(name) != -1) { + indexOfMatch = col; + } + if (col.getName().toLowerCase().equals(name.toLowerCase())) { + exactLowercaseMatch = col; + } + if (col.getName().toLowerCase().indexOf(name.toLowerCase()) != -1) { + indexOfLowerCaseMatch = col; + } + } + + if (exactMatch != null) { + return exactMatch; + } + if (exactLowercaseMatch != null) { + return exactLowercaseMatch; + } + if (indexOfMatch != null) { + return indexOfMatch; + } + if (indexOfLowerCaseMatch != null) { + return indexOfLowerCaseMatch; + } + + throw new SQLException("Unknown field name '" + name + "'"); + } + + + public void addParent(XSQLBluePrintNode parent, String property) { + try { + if (property.equals("ContainingTPs")) { + return; + } + //Method m = parent.getInterface().getMethod("get"+property, null); + //if(!m.getDeclaringClass().equals(parent.getInterface())) + //return; + XSQLBluePrintRelation rel = + new XSQLBluePrintRelation(parent, property, myInterface); + relations.add(rel); + } catch (Exception err) { + err.printStackTrace(); + } + } + + public XSQLBluePrintNode getParent() { + return this.parent; + } + + public Set getClonedParents() { + Set result = + new HashSet(); + result.addAll(this.relations); + return result; + } + + public String toString() { + if (myInterfaceName != null) { + return myInterfaceName; + } + if (odlNode != null) { + return getBluePrintNodeName(); + } + return "Unknown"; + } + + public Class getInterface() { + return this.myInterface; + } + + public int getLevel() { + return this.level; + } + + @Override + public boolean equals(Object obj) { + XSQLBluePrintNode other = (XSQLBluePrintNode) obj; + if (odlNode != null) { + return getBluePrintNodeName().equals(other.getBluePrintNodeName()); + } else if (this.odlTableName != null) { + return this.odlTableName.equals(other.odlTableName); + } else { + return other.myInterface.equals(myInterface); + } + } + + @Override + public int hashCode() { + if (myInterfaceString != null) { + return myInterfaceString.hashCode(); + } else if (odlNode != null) { + return bluePrintTableName.hashCode(); + } + return 0; + } + +} diff --git a/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLBluePrintRelation.java b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLBluePrintRelation.java new file mode 100644 index 0000000000..1cb3aa5559 --- /dev/null +++ b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLBluePrintRelation.java @@ -0,0 +1,139 @@ +package org.opendaylight.controller.md.sal.dom.xsql; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class XSQLBluePrintRelation implements Serializable { + private static final long serialVersionUID = 2L; + private XSQLBluePrintNode parent = null; + private String property = null; + private Class childClass = null; + + public XSQLBluePrintRelation(XSQLBluePrintNode _parent, String _property, + Class _childClass) { + this.parent = _parent; + this.property = _property; + this.childClass = _childClass; + } + + public Class getNEClosestClass() { + Class p = parent.getInterface(); + return getNEClosestClass(p); + } + + + public static Class getNEClosestClass(Class p) { + while (!p.getInterfaces()[0] + .equals(Object.class/*XSQLBluePrint.STOP_INTERFACE*/)) { + p = p.getInterfaces()[0]; + } + return p; + } + + public XSQLBluePrintNode getParent() { + return parent; + } + + public String getProperty() { + return property; + } + + public Class getChildClass() { + return this.childClass; + } + + public boolean equals(Object obj) { + XSQLBluePrintRelation other = (XSQLBluePrintRelation) obj; + if (other.parent != null && this.parent == null) { + return false; + } + if (other.parent == null && this.parent != null) { + return false; + } + + if (other.parent == null && this.parent == null) { + return property.equals(other.property); + } + + if (other.parent.toString().equals(this.parent.toString())) { + return property.equals(other.property); + } + + return false; + } + + public int hashCode() { + if (parent != null) { + return parent.toString().hashCode() + property.hashCode(); + } + return property.hashCode(); + } + + public String toString() { + if (parent != null) { + return parent.toString() + ":" + property; + } else { + return property; + } + } + + public List execute(Object o) { + List result = new LinkedList(); + if (o == null) { + return null; + } + + if (Set.class.isAssignableFrom(o.getClass())) { + Set lst = (Set) o; + for (Object oo : lst) { + addToResult(result, execute(oo)); + } + return result; + } else if (List.class.isAssignableFrom(o.getClass())) { + List lst = (List) o; + for (Object oo : lst) { + addToResult(result, execute(oo)); + } + return result; + } else if (Map.class.isAssignableFrom(o.getClass())) { + Map map = (Map) o; + for (Object oo : map.values()) { + addToResult(result, execute(oo)); + } + return result; + } + + addToResult(result, XSQLCriteria.getValue(o, this.property)); + + return result; + } + + public static void addToResult(List result, Object o) { + if (o == null) { + return; + } + if (Set.class.isAssignableFrom(o.getClass())) { + Set lst = (Set) o; + for (Object oo : lst) { + result.add(oo); + } + } else if (List.class.isAssignableFrom(o.getClass())) { + List lst = (List) o; + for (Object oo : lst) { + result.add(oo); + } + } else if (Map.class.isAssignableFrom(o.getClass())) { + Map map = (Map) o; + for (Object oo : map.values()) { + result.add(oo); + } + } else { + result.add(o); + } + } + +} + diff --git a/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLColumn.java b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLColumn.java new file mode 100644 index 0000000000..55ac600f4a --- /dev/null +++ b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLColumn.java @@ -0,0 +1,80 @@ +package org.opendaylight.controller.md.sal.dom.xsql; + +import java.io.Serializable; + +public class XSQLColumn implements Serializable, Comparable { + private String name = null; + private String tableName = null; + private int charWidth = -1; + private Class type = null; + private transient Object bluePrintNode = null; + + public XSQLColumn(Object odlNode, String _tableName, Object _bluePrintNode) { + this.name = XSQLODLUtils.getNodeNameFromDSN(odlNode); + this.tableName = _tableName; + this.bluePrintNode = _bluePrintNode; + this.type = XSQLODLUtils.getTypeForODLColumn(odlNode); + } + + public String getName() { + return name; + } + + public String getTableName() { + return tableName; + } + + public void setCharWidth(int i) { + if (this.charWidth < i) { + this.charWidth = i; + } + } + + public int getCharWidth() { + return this.charWidth; + } + + @Override + public int hashCode() { + return this.name.hashCode() + this.tableName.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof XSQLColumn)) { + return false; + } + XSQLColumn other = (XSQLColumn) obj; + return tableName.equals(other.tableName) && name.equals(other.name); + } + + public Object getBluePrintNode() { + return this.bluePrintNode; + } + + @Override + public String toString() { + return tableName + "." + name; + } + + @Override + public int compareTo(Object o) { + return this.toString().compareTo(o.toString()); + } + + public Object getResultSetValue(Object obj){ + if(this.type.equals(String.class)){ + return obj.toString(); + }else + if(this.type.equals(int.class)){ + return Integer.parseInt(obj.toString()); + }else + if(this.type.equals(long.class)){ + return Long.parseLong(obj.toString()); + }else + if(this.type.equals(byte.class)){ + return Byte.parseByte(obj.toString()); + } + return null; + } +} diff --git a/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLCriteria.java b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLCriteria.java new file mode 100644 index 0000000000..ed75254bb2 --- /dev/null +++ b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLCriteria.java @@ -0,0 +1,371 @@ +package org.opendaylight.controller.md.sal.dom.xsql; + +import java.io.Serializable; +import java.lang.reflect.Method; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public class XSQLCriteria implements Serializable { + private static final long serialVersionUID = 1L; + + private static final String operators[] = + new String[] {" and ", " or ", ">=", "<=", "!=", "=", ">", "<", "like", + "is null", "not null", "skip"}; + private static final String STRING_CHAR = "'"; + + public static final int OP_CODE_AND = 0; + public static final int OP_CODE_OR = 1; + public static final int OP_CODE_GTEQ = 2; + public static final int OP_CODE_LTEQ = 3; + public static final int OP_CODE_NOT_EQ = 4; + public static final int OP_CODE_EQUAL = 5; + public static final int OP_CODE_GT = 6; + public static final int OP_CODE_LT = 7; + public static final int OP_CODE_LIKE = 8; + public static final int OP_CODE_NULL = 9; + public static final int OP_CODE_NOT_NULL = 10; + public static final int OP_CODE_SKIP = 11; + + private XSQLCriteria left = null; + private XSQLCriteria right = null; + + private int operation = -1; + + private Object leftValue = null; + private Object rightValue = null; + private String criteria = null; + + private static final Map, Map> methodCache = + new ConcurrentHashMap, Map>(); + + public XSQLCriteria(final String data, final int parentOperation) { + criteria = data; + parse(data, parentOperation); + } + + private void parse(String data, int parentOperation) { + + data = data.trim(); + + int index1 = data.indexOf("("); + if (index1 != -1) { + String leftCondition = data.substring(0, index1).trim(); + if (leftCondition.trim().equals("")) { + int index2 = data.lastIndexOf(")"); + if (index2 < data.length() - 1) { + String rtValue = data.substring(index2 + 1).trim(); + if (!rtValue.equals("")) { + left = + new XSQLCriteria(data.substring(index1 + 1, index2), + parentOperation); + data = data.substring(index2 + 1); + } else { + data = data.substring(1, index2); + } + } else { + data = data.substring(1, index2); + } + } else { + right = new XSQLCriteria( + data.substring(index1 + 1, data.length() - 1), + parentOperation); + data = data.substring(0, index1); + } + } + + for (int i = 0; i < operators.length; i++) { + index1 = data.indexOf(operators[i]); + if (index1 != -1) { + this.operation = i; + if (left == null) { + left = new XSQLCriteria(data.substring(0, index1), + this.operation); + } + if (left.leftValue != null && left.rightValue == null + && left.right == null) { + leftValue = left.leftValue; + left = null; + } + if (right == null) { + right = new XSQLCriteria( + data.substring(index1 + operators[i].length()), + this.operation); + } + if (right.leftValue != null && right.rightValue == null + && right.right == null) { + rightValue = right.leftValue; + right = null; + } + return; + } + } + + if (data.startsWith("'") && data.endsWith("'")) { + data = data.substring(1, data.length() - 1); + } + + if (parentOperation == OP_CODE_LIKE && data.startsWith("%") && data.endsWith("%") + && data.substring(1, data.length() - 1).indexOf("%") == -1) { + data = data.substring(1, data.length() - 1); + } + + leftValue = data; + } + + public static Object getValue(Object element, String propertyName) { + try { + Map cache = methodCache.get(element.getClass()); + if (cache == null) { + cache = new ConcurrentHashMap(); + methodCache.put(element.getClass(), cache); + } + + Method m = cache.get(propertyName); + if (m == null) { + Method methods[] = element.getClass().getMethods(); + for (Method mm : methods) { + if (mm.getName().equals(propertyName) || mm.getName() + .equals("get" + propertyName) || mm.getName() + .equals("is" + propertyName)) { + m = mm; + m.setAccessible(true); + cache.put(propertyName, m); + break; + } + } + } + + Object value = null; + if (m == null) { + return null; + } + if (m.getParameterTypes() == null + || m.getParameterTypes().length == 0) { + value = m.invoke(element, null); + } else { + if (String.class.isAssignableFrom(m.getParameterTypes()[0])) { + return null; + } + Object arg = m.getParameterTypes()[0].newInstance(); + value = m.invoke(element, arg); + } + return value; + } catch (Exception err) { + err.printStackTrace(); + } + return null; + } + + public int isObjectFitCriteria(Object element, String propertyName) { + Object value = getValue(element, propertyName); + if (value != null) { + value = value.toString(); + } + return checkValue(value); + } + + public int checkValue(Object value) { + if (leftValue != null && rightValue != null) { + Object aSide = null; + Object bSide = null; + if (leftValue.equals("?")) { + aSide = value; + } else { + aSide = leftValue; + } + + if (rightValue.equals("?")) { + bSide = value; + } else { + bSide = rightValue; + } + if (operation != OP_CODE_SKIP && operation != OP_CODE_NULL) { + if (aSide == null && bSide != null) { + return 0; + } else if (aSide != null && bSide == null) { + return 0; + } else if (aSide == null && bSide == null) { + return 1; + } + } + switch (operation) { + case OP_CODE_EQUAL: + if (aSide.equals(bSide)) { + return 1; + } else { + return 0; + } + case OP_CODE_NOT_EQ: + if (!aSide.equals(bSide)) { + return 1; + } else { + return 0; + } + case OP_CODE_LIKE: + if (aSide.toString().indexOf(bSide.toString()) != -1) { + return 1; + } else { + return 0; + } + case OP_CODE_NULL: + if (aSide == null) { + return 1; + } else { + return 0; + } + case OP_CODE_NOT_NULL: + if (aSide != null) { + return 1; + } else { + return 0; + } + case OP_CODE_GT: + if (aSide == null || bSide == null) { + return 0; + } + if (Double.parseDouble(aSide.toString().trim()) > Double + .parseDouble(bSide.toString().trim())) { + return 1; + } else { + return 0; + } + case OP_CODE_GTEQ: + if (aSide == null || bSide == null) { + return 0; + } + if (Double.parseDouble(aSide.toString().trim()) >= Double + .parseDouble(bSide.toString().trim())) { + return 1; + } else { + return 0; + } + + case OP_CODE_LT: + if (aSide == null || bSide == null) { + return 0; + } + if (Double.parseDouble(aSide.toString().trim()) < Double + .parseDouble(bSide.toString().trim())) { + return 1; + } else { + return 0; + } + case OP_CODE_LTEQ: + if (aSide == null || bSide == null) { + return 0; + } + if (Double.parseDouble(aSide.toString().trim()) <= Double + .parseDouble(bSide.toString().trim())) { + return 1; + } else { + return 0; + } + } + } + + int leftResult = 0; + if (left != null) { + leftResult = left.checkValue(value); + } + + int rightResult = 0; + if (right != null) { + rightResult = right.checkValue(value); + } + + if (operation == OP_CODE_SKIP) { + if (rightResult == 0) { + return 2; + } else { + return 3; + } + } + + if (operation == OP_CODE_AND) { + if (leftResult == 0) { + return 0; + } + if (rightResult == 0) { + return 0; + } + if (leftResult >= 2) { + return leftResult; + } + if (rightResult >= 2) { + return rightResult; + } + + return 1; + } + + if (operation == OP_CODE_OR) { + if (leftResult == 0 && rightResult == 0) { + return 0; + } + if (leftResult >= 2) { + return leftResult; + } + if (rightResult >= 2) { + return rightResult; + } + return 1; + } + + return 0; + } + + public String toString() { + return criteria; + } + + public String getCriteriaForProperty(XSQLColumn col) { + StringBuffer result = new StringBuffer(); + if (criteria == null) { + return ""; + } + + if (leftValue != null && rightValue != null) { + if (leftValue.toString().toLowerCase().equals(col.getName().toLowerCase()) || + leftValue.toString().toLowerCase().equals(col.toString().toLowerCase()) /*|| + /*col.getName().toLowerCase().indexOf(leftValue.toString().toLowerCase()) != -1*/) { + result.append("? ").append(operators[operation]).append(" ").append(rightValue); + }else + if (rightValue.toString().toLowerCase().equals(col.getName().toLowerCase()) || + rightValue.toString().toLowerCase().equals(col.toString().toLowerCase()) /*|| + col.getName().toLowerCase().indexOf(rightValue.toString().toLowerCase()) != -1*/) { + result.append("? ").append(operators[operation]).append(" ").append(leftValue); + } + return result.toString(); + } else if (left != null && right != null) { + String leftString = left.getCriteriaForProperty(col); + String rightString = right.getCriteriaForProperty(col); + if (!leftString.equals("") && !rightString.equals("")) { + return leftString + " " + operators[operation] + " " + + rightString; + } else if (!leftString.equals("")) { + return leftString; + } else if (!rightString.equals("")) { + return rightString; + } + return ""; + } else if (leftValue != null && leftValue.toString().toLowerCase() + .equals(col.toString().toLowerCase()) && right != null) { + return "? " + operators[operation] + " (" + right + .getCriteriaForProperty(col) + ")"; + } else if (rightValue != null && rightValue.toString().toLowerCase() + .equals(col.toString().toLowerCase()) && left != null) { + return "(" + left.getCriteriaForProperty(col) + ") " + + operators[operation] + " ?"; + } + return ""; + } + + public static void main(String args[]) { + XSQLCriteria p = + new XSQLCriteria("ip like '%101%' or (354>=0 or 456>=3)", -1); + System.out.println(p.checkValue("192.268.4.4")); + p = new XSQLCriteria("? like '%267%'", -1); + System.out.println(p.checkValue("192.268.4.4")); + + } +} diff --git a/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLODLUtils.java b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLODLUtils.java new file mode 100644 index 0000000000..6a27230664 --- /dev/null +++ b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLODLUtils.java @@ -0,0 +1,246 @@ +package org.opendaylight.controller.md.sal.dom.xsql; + +import java.lang.reflect.Field; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; +import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; +import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; +import org.opendaylight.yangtools.yang.model.api.Module; +import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.Status; +import org.opendaylight.yangtools.yang.model.util.Uint16; +import org.opendaylight.yangtools.yang.model.util.Uint32; +import org.opendaylight.yangtools.yang.model.util.Uint64; +import org.opendaylight.yangtools.yang.model.util.Uint8; + +public class XSQLODLUtils { + + private static Map, Class> types = + new ConcurrentHashMap, Class>(); + + static { + types.put(QName.class, QName.class); + types.put(SchemaPath.class, SchemaPath.class); + types.put(Status.class, Status.class); + } + + public static boolean isColumnType(Class cls) { + return types.containsKey(cls); + } + + public static String getTableName(Object odlNode) { + if (odlNode instanceof Module) { + return ((Module) odlNode).getNamespace().toString(); + } else if (odlNode instanceof DataSchemaNode) { + SchemaPath p = ((DataSchemaNode) odlNode).getPath(); + return extractTableName(p); + } else { + int i = 0; + } + return null; + } + + public static String extractTableName(SchemaPath path) { + List lst = path.getPath(); + StringBuffer name = new StringBuffer(); + int i = 0; + for (QName q : lst) { + name.append(q.getLocalName()); + i++; + if (i < lst.size()) { + name.append("/"); + } + } + return name.toString(); + } + + public static String getBluePrintName(Object odlNode){ + if (odlNode instanceof Module) { + return ((Module) odlNode).getNamespace().toString(); + } else if (odlNode instanceof DataSchemaNode) { + SchemaPath p = ((DataSchemaNode) odlNode).getPath(); + return extractTableName(p); + } + return null; + } + + public static String getODLNodeName(Object odlNode) { + if (odlNode instanceof Module) { + return ((Module) odlNode).getNamespace().toString(); + } else if (odlNode instanceof DataSchemaNode) { + SchemaPath p = ((DataSchemaNode) odlNode).getPath(); + List lst = p.getPath(); + return lst.get(lst.size() - 1).toString(); + } + return null; + } + + public static List getPath(Object odlNode) { + return ((DataSchemaNode) odlNode).getPath().getPath(); + } + + + public static String getODLTableName(Object odlNode) { + if (odlNode instanceof Module) { + return ((Module) odlNode).getNamespace().toString(); + } else if (odlNode instanceof DataSchemaNode) { + return ((DataSchemaNode) odlNode).getPath().toString(); + } + return null; + } + + public static String getNodeNameFromDSN(Object o) { + DataSchemaNode node = (DataSchemaNode) o; + String nodeName = node.getQName().toString(); + int index = nodeName.lastIndexOf(")"); + return nodeName.substring(index + 1); + } + + public static boolean isModule(Object o) { + if (o instanceof Module) { + return true; + } + return false; + } + + public static boolean createOpenDaylightCache(XSQLBluePrint bluePrint,Object module) { + XSQLBluePrintNode node = new XSQLBluePrintNode(module, 0,null); + bluePrint.addToBluePrintCache(node); + collectODL(bluePrint, node, ((Module) module).getChildNodes(), 1); + return true; + } + + private static void collectODL(XSQLBluePrint bluePrint, + XSQLBluePrintNode parent, Collection nodes, int level) { + if (nodes == null) { + return; + } + for (DataSchemaNode n : nodes) { + if (n instanceof DataNodeContainer /*|| n instanceof LeafListSchemaNode*/ + || n instanceof ListSchemaNode) { + XSQLBluePrintNode bn = new XSQLBluePrintNode(n, level,parent); + bluePrint.addToBluePrintCache(bn); + parent.AddChild(bn); + if (n instanceof DataNodeContainer) { + level++; + collectODL(bluePrint, bn, + ((DataNodeContainer) n).getChildNodes(), level); + level--; + } else if (n instanceof ListSchemaNode) { + level++; + collectODL(bluePrint, bn, + ((ListSchemaNode) n).getChildNodes(), level); + level--; + } + } else { + if (parent != null) { + parent.addColumn(n, parent.getParent().getBluePrintNodeName()); + } else { + XSQLAdapter.log("NO Parent!"); + } + } + } + } + + public static Map refFieldsCache = + new HashMap(); + + public static Field findField(Class c, String name) { + if (c == null) { + return null; + } + String cacheKey = c.getName() + name; + Field f = refFieldsCache.get(cacheKey); + if (f != null) { + return f; + } + + try { + f = c.getDeclaredField(name); + f.setAccessible(true); + refFieldsCache.put(cacheKey, f); + return f; + } catch (Exception err) { + } + + Class s = c.getSuperclass(); + if (s != null) { + f = findField(s, name); + if (f != null) { + refFieldsCache.put(cacheKey, f); + } + return f; + } + return null; + } + + + public static Object get(Object o, String name) { + try { + Class c = o.getClass(); + Field f = findField(c, name); + return f.get(o); + } catch (Exception err) { + XSQLAdapter.log(err); + } + return null; + } + + public static List getMChildren(Object o) { + Map children = getChildren(o); + List result = new LinkedList(); + for (Object val : children.values()) { + result.add((Object) val); + } + return result; + } + + public static Map getChildren(Object o) { + return (Map) get(o, "children"); + } + + public static Object getValue(Object o) { + return get(o, "value"); + } + + public static String getNodeIdentiofier(Object o) { + try{ + return ((PathArgument) get(o, "nodeIdentifier")).getNodeType().toString(); + }catch(Exception err){ + return null; + } + } + + public static String getNodeName(Object o) { + Object nodeID = get(o, "nodeIdentifier"); + if (nodeID != null) { + String nodeName = nodeID.toString(); + int index = nodeName.lastIndexOf(")"); + return nodeName.substring(index + 1); + } + return "NULL"; + } + + public static Class getTypeForODLColumn(Object odlNode){ + Object type = get(odlNode,"type"); + if(type instanceof Uint32 || type instanceof Uint64){ + return long.class; + }else + if(type instanceof Uint16){ + return int.class; + }else + if(type instanceof Uint8){ + return byte.class; + } + return String.class; + } + +} diff --git a/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLThreadPool.java b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLThreadPool.java new file mode 100644 index 0000000000..c1db6273ea --- /dev/null +++ b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLThreadPool.java @@ -0,0 +1,110 @@ +package org.opendaylight.controller.md.sal.dom.xsql; + +import java.util.LinkedList; + +public class XSQLThreadPool { + private LinkedList tasks = new LinkedList(); + private int threadCount = 0; + private int maxThreadCount = 10; + private String threadPoolName = "Simple Thread Pool"; + private int waitTimeForIdle = 10000; + private int maxQueueSize = -1; + public Object waitForSlotSync = new Object(); + + public XSQLThreadPool(int _maxThreadCount, String name, + int _waitTimeForIdle) { + this.maxThreadCount = _maxThreadCount; + this.threadPoolName = name; + this.waitTimeForIdle = _waitTimeForIdle; + } + + public void addTask(Runnable r) { + synchronized (tasks) { + tasks.add(r); + tasks.notifyAll(); + if (threadCount < maxThreadCount) { + threadCount++; + new WorkerThread(threadCount).start(); + } + } + } + + private class WorkerThread extends Thread { + + private long lastTimeExecuted = System.currentTimeMillis(); + + public WorkerThread(int threadNumber) { + super( + "Thread #" + threadNumber + " Of Threadpool " + threadPoolName); + } + + public void run() { + Runnable runthis = null; + while (true) { + runthis = null; + if (maxQueueSize != -1) { + synchronized (waitForSlotSync) { + if (tasks.size() < maxQueueSize) { + waitForSlotSync.notifyAll(); + } + } + } + synchronized (tasks) { + if (tasks.isEmpty()) { + try { + tasks.wait(2000); + } catch (Exception err) { + } + } + + if (!tasks.isEmpty()) { + runthis = tasks.removeFirst(); + } + } + if (runthis != null) { + try { + runthis.run(); + } catch (Exception err) { + err.printStackTrace(); + } + lastTimeExecuted = System.currentTimeMillis(); + } + if (System.currentTimeMillis() - lastTimeExecuted + > waitTimeForIdle) { + break; + } + } + synchronized (tasks) { + threadCount--; + } + } + } + + public int getNumberOfThreads() { + return threadCount; + } + + public void waitForSlot() { + if (tasks.size() > maxQueueSize) { + synchronized (waitForSlotSync) { + try { + waitForSlotSync.wait(); + } catch (Exception err) { + err.printStackTrace(); + } + } + } + } + + public boolean isEmpty() { + if (this.threadCount == 0) { + return true; + } + return false; + } + + public void setMaxQueueSize(int size) { + this.maxQueueSize = size; + } + +} diff --git a/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCCommand.java b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCCommand.java new file mode 100644 index 0000000000..85ce0e5392 --- /dev/null +++ b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCCommand.java @@ -0,0 +1,62 @@ +package org.opendaylight.controller.md.sal.dom.xsql.jdbc; + +import java.io.Serializable; +import java.util.Map; + +public class JDBCCommand implements Serializable { + public int type = 0; + public static final int TYPE_EXECUTE_QUERY = 1; + public static final int TYPE_QUERY_REPLY = 2; + public static final int TYPE_QUERY_RECORD = 3; + public static final int TYPE_QUERY_FINISH = 4; + public static final int TYPE_QUERY_ERROR = 5; + + private JDBCResultSet rs = null; + private Map record = null; + private int rsID = -1; + private Exception err = null; + + public JDBCCommand(Exception _err, int _RSID) { + this.type = TYPE_QUERY_ERROR; + this.err = _err; + this.rsID = _RSID; + } + + public JDBCCommand(JDBCResultSet _rs, int _type) { + this.type = TYPE_EXECUTE_QUERY; + this.rs = _rs; + this.type = _type; + this.rsID = rs.getID(); + } + + public JDBCCommand(Map _record, int _rsID) { + this.record = _record; + this.rsID = _rsID; + this.type = TYPE_QUERY_RECORD; + } + + public JDBCCommand(int _rsID) { + this.rsID = _rsID; + this.type = TYPE_QUERY_FINISH; + } + + public int getType() { + return this.type; + } + + public JDBCResultSet getRS() { + return this.rs; + } + + public Map getRecord() { + return this.record; + } + + public int getRSID() { + return this.rsID; + } + + public Exception getERROR() { + return this.err; + } +} diff --git a/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCConnection.java b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCConnection.java new file mode 100644 index 0000000000..3e72dc95ee --- /dev/null +++ b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCConnection.java @@ -0,0 +1,583 @@ +package org.opendaylight.controller.md.sal.dom.xsql.jdbc; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.net.ServerSocket; +import java.net.Socket; +import java.sql.Array; +import java.sql.Blob; +import java.sql.CallableStatement; +import java.sql.Clob; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.NClob; +import java.sql.PreparedStatement; +import java.sql.SQLClientInfoException; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.SQLXML; +import java.sql.Savepoint; +import java.sql.Statement; +import java.sql.Struct; +import java.util.LinkedList; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.Executor; + +import org.opendaylight.controller.md.sal.dom.xsql.XSQLAdapter; + +public class JDBCConnection extends Thread implements Connection { + private Socket socket = null; + private DataInputStream in = null; + private DataOutputStream out = null; + private LinkedList queue = new LinkedList(); + private XSQLAdapter adapter = null; + + public JDBCConnection(Socket s, XSQLAdapter _a) { + this.socket = s; + this.adapter = _a; + try { + in = new DataInputStream( + new BufferedInputStream(s.getInputStream())); + out = new DataOutputStream( + new BufferedOutputStream(s.getOutputStream())); + new JDBCObjectReader(); + this.start(); + } catch (Exception err) { + err.printStackTrace(); + } + } + + public JDBCConnection(String addr) throws Exception { + socket = new Socket(addr, 40004); + try { + in = new DataInputStream( + new BufferedInputStream(socket.getInputStream())); + out = new DataOutputStream( + new BufferedOutputStream(socket.getOutputStream())); + new JDBCObjectReader(); + this.start(); + } catch (Exception err) { + err.printStackTrace(); + } + } + + public JDBCConnection(boolean server) { + try { + ServerSocket s = new ServerSocket(50003); + socket = s.accept(); + try { + in = new DataInputStream( + new BufferedInputStream(socket.getInputStream())); + out = new DataOutputStream( + new BufferedOutputStream(socket.getOutputStream())); + new JDBCObjectReader(); + this.start(); + } catch (Exception err) { + err.printStackTrace(); + } + } catch (Exception err) { + err.printStackTrace(); + } + } + + + private boolean isStopped() { + if (adapter != null && adapter.stopped) { + return true; + } + if (socket == null || socket.isClosed()) { + return true; + } + return false; + } + + public void run() { + byte data[] = null; + while (!isStopped()) { + try { + int len = in.readInt(); + data = new byte[len]; + in.readFully(data); + addObject(data); + + } catch (Exception err) { + System.out.println("Connection Lost or Closed."); + try { + socket.close(); + } catch (Exception err2) { + } + //err.printStackTrace(); + } + } + } + + private void addObject(byte[] data) { + synchronized (queue) { + queue.add(data); + queue.notifyAll(); + } + } + + private class JDBCObjectReader extends Thread { + + public JDBCObjectReader() { + super("JDBCObjectReader"); + start(); + } + + public void run() { + while (!isStopped()) { + byte data[] = null; + synchronized (queue) { + if (queue.size() == 0) { + try { + queue.wait(1000); + } catch (Exception err) { + } + } + if (queue.size() > 0) { + data = queue.removeFirst(); + } + } + if (data != null) { + JDBCCommand command = (JDBCCommand) deSerialize(data); + processCommand(command); + } + } + } + + private Object deSerialize(byte data[]) { + try { + ByteArrayInputStream in = new ByteArrayInputStream(data); + ObjectInputStream oin = new ObjectInputStream(in); + return oin.readObject(); + } catch (Exception err) { + err.printStackTrace(); + } + return null; + } + } + + public void processCommand(JDBCCommand cmd) { + switch (cmd.getType()) { + case JDBCCommand.TYPE_EXECUTE_QUERY: + try { + JDBCServer.execute(cmd.getRS(), adapter); + send(new JDBCCommand(cmd.getRS(), + JDBCCommand.TYPE_QUERY_REPLY)); + QueryUpdater u = new QueryUpdater(cmd.getRS()); + new Thread(u).start(); + } catch (Exception err) { + send(new JDBCCommand(err, cmd.getRSID())); + } + break; + case JDBCCommand.TYPE_QUERY_REPLY: + JDBCResultSet rs1 = JDBCStatement.getQuery(cmd.getRS().getID()); + rs1.updateData(cmd.getRS()); + break; + case JDBCCommand.TYPE_QUERY_RECORD: + JDBCResultSet rs2 = JDBCStatement.getQuery(cmd.getRSID()); + rs2.addRecord(cmd.getRecord()); + break; + case JDBCCommand.TYPE_QUERY_FINISH: + JDBCResultSet rs3 = JDBCStatement.removeQuery(cmd.getRSID()); + rs3.setFinished(true); + break; + case JDBCCommand.TYPE_QUERY_ERROR: + System.err.println("ERROR Executing Query\n"); + cmd.getERROR().printStackTrace(); + JDBCResultSet rs4 = JDBCStatement.removeQuery(cmd.getRSID()); + rs4.setError(cmd.getERROR()); + rs4.setFinished(true); + synchronized (rs4) { + rs4.notifyAll(); + } + } + } + + private class QueryUpdater implements Runnable { + + private JDBCResultSet rs = null; + + public QueryUpdater(JDBCResultSet _rs) { + this.rs = _rs; + } + + public void run() { + while (rs.next()) { + JDBCCommand rec = new JDBCCommand(rs.getCurrent(), rs.getID()); + send(rec); + } + JDBCCommand end = new JDBCCommand(rs.getID()); + send(end); + } + } + + public void send(Object o) { + try { + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + ObjectOutputStream oout = new ObjectOutputStream(bout); + oout.writeObject(o); + byte data[] = bout.toByteArray(); + synchronized (socket) { + out.writeInt(data.length); + out.write(data); + out.flush(); + } + } catch (Exception err) { + err.printStackTrace(); + } + } + + @Override + public boolean isWrapperFor(Class arg0) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public T unwrap(Class arg0) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public void clearWarnings() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void close() throws SQLException { + try { + socket.close(); + } catch (Exception err) { + } + socket = null; + } + + @Override + public void commit() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public Array createArrayOf(String typeName, Object[] elements) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Blob createBlob() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Clob createClob() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public NClob createNClob() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public SQLXML createSQLXML() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Statement createStatement() throws SQLException { + return new JDBCStatement(this); + } + + @Override + public Statement createStatement(int resultSetType, + int resultSetConcurrency, int resultSetHoldability) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Statement createStatement(int resultSetType, + int resultSetConcurrency) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Struct createStruct(String typeName, Object[] attributes) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean getAutoCommit() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public String getCatalog() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Properties getClientInfo() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getClientInfo(String name) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public int getHoldability() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public DatabaseMetaData getMetaData() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public int getTransactionIsolation() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public Map> getTypeMap() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public SQLWarning getWarnings() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean isClosed() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isReadOnly() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isValid(int timeout) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public String nativeSQL(String sql) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public CallableStatement prepareCall(String sql, int resultSetType, + int resultSetConcurrency, int resultSetHoldability) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public CallableStatement prepareCall(String sql, int resultSetType, + int resultSetConcurrency) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public CallableStatement prepareCall(String sql) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public PreparedStatement prepareStatement(String sql, int resultSetType, + int resultSetConcurrency, int resultSetHoldability) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public PreparedStatement prepareStatement(String sql, int resultSetType, + int resultSetConcurrency) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public PreparedStatement prepareStatement(String sql, int[] columnIndexes) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public PreparedStatement prepareStatement(String sql, String[] columnNames) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public PreparedStatement prepareStatement(String sql) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public void releaseSavepoint(Savepoint savepoint) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void rollback() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void rollback(Savepoint savepoint) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void setAutoCommit(boolean autoCommit) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void setCatalog(String catalog) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void setClientInfo(Properties properties) + throws SQLClientInfoException { + // TODO Auto-generated method stub + + } + + @Override + public void setClientInfo(String name, String value) + throws SQLClientInfoException { + // TODO Auto-generated method stub + + } + + @Override + public void setHoldability(int holdability) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void setReadOnly(boolean readOnly) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public Savepoint setSavepoint() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Savepoint setSavepoint(String name) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public void setTransactionIsolation(int level) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void setTypeMap(Map> map) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void setSchema(String schema) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public String getSchema() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public void abort(Executor executor) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void setNetworkTimeout(Executor executor, int milliseconds) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public int getNetworkTimeout() throws SQLException { + // TODO Auto-generated method stub + return 0; + } +} + diff --git a/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCDriver.java b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCDriver.java new file mode 100644 index 0000000000..e4b4e249df --- /dev/null +++ b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCDriver.java @@ -0,0 +1,73 @@ +package org.opendaylight.controller.md.sal.dom.xsql.jdbc; + +import java.sql.Connection; +import java.sql.Driver; +import java.sql.DriverManager; +import java.sql.DriverPropertyInfo; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.util.Properties; +import java.util.logging.Logger; + +public class JDBCDriver implements Driver { + + public static JDBCDriver drv = new JDBCDriver(); + + public JDBCDriver() { + try { + DriverManager.registerDriver(this); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Override + public boolean acceptsURL(String arg0) throws SQLException { + return true; + } + + @Override + public Connection connect(String url, Properties arg1) throws SQLException { + System.err.println("JDBC Connection"); + try { + if (url.equals("svr")) { + return new JDBCConnection(true); + } else { + return new JDBCConnection(url); + } + } catch (Exception err) { + err.printStackTrace(); + } + return null; + } + + @Override + public int getMajorVersion() { + return 1; + } + + @Override + public int getMinorVersion() { + return 0; + } + + @Override + public DriverPropertyInfo[] getPropertyInfo(String arg0, Properties arg1) + throws SQLException { + DriverPropertyInfo i = new DriverPropertyInfo("NQL", "NQL"); + return new DriverPropertyInfo[] {i}; + } + + @Override + public boolean jdbcCompliant() { + return false; + } + + @Override + public Logger getParentLogger() throws SQLFeatureNotSupportedException { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCResultSet.java b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCResultSet.java new file mode 100644 index 0000000000..7603a3e9ae --- /dev/null +++ b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCResultSet.java @@ -0,0 +1,1780 @@ +package org.opendaylight.controller.md.sal.dom.xsql.jdbc; + +import java.io.InputStream; +import java.io.Reader; +import java.io.Serializable; +import java.lang.reflect.Method; +import java.math.BigDecimal; +import java.net.URL; +import java.sql.Array; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.Date; +import java.sql.NClob; +import java.sql.Ref; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.RowId; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.SQLXML; +import java.sql.Statement; +import java.sql.Time; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +import org.opendaylight.controller.md.sal.dom.xsql.XSQLBluePrint; +import org.opendaylight.controller.md.sal.dom.xsql.XSQLBluePrintNode; +import org.opendaylight.controller.md.sal.dom.xsql.XSQLColumn; +import org.opendaylight.controller.md.sal.dom.xsql.XSQLCriteria; +import org.opendaylight.controller.md.sal.dom.xsql.XSQLODLUtils; + +public class JDBCResultSet + implements Serializable, ResultSet, ResultSetMetaData { + private static final long serialVersionUID = -7450200738431047057L; + + private String sql = null; + private List tablesInQuery = + new ArrayList(); + private Map tablesInQueryMap = + new ConcurrentHashMap(); + private List fieldsInQuery = new ArrayList(); + private transient LinkedList records = new LinkedList(); + private transient Map currentRecord = null; + private boolean finished = false; + private int id = 0; + private static Integer nextID = new Integer(0); + public int numberOfTasks = 0; + private Map>> criteria = + new ConcurrentHashMap>>(); + private Exception err = null; + private List EMPTY_RESULT = new LinkedList(); + + public JDBCResultSet(String _sql) { + synchronized (JDBCResultSet.class) { + nextID++; + id = nextID; + } + this.sql = _sql; + } + + public String getSQL() { + return this.sql; + } + + public void setError(Exception _err) { + this.err = _err; + } + + public Exception getError() { + return this.err; + } + + public void updateData(JDBCResultSet rs) { + synchronized (this) { + this.tablesInQuery = rs.tablesInQuery; + this.tablesInQueryMap = rs.tablesInQueryMap; + this.fieldsInQuery = rs.fieldsInQuery; + this.notifyAll(); + } + } + + public int isObjectFitCriteria(Map objValues, String tableName) { + Map> tblCriteria = criteria.get(tableName); + if (tblCriteria == null) { + return 1; + } + for (Map.Entry> cc : tblCriteria + .entrySet()) { + for (XSQLCriteria c : cc.getValue()) { + Object value = objValues.get(cc.getKey().toString()); + int result = c.checkValue(value); + if (result == 0) { + return 0; + } + } + } + return 1; + } + + public int isObjectFitCriteria(Object element, Class cls) { + Map> tblCriteria = + criteria.get(cls.getName()); + if (tblCriteria == null) { + return 1; + } + for (Map.Entry> cc : tblCriteria + .entrySet()) { + for (XSQLCriteria c : cc.getValue()) { + int result = + c.isObjectFitCriteria(element, cc.getKey().getName()); + if (result == 0) { + return 0; + } + } + } + return 1; + } + + public Map>> getCriteria() { + return this.criteria; + } + + public int getID() { + return this.id; + } + + public List getTables() { + return tablesInQuery; + } + + public void addTableToQuery(XSQLBluePrintNode node) { + if (this.tablesInQueryMap.containsKey(node.getBluePrintNodeName())) { + return; + } + this.tablesInQuery.add(node); + this.tablesInQueryMap.put(node.getBluePrintNodeName(), node); + } + + public List getFields() { + return this.fieldsInQuery; + } + + public XSQLBluePrintNode getMainTable() { + if (tablesInQuery.size() == 1) { + return tablesInQuery.get(0); + } + XSQLBluePrintNode result = null; + for (XSQLBluePrintNode node : tablesInQuery) { + if (result == null) { + result = node; + } else if (result.getLevel() < node.getLevel()) { + result = node; + } + } + return result; + } + + public boolean isFinished() { + return finished; + } + + public void setFinished(boolean b) { + this.finished = b; + } + + public int size() { + return this.records.size(); + } + + public void addRecord(Map r) { + synchronized (this) { + if (records == null) { + records = new LinkedList(); + } + records.add(r); + this.notifyAll(); + } + } + + + public void addRecord(ArrayList hierarchy) { + Map rec = new HashMap(); + for (int i = hierarchy.size() - 1; i >= 0; i--) { + Object element = hierarchy.get(i); + for (XSQLColumn c : fieldsInQuery) { + if (c.getTableName() + .equals(element.getClass().getSimpleName())) { + try { + Method m = element.getClass().getMethod(c.getName(), null); + Object value = m.invoke(element, null); + rec.put(c.getName(), value); + } catch (Exception err) { + err.printStackTrace(); + } + } + } + } + this.records.add(rec); + } + + public boolean next() { + this.currentRecord = null; + if (records == null) { + records = new LinkedList(); + } + while (!finished || records.size() > 0) { + synchronized (this) { + if (records.size() == 0) { + try { + this.wait(1000); + } catch (Exception err) { + } + if (records.size() > 0) { + try { + currentRecord = records.removeFirst(); + return true; + } finally { + this.notifyAll(); + } + } + } else { + try { + currentRecord = records.removeFirst(); + return true; + } finally { + this.notifyAll(); + } + } + } + } + return false; + } + + public Map getCurrent() { + return this.currentRecord; + } + + private void createRecord(Object data, XSQLBluePrintNode node) { + Map rec = new HashMap(); + for (XSQLColumn c : this.fieldsInQuery) { + if (c.getTableName().equals(node.getBluePrintNodeName())) { + try { + Method m = node.getInterface().getMethod(c.getName(), null); + Object value = m.invoke(data, null); + if (value != null) { + rec.put(c.getName(), value); + } else { + rec.put(c.getName(), ""); + } + } catch (Exception err) { + err.printStackTrace(); + } + + } + } + } + + public static class Record { + public Map data = new HashMap(); + public Object element = null; + + public Map getRecord() { + return this.data; + } + } + + private Map collectColumnValues(Object node, XSQLBluePrintNode bpn) { + Map subChildren = XSQLODLUtils.getChildren(node); + Map result = new HashMap(); + for (Object stc : subChildren.values()) { + if (stc.getClass().getName() + .endsWith("ImmutableAugmentationNode")) { + Map values = XSQLODLUtils.getChildren(stc); + for (Object key : values.keySet()) { + Object val = values.get(key); + if (val.getClass().getName() + .endsWith("ImmutableLeafNode")) { + Object value = XSQLODLUtils.getValue(val); + String k = XSQLODLUtils.getNodeName(val); + if (value != null) { + result.put(bpn.getBluePrintNodeName() + "." + k, + value.toString()); + } + } + } + } else if (stc.getClass().getName().endsWith("ImmutableLeafNode")) { + String k = XSQLODLUtils.getNodeName(stc); + Object value = XSQLODLUtils.getValue(stc); + if (value != null) { + result.put(bpn.getBluePrintNodeName() + "." + k, value.toString()); + } + } + } + return result; + } + + private void addToData(Record rec, XSQLBluePrintNode bpn, XSQLBluePrint bluePrint, Map fullRecord) { + XSQLBluePrintNode eNodes[] = bluePrint.getBluePrintNodeByODLTableName(XSQLODLUtils.getNodeIdentiofier(rec.element)); + if (bpn != null) { + for (XSQLColumn c : fieldsInQuery) { + for(XSQLBluePrintNode eNode:eNodes){ + if (((XSQLBluePrintNode) c.getBluePrintNode()).getBluePrintNodeName().equals(eNode.getBluePrintNodeName())) { + //Object value = Criteria.getValue(rec.element, c.getName()); + String columnName = c.toString(); + Object value = fullRecord.get(columnName); + if (value != null) { + try { + Object rsValue = c.getResultSetValue(value); + c.setCharWidth(rsValue.toString().length()); + rec.data.put(columnName, rsValue); + } catch (Exception err) { + } + } + } + } + } + } + } + + private boolean beenHere(Set beenHereElement, Object element) { + if (beenHereElement == null) { + beenHereElement = new HashSet(); + } + + String elementKey = null; + + try { + elementKey = element.toString(); + } catch (Exception err) { + elementKey = "Unknown"; + } + + if (beenHereElement.contains(elementKey)) { + return true; + } + + beenHereElement.add(elementKey); + return false; + } + + public List getChildren(Object node, String tableName,XSQLBluePrint bluePrint) { + + List children = XSQLODLUtils.getMChildren(node); + List result = new LinkedList(); + + for (Object child : children) { + + String odlNodeName = XSQLODLUtils.getNodeIdentiofier(child); + if(odlNodeName==null) continue; + + XSQLBluePrintNode eNodes[] = bluePrint.getBluePrintNodeByODLTableName(odlNodeName); + if(eNodes==null) continue; + + boolean match = false; + for(XSQLBluePrintNode enode:eNodes){ + if(tableName.startsWith(enode.toString())){ + match = true; + break; + } + } + + if(!match) continue; + + if (child.getClass().getName().endsWith("ImmutableContainerNode")) { + result.add(child); + }else + if (child.getClass().getName().endsWith("ImmutableAugmentationNode")) { + List _children = XSQLODLUtils.getMChildren(child); + for (Object c : _children) { + if (c.getClass().getName().endsWith("ImmutableContainerNode")) { + result.add(c); + } + } + } else if (child.getClass().getName().endsWith("ImmutableMapNode")) { + result.addAll(XSQLODLUtils.getMChildren(child)); + } + } + return result; + } + + public List addRecords(Object element, XSQLBluePrintNode node,boolean root, String tableName,XSQLBluePrint bluePrint) { + + List result = new LinkedList(); + String nodeID = XSQLODLUtils.getNodeIdentiofier(element); + if (node.getODLTableName().equals(nodeID)) { + XSQLBluePrintNode bluePrintNode = bluePrint.getBluePrintNodeByODLTableName(nodeID)[0]; + Record rec = new Record(); + rec.element = element; + XSQLBluePrintNode bpn = this.tablesInQueryMap.get(bluePrintNode.getBluePrintNodeName()); + if (this.criteria.containsKey(bluePrintNode.getBluePrintNodeName()) || bpn != null) { + Map allKeyValues = collectColumnValues(element, bpn); + if (!(isObjectFitCriteria(allKeyValues, bpn.getBluePrintNodeName()) == 1)) { + return EMPTY_RESULT; + } + addToData(rec, bpn, bluePrint,allKeyValues); + } + if (root) { + addRecord(rec.data); + } else { + result.add(rec); + } + return result; + } + + XSQLBluePrintNode parent = node.getParent(); + List subRecords = addRecords(element, parent, false, tableName,bluePrint); + for (Record subRec : subRecords) { + List subO = getChildren(subRec.element, tableName,bluePrint); + if (subO != null) { + for (Object subData : subO) { + Record rec = new Record(); + rec.element = subData; + rec.data.putAll(subRec.data); + + String recID = XSQLODLUtils.getNodeIdentiofier(rec.element); + XSQLBluePrintNode eNodes[] = bluePrint.getBluePrintNodeByODLTableName(recID); + XSQLBluePrintNode bpn = null; + for(XSQLBluePrintNode eNode:eNodes){ + bpn = this.tablesInQueryMap.get(eNode.getBluePrintNodeName()); + if(bpn!=null) + break; + } + boolean isObjectInCriteria = true; + if (bpn != null) { + Map allKeyValues = collectColumnValues(rec.element, bpn); + if ((isObjectFitCriteria(allKeyValues, bpn.getBluePrintNodeName()) == 1)) { + addToData(rec, bpn,bluePrint,allKeyValues); + } else { + isObjectInCriteria = false; + } + } + + if (isObjectInCriteria) { + if (root) { + if(!rec.data.isEmpty()) + addRecord(rec.data); + } else { + result.add(rec); + } + } + } + } + } + + return result; + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public T unwrap(Class iface) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean absolute(int row) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public void afterLast() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void beforeFirst() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void cancelRowUpdates() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void clearWarnings() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void close() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void deleteRow() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public int findColumn(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public boolean first() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public Array getArray(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Array getArray(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public InputStream getAsciiStream(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public InputStream getAsciiStream(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public BigDecimal getBigDecimal(int columnIndex, int scale) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public BigDecimal getBigDecimal(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public BigDecimal getBigDecimal(String columnLabel, int scale) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public BigDecimal getBigDecimal(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public InputStream getBinaryStream(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public InputStream getBinaryStream(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Blob getBlob(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Blob getBlob(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean getBoolean(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean getBoolean(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public byte getByte(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public byte getByte(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public byte[] getBytes(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public byte[] getBytes(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Reader getCharacterStream(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Reader getCharacterStream(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Clob getClob(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Clob getClob(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public int getConcurrency() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public String getCursorName() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Date getDate(int columnIndex, Calendar cal) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Date getDate(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Date getDate(String columnLabel, Calendar cal) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Date getDate(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public double getDouble(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public double getDouble(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getFetchDirection() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getFetchSize() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public float getFloat(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public float getFloat(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getHoldability() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getInt(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getInt(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public long getLong(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public long getLong(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public ResultSetMetaData getMetaData() throws SQLException { + return this; + } + + @Override + public Reader getNCharacterStream(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Reader getNCharacterStream(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public NClob getNClob(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public NClob getNClob(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getNString(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getNString(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object getObject(int columnIndex, Map> map) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object getObject(int columnIndex) throws SQLException { + return currentRecord + .get(this.fieldsInQuery.get(columnIndex - 1).toString()); + } + + @Override + public Object getObject(String columnLabel, Map> map) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object getObject(String columnLabel) throws SQLException { + return currentRecord.get(columnLabel); + } + + @Override + public Ref getRef(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Ref getRef(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public int getRow() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public RowId getRowId(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public RowId getRowId(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public SQLXML getSQLXML(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public SQLXML getSQLXML(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public short getShort(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public short getShort(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public Statement getStatement() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getString(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getString(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Time getTime(int columnIndex, Calendar cal) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Time getTime(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Time getTime(String columnLabel, Calendar cal) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Time getTime(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Timestamp getTimestamp(int columnIndex, Calendar cal) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Timestamp getTimestamp(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Timestamp getTimestamp(String columnLabel, Calendar cal) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Timestamp getTimestamp(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public int getType() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public URL getURL(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public URL getURL(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public InputStream getUnicodeStream(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public InputStream getUnicodeStream(String columnLabel) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public SQLWarning getWarnings() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public void insertRow() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public boolean isAfterLast() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isBeforeFirst() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isClosed() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isFirst() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isLast() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean last() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public void moveToCurrentRow() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void moveToInsertRow() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public boolean previous() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public void refreshRow() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public boolean relative(int rows) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean rowDeleted() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean rowInserted() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean rowUpdated() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public void setFetchDirection(int direction) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void setFetchSize(int rows) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateArray(int columnIndex, Array x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateArray(String columnLabel, Array x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x, int length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x, long length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x, int length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x, + long length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBigDecimal(int columnIndex, BigDecimal x) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBigDecimal(String columnLabel, BigDecimal x) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x, int length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x, long length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x, + int length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x, + long length) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBlob(int columnIndex, Blob x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBlob(int columnIndex, InputStream inputStream, + long length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBlob(int columnIndex, InputStream inputStream) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBlob(String columnLabel, Blob x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBlob(String columnLabel, InputStream inputStream, + long length) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBlob(String columnLabel, InputStream inputStream) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBoolean(int columnIndex, boolean x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBoolean(String columnLabel, boolean x) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateByte(int columnIndex, byte x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateByte(String columnLabel, byte x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBytes(int columnIndex, byte[] x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateBytes(String columnLabel, byte[] x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x, int length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x, long length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader, + int length) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader, + long length) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateClob(int columnIndex, Clob x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateClob(int columnIndex, Reader reader, long length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateClob(int columnIndex, Reader reader) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateClob(String columnLabel, Clob x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateClob(String columnLabel, Reader reader, long length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateClob(String columnLabel, Reader reader) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateDate(int columnIndex, Date x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateDate(String columnLabel, Date x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateDouble(int columnIndex, double x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateDouble(String columnLabel, double x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateFloat(int columnIndex, float x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateFloat(String columnLabel, float x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateInt(int columnIndex, int x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateInt(String columnLabel, int x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateLong(int columnIndex, long x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateLong(String columnLabel, long x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateNCharacterStream(int columnIndex, Reader x, long length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateNCharacterStream(int columnIndex, Reader x) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateNCharacterStream(String columnLabel, Reader reader, + long length) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateNCharacterStream(String columnLabel, Reader reader) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateNClob(int columnIndex, NClob nClob) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateNClob(int columnIndex, Reader reader, long length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateNClob(int columnIndex, Reader reader) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateNClob(String columnLabel, NClob nClob) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateNClob(String columnLabel, Reader reader, long length) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateNClob(String columnLabel, Reader reader) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateNString(int columnIndex, String nString) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateNString(String columnLabel, String nString) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateNull(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateNull(String columnLabel) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateObject(int columnIndex, Object x, int scaleOrLength) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateObject(int columnIndex, Object x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateObject(String columnLabel, Object x, int scaleOrLength) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateObject(String columnLabel, Object x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateRef(int columnIndex, Ref x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateRef(String columnLabel, Ref x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateRow() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateRowId(int columnIndex, RowId x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateRowId(String columnLabel, RowId x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateSQLXML(int columnIndex, SQLXML xmlObject) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateSQLXML(String columnLabel, SQLXML xmlObject) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateShort(int columnIndex, short x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateShort(String columnLabel, short x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateString(int columnIndex, String x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateString(String columnLabel, String x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateTime(int columnIndex, Time x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateTime(String columnLabel, Time x) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateTimestamp(int columnIndex, Timestamp x) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void updateTimestamp(String columnLabel, Timestamp x) + throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public boolean wasNull() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public String getCatalogName(int column) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getColumnClassName(int column) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public int getColumnCount() throws SQLException { + return fieldsInQuery.size(); + } + + @Override + public int getColumnDisplaySize(int column) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public String getColumnLabel(int column) throws SQLException { + return this.fieldsInQuery.get(column - 1).toString(); + } + + @Override + public String getColumnName(int column) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public int getColumnType(int column) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public String getColumnTypeName(int column) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public int getPrecision(int column) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getScale(int column) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public String getSchemaName(int column) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getTableName(int column) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean isAutoIncrement(int column) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isCaseSensitive(int column) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isCurrency(int column) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isDefinitelyWritable(int column) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public int isNullable(int column) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public boolean isReadOnly(int column) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isSearchable(int column) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isSigned(int column) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isWritable(int column) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public T getObject(int columnIndex, Class type) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public T getObject(String columnLabel, Class type) + throws SQLException { + // TODO Auto-generated method stub + return null; + } + + + + ////Metadata + + + +} diff --git a/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCServer.java b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCServer.java new file mode 100644 index 0000000000..26b8c70b8b --- /dev/null +++ b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCServer.java @@ -0,0 +1,206 @@ +package org.opendaylight.controller.md.sal.dom.xsql.jdbc; + +import org.opendaylight.controller.md.sal.dom.xsql.XSQLAdapter; +import org.opendaylight.controller.md.sal.dom.xsql.XSQLBluePrint; +import org.opendaylight.controller.md.sal.dom.xsql.XSQLBluePrintNode; +import org.opendaylight.controller.md.sal.dom.xsql.XSQLColumn; +import org.opendaylight.controller.md.sal.dom.xsql.XSQLCriteria; + +import java.net.ServerSocket; +import java.net.Socket; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.StringTokenizer; +import java.util.concurrent.ConcurrentHashMap; + +public class JDBCServer extends Thread { + private ServerSocket socket = null; + private XSQLAdapter adapter = null; + + public JDBCServer(XSQLAdapter a) { + super("JDBC Server"); + this.adapter = a; + start(); + } + + public void run() { + try { + socket = new ServerSocket(40004); + while (!adapter.stopped) { + Socket s = socket.accept(); + new JDBCConnection(s, adapter); + } + } catch (Exception err) { + err.printStackTrace(); + } + } + + public void connectToClient(String addr) { + try { + Socket s = new Socket(addr, 50003); + new JDBCConnection(s, adapter); + } catch (Exception err) { + err.printStackTrace(); + } + } + + public static void execute(JDBCResultSet rs, XSQLAdapter adapter) + throws SQLException { + parseTables(rs, adapter.getBluePrint()); + parseFields(rs, adapter.getBluePrint()); + parseCriteria(rs, adapter.getBluePrint()); + try { + adapter.execute(rs); + } catch (Exception err) { + throw new SQLException("Error", err); + } + } + + public static void parseTables(JDBCResultSet rs, XSQLBluePrint bp) + throws SQLException { + String lowSQL = rs.getSQL().toLowerCase(); + int from = lowSQL.indexOf("from"); + int where = lowSQL.indexOf("where"); + int subQuery = lowSQL.indexOf("select", 2); + int fromTo = lowSQL.indexOf(";"); + + if (where != -1 && subQuery != -1 && where < subQuery) { + fromTo = where; + } else if (where != -1 && subQuery != -1 && where > subQuery) { + fromTo = subQuery; + } else if (where != -1) { + fromTo = where; + } else if (subQuery != -1) { + fromTo = subQuery; + } + + if (from == -1) { + throw new SQLException("Missing \"from\" statement."); + } + + if (fromTo == -1) { + throw new SQLException("Missing terminating \";\"."); + } + + String tableNames = rs.getSQL().substring(from + 4, fromTo).trim(); + StringTokenizer tokens = new StringTokenizer(tableNames, ","); + while (tokens.hasMoreTokens()) { + String tableName = tokens.nextToken().trim(); + XSQLBluePrintNode table = bp.getBluePrintNodeByTableName(tableName); + if (table == null) { + throw new SQLException( + "Unknown table name \"" + tableName + "\""); + } + rs.addTableToQuery(table); + } + } + + public static void addCriteria(XSQLColumn col, XSQLCriteria c, + JDBCResultSet rs) { + Map> tblCriteria = + rs.getCriteria().get(col.getTableName()); + if (tblCriteria == null) { + tblCriteria = + new ConcurrentHashMap>(); + rs.getCriteria().put(col.getTableName(), tblCriteria); + } + List lstCriteria = tblCriteria.get(col); + if (lstCriteria == null) { + lstCriteria = new ArrayList(); + tblCriteria.put(col, lstCriteria); + } + lstCriteria.add(c); + } + + public static void parseFields(JDBCResultSet rs, XSQLBluePrint bp) + throws SQLException { + String lowSQL = rs.getSQL().toLowerCase(); + if (!lowSQL.startsWith("select")) { + throw new SQLException("Missing 'select' statement."); + } + int from = lowSQL.indexOf("from"); + if (from == -1) { + throw new SQLException("Missing 'from' statement."); + } + String fields = rs.getSQL().substring(6, from).trim(); + StringTokenizer tokens = new StringTokenizer(fields, ","); + while (tokens.hasMoreTokens()) { + String token = tokens.nextToken().trim(); + if (token.equals("*")) { + for (XSQLBluePrintNode table : rs.getTables()) { + rs.getFields().addAll(table.getColumns()); + } + return; + } + if (token.indexOf(".") != -1) { + XSQLBluePrintNode tbl = bp.getBluePrintNodeByTableName( + token.substring(0, token.indexOf(".")).trim()); + String p = token.substring(token.indexOf(".") + 1); + if (p.equals("*")) { + for (XSQLColumn c : tbl.getColumns()) { + rs.getFields().add(c); + } + } else { + XSQLColumn col = tbl.findColumnByName(p); + rs.getFields().add(col); + } + } else { + XSQLColumn col = null; + for (XSQLBluePrintNode table : rs.getTables()) { + try { + col = table.findColumnByName(token); + } catch (Exception err) { + } + if (col != null) { + break; + } + } + if (col == null) { + throw new SQLException( + "Unknown field name '" + token + "'."); + } + + rs.getFields().add(col); + } + } + } + + public static void parseCriteria(JDBCResultSet rs, XSQLBluePrint bp) { + String lowSQL = rs.getSQL().toLowerCase(); + int where = lowSQL.indexOf("where"); + int order = lowSQL.indexOf("order"); + int subQuery = lowSQL.indexOf("select", 2); + int whereTo = lowSQL.indexOf(";"); + + if (where == -1) { + return; + } + + if (where != -1 && subQuery != -1 && subQuery < where) { + return; + } + + if (order != -1 && subQuery != -1 && order < subQuery) { + whereTo = order; + } else if (order != -1 && subQuery != -1 && order > subQuery) { + whereTo = subQuery; + } else if (order != -1) { + whereTo = order; + } else if (subQuery != -1) { + whereTo = subQuery; + } + String whereStatement = + rs.getSQL().substring(where + 5, whereTo).trim(); + XSQLCriteria cr = new XSQLCriteria(whereStatement, -1); + for (XSQLBluePrintNode tbl : rs.getTables()) { + for (XSQLColumn col : tbl.getColumns()) { + String colCriteria = cr.getCriteriaForProperty(col); + if (colCriteria != null && !colCriteria.trim().equals("")) { + addCriteria(col, new XSQLCriteria(colCriteria, -1), rs); + } + } + } + } +} diff --git a/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCStatement.java b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCStatement.java new file mode 100644 index 0000000000..a9ce1dd9bf --- /dev/null +++ b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCStatement.java @@ -0,0 +1,330 @@ +package org.opendaylight.controller.md.sal.dom.xsql.jdbc; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public class JDBCStatement implements Statement { + private JDBCResultSet rs = null; + private transient JDBCConnection connection = null; + private static Map queries = + new ConcurrentHashMap(); + + public JDBCStatement(JDBCConnection con) { + this.connection = con; + } + + public JDBCStatement() { + + } + + public static JDBCResultSet getQuery(int id) { + return queries.get(id); + } + + public static JDBCResultSet removeQuery(int id) { + return queries.remove(id); + } + + @Override + public java.sql.ResultSet executeQuery(String _sql) throws SQLException { + rs = new JDBCResultSet(_sql); + queries.put(rs.getID(), rs); + synchronized (rs) { + this.connection + .send(new JDBCCommand(rs, JDBCCommand.TYPE_EXECUTE_QUERY)); + try { + rs.wait(); + } catch (Exception err) { + } + if (rs.getError() != null) { + throw ((SQLException) rs.getError()); + } + } + return rs; + } + + @Override + public boolean execute(String _sql) throws SQLException { + return true; + } + + public void addRecord(ArrayList hierarchy) { + rs.addRecord(hierarchy); + } + + public int size() { + return rs.size(); + } + + public void setFinished(boolean b) { + this.rs.setFinished(b); + } + + public JDBCResultSet getRS() { + return this.rs; + } + + public ResultSet getResultSet() { + return this.rs; + } + + @Override + public boolean isWrapperFor(Class arg0) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public T unwrap(Class arg0) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public void addBatch(String sql) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void cancel() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void clearBatch() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void clearWarnings() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void close() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public boolean execute(String sql, int autoGeneratedKeys) + throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean execute(String sql, int[] columnIndexes) + throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean execute(String sql, String[] columnNames) + throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public int[] executeBatch() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public int executeUpdate(String sql, int autoGeneratedKeys) + throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int executeUpdate(String sql, int[] columnIndexes) + throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int executeUpdate(String sql, String[] columnNames) + throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int executeUpdate(String sql) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public Connection getConnection() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public int getFetchDirection() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getFetchSize() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public java.sql.ResultSet getGeneratedKeys() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public int getMaxFieldSize() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxRows() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public boolean getMoreResults() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean getMoreResults(int current) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public int getQueryTimeout() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getResultSetConcurrency() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getResultSetHoldability() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getResultSetType() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getUpdateCount() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public SQLWarning getWarnings() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean isClosed() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isPoolable() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public void setCursorName(String name) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void setEscapeProcessing(boolean enable) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void setFetchDirection(int direction) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void setFetchSize(int rows) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void setMaxFieldSize(int max) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void setMaxRows(int max) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void setPoolable(boolean poolable) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void setQueryTimeout(int seconds) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void closeOnCompletion() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public boolean isCloseOnCompletion() throws SQLException { + // TODO Auto-generated method stub + return false; + } + + +} diff --git a/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/xsql/XSQLProvider.java b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/xsql/XSQLProvider.java new file mode 100644 index 0000000000..b421e56cf4 --- /dev/null +++ b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/xsql/XSQLProvider.java @@ -0,0 +1,41 @@ +package org.opendaylight.xsql; + +import java.util.concurrent.ExecutionException; + +import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; +import org.opendaylight.controller.sal.binding.api.data.DataProviderService; +import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.xsql.rev140626.XSQL; +import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.xsql.rev140626.XSQLBuilder; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Created by root on 6/26/14. + */ +public class XSQLProvider implements AutoCloseable { + + public static final InstanceIdentifier ID = InstanceIdentifier.builder(XSQL.class).build(); + private static final Logger LOG = LoggerFactory.getLogger(XSQLProvider.class); + + public void close() { + } + + public XSQL buildXSQL(DataProviderService dps) { + XSQLBuilder builder = new XSQLBuilder(); + builder.setPort("34343"); + XSQL xsql = builder.build(); + if (dps != null) { + final DataModificationTransaction t = dps.beginTransaction(); + t.removeOperationalData(ID); + t.putOperationalData(ID,xsql); + + try { + t.commit().get(); + } catch (InterruptedException | ExecutionException e) { + LOG.warn("Failed to update toaster status, operational otherwise", e); + } + } + return xsql; + } +} diff --git a/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/yang/gen/v1/http/netconfcentral/org/ns/xsql/rev140626/XSQLModule.java b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/yang/gen/v1/http/netconfcentral/org/ns/xsql/rev140626/XSQLModule.java new file mode 100644 index 0000000000..399f49bd6b --- /dev/null +++ b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/yang/gen/v1/http/netconfcentral/org/ns/xsql/rev140626/XSQLModule.java @@ -0,0 +1,30 @@ +package org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.xsql.rev140626; + +import org.opendaylight.controller.md.sal.dom.xsql.XSQLAdapter; +import org.opendaylight.xsql.XSQLProvider; + +public class XSQLModule extends org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.xsql.rev140626.AbstractXSQLModule { + public XSQLModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public XSQLModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.xsql.rev140626.XSQLModule oldModule, java.lang.AutoCloseable oldInstance) { + super(identifier, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void customValidation() { + // add custom validation form module attributes here. + } + + @Override + public java.lang.AutoCloseable createInstance() { + XSQLAdapter xsqlAdapter = XSQLAdapter.getInstance(); + getSchemaServiceDependency().registerSchemaServiceListener(xsqlAdapter); + xsqlAdapter.setDataBroker(getAsyncDataBrokerDependency()); + XSQLProvider p = new XSQLProvider(); + p.buildXSQL(getDataBrokerDependency()); + return p; + } + +} diff --git a/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/yang/gen/v1/http/netconfcentral/org/ns/xsql/rev140626/XSQLModuleFactory.java b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/yang/gen/v1/http/netconfcentral/org/ns/xsql/rev140626/XSQLModuleFactory.java new file mode 100644 index 0000000000..ac0d9c1837 --- /dev/null +++ b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/yang/gen/v1/http/netconfcentral/org/ns/xsql/rev140626/XSQLModuleFactory.java @@ -0,0 +1,13 @@ +/* +* Generated file +* +* Generated from: yang module name: XSQL yang module local name: XSQL +* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator +* Generated at: Thu Jun 26 14:56:25 PDT 2014 +* +* Do not modify this file unless it is present under src/main directory +*/ +package org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.xsql.rev140626; +public class XSQLModuleFactory extends org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.xsql.rev140626.AbstractXSQLModuleFactory { + +} diff --git a/opendaylight/md-sal/sal-dom-xsql/src/main/resources/04-xsql.xml b/opendaylight/md-sal/sal-dom-xsql/src/main/resources/04-xsql.xml new file mode 100644 index 0000000000..d7d547d19e --- /dev/null +++ b/opendaylight/md-sal/sal-dom-xsql/src/main/resources/04-xsql.xml @@ -0,0 +1,29 @@ + + + + + + + XSQL:XSQL + + XSQL + + binding:binding-data-broker + binding-data-broker + + + dom:dom-async-data-broker + inmemory-data-broker + + + dom:schema-service + yang-schema-service + + + + + + + http://netconfcentral.org/ns/XSQL?module=XSQL&revision=2014-06-26 + + diff --git a/opendaylight/md-sal/sal-dom-xsql/src/main/yang/XSQL.yang b/opendaylight/md-sal/sal-dom-xsql/src/main/yang/XSQL.yang new file mode 100644 index 0000000000..0437e10e34 --- /dev/null +++ b/opendaylight/md-sal/sal-dom-xsql/src/main/yang/XSQL.yang @@ -0,0 +1,72 @@ +module XSQL{ + yang-version 1; + namespace "http://netconfcentral.org/ns/XSQL"; + prefix XSQL; + + import config { prefix config; revision-date 2013-04-05; } + import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; } + import rpc-context { prefix rpcx; revision-date 2013-06-17; } + import opendaylight-md-sal-dom {prefix sal;} + import opendaylight-md-sal-common {prefix common;} + + organization "Netconf Central"; + contact "Sharon Aicler "; + description "YANG version of the XSQL status"; + + revision "2014-06-26" { + description "XSQL module initial version"; + } + + container XSQL { + presence "Indicates the XSQL service is available"; + description "Container to indicate the XSQL availability"; + leaf port { + type string; + config false; + mandatory true; + description "The port the XSQL binds on"; + } + } + + identity XSQL { + base config:module-type; + config:java-name-prefix XSQL; + } + + augment "/config:modules/config:module/config:configuration" { + case XSQL { + when "/config:modules/config:module/config:type = 'XSQL'"; + + container data-broker { + uses config:service-ref { + refine type { + mandatory false; + config:required-identity mdsal:binding-data-broker; + } + } + } + + container async-data-broker { + uses config:service-ref { + refine type { + mandatory false; + config:required-identity sal:dom-async-data-broker; + } + } + + } + + container schema-service { + uses config:service-ref { + refine type { + mandatory false; + config:required-identity sal:schema-service; + } + } + + } + + } + } + +} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModule.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModule.java index 172b0dbc01..b39c9bbbd8 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModule.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModule.java @@ -23,7 +23,7 @@ public class InMemoryOperationalDataStoreProviderModule extends org.opendaylight @Override public java.lang.AutoCloseable createInstance() { InMemoryDOMDataStore ids = new InMemoryDOMDataStore("DOM-OPER", MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor())); - getSchemaServiceDependency().registerSchemaServiceListener(ids); + getOperationalSchemaServiceDependency().registerSchemaServiceListener(ids); return ids; } diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ChangeListenerNotifyTask.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ChangeListenerNotifyTask.java index 375376f383..27325d84a9 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ChangeListenerNotifyTask.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ChangeListenerNotifyTask.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.md.sal.dom.store.impl; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -17,10 +17,10 @@ class ChangeListenerNotifyTask implements Runnable { private static final Logger LOG = LoggerFactory.getLogger(ChangeListenerNotifyTask.class); private final Iterable> listeners; - private final AsyncDataChangeEvent> event; + private final AsyncDataChangeEvent> event; public ChangeListenerNotifyTask(final Iterable> listeners, - final AsyncDataChangeEvent> event) { + final AsyncDataChangeEvent> event) { this.listeners = listeners; this.event = event; } diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DOMImmutableDataChangeEvent.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DOMImmutableDataChangeEvent.java index 743ddd1ae0..5faebcef36 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DOMImmutableDataChangeEvent.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DOMImmutableDataChangeEvent.java @@ -15,14 +15,14 @@ import java.util.Set; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import com.google.common.base.Preconditions; public final class DOMImmutableDataChangeEvent implements - AsyncDataChangeEvent> { + AsyncDataChangeEvent> { private static final RemoveEventFactory REMOVE_EVENT_FACTORY = new RemoveEventFactory(); @@ -30,10 +30,10 @@ public final class DOMImmutableDataChangeEvent implements private final NormalizedNode original; private final NormalizedNode updated; - private final Map> originalData; - private final Map> createdData; - private final Map> updatedData; - private final Set removedPaths; + private final Map> originalData; + private final Map> createdData; + private final Map> updatedData; + private final Set removedPaths; private final DataChangeScope scope; @@ -67,22 +67,22 @@ public final class DOMImmutableDataChangeEvent implements } @Override - public Map> getOriginalData() { + public Map> getOriginalData() { return originalData; } @Override - public Map> getCreatedData() { + public Map> getCreatedData() { return createdData; } @Override - public Map> getUpdatedData() { + public Map> getUpdatedData() { return updatedData; } @Override - public Set getRemovedPaths() { + public Set getRemovedPaths() { return removedPaths; } @@ -98,7 +98,7 @@ public final class DOMImmutableDataChangeEvent implements * */ public interface SimpleEventFactory { - DOMImmutableDataChangeEvent create(InstanceIdentifier path, NormalizedNode data); + DOMImmutableDataChangeEvent create(YangInstanceIdentifier path, NormalizedNode data); } /** @@ -133,10 +133,10 @@ public final class DOMImmutableDataChangeEvent implements private NormalizedNode after; private NormalizedNode before; - private final Map> original = new HashMap<>(); - private final Map> created = new HashMap<>(); - private final Map> updated = new HashMap<>(); - private final Set removed = new HashSet<>(); + private final Map> original = new HashMap<>(); + private final Map> created = new HashMap<>(); + private final Map> updated = new HashMap<>(); + private final Set removed = new HashSet<>(); private Builder(final DataChangeScope scope) { Preconditions.checkNotNull(scope, "Data change scope should not be null."); @@ -167,18 +167,18 @@ public final class DOMImmutableDataChangeEvent implements return this; } - public Builder addCreated(final InstanceIdentifier path, final NormalizedNode node) { + public Builder addCreated(final YangInstanceIdentifier path, final NormalizedNode node) { created.put(path, node); return this; } - public Builder addRemoved(final InstanceIdentifier path, final NormalizedNode node) { + public Builder addRemoved(final YangInstanceIdentifier path, final NormalizedNode node) { original.put(path, node); removed.add(path); return this; } - public Builder addUpdated(final InstanceIdentifier path, final NormalizedNode before, + public Builder addUpdated(final YangInstanceIdentifier path, final NormalizedNode before, final NormalizedNode after) { original.put(path, before); updated.put(path, after); @@ -189,7 +189,7 @@ public final class DOMImmutableDataChangeEvent implements private static final class RemoveEventFactory implements SimpleEventFactory { @Override - public DOMImmutableDataChangeEvent create(final InstanceIdentifier path, final NormalizedNode data) { + public DOMImmutableDataChangeEvent create(final YangInstanceIdentifier path, final NormalizedNode data) { return builder(DataChangeScope.BASE) // .setBefore(data) // .addRemoved(path, data) // @@ -201,7 +201,7 @@ public final class DOMImmutableDataChangeEvent implements private static final class CreateEventFactory implements SimpleEventFactory { @Override - public DOMImmutableDataChangeEvent create(final InstanceIdentifier path, final NormalizedNode data) { + public DOMImmutableDataChangeEvent create(final YangInstanceIdentifier path, final NormalizedNode data) { return builder(DataChangeScope.BASE) // .setAfter(data) // .addCreated(path, data) // diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataChangeListenerRegistration.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataChangeListenerRegistration.java index d8f024017f..b26f43b2b7 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataChangeListenerRegistration.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataChangeListenerRegistration.java @@ -10,14 +10,14 @@ package org.opendaylight.controller.md.sal.dom.store.impl; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -public interface DataChangeListenerRegistration>> extends ListenerRegistration { +public interface DataChangeListenerRegistration>> extends ListenerRegistration { @Override L getInstance(); - InstanceIdentifier getPath(); + YangInstanceIdentifier getPath(); DataChangeScope getScope(); } diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java index bef37980e5..c44d0909d6 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java @@ -35,7 +35,7 @@ import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; import org.opendaylight.yangtools.concepts.Identifiable; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +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 org.opendaylight.yangtools.yang.model.api.SchemaContextListener; @@ -108,8 +108,8 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch executor.shutdownNow(); } @Override - public >> ListenerRegistration registerChangeListener( - final InstanceIdentifier path, final L listener, final DataChangeScope scope) { + public >> ListenerRegistration registerChangeListener( + final YangInstanceIdentifier path, final L listener, final DataChangeScope scope) { /* * Make sure commit is not occurring right now. Listener has to be 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 b679de54d6..ff64cd64c4 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 @@ -24,11 +24,11 @@ import org.opendaylight.controller.md.sal.dom.store.impl.DOMImmutableDataChangeE import org.opendaylight.controller.md.sal.dom.store.impl.tree.ListenerTree; import org.opendaylight.controller.md.sal.dom.store.impl.tree.ListenerTree.Node; import org.opendaylight.controller.md.sal.dom.store.impl.tree.ListenerTree.Walker; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeWithValue; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +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.NodeIdentifierWithPredicates; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; @@ -239,7 +239,7 @@ final class ResolveDataChangeEventsTask implements Callable listeners, final DataTreeCandidateNode node) { if (node.getModificationType() != ModificationType.UNMODIFIED && @@ -274,7 +274,7 @@ final class ResolveDataChangeEventsTask implements Callable listeners, final NormalizedNode beforeData, final NormalizedNode afterData) { @@ -302,7 +302,7 @@ final class ResolveDataChangeEventsTask implements Callable listeners, final NormalizedNodeContainer> beforeCont, final NormalizedNodeContainer> afterCont) { @@ -314,7 +314,7 @@ final class ResolveDataChangeEventsTask implements Callable beforeChild : beforeCont.getValue()) { PathArgument childId = beforeChild.getIdentifier(); alreadyProcessed.add(childId); - InstanceIdentifier childPath = path.node(childId); + YangInstanceIdentifier childPath = path.node(childId); Collection childListeners = getListenerChildrenWildcarded(listeners, childId); Optional> afterChild = afterCont.getChild(childId); DOMImmutableDataChangeEvent childChange = resolveNodeContainerChildUpdated(childPath, childListeners, @@ -333,7 +333,7 @@ final class ResolveDataChangeEventsTask implements Callable childListeners = getListenerChildrenWildcarded(listeners, childId); - InstanceIdentifier childPath = path.node(childId); + YangInstanceIdentifier childPath = path.node(childId); childChanges.add(resolveSameEventRecursivelly(childPath , childListeners, afterChild, DOMImmutableDataChangeEvent.getCreateEventFactory())); } @@ -355,7 +355,7 @@ final class ResolveDataChangeEventsTask implements Callable listeners, final NormalizedNode before, final Optional> after) { @@ -379,14 +379,14 @@ final class ResolveDataChangeEventsTask implements Callable listeners, final NormalizedNode afterState) { @SuppressWarnings({ "unchecked", "rawtypes" }) final NormalizedNode node = (NormalizedNode) afterState; return resolveSameEventRecursivelly(path, listeners, node, DOMImmutableDataChangeEvent.getCreateEventFactory()); } - private DOMImmutableDataChangeEvent resolveDeleteEvent(final InstanceIdentifier path, + private DOMImmutableDataChangeEvent resolveDeleteEvent(final YangInstanceIdentifier path, final Collection listeners, final NormalizedNode beforeState) { @SuppressWarnings({ "unchecked", "rawtypes" }) @@ -394,7 +394,7 @@ final class ResolveDataChangeEventsTask implements Callable listeners, final NormalizedNode node, final SimpleEventFactory eventFactory) { final DOMImmutableDataChangeEvent event = eventFactory.create(path, node); @@ -427,7 +427,7 @@ final class ResolveDataChangeEventsTask implements Callable listeners, final DataTreeCandidateNode modification) { Preconditions.checkArgument(modification.getDataBefore().isPresent(), "Subtree change with before-data not present at path %s", path); @@ -442,7 +442,7 @@ final class ResolveDataChangeEventsTask implements Callable childListeners = getListenerChildrenWildcarded(listeners, childId); diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedReadTransaction.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedReadTransaction.java index c76c70b700..39d6483c52 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedReadTransaction.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedReadTransaction.java @@ -12,7 +12,7 @@ import static com.google.common.base.Preconditions.checkState; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot; import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,7 +48,7 @@ DOMStoreReadTransaction { } @Override - public ListenableFuture>> read(final InstanceIdentifier path) { + public ListenableFuture>> read(final YangInstanceIdentifier path) { checkNotNull(path, "Path must not be null."); checkState(stableSnapshot != null, "Transaction is closed"); return Futures.immediateFuture(stableSnapshot.readNode(path)); diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedReadWriteTransaction.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedReadWriteTransaction.java index 1456386ff9..ec17d7a3f7 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedReadWriteTransaction.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedReadWriteTransaction.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.md.sal.dom.store.impl; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot; import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,7 +41,7 @@ DOMStoreReadWriteTransaction { } @Override - public ListenableFuture>> read(final InstanceIdentifier path) { + public ListenableFuture>> read(final YangInstanceIdentifier path) { LOG.debug("Tx: {} Read: {}", getIdentifier(), path); try { return Futures.immediateFuture(getMutatedView().readNode(path)); diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedWriteTransaction.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedWriteTransaction.java index 16675d3a85..34532ab98f 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedWriteTransaction.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedWriteTransaction.java @@ -12,7 +12,7 @@ import static com.google.common.base.Preconditions.checkState; import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -62,7 +62,7 @@ class SnapshotBackedWriteTransaction extends AbstractDOMStoreTransaction impleme } @Override - public void write(final InstanceIdentifier path, final NormalizedNode data) { + public void write(final YangInstanceIdentifier path, final NormalizedNode data) { checkNotReady(); try { LOG.debug("Tx: {} Write: {}:{}", getIdentifier(), path, data); @@ -79,7 +79,7 @@ class SnapshotBackedWriteTransaction extends AbstractDOMStoreTransaction impleme } @Override - public void merge(final InstanceIdentifier path, final NormalizedNode data) { + public void merge(final YangInstanceIdentifier path, final NormalizedNode data) { checkNotReady(); try { LOG.debug("Tx: {} Merge: {}:{}", getIdentifier(), path, data); @@ -96,7 +96,7 @@ class SnapshotBackedWriteTransaction extends AbstractDOMStoreTransaction impleme } @Override - public void delete(final InstanceIdentifier path) { + public void delete(final YangInstanceIdentifier path) { checkNotReady(); try { LOG.debug("Tx: {} Delete: {}", getIdentifier(), path); diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ListenerTree.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ListenerTree.java index 9d04a1b6ed..39152767dd 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ListenerTree.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ListenerTree.java @@ -27,8 +27,8 @@ import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListene import org.opendaylight.controller.md.sal.dom.store.impl.DataChangeListenerRegistration; import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; import org.opendaylight.yangtools.concepts.Identifiable; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.api.schema.tree.StoreTreeNode; import org.slf4j.Logger; @@ -64,7 +64,7 @@ public final class ListenerTree { * @param scope Scope of triggering event. * @return Listener registration */ - public >> DataChangeListenerRegistration registerDataChangeListener(final InstanceIdentifier path, + public >> DataChangeListenerRegistration registerDataChangeListener(final YangInstanceIdentifier path, final L listener, final DataChangeScope scope) { // Take the write lock @@ -84,7 +84,7 @@ public final class ListenerTree { } @Override - public InstanceIdentifier getPath() { + public YangInstanceIdentifier getPath() { return path; } @@ -251,7 +251,7 @@ public final class ListenerTree { } - private abstract static class DataChangeListenerRegistrationImpl>> extends AbstractListenerRegistration // + private abstract static class DataChangeListenerRegistrationImpl>> extends AbstractListenerRegistration // implements DataChangeListenerRegistration { public DataChangeListenerRegistrationImpl(final T listener) { super(listener); diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/yang/opendaylight-inmemory-datastore-provider.yang b/opendaylight/md-sal/sal-inmemory-datastore/src/main/yang/opendaylight-inmemory-datastore-provider.yang index 03220a3e5d..d4f57b53fe 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/yang/opendaylight-inmemory-datastore-provider.yang +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/yang/opendaylight-inmemory-datastore-provider.yang @@ -58,7 +58,10 @@ module opendaylight-inmemory-datastore-provider { case inmemory-operational-datastore-provider { when "/config:modules/config:module/config:type = 'inmemory-operational-datastore-provider'"; - container schema-service { + // Yang does not allow two cases from same namespaces with same children + // Schema-service dependency renamed to operational-schema-service + // to prevent conflict with schema-service container from inmemory-config-datastore-provider + container operational-schema-service { uses config:service-ref { refine type { mandatory false; diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDataChangeListenerTest.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDataChangeListenerTest.java index 4d2d07884f..3176ca764d 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDataChangeListenerTest.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDataChangeListenerTest.java @@ -21,9 +21,9 @@ import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedCon import org.opendaylight.yangtools.yang.binding.YangModuleInfo; import org.opendaylight.yangtools.yang.binding.util.BindingReflections; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates; +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.NodeIdentifierWithPredicates; 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; @@ -39,7 +39,7 @@ import com.google.common.util.concurrent.MoreExecutors; public abstract class AbstractDataChangeListenerTest { - protected static final InstanceIdentifier TOP_LEVEL = InstanceIdentifier + protected static final YangInstanceIdentifier TOP_LEVEL = YangInstanceIdentifier .of(Top.QNAME); private static final QName NAME_QNAME = QName.create(Top.QNAME, "name"); protected static final String FOO = "foo"; @@ -67,14 +67,14 @@ public abstract class AbstractDataChangeListenerTest { } - public static final InstanceIdentifier path(final String topName, + public static final YangInstanceIdentifier path(final String topName, final String nestedName) { return path(topName).node(NestedList.QNAME).node( new NodeIdentifierWithPredicates(NestedList.QNAME, NAME_QNAME, nestedName)); } - public static final InstanceIdentifier path(final String topName) { + public static final YangInstanceIdentifier path(final String topName) { return TOP_LEVEL.node(TopLevelList.QNAME).node( new NodeIdentifierWithPredicates(TopLevelList.QNAME, NAME_QNAME, topName)); diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/DatastoreTestTask.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/DatastoreTestTask.java index 8ac93b1804..26987a6fba 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/DatastoreTestTask.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/DatastoreTestTask.java @@ -20,7 +20,7 @@ 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.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import com.google.common.base.Preconditions; @@ -29,13 +29,13 @@ import com.google.common.util.concurrent.SettableFuture; public class DatastoreTestTask { private final DOMStore store; - private AsyncDataChangeListener> changeListener; + private AsyncDataChangeListener> changeListener; private WriteTransactionCustomizer setup; private WriteTransactionCustomizer write; private ReadTransactionVerifier read; private WriteTransactionCustomizer cleanup; - private InstanceIdentifier changePath; + private YangInstanceIdentifier changePath; private DataChangeScope changeScope; private boolean postSetup = false; private final ChangeEventListener internalListener; @@ -45,15 +45,15 @@ public class DatastoreTestTask { internalListener = new ChangeEventListener(); } - public DatastoreTestTask changeListener(final InstanceIdentifier path, final DataChangeScope scope, - final AsyncDataChangeListener> changeListener) { + public DatastoreTestTask changeListener(final YangInstanceIdentifier path, final DataChangeScope scope, + final AsyncDataChangeListener> changeListener) { this.changeListener = changeListener; this.changePath = path; this.changeScope = scope; return this; } - public DatastoreTestTask changeListener(final InstanceIdentifier path, final DataChangeScope scope) { + public DatastoreTestTask changeListener(final YangInstanceIdentifier path, final DataChangeScope scope) { this.changePath = path; this.changeScope = scope; return this; @@ -105,7 +105,7 @@ public class DatastoreTestTask { } } - public Future>> getChangeEvent() { + public Future>> getChangeEvent() { return internalListener.receivedChange; } @@ -128,20 +128,20 @@ public class DatastoreTestTask { } private final class ChangeEventListener implements - AsyncDataChangeListener> { + AsyncDataChangeListener> { - protected final SettableFuture>> receivedChange = SettableFuture + protected final SettableFuture>> receivedChange = SettableFuture .create(); @Override - public void onDataChanged(final AsyncDataChangeEvent> change) { + public void onDataChanged(final AsyncDataChangeEvent> change) { if (postSetup) { receivedChange.set(change); } } } - public static final WriteTransactionCustomizer simpleWrite(final InstanceIdentifier path, + public static final WriteTransactionCustomizer simpleWrite(final YangInstanceIdentifier path, final NormalizedNode data) { return new WriteTransactionCustomizer() { @@ -152,7 +152,7 @@ public class DatastoreTestTask { }; } - public static final WriteTransactionCustomizer simpleMerge(final InstanceIdentifier path, + public static final WriteTransactionCustomizer simpleMerge(final YangInstanceIdentifier path, final NormalizedNode data) { return new WriteTransactionCustomizer() { @@ -163,7 +163,7 @@ public class DatastoreTestTask { }; } - public static final WriteTransactionCustomizer simpleDelete(final InstanceIdentifier path) { + public static final WriteTransactionCustomizer simpleDelete(final YangInstanceIdentifier path) { return new WriteTransactionCustomizer() { @Override public void customize(final DOMStoreReadWriteTransaction tx) { diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/RootScopeSubtreeTest.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/RootScopeSubtreeTest.java index ef2a4743e2..905dc0d19b 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/RootScopeSubtreeTest.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/RootScopeSubtreeTest.java @@ -11,7 +11,7 @@ import java.util.concurrent.ExecutionException; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; public class RootScopeSubtreeTest extends DefaultDataChangeListenerTestSuite { @@ -23,7 +23,7 @@ public class RootScopeSubtreeTest extends DefaultDataChangeListenerTestSuite { @Override public void putTopLevelOneNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertContains(change.getCreatedData(), TOP_LEVEL, path(FOO), path(FOO, BAR)); assertEmpty(change.getUpdatedData()); @@ -34,7 +34,7 @@ public class RootScopeSubtreeTest extends DefaultDataChangeListenerTestSuite { public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertContains(change.getCreatedData(), path(FOO, BAZ)); assertContains(change.getUpdatedData(), TOP_LEVEL, path(FOO)); @@ -45,7 +45,7 @@ public class RootScopeSubtreeTest extends DefaultDataChangeListenerTestSuite { protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertContains(change.getCreatedData(), TOP_LEVEL, path(FOO), path(FOO, BAR), path(FOO, BAZ)); assertEmpty(change.getUpdatedData()); @@ -56,7 +56,7 @@ public class RootScopeSubtreeTest extends DefaultDataChangeListenerTestSuite { protected void twoNestedExistsOneIsDeleted(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertEmpty(change.getCreatedData()); assertContains(change.getUpdatedData(), TOP_LEVEL, path(FOO)); @@ -67,7 +67,7 @@ public class RootScopeSubtreeTest extends DefaultDataChangeListenerTestSuite { protected void nestedListExistsRootDeleted(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertEmpty(change.getCreatedData()); assertEmpty(change.getUpdatedData()); @@ -76,7 +76,7 @@ public class RootScopeSubtreeTest extends DefaultDataChangeListenerTestSuite { @Override protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertContains(change.getCreatedData(), path(FOO,BAZ)); assertNotContains(change.getCreatedData(), path(FOO,BAR)); @@ -86,7 +86,7 @@ public class RootScopeSubtreeTest extends DefaultDataChangeListenerTestSuite { @Override protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertContains(change.getCreatedData(), path(FOO,BAR),path(FOO,BAZ)); assertContains(change.getUpdatedData(), TOP_LEVEL, path(FOO)); @@ -96,7 +96,7 @@ public class RootScopeSubtreeTest extends DefaultDataChangeListenerTestSuite { @Override protected void existingTopWriteSibling(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertContains(change.getCreatedData(), path(FOO_SIBLING)); assertContains(change.getUpdatedData(), TOP_LEVEL); diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaUpdateForTransactionTest.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaUpdateForTransactionTest.java index ee62c0bfbf..5cba93a712 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaUpdateForTransactionTest.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaUpdateForTransactionTest.java @@ -19,7 +19,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controll import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext; import org.opendaylight.yangtools.yang.binding.YangModuleInfo; import org.opendaylight.yangtools.yang.binding.util.BindingReflections; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import org.opendaylight.yangtools.yang.model.api.SchemaContext; @@ -28,7 +28,7 @@ import com.google.common.util.concurrent.MoreExecutors; public class SchemaUpdateForTransactionTest { - private static final InstanceIdentifier TOP_PATH = InstanceIdentifier.of(Top.QNAME); + private static final YangInstanceIdentifier TOP_PATH = YangInstanceIdentifier.of(Top.QNAME); private SchemaContext schemaContext; private InMemoryDOMDataStore domStore; diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java index 3feeb29672..66e71a399f 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.md.sal.dom.store.impl; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl; @@ -29,8 +29,8 @@ public class TestModel { public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value"); private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang"; - public static final InstanceIdentifier TEST_PATH = InstanceIdentifier.of(TEST_QNAME); - public static final InstanceIdentifier OUTER_LIST_PATH = InstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build(); + public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_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-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeBaseTest.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeBaseTest.java index 4c1a860f2a..7c8676eff5 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeBaseTest.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeBaseTest.java @@ -16,12 +16,12 @@ import java.util.concurrent.Future; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; public class WildcardedScopeBaseTest extends DefaultDataChangeListenerTestSuite { - private static final InstanceIdentifier TOP_LEVEL_LIST_ALL = TOP_LEVEL.node(TopLevelList.QNAME).node( + private static final YangInstanceIdentifier TOP_LEVEL_LIST_ALL = TOP_LEVEL.node(TopLevelList.QNAME).node( TopLevelList.QNAME); @Override @@ -32,7 +32,7 @@ public class WildcardedScopeBaseTest extends DefaultDataChangeListenerTestSuite @Override public void putTopLevelOneNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertNotNull(change); @@ -48,7 +48,7 @@ public class WildcardedScopeBaseTest extends DefaultDataChangeListenerTestSuite public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertNotNull(change); assertContains(change.getCreatedData(), path(FOO, BAZ)); @@ -62,7 +62,7 @@ public class WildcardedScopeBaseTest extends DefaultDataChangeListenerTestSuite protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertNotNull(change); assertFalse(change.getCreatedData().isEmpty()); @@ -92,7 +92,7 @@ public class WildcardedScopeBaseTest extends DefaultDataChangeListenerTestSuite public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertEmpty(change.getCreatedData()); assertEmpty(change.getUpdatedData()); @@ -131,7 +131,7 @@ public class WildcardedScopeBaseTest extends DefaultDataChangeListenerTestSuite @Override protected void existingTopWriteSibling(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertContains(change.getCreatedData(), path(FOO_SIBLING)); assertNotContains(change.getUpdatedData(), path(FOO), TOP_LEVEL); diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeOneTest.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeOneTest.java index 1f2cb224ab..ac18d5c976 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeOneTest.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeOneTest.java @@ -16,12 +16,12 @@ import java.util.concurrent.Future; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; public class WildcardedScopeOneTest extends DefaultDataChangeListenerTestSuite { - private static final InstanceIdentifier TOP_LEVEL_LIST_ALL = TOP_LEVEL.node(TopLevelList.QNAME).node( + private static final YangInstanceIdentifier TOP_LEVEL_LIST_ALL = TOP_LEVEL.node(TopLevelList.QNAME).node( TopLevelList.QNAME); @Override @@ -32,7 +32,7 @@ public class WildcardedScopeOneTest extends DefaultDataChangeListenerTestSuite { @Override public void putTopLevelOneNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertNotNull(change); @@ -48,7 +48,7 @@ public class WildcardedScopeOneTest extends DefaultDataChangeListenerTestSuite { public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertNotNull(change); assertContains(change.getCreatedData(), path(FOO, BAZ)); @@ -62,7 +62,7 @@ public class WildcardedScopeOneTest extends DefaultDataChangeListenerTestSuite { protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertNotNull(change); assertFalse(change.getCreatedData().isEmpty()); @@ -93,7 +93,7 @@ public class WildcardedScopeOneTest extends DefaultDataChangeListenerTestSuite { public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertEmpty(change.getCreatedData()); assertEmpty(change.getUpdatedData()); @@ -132,7 +132,7 @@ public class WildcardedScopeOneTest extends DefaultDataChangeListenerTestSuite { @Override protected void existingTopWriteSibling(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertContains(change.getCreatedData(), path(FOO_SIBLING)); assertNotContains(change.getUpdatedData(),path(FOO), TOP_LEVEL); diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeSubtreeTest.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeSubtreeTest.java index 010204888b..7e67242dd3 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeSubtreeTest.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeSubtreeTest.java @@ -16,12 +16,12 @@ import java.util.concurrent.ExecutionException; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; public class WildcardedScopeSubtreeTest extends DefaultDataChangeListenerTestSuite { - private static final InstanceIdentifier TOP_LEVEL_LIST_ALL = TOP_LEVEL.node(TopLevelList.QNAME).node( + private static final YangInstanceIdentifier TOP_LEVEL_LIST_ALL = TOP_LEVEL.node(TopLevelList.QNAME).node( TopLevelList.QNAME); @Override @@ -32,7 +32,7 @@ public class WildcardedScopeSubtreeTest extends DefaultDataChangeListenerTestSui @Override public void putTopLevelOneNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertNotContains(change.getCreatedData(), TOP_LEVEL); assertContains(change.getCreatedData(), path(FOO), path(FOO, BAR)); @@ -45,7 +45,7 @@ public class WildcardedScopeSubtreeTest extends DefaultDataChangeListenerTestSui public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertNotNull(change); assertContains(change.getCreatedData(), path(FOO, BAZ)); @@ -59,7 +59,7 @@ public class WildcardedScopeSubtreeTest extends DefaultDataChangeListenerTestSui protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertNotNull(change); assertFalse(change.getCreatedData().isEmpty()); @@ -74,7 +74,7 @@ public class WildcardedScopeSubtreeTest extends DefaultDataChangeListenerTestSui protected void twoNestedExistsOneIsDeleted(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertNotNull(change); assertTrue(change.getCreatedData().isEmpty()); assertContains(change.getUpdatedData(), path(FOO)); @@ -86,7 +86,7 @@ public class WildcardedScopeSubtreeTest extends DefaultDataChangeListenerTestSui public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertEmpty(change.getCreatedData()); assertEmpty(change.getUpdatedData()); @@ -97,7 +97,7 @@ public class WildcardedScopeSubtreeTest extends DefaultDataChangeListenerTestSui @Override protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertContains(change.getCreatedData(), path(FOO,BAZ)); assertNotContains(change.getCreatedData(), path(FOO,BAR)); @@ -108,7 +108,7 @@ public class WildcardedScopeSubtreeTest extends DefaultDataChangeListenerTestSui @Override protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertContains(change.getCreatedData(), path(FOO,BAR),path(FOO,BAZ)); assertContains(change.getUpdatedData(), path(FOO)); @@ -118,7 +118,7 @@ public class WildcardedScopeSubtreeTest extends DefaultDataChangeListenerTestSui @Override protected void existingTopWriteSibling(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent().get(); assertContains(change.getCreatedData(), path(FOO_SIBLING)); assertNotContains(change.getUpdatedData(), path(FOO), TOP_LEVEL); diff --git a/opendaylight/md-sal/sal-netconf-connector/pom.xml b/opendaylight/md-sal/sal-netconf-connector/pom.xml index 0bf4b3238d..10fe4a587a 100644 --- a/opendaylight/md-sal/sal-netconf-connector/pom.xml +++ b/opendaylight/md-sal/sal-netconf-connector/pom.xml @@ -13,7 +13,6 @@ - ${project.groupId} netconf-client ${netconf.version} @@ -62,6 +61,10 @@ org.opendaylight.controller.model model-inventory + + org.opendaylight.controller + sal-broker-impl + org.opendaylight.yangtools yang-data-impl @@ -161,12 +164,6 @@ test-jar test - - org.opendaylight.controller - sal-broker-impl - jar - test - org.opendaylight.yangtools mockito-configuration diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceCommitHandler.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceCommitHandler.java deleted file mode 100644 index 26c6a2758c..0000000000 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceCommitHandler.java +++ /dev/null @@ -1,85 +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.connect.netconf.sal; - -import java.util.concurrent.ExecutionException; - -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.connect.util.RemoteDeviceId; -import org.opendaylight.controller.sal.core.api.RpcImplementation; -import org.opendaylight.yangtools.yang.common.RpcError; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public final class NetconfDeviceCommitHandler implements DataCommitHandler { - - private static final Logger logger= LoggerFactory.getLogger(NetconfDeviceCommitHandler.class); - - private final RemoteDeviceId id; - private final RpcImplementation rpc; - private final boolean rollbackSupported; - - public NetconfDeviceCommitHandler(final RemoteDeviceId id, final RpcImplementation rpc, final boolean rollbackSupported) { - this.id = id; - this.rpc = rpc; - this.rollbackSupported = rollbackSupported; - } - - @Override - public DataCommitTransaction requestCommit( - final DataModification modification) { - - final NetconfDeviceTwoPhaseCommitTransaction twoPhaseCommit = new NetconfDeviceTwoPhaseCommitTransaction(id, rpc, - modification, true, rollbackSupported); - try { - twoPhaseCommit.prepare(); - } catch (final InterruptedException e) { - Thread.currentThread().interrupt(); - throw new RuntimeException(id + ": Interrupted while waiting for response", e); - } catch (final ExecutionException e) { - logger.warn("{}: Error executing pre commit operation on remote device", id, e); - return new FailingTransaction(twoPhaseCommit, e); - } - - return twoPhaseCommit; - } - - /** - * Always fail commit transaction that rolls back delegate transaction afterwards - */ - private class FailingTransaction implements DataCommitTransaction { - private final NetconfDeviceTwoPhaseCommitTransaction twoPhaseCommit; - private final ExecutionException e; - - public FailingTransaction(final NetconfDeviceTwoPhaseCommitTransaction twoPhaseCommit, final ExecutionException e) { - this.twoPhaseCommit = twoPhaseCommit; - this.e = e; - } - - @Override - public DataModification getModification() { - return twoPhaseCommit.getModification(); - } - - @Override - public RpcResult finish() throws IllegalStateException { - return RpcResultBuilder.failed().withError( RpcError.ErrorType.APPLICATION, - id + ": Unexpected operation error during pre-commit operations", e ).build(); - } - - @Override - public RpcResult rollback() throws IllegalStateException { - return twoPhaseCommit.rollback(); - } - } -} diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceDataBroker.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceDataBroker.java new file mode 100644 index 0000000000..ee0c8b7217 --- /dev/null +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceDataBroker.java @@ -0,0 +1,69 @@ +/* + * 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.connect.netconf.sal; + +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; +import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; +import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener; +import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; +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.api.DOMTransactionChain; +import org.opendaylight.controller.sal.connect.netconf.listener.NetconfSessionCapabilities; +import org.opendaylight.controller.sal.connect.netconf.sal.tx.NetconfDeviceReadOnlyTx; +import org.opendaylight.controller.sal.connect.netconf.sal.tx.NetconfDeviceReadWriteTx; +import org.opendaylight.controller.sal.connect.netconf.sal.tx.NetconfDeviceWriteOnlyTx; +import org.opendaylight.controller.sal.connect.util.RemoteDeviceId; +import org.opendaylight.controller.sal.core.api.RpcImplementation; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; + +final class NetconfDeviceDataBroker implements DOMDataBroker { + private final RemoteDeviceId id; + private final RpcImplementation rpc; + private final NetconfSessionCapabilities netconfSessionPreferences; + private final DataNormalizer normalizer; + + public NetconfDeviceDataBroker(final RemoteDeviceId id, final RpcImplementation rpc, final SchemaContext schemaContext, NetconfSessionCapabilities netconfSessionPreferences) { + this.id = id; + this.rpc = rpc; + this.netconfSessionPreferences = netconfSessionPreferences; + normalizer = new DataNormalizer(schemaContext); + } + + @Override + public DOMDataReadOnlyTransaction newReadOnlyTransaction() { + return new NetconfDeviceReadOnlyTx(rpc, normalizer); + } + + @Override + public DOMDataReadWriteTransaction newReadWriteTransaction() { + return new NetconfDeviceReadWriteTx(newReadOnlyTransaction(), newWriteOnlyTransaction()); + } + + @Override + public DOMDataWriteTransaction newWriteOnlyTransaction() { + // FIXME detect if candidate is supported, true is hardcoded + return new NetconfDeviceWriteOnlyTx(id, rpc, normalizer, true, netconfSessionPreferences.isRollbackSupported()); + } + + @Override + public ListenerRegistration registerDataChangeListener(final LogicalDatastoreType store, final YangInstanceIdentifier path, final DOMDataChangeListener listener, final DataChangeScope triggeringScope) { + throw new UnsupportedOperationException("Data change listeners not supported for netconf mount point"); + } + + @Override + public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) { + // TODO implement + throw new UnsupportedOperationException("Transaction chains not supported for netconf mount point"); + } +} diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceDataReader.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceDataReader.java deleted file mode 100644 index 3535c96c80..0000000000 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceDataReader.java +++ /dev/null @@ -1,100 +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.connect.netconf.sal; - -import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.CONFIG_SOURCE_RUNNING; -import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_DATA_QNAME; -import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_CONFIG_QNAME; -import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_QNAME; -import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.toFilterStructure; - -import java.util.concurrent.ExecutionException; - -import org.opendaylight.controller.md.sal.common.api.data.DataReader; -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; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.Node; -import org.opendaylight.yangtools.yang.data.api.SimpleNode; - -public final class NetconfDeviceDataReader implements DataReader { - - private final RpcImplementation rpc; - private final RemoteDeviceId id; - - public NetconfDeviceDataReader(final RemoteDeviceId id, final RpcImplementation rpc) { - this.id = id; - this.rpc = rpc; - } - - @Override - public CompositeNode readConfigurationData(final InstanceIdentifier path) { - final RpcResult result; - try { - result = rpc.invokeRpc(NETCONF_GET_CONFIG_QNAME, - NetconfMessageTransformUtil.wrap(NETCONF_GET_CONFIG_QNAME, CONFIG_SOURCE_RUNNING, toFilterStructure(path))).get(); - } catch (final InterruptedException e) { - throw onInterruptedException(e); - } catch (final ExecutionException e) { - throw new RuntimeException(id + ": Read configuration data " + path + " failed", e); - } - - final CompositeNode data = result.getResult().getFirstCompositeByName(NETCONF_DATA_QNAME); - return data == null ? null : (CompositeNode) findNode(data, path); - } - - private RuntimeException onInterruptedException(final InterruptedException e) { - Thread.currentThread().interrupt(); - return new RuntimeException(id + ": Interrupted while waiting for response", e); - } - - @Override - public CompositeNode readOperationalData(final InstanceIdentifier path) { - final RpcResult result; - try { - result = rpc.invokeRpc(NETCONF_GET_QNAME, NetconfMessageTransformUtil.wrap(NETCONF_GET_QNAME, toFilterStructure(path))).get(); - } catch (final InterruptedException e) { - throw onInterruptedException(e); - } catch (final ExecutionException e) { - throw new RuntimeException(id + ": Read operational data " + path + " failed", e); - } - - final CompositeNode data = result.getResult().getFirstCompositeByName(NETCONF_DATA_QNAME); - return (CompositeNode) findNode(data, path); - } - - private static Node findNode(final CompositeNode node, final InstanceIdentifier identifier) { - - Node current = node; - for (final InstanceIdentifier.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/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceDatastoreAdapter.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceDatastoreAdapter.java index e491496eed..04d5e5e449 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceDatastoreAdapter.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceDatastoreAdapter.java @@ -8,27 +8,28 @@ package org.opendaylight.controller.sal.connect.netconf.sal; import com.google.common.base.Function; +import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.collect.FluentIterable; +import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.MoreExecutors; import java.util.Set; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import org.opendaylight.controller.md.sal.common.api.TransactionStatus; -import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; -import org.opendaylight.controller.sal.binding.api.data.DataProviderService; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; +import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.controller.sal.connect.util.RemoteDeviceId; +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.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.inventory.rev140108.NetconfNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.inventory.rev140108.NetconfNodeBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,123 +43,86 @@ final class NetconfDeviceDatastoreAdapter implements AutoCloseable { private static final Logger logger = LoggerFactory.getLogger(NetconfDeviceDatastoreAdapter.class); private final RemoteDeviceId id; - private final DataProviderService dataService; - private final ListeningExecutorService executor; + private final DataBroker dataService; - NetconfDeviceDatastoreAdapter(final RemoteDeviceId deviceId, final DataProviderService dataService, - final ExecutorService executor) { + NetconfDeviceDatastoreAdapter(final RemoteDeviceId deviceId, final DataBroker dataService) { this.id = Preconditions.checkNotNull(deviceId); this.dataService = Preconditions.checkNotNull(dataService); - this.executor = MoreExecutors.listeningDecorator(Preconditions.checkNotNull(executor)); - // Initial data change scheduled - submitDataChangeToExecutor(this.executor, new Runnable() { - @Override - public void run() { - initDeviceData(); - } - }, deviceId); + initDeviceData(); } public void updateDeviceState(final boolean up, final Set capabilities) { - submitDataChangeToExecutor(this.executor, new Runnable() { - @Override - public void run() { - updateDeviceStateInternal(up, capabilities); - } - }, id); - } - - private void updateDeviceStateInternal(final boolean up, final Set capabilities) { final org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node data = buildDataForDeviceState( up, capabilities, id); - final DataModificationTransaction transaction = dataService.beginTransaction(); - logger.trace("{}: Update device state transaction {} putting operational data started.", id, transaction.getIdentifier()); - transaction.removeOperationalData(id.getBindingPath()); - transaction.putOperationalData(id.getBindingPath(), data); - logger.trace("{}: Update device state transaction {} putting operational data ended.", id, transaction.getIdentifier()); + final ReadWriteTransaction transaction = dataService.newReadWriteTransaction(); + logger.trace("{}: Update device state transaction {} merging operational data started.", id, transaction.getIdentifier()); + transaction.merge(LogicalDatastoreType.OPERATIONAL, id.getBindingPath(), data); + logger.trace("{}: Update device state transaction {} merging operational data ended.", id, transaction.getIdentifier()); commitTransaction(transaction, "update"); } private void removeDeviceConfigAndState() { - final DataModificationTransaction transaction = dataService.beginTransaction(); + final WriteTransaction transaction = dataService.newWriteOnlyTransaction(); logger.trace("{}: Close device state transaction {} removing all data started.", id, transaction.getIdentifier()); - transaction.removeConfigurationData(id.getBindingPath()); - transaction.removeOperationalData(id.getBindingPath()); + transaction.delete(LogicalDatastoreType.CONFIGURATION, id.getBindingPath()); + transaction.delete(LogicalDatastoreType.OPERATIONAL, id.getBindingPath()); logger.trace("{}: Close device state transaction {} removing all data ended.", id, transaction.getIdentifier()); commitTransaction(transaction, "close"); } private void initDeviceData() { - final DataModificationTransaction transaction = dataService.beginTransaction(); + final WriteTransaction transaction = dataService.newWriteOnlyTransaction(); - final InstanceIdentifier path = id.getBindingPath(); + createNodesListIfNotPresent(transaction); + final InstanceIdentifier path = id.getBindingPath(); final Node nodeWithId = getNodeWithId(id); - if (operationalNodeNotExisting(transaction, path)) { - transaction.putOperationalData(path, nodeWithId); - } - if (configurationNodeNotExisting(transaction, path)) { - transaction.putConfigurationData(path, nodeWithId); - } - commitTransaction(transaction, "init"); - } + logger.trace("{}: Init device state transaction {} putting if absent operational data started.", id, transaction.getIdentifier()); + transaction.merge(LogicalDatastoreType.OPERATIONAL, path, nodeWithId); + logger.trace("{}: Init device state transaction {} putting operational data ended.", id, transaction.getIdentifier()); - private void commitTransaction(final DataModificationTransaction transaction, final String txType) { - // attempt commit - final RpcResult result; - try { - result = transaction.commit().get(); - } catch (InterruptedException | ExecutionException e) { - logger.error("{}: Transaction({}) failed", id, txType, e); - throw new IllegalStateException(id + " Transaction(" + txType + ") not committed correctly", e); - } - - // verify success result + committed state - if (isUpdateSuccessful(result)) { - logger.trace("{}: Transaction({}) {} SUCCESSFUL", id, txType, transaction.getIdentifier()); - } else { - logger.error("{}: Transaction({}) {} FAILED!", id, txType, transaction.getIdentifier()); - throw new IllegalStateException(id + " Transaction(" + txType + ") not committed correctly, " + - "Errors: " + result.getErrors()); - } - } + logger.trace("{}: Init device state transaction {} putting if absent config data started.", id, transaction.getIdentifier()); + transaction.merge(LogicalDatastoreType.CONFIGURATION, path, nodeWithId); + logger.trace("{}: Init device state transaction {} putting config data ended.", id, transaction.getIdentifier()); - @Override - public void close() throws Exception { - // Remove device data from datastore - submitDataChangeToExecutor(executor, new Runnable() { - @Override - public void run() { - removeDeviceConfigAndState(); - } - }, id); + commitTransaction(transaction, "init"); } - private static boolean isUpdateSuccessful(final RpcResult result) { - return result.getResult() == TransactionStatus.COMMITED && result.isSuccessful(); + private void createNodesListIfNotPresent(final WriteTransaction writeTx) { + final Nodes nodes = new NodesBuilder().build(); + final InstanceIdentifier path = InstanceIdentifier.builder(Nodes.class).build(); + logger.trace("{}: Merging {} container to ensure its presence", id, Nodes.QNAME, writeTx.getIdentifier()); + writeTx.merge(LogicalDatastoreType.CONFIGURATION, path, nodes); + writeTx.merge(LogicalDatastoreType.OPERATIONAL, path, nodes); } - private static void submitDataChangeToExecutor(final ListeningExecutorService executor, final Runnable r, - final RemoteDeviceId id) { - // Submit data change - final ListenableFuture f = executor.submit(r); - // Verify update execution - Futures.addCallback(f, new FutureCallback() { + private void commitTransaction(final WriteTransaction transaction, final String txType) { + logger.trace("{}: Committing Transaction {}:{}", id, txType, transaction.getIdentifier()); + final CheckedFuture result = transaction.submit(); + + Futures.addCallback(result, new FutureCallback() { @Override - public void onSuccess(final Object result) { - logger.debug("{}: Device data updated successfully", id); + public void onSuccess(final Void result) { + logger.trace("{}: Transaction({}) {} SUCCESSFUL", id, txType, transaction.getIdentifier()); } @Override public void onFailure(final Throwable t) { - logger.warn("{}: Device data update failed", id, t); + logger.error("{}: Transaction({}) {} FAILED!", id, txType, transaction.getIdentifier(), t); + throw new IllegalStateException(id + " Transaction(" + txType + ") not committed correctly", t); } }); + + } + + @Override + public void close() throws Exception { + removeDeviceConfigAndState(); } public static org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node buildDataForDeviceState( @@ -179,14 +143,11 @@ final class NetconfDeviceDatastoreAdapter implements AutoCloseable { return nodeBuilder.build(); } - private static boolean configurationNodeNotExisting(final DataModificationTransaction transaction, - final InstanceIdentifier path) { - return null == transaction.readConfigurationData(path); - } - - private static boolean operationalNodeNotExisting(final DataModificationTransaction transaction, + private static ListenableFuture> readNodeData( + final LogicalDatastoreType store, + final ReadWriteTransaction transaction, final InstanceIdentifier path) { - return null == transaction.readOperationalData(path); + return transaction.read(store, path); } private static Node getNodeWithId(final RemoteDeviceId id) { diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceRpc.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceRpc.java index 8d5b7aed2f..a0453bce55 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceRpc.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceRpc.java @@ -44,6 +44,8 @@ public final class NetconfDeviceRpc implements RpcImplementation { return Collections.emptySet(); } + // TODO change this to work with NormalizedNode api. Then we can loose DataNormalizer from Transactions + @Override public ListenableFuture> invokeRpc(final QName rpc, final CompositeNode input) { final NetconfMessage message = transformRequest(rpc, input); diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceSalFacade.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceSalFacade.java index 37b87045d5..dbef290197 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceSalFacade.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceSalFacade.java @@ -7,32 +7,40 @@ */ package org.opendaylight.controller.sal.connect.netconf.sal; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.ExecutorService; + +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; import org.opendaylight.controller.sal.connect.api.RemoteDeviceHandler; import org.opendaylight.controller.sal.connect.netconf.listener.NetconfSessionCapabilities; import org.opendaylight.controller.sal.connect.util.RemoteDeviceId; import org.opendaylight.controller.sal.core.api.Broker; import org.opendaylight.controller.sal.core.api.RpcImplementation; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance; +import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry; +import org.opendaylight.controller.sal.core.api.notify.NotificationListener; +import org.opendaylight.controller.sal.core.api.notify.NotificationPublishService; +import org.opendaylight.controller.sal.dom.broker.impl.NotificationRouterImpl; +import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareRpcBroker; +import org.opendaylight.controller.sal.dom.broker.spi.NotificationRouter; +import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.RpcDefinition; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider; import org.osgi.framework.BundleContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + public final class NetconfDeviceSalFacade implements AutoCloseable, RemoteDeviceHandler { private static final Logger logger= LoggerFactory.getLogger(NetconfDeviceSalFacade.class); - private static final InstanceIdentifier ROOT_PATH = InstanceIdentifier.builder().toInstance(); private final RemoteDeviceId id; private final NetconfDeviceSalProvider salProvider; @@ -58,24 +66,50 @@ public final class NetconfDeviceSalFacade implements AutoCloseable, RemoteDevice @Override public synchronized void onDeviceConnected(final SchemaContextProvider remoteSchemaContextProvider, final NetconfSessionCapabilities netconfSessionPreferences, final RpcImplementation deviceRpc) { - salProvider.getMountInstance().setSchemaContext(remoteSchemaContextProvider.getSchemaContext()); + final SchemaContext schemaContext = remoteSchemaContextProvider.getSchemaContext(); + + // TODO remove deprecated SchemaContextProvider from SchemaAwareRpcBroker + // TODO move SchemaAwareRpcBroker from sal-broker-impl, now we have depend on the whole sal-broker-impl + final RpcProvisionRegistry rpcRegistry = new SchemaAwareRpcBroker(id.getPath().toString(), new org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProvider() { + @Override + public SchemaContext getSchemaContext() { + return schemaContext; + } + }); + registerRpcsToSal(schemaContext, rpcRegistry, deviceRpc); + final DOMDataBroker domBroker = new NetconfDeviceDataBroker(id, deviceRpc, schemaContext, netconfSessionPreferences); + + // TODO NotificationPublishService and NotificationRouter have the same interface + final NotificationPublishService notificationService = new NotificationPublishService() { + + private final NotificationRouter innerRouter = new NotificationRouterImpl(); + + @Override + public void publish(final CompositeNode notification) { + innerRouter.publish(notification); + } + + @Override + public ListenerRegistration addNotificationListener(final QName notification, final NotificationListener listener) { + return innerRouter.addNotificationListener(notification, listener); + } + }; + + salProvider.getMountInstance().onDeviceConnected(schemaContext, domBroker, rpcRegistry, notificationService); salProvider.getDatastoreAdapter().updateDeviceState(true, netconfSessionPreferences.getModuleBasedCaps()); - registerDataHandlersToSal(deviceRpc, netconfSessionPreferences); - registerRpcsToSal(deviceRpc); } @Override public void onDeviceDisconnected() { salProvider.getDatastoreAdapter().updateDeviceState(false, Collections.emptySet()); + salProvider.getMountInstance().onDeviceDisconnected(); } - private void registerRpcsToSal(final RpcImplementation deviceRpc) { - final MountProvisionInstance mountInstance = salProvider.getMountInstance(); - + private void registerRpcsToSal(final SchemaContext schemaContext, final RpcProvisionRegistry rpcRegistry, final RpcImplementation deviceRpc) { final Map failedRpcs = Maps.newHashMap(); - for (final RpcDefinition rpcDef : mountInstance.getSchemaContext().getOperations()) { + for (final RpcDefinition rpcDef : schemaContext.getOperations()) { try { - salRegistrations.add(mountInstance.addRpcImplementation(rpcDef.getQName(), deviceRpc)); + salRegistrations.add(rpcRegistry.addRpcImplementation(rpcDef.getQName(), deviceRpc)); logger.debug("{}: Rpc {} from netconf registered successfully", id, rpcDef.getQName()); } catch (final Exception e) { // Only debug per rpc, warn for all of them at the end to pollute log a little less (e.g. routed rpcs) @@ -94,18 +128,6 @@ public final class NetconfDeviceSalFacade implements AutoCloseable, RemoteDevice } } - private void registerDataHandlersToSal(final RpcImplementation deviceRpc, - final NetconfSessionCapabilities netconfSessionPreferences) { - final NetconfDeviceDataReader dataReader = new NetconfDeviceDataReader(id, deviceRpc); - final NetconfDeviceCommitHandler commitHandler = new NetconfDeviceCommitHandler(id, deviceRpc, - netconfSessionPreferences.isRollbackSupported()); - - final MountProvisionInstance mountInstance = salProvider.getMountInstance(); - salRegistrations.add(mountInstance.registerConfigurationReader(ROOT_PATH, dataReader)); - salRegistrations.add(mountInstance.registerOperationalReader(ROOT_PATH, dataReader)); - salRegistrations.add(mountInstance.registerCommitHandler(ROOT_PATH, commitHandler)); - } - @Override public void close() { for (final AutoCloseable reg : Lists.reverse(salRegistrations)) { diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceSalProvider.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceSalProvider.java index fc54bfbc3d..cf9174dd50 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceSalProvider.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceSalProvider.java @@ -11,15 +11,21 @@ import com.google.common.base.Preconditions; import java.util.Collection; import java.util.Collections; import java.util.concurrent.ExecutorService; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; +import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; +import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; -import org.opendaylight.controller.sal.binding.api.data.DataProviderService; import org.opendaylight.controller.sal.connect.util.RemoteDeviceId; import org.opendaylight.controller.sal.core.api.Broker; import org.opendaylight.controller.sal.core.api.Provider; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionService; +import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry; +import org.opendaylight.controller.sal.core.api.notify.NotificationPublishService; +import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.RpcService; +import org.opendaylight.yangtools.yang.data.api.CompositeNode; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -29,17 +35,17 @@ final class NetconfDeviceSalProvider implements AutoCloseable, Provider, Binding private final RemoteDeviceId id; private final ExecutorService executor; - private volatile MountProvisionInstance mountInstance; private volatile NetconfDeviceDatastoreAdapter datastoreAdapter; + private MountInstance mountInstance; public NetconfDeviceSalProvider(final RemoteDeviceId deviceId, final ExecutorService executor) { this.id = deviceId; this.executor = executor; } - public MountProvisionInstance getMountInstance() { + public MountInstance getMountInstance() { Preconditions.checkState(mountInstance != null, - "%s: Sal provider was not initialized by sal. Cannot get mount instance", id); + "%s: Mount instance was not initialized by sal. Cannot get mount instance", id); return mountInstance; } @@ -51,12 +57,12 @@ final class NetconfDeviceSalProvider implements AutoCloseable, Provider, Binding @Override public void onSessionInitiated(final Broker.ProviderSession session) { - final MountProvisionService mountService = session.getService(MountProvisionService.class); + logger.debug("{}: (BI)Session with sal established {}", id, session); + + final DOMMountPointService mountService = session.getService(DOMMountPointService.class); if (mountService != null) { - mountInstance = mountService.createOrGetMountPoint(id.getPath()); + mountInstance = new MountInstance(mountService, id); } - - logger.debug("{}: (BI)Session with sal established {}", id, session); } @Override @@ -76,20 +82,78 @@ final class NetconfDeviceSalProvider implements AutoCloseable, Provider, Binding @Override public void onSessionInitiated(final BindingAwareBroker.ProviderContext session) { - final DataProviderService dataBroker = session.getSALService(DataProviderService.class); - datastoreAdapter = new NetconfDeviceDatastoreAdapter(id, dataBroker, executor); - logger.debug("{}: Session with sal established {}", id, session); + + final DataBroker dataBroker = session.getSALService(DataBroker.class); + datastoreAdapter = new NetconfDeviceDatastoreAdapter(id, dataBroker); } @Override - public void onSessionInitialized(final BindingAwareBroker.ConsumerContext session) { - } + public void onSessionInitialized(final BindingAwareBroker.ConsumerContext session) {} public void close() throws Exception { - mountInstance = null; + mountInstance.close(); datastoreAdapter.close(); datastoreAdapter = null; } + static final class MountInstance implements AutoCloseable { + + private DOMMountPointService mountService; + private final RemoteDeviceId id; + private ObjectRegistration registration; + private NotificationPublishService notificationSerivce; + + MountInstance(final DOMMountPointService mountService, final RemoteDeviceId id) { + this.mountService = Preconditions.checkNotNull(mountService); + this.id = Preconditions.checkNotNull(id); + } + + synchronized void onDeviceConnected(final SchemaContext initialCtx, + final DOMDataBroker broker, final RpcProvisionRegistry rpc, + final NotificationPublishService notificationSerivce) { + + Preconditions.checkNotNull(mountService, "Closed"); + Preconditions.checkState(registration == null, "Already initialized"); + + final DOMMountPointService.DOMMountPointBuilder mountBuilder = mountService.createMountPoint(id.getPath()); + mountBuilder.addInitialSchemaContext(initialCtx); + + mountBuilder.addService(DOMDataBroker.class, broker); + mountBuilder.addService(RpcProvisionRegistry.class, rpc); + this.notificationSerivce = notificationSerivce; + mountBuilder.addService(NotificationPublishService.class, notificationSerivce); + + registration = mountBuilder.register(); + } + + synchronized void onDeviceDisconnected() { + if(registration == null) { + return; + } + + try { + registration.close(); + } catch (final Exception e) { + // Only log and ignore + logger.warn("Unable to unregister mount instance for {}. Ignoring exception", id.getPath(), e); + } finally { + registration = null; + } + } + + @Override + synchronized public void close() throws Exception { + if(registration != null) { + onDeviceDisconnected(); + } + mountService = null; + } + + public synchronized void publish(final CompositeNode domNotification) { + Preconditions.checkNotNull(notificationSerivce, "Device not set up yet, cannot handle notification {}", domNotification); + notificationSerivce.publish(domNotification); + } + } + } 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 new file mode 100644 index 0000000000..3248453baf --- /dev/null +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/tx/NetconfDeviceReadOnlyTx.java @@ -0,0 +1,152 @@ +/* + * 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.connect.netconf.sal.tx; + +import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.CONFIG_SOURCE_RUNNING; +import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_DATA_QNAME; +import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_CONFIG_QNAME; +import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_QNAME; +import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.toFilterStructure; + +import com.google.common.base.Function; +import com.google.common.base.Optional; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException; +import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer; +import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; +import org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil; +import org.opendaylight.controller.sal.core.api.RpcImplementation; +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.Node; +import org.opendaylight.yangtools.yang.data.api.SimpleNode; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public final class NetconfDeviceReadOnlyTx implements DOMDataReadOnlyTransaction { + + private static final Logger LOG = LoggerFactory.getLogger(NetconfDeviceReadOnlyTx.class); + + private final RpcImplementation rpc; + private final DataNormalizer normalizer; + + public NetconfDeviceReadOnlyTx(final RpcImplementation rpc, final DataNormalizer normalizer) { + this.rpc = rpc; + this.normalizer = normalizer; + } + + public ListenableFuture>> readConfigurationData(final YangInstanceIdentifier path) { + final ListenableFuture> future = rpc.invokeRpc(NETCONF_GET_CONFIG_QNAME, + NetconfMessageTransformUtil.wrap(NETCONF_GET_CONFIG_QNAME, CONFIG_SOURCE_RUNNING, toFilterStructure(path))); + + return Futures.transform(future, new Function, Optional>>() { + @Override + public Optional> apply(final RpcResult result) { + final CompositeNode data = result.getResult().getFirstCompositeByName(NETCONF_DATA_QNAME); + final CompositeNode node = (CompositeNode) findNode(data, path); + + return data == null ? + Optional.>absent() : + transform(path, node); + } + }); + } + + private Optional> transform(final YangInstanceIdentifier path, final CompositeNode node) { + if(node == null) { + return Optional.absent(); + } + try { + return Optional.>of(normalizer.toNormalized(path, node).getValue()); + } catch (final Exception e) { + LOG.error("Unable to normalize data for {}, data: {}", path, node, e); + throw e; + } + } + + public ListenableFuture>> readOperationalData(final YangInstanceIdentifier path) { + final ListenableFuture> future = rpc.invokeRpc(NETCONF_GET_QNAME, NetconfMessageTransformUtil.wrap(NETCONF_GET_QNAME, toFilterStructure(path))); + + return Futures.transform(future, new Function, Optional>>() { + @Override + public Optional> apply(final RpcResult result) { + final CompositeNode data = result.getResult().getFirstCompositeByName(NETCONF_DATA_QNAME); + final CompositeNode node = (CompositeNode) findNode(data, path); + + return data == null ? + Optional.>absent() : + transform(path, node); + } + }); + } + + 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 + } + + @Override + public ListenableFuture>> read(final LogicalDatastoreType store, final YangInstanceIdentifier path) { + final YangInstanceIdentifier legacyPath = toLegacyPath(normalizer, path); + + switch (store) { + case CONFIGURATION : { + return readConfigurationData(legacyPath); + } + case OPERATIONAL : { + return readOperationalData(legacyPath); + } + } + + throw new IllegalArgumentException(String.format("Cannot read data %s for %s datastore, unknown datastore type", path, store)); + } + + static YangInstanceIdentifier toLegacyPath(final DataNormalizer normalizer, final YangInstanceIdentifier path) { + try { + return normalizer.toLegacy(path); + } catch (final DataNormalizationException e) { + throw new IllegalArgumentException("Cannot normalize path " + path, e); + } + } + + @Override + public Object getIdentifier() { + return this; + } +} diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/tx/NetconfDeviceReadWriteTx.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/tx/NetconfDeviceReadWriteTx.java new file mode 100644 index 0000000000..4054cf9403 --- /dev/null +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/tx/NetconfDeviceReadWriteTx.java @@ -0,0 +1,73 @@ +/* + * 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.connect.netconf.sal.tx; + +import com.google.common.base.Optional; +import com.google.common.util.concurrent.CheckedFuture; +import com.google.common.util.concurrent.ListenableFuture; +import org.opendaylight.controller.md.sal.common.api.TransactionStatus; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction; +import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; +import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; + +public class NetconfDeviceReadWriteTx implements DOMDataReadWriteTransaction { + + private final DOMDataReadTransaction delegateReadTx; + private final DOMDataWriteTransaction delegateWriteTx; + + public NetconfDeviceReadWriteTx(final DOMDataReadTransaction delegateReadTx, final DOMDataWriteTransaction delegateWriteTx) { + this.delegateReadTx = delegateReadTx; + this.delegateWriteTx = delegateWriteTx; + } + + @Override + public boolean cancel() { + return delegateWriteTx.cancel(); + } + + @Override + public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data) { + delegateWriteTx.put(store, path, data); + } + + @Override + public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data) { + delegateWriteTx.merge(store, path, data); + } + + @Override + public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) { + delegateWriteTx.delete(store, path); + } + + @Override + public CheckedFuture submit() { + return delegateWriteTx.submit(); + } + + @Override + public ListenableFuture> commit() { + return delegateWriteTx.commit(); + } + + @Override + public ListenableFuture>> read(final LogicalDatastoreType store, final YangInstanceIdentifier path) { + return delegateReadTx.read(store, path); + } + + @Override + public Object getIdentifier() { + return this; + } +} diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceTwoPhaseCommitTransaction.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/tx/NetconfDeviceWriteOnlyTx.java similarity index 50% rename from opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceTwoPhaseCommitTransaction.java rename to opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/tx/NetconfDeviceWriteOnlyTx.java index 960f2ef2e8..c8d9028210 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceTwoPhaseCommitTransaction.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/tx/NetconfDeviceWriteOnlyTx.java @@ -3,9 +3,10 @@ * * 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 + * and is available at http://www.eclipse.org/legal/epl-v10.html. */ -package org.opendaylight.controller.sal.connect.netconf.sal; + +package org.opendaylight.controller.sal.connect.netconf.sal.tx; import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_CANDIDATE_QNAME; import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_COMMIT_QNAME; @@ -18,21 +19,25 @@ import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessag import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_TARGET_QNAME; import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.ROLLBACK_ON_ERROR_OPTION; +import com.google.common.base.Function; import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; - -import java.util.Collection; +import com.google.common.util.concurrent.CheckedFuture; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.concurrent.ExecutionException; - -import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction; -import org.opendaylight.controller.md.sal.common.api.data.DataModification; +import javax.annotation.Nullable; +import org.opendaylight.controller.md.sal.common.api.TransactionStatus; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer; +import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; 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; @@ -41,103 +46,165 @@ import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.ModifyAction; import org.opendaylight.yangtools.yang.data.api.Node; import org.opendaylight.yangtools.yang.data.api.SimpleNode; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode; import org.opendaylight.yangtools.yang.data.impl.NodeFactory; import org.opendaylight.yangtools.yang.data.impl.util.CompositeNodeBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** - * Remote transaction that delegates data change to remote device using netconf messages. - */ -final class NetconfDeviceTwoPhaseCommitTransaction implements DataCommitTransaction { +public class NetconfDeviceWriteOnlyTx implements DOMDataWriteTransaction { - private static final Logger LOG = LoggerFactory.getLogger(NetconfDeviceTwoPhaseCommitTransaction.class); + private static final Logger LOG = LoggerFactory.getLogger(NetconfDeviceWriteOnlyTx.class); - private final DataModification modification; + private final RemoteDeviceId id; private final RpcImplementation rpc; + private final DataNormalizer normalizer; private final boolean rollbackSupported; - private final RemoteDeviceId id; private final CompositeNode targetNode; - public NetconfDeviceTwoPhaseCommitTransaction(final RemoteDeviceId id, final RpcImplementation rpc, - final DataModification modification, - final boolean candidateSupported, final boolean rollbackOnErrorSupported) { + public NetconfDeviceWriteOnlyTx(final RemoteDeviceId id, final RpcImplementation rpc, final DataNormalizer normalizer, final boolean candidateSupported, final boolean rollbackOnErrorSupported) { this.id = id; - this.rpc = Preconditions.checkNotNull(rpc); - this.modification = Preconditions.checkNotNull(modification); + this.rpc = rpc; + this.normalizer = normalizer; this.targetNode = getTargetNode(candidateSupported); this.rollbackSupported = rollbackOnErrorSupported; } - /** - * Prepare phase, sends 1 or more netconf edit config operations to modify the data - * - * In case of failure or unexpected error response, ExecutionException is thrown - */ - void prepare() throws InterruptedException, ExecutionException { - for (final InstanceIdentifier toRemove : modification.getRemovedConfigurationData()) { - sendDelete(toRemove); - } - for(final Entry toUpdate : modification.getUpdatedConfigurationData().entrySet()) { - sendMerge(toUpdate.getKey(),toUpdate.getValue()); + // FIXME add logging + + @Override + public boolean cancel() { + if(isCommitted()) { + return false; } + + return discardChanges(); } - private void sendMerge(final InstanceIdentifier key, final CompositeNode value) throws InterruptedException, ExecutionException { - sendEditRpc(createEditConfigStructure(key, Optional.absent(), Optional.of(value)), Optional.absent()); + private boolean isCommitted() { + // TODO 732 + return true; } - private void sendDelete(final InstanceIdentifier toDelete) throws InterruptedException, ExecutionException { - sendEditRpc(createEditConfigStructure(toDelete, Optional.of(ModifyAction.DELETE), Optional.absent()), Optional.of(ModifyAction.NONE)); + private boolean discardChanges() { + // TODO 732 + return true; } - private void sendEditRpc(final CompositeNode editStructure, final Optional defaultOperation) throws InterruptedException, ExecutionException { - final ImmutableCompositeNode editConfigRequest = createEditConfigRequest(editStructure, defaultOperation); - final RpcResult rpcResult = rpc.invokeRpc(NETCONF_EDIT_CONFIG_QNAME, editConfigRequest).get(); + // TODO should the edit operations be blocking ? - // Check result - if(rpcResult.isSuccessful() == false) { - throw new ExecutionException( - String.format("%s: Pre-commit rpc failed, request: %s, errors: %s", id, editConfigRequest, rpcResult.getErrors()), null); + @Override + public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data) { + Preconditions.checkArgument(store == LogicalDatastoreType.CONFIGURATION, "Can merge only configuration, not %s", store); + + try { + final YangInstanceIdentifier legacyPath = NetconfDeviceReadOnlyTx.toLegacyPath(normalizer, path); + final CompositeNode legacyData = normalizer.toLegacy(path, data); + sendEditRpc(createEditConfigStructure(legacyPath, Optional.of(ModifyAction.REPLACE), Optional.fromNullable(legacyData)), Optional.of(ModifyAction.NONE)); + } catch (final ExecutionException e) { + LOG.warn("Error putting data to {}, data: {}, discarding changes", path, data, e); + discardChanges(); + throw new RuntimeException("Error while replacing " + path, e); } } - private ImmutableCompositeNode createEditConfigRequest(final CompositeNode editStructure, final Optional defaultOperation) { - final CompositeNodeBuilder ret = ImmutableCompositeNode.builder(); + @Override + public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data) { + Preconditions.checkArgument(store == LogicalDatastoreType.CONFIGURATION, "Can merge only configuration, not %s", store); - // Target - final Node targetWrapperNode = ImmutableCompositeNode.create(NETCONF_TARGET_QNAME, ImmutableList.>of(targetNode)); - ret.add(targetWrapperNode); + try { + final YangInstanceIdentifier legacyPath = NetconfDeviceReadOnlyTx.toLegacyPath(normalizer, path); + final CompositeNode legacyData = normalizer.toLegacy(path, data); + sendEditRpc( + createEditConfigStructure(legacyPath, Optional. absent(), Optional.fromNullable(legacyData)), Optional. absent()); + } catch (final ExecutionException e) { + LOG.warn("Error merging data to {}, data: {}, discarding changes", path, data, e); + discardChanges(); + throw new RuntimeException("Error while merging " + path, e); + } + } - // Default operation - if(defaultOperation.isPresent()) { - final SimpleNode defOp = NodeFactory.createImmutableSimpleNode(NETCONF_DEFAULT_OPERATION_QNAME, null, modifyOperationToXmlString(defaultOperation.get())); - ret.add(defOp); + @Override + public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) { + Preconditions.checkArgument(store == LogicalDatastoreType.CONFIGURATION, "Can merge only configuration, not %s", store); + + try { + sendEditRpc(createEditConfigStructure(NetconfDeviceReadOnlyTx.toLegacyPath(normalizer, path), Optional.of(ModifyAction.DELETE), Optional.absent()), Optional.of(ModifyAction.NONE)); + } catch (final ExecutionException e) { + LOG.warn("Error deleting data {}, discarding changes", path, e); + discardChanges(); + throw new RuntimeException("Error while deleting " + path, e); } + } - // Error option - if(rollbackSupported) { - ret.addLeaf(NETCONF_ERROR_OPTION_QNAME, ROLLBACK_ON_ERROR_OPTION); + @Override + public CheckedFuture submit() { + final ListenableFuture commmitFutureAsVoid = Futures.transform(commit(), new Function, Void>() { + @Nullable + @Override + public Void apply(@Nullable final RpcResult input) { + return null; + } + }); + + return Futures.makeChecked(commmitFutureAsVoid, new Function() { + @Override + public TransactionCommitFailedException apply(final Exception input) { + return new TransactionCommitFailedException("Submit of transaction " + getIdentifier() + " failed", input); + } + }); + } + + @Override + public ListenableFuture> commit() { + // FIXME do not allow commit if closed or failed + + final ListenableFuture> rpcResult = rpc.invokeRpc(NetconfMessageTransformUtil.NETCONF_COMMIT_QNAME, getCommitRequest()); + return Futures.transform(rpcResult, new Function, RpcResult>() { + @Override + public RpcResult apply(@Nullable final RpcResult input) { + if(input.isSuccessful()) { + return RpcResultBuilder.success(TransactionStatus.COMMITED).build(); + } else { + final RpcResultBuilder failed = RpcResultBuilder.failed(); + for (final RpcError rpcError : input.getErrors()) { + failed.withError(rpcError.getErrorType(), rpcError.getTag(), rpcError.getMessage(), rpcError.getApplicationTag(), rpcError.getInfo(), rpcError.getCause()); + } + return failed.build(); + } + } + }); + + // FIXME 732 detect commit failure + } + + private void sendEditRpc(final CompositeNode editStructure, final Optional defaultOperation) throws ExecutionException { + final CompositeNode editConfigRequest = createEditConfigRequest(editStructure, defaultOperation); + final RpcResult rpcResult; + try { + rpcResult = rpc.invokeRpc(NETCONF_EDIT_CONFIG_QNAME, editConfigRequest).get(); + } catch (final InterruptedException e) { + Thread.currentThread().interrupt(); + throw new RuntimeException(id + ": Interrupted while waiting for response", e); } - ret.setQName(NETCONF_EDIT_CONFIG_QNAME); - // Edit content - ret.add(editStructure); - return ret.toInstance(); + // Check result + if(rpcResult.isSuccessful() == false) { + throw new ExecutionException( + String.format("%s: Pre-commit rpc failed, request: %s, errors: %s", id, editConfigRequest, rpcResult.getErrors()), null); + } } - private CompositeNode createEditConfigStructure(final InstanceIdentifier dataPath, final Optional operation, - final Optional lastChildOverride) { + private CompositeNode createEditConfigStructure(final YangInstanceIdentifier dataPath, final Optional operation, + final Optional lastChildOverride) { Preconditions.checkArgument(Iterables.isEmpty(dataPath.getPathArguments()) == false, "Instance identifier with empty path %s", dataPath); - List reversedPath = Lists.reverse(dataPath.getPath()); + List reversedPath = Lists.reverse(dataPath.getPath()); // Create deepest edit element with expected edit operation CompositeNode previous = getDeepestEditElement(reversedPath.get(0), operation, lastChildOverride); @@ -147,7 +214,7 @@ final class NetconfDeviceTwoPhaseCommitTransaction implements DataCommitTransact reversedPath.remove(0); // Create edit structure in reversed order - for (final PathArgument arg : reversedPath) { + for (final YangInstanceIdentifier.PathArgument arg : reversedPath) { final CompositeNodeBuilder builder = ImmutableCompositeNode.builder(); builder.setQName(arg.getNodeType()); @@ -160,20 +227,20 @@ final class NetconfDeviceTwoPhaseCommitTransaction implements DataCommitTransact } private void addPredicatesToCompositeNodeBuilder(final Map predicates, final CompositeNodeBuilder builder) { - for (final Entry entry : predicates.entrySet()) { + for (final Map.Entry entry : predicates.entrySet()) { builder.addLeaf(entry.getKey(), entry.getValue()); } } - private Map getPredicates(final PathArgument arg) { + private Map getPredicates(final YangInstanceIdentifier.PathArgument arg) { Map predicates = Collections.emptyMap(); - if (arg instanceof NodeIdentifierWithPredicates) { - predicates = ((NodeIdentifierWithPredicates) arg).getKeyValues(); + if (arg instanceof YangInstanceIdentifier.NodeIdentifierWithPredicates) { + predicates = ((YangInstanceIdentifier.NodeIdentifierWithPredicates) arg).getKeyValues(); } return predicates; } - private CompositeNode getDeepestEditElement(final PathArgument arg, final Optional operation, final Optional lastChildOverride) { + private CompositeNode getDeepestEditElement(final YangInstanceIdentifier.PathArgument arg, final Optional operation, final Optional lastChildOverride) { final CompositeNodeBuilder builder = ImmutableCompositeNode.builder(); builder.setQName(arg.getNodeType()); @@ -195,44 +262,32 @@ final class NetconfDeviceTwoPhaseCommitTransaction implements DataCommitTransact return builder.toInstance(); } - private String modifyOperationToXmlString(final ModifyAction operation) { - return operation.name().toLowerCase(); - } + private CompositeNode createEditConfigRequest(final CompositeNode editStructure, final Optional defaultOperation) { + final CompositeNodeBuilder ret = ImmutableCompositeNode.builder(); - /** - * Send commit rpc to finish the transaction - * In case of failure or unexpected error response, ExecutionException is thrown - */ - @Override - public RpcResult finish() { - try { - final RpcResult rpcResult = rpc.invokeRpc(NetconfMessageTransformUtil.NETCONF_COMMIT_QNAME, getCommitRequest()).get(); - return new RpcResultVoidWrapper(rpcResult); - } catch (final InterruptedException e) { - Thread.currentThread().interrupt(); - throw new RuntimeException(id + ": Interrupted while waiting for response", e); - } catch (final ExecutionException e) { - LOG.warn("{}: Failed to finish commit operation", id, e); - return RpcResultBuilder.failed().withError( RpcError.ErrorType.APPLICATION, - id + ": Unexpected operation error during commit operation", e ).build(); + // Target + final Node targetWrapperNode = ImmutableCompositeNode.create(NETCONF_TARGET_QNAME, ImmutableList.>of(targetNode)); + ret.add(targetWrapperNode); + + // Default operation + if(defaultOperation.isPresent()) { + final SimpleNode defOp = NodeFactory.createImmutableSimpleNode(NETCONF_DEFAULT_OPERATION_QNAME, null, modifyOperationToXmlString(defaultOperation.get())); + ret.add(defOp); } - } - private ImmutableCompositeNode getCommitRequest() { - final CompositeNodeBuilder commitInput = ImmutableCompositeNode.builder(); - commitInput.setQName(NETCONF_COMMIT_QNAME); - return commitInput.toInstance(); - } + // Error option + if(rollbackSupported) { + ret.addLeaf(NETCONF_ERROR_OPTION_QNAME, ROLLBACK_ON_ERROR_OPTION); + } - @Override - public DataModification getModification() { - return this.modification; + ret.setQName(NETCONF_EDIT_CONFIG_QNAME); + // Edit content + ret.add(editStructure); + return ret.toInstance(); } - @Override - public RpcResult rollback() throws IllegalStateException { - // TODO BUG-732 implement rollback by sending discard changes - return null; + private String modifyOperationToXmlString(final ModifyAction operation) { + return operation.name().toLowerCase(); } public CompositeNode getTargetNode(final boolean candidateSupported) { @@ -243,27 +298,15 @@ final class NetconfDeviceTwoPhaseCommitTransaction implements DataCommitTransact } } - private static final class RpcResultVoidWrapper implements RpcResult { - - private final RpcResult rpcResult; - - public RpcResultVoidWrapper(final RpcResult rpcResult) { - this.rpcResult = rpcResult; - } - - @Override - public boolean isSuccessful() { - return rpcResult.isSuccessful(); - } + private ImmutableCompositeNode getCommitRequest() { + final CompositeNodeBuilder commitInput = ImmutableCompositeNode.builder(); + commitInput.setQName(NETCONF_COMMIT_QNAME); + return commitInput.toInstance(); + } - @Override - public Void getResult() { - return null; - } - @Override - public Collection getErrors() { - return rpcResult.getErrors(); - } + @Override + public Object getIdentifier() { + return this; } } diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/NetconfMessageTransformUtil.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/NetconfMessageTransformUtil.java index 3ec3eb1633..a6924d9d37 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/NetconfMessageTransformUtil.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/NetconfMessageTransformUtil.java @@ -31,7 +31,7 @@ import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.Node; import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl; import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode; @@ -74,15 +74,15 @@ public class NetconfMessageTransformUtil { .create("urn:ietf:params:netconf:capability:rollback-on-error:1.0"); public static String ROLLBACK_ON_ERROR_OPTION = "rollback-on-error"; - public static Node toFilterStructure(final InstanceIdentifier identifier) { + public static Node toFilterStructure(final YangInstanceIdentifier identifier) { Node previous = null; if (Iterables.isEmpty(identifier.getPathArguments())) { return null; } - for (final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument component : identifier.getReversePathArguments()) { - if (component instanceof InstanceIdentifier.NodeIdentifierWithPredicates) { - previous = toNode((InstanceIdentifier.NodeIdentifierWithPredicates)component, previous); + for (final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument component : identifier.getReversePathArguments()) { + if (component instanceof YangInstanceIdentifier.NodeIdentifierWithPredicates) { + previous = toNode((YangInstanceIdentifier.NodeIdentifierWithPredicates)component, previous); } else { previous = toNode(component, previous); } @@ -90,7 +90,7 @@ public class NetconfMessageTransformUtil { return filter("subtree", previous); } - static Node toNode(final InstanceIdentifier.NodeIdentifierWithPredicates argument, final Node node) { + static Node toNode(final YangInstanceIdentifier.NodeIdentifierWithPredicates argument, final Node node) { final List> list = new ArrayList<>(); for (final Map.Entry arg : argument.getKeyValues().entrySet()) { list.add(new SimpleNodeTOImpl(arg.getKey(), null, arg.getValue())); @@ -195,7 +195,7 @@ public class NetconfMessageTransformUtil { return input; } - static Node toNode(final InstanceIdentifier.PathArgument argument, final Node node) { + static Node toNode(final YangInstanceIdentifier.PathArgument argument, final Node node) { if (node != null) { return new CompositeNodeTOImpl(argument.getNodeType(), null, Collections.> singletonList(node)); } else { diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/util/RemoteDeviceId.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/util/RemoteDeviceId.java index 4670846c7c..175cb8e207 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/util/RemoteDeviceId.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/util/RemoteDeviceId.java @@ -20,7 +20,7 @@ import org.opendaylight.yangtools.yang.common.QName; public class RemoteDeviceId { private final String name; - private final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier path; + private final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier path; private final InstanceIdentifier bindingPath; private final NodeKey key; @@ -40,9 +40,9 @@ public class RemoteDeviceId { return InstanceIdentifier.builder(Nodes.class).child(Node.class, key).build(); } - private static org.opendaylight.yangtools.yang.data.api.InstanceIdentifier createBIPath(final String name) { - final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.InstanceIdentifierBuilder builder = - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder(); + private static org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier createBIPath(final String name) { + final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder builder = + org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.builder(); builder.node(Nodes.QNAME).nodeWithKey(Node.QNAME, QName.create(Node.QNAME.getNamespace(), Node.QNAME.getRevision(), "id"), name); return builder.build(); @@ -56,7 +56,7 @@ public class RemoteDeviceId { return bindingPath; } - public org.opendaylight.yangtools.yang.data.api.InstanceIdentifier getPath() { + public org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier getPath() { return path; } diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/pom.xml b/opendaylight/md-sal/sal-protocolbuffer-encoding/pom.xml index 5254c19fcb..28e629a92c 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/pom.xml +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/pom.xml @@ -13,15 +13,78 @@ bundle + + com.google.code.findbugs + jsr305 + 2.0.1 + + + com.google.guava + guava + com.google.protobuf protobuf-java 2.5.0 + + commons-lang + commons-lang + + + org.opendaylight.yangtools + util + + + org.opendaylight.yangtools + yang-binding + + + org.opendaylight.yangtools + yang-common + + + org.opendaylight.yangtools + yang-data-api + + + org.opendaylight.yangtools + yang-data-impl + + + org.opendaylight.yangtools + yang-model-api + + + org.opendaylight.yangtools + yang-model-util + + + + org.opendaylight.yangtools + yang-parser-impl + + + + xmlunit + xmlunit + 1.5 + junit junit test + + + junit + junit + test + + + org.slf4j + slf4j-simple + ${slf4j.version} + test org.opendaylight.yangtools @@ -51,6 +114,13 @@ org.opendaylight.yangtools yang-binding + + + org.opendaylight.controller + sal-akka-raft + 1.1-SNAPSHOT + + com.google.guava guava diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/run.sh b/opendaylight/md-sal/sal-protocolbuffer-encoding/run.sh index c9e586ba1a..f0907db664 100755 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/run.sh +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/run.sh @@ -36,3 +36,6 @@ echo "Done generating Java source files." #to remove trailing spaces in the code files find src/main/java -type f -name '*.java' -exec sed --in-place 's/[[:space:]]\+$//' {} \+ + +#to remove trailing spaces in the generated code on OSX +find src/main/java -type f -print0 |xargs -0 perl -pi -e 's/ +$//' 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-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NodeToNormalizedNodeBuilder.java new file mode 100644 index 0000000000..ce120809d7 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NodeToNormalizedNodeBuilder.java @@ -0,0 +1,846 @@ +package org.opendaylight.controller.cluster.datastore.node; + +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 org.opendaylight.controller.cluster.datastore.node.utils.NodeIdentifierFactory; +import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node; +import org.opendaylight.yangtools.concepts.Identifiable; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode; +import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; +import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; +import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; +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.api.schema.NormalizedNodeContainer; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; +import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeContainerBuilder; +import org.opendaylight.yangtools.yang.model.api.AugmentationSchema; +import org.opendaylight.yangtools.yang.model.api.AugmentationTarget; +import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode; +import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; +import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; +import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; +import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; +import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; +import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +import static com.google.common.base.Preconditions.checkArgument; + +/** + * NormalizedNodeBuilder is a builder that walks through a tree like structure and constructs a + * NormalizedNode from it. + *

+ * A large part of this code has been copied over from a similar class in sal-common-impl which was + * originally supposed to convert a CompositeNode to NormalizedNode + * + * @param + */ +public abstract class NodeToNormalizedNodeBuilder + implements Identifiable { + + private final T identifier; + + protected static final Logger logger = LoggerFactory + .getLogger(NodeToNormalizedNodeBuilder.class); + + @Override + public T getIdentifier() { + return identifier; + } + + ; + + protected NodeToNormalizedNodeBuilder(final T identifier) { + super(); + this.identifier = identifier; + + } + + /** + * @return Should return true if the node that this operation corresponds to is a mixin + */ + public boolean isMixin() { + return false; + } + + + /** + * @return Should return true if the node that this operation corresponds to has a 'key' + * associated with it. This is typically true for a list-item or leaf-list entry in yang + */ + public boolean isKeyedEntry() { + return false; + } + + protected Set getQNameIdentifiers() { + return Collections.singleton(identifier.getNodeType()); + } + + public abstract NodeToNormalizedNodeBuilder getChild( + final PathArgument child); + + public abstract NodeToNormalizedNodeBuilder getChild(QName child); + + public abstract NormalizedNode normalize(QName nodeType, Node node); + + + + private static abstract class SimpleTypeNormalization + extends NodeToNormalizedNodeBuilder { + + protected SimpleTypeNormalization(final T identifier) { + super(identifier); + } + + @Override + public NormalizedNode normalize(final QName nodeType, + final Node node) { + checkArgument(node != null); + return normalizeImpl(nodeType, node); + } + + protected abstract NormalizedNode normalizeImpl(QName nodeType, + Node node); + + @Override + public NodeToNormalizedNodeBuilder getChild( + final PathArgument child) { + return null; + } + + @Override + public NodeToNormalizedNodeBuilder getChild(final QName child) { + return null; + } + + @Override + public NormalizedNode createDefault( + final PathArgument currentArg) { + // TODO Auto-generated method stub + return null; + } + + } + + + private static final class LeafNormalization extends + SimpleTypeNormalization { + + private final LeafSchemaNode schema; + + protected LeafNormalization(final LeafSchemaNode schema, final NodeIdentifier identifier) { + super(identifier); + this.schema = schema; + } + + @Override + protected NormalizedNode normalizeImpl(final QName nodeType, + final Node node) { + Object value = NodeValueCodec.toTypeSafeValue(this.schema, this.schema.getType(), node); + return ImmutableNodes.leafNode(nodeType, value); + + } + + } + + + private static final class LeafListEntryNormalization extends + SimpleTypeNormalization { + + private final LeafListSchemaNode schema; + + public LeafListEntryNormalization(final LeafListSchemaNode potential) { + super(new NodeWithValue(potential.getQName(), null)); + this.schema = potential; + } + + @Override + protected NormalizedNode normalizeImpl(final QName nodeType, + final Node node) { + final Object data = node.getValue(); + if (data == null) { + Preconditions.checkArgument(false, + "No data available in leaf list entry for " + nodeType); + } + + Object value = NodeValueCodec.toTypeSafeValue(this.schema, this.schema.getType(), node); + + NodeWithValue nodeId = new NodeWithValue(nodeType, value); + return Builders.leafSetEntryBuilder().withNodeIdentifier(nodeId) + .withValue(value).build(); + } + + + @Override + public boolean isKeyedEntry() { + return true; + } + } + + + private static abstract class NodeToNormalizationNodeOperation + extends NodeToNormalizedNodeBuilder { + + protected NodeToNormalizationNodeOperation(final T identifier) { + super(identifier); + } + + @SuppressWarnings({"rawtypes", "unchecked"}) + @Override + public final NormalizedNodeContainer normalize( + final QName nodeType, final Node node) { + checkArgument(node != null); + + if (!node.getType().equals(AugmentationNode.class.getSimpleName()) + && !node.getType().equals(ContainerNode.class.getSimpleName()) + && !node.getType().equals(MapNode.class.getSimpleName())) { + checkArgument(nodeType != null); + } + + NormalizedNodeContainerBuilder builder = createBuilder(node); + + Set> usedMixins = new HashSet<>(); + + logNode(node); + + if (node.getChildCount() == 0 && ( + node.getType().equals(LeafSetEntryNode.class.getSimpleName()) + || node.getType().equals(LeafNode.class.getSimpleName()))) { + PathArgument childPathArgument = + NodeIdentifierFactory.getArgument(node.getPath()); + + final NormalizedNode child; + if (childPathArgument instanceof NodeWithValue) { + final NodeWithValue nodeWithValue = + new NodeWithValue(childPathArgument.getNodeType(), + node.getValue()); + child = + Builders.leafSetEntryBuilder() + .withNodeIdentifier(nodeWithValue) + .withValue(node.getValue()).build(); + } else { + child = + ImmutableNodes.leafNode(childPathArgument.getNodeType(), + node.getValue()); + } + builder.addChild(child); + } + + final List children = node.getChildList(); + for (Node nodeChild : children) { + + PathArgument childPathArgument = + NodeIdentifierFactory.getArgument(nodeChild.getPath()); + + QName childNodeType = null; + NodeToNormalizedNodeBuilder childOp = null; + + if (childPathArgument instanceof AugmentationIdentifier) { + childOp = getChild(childPathArgument); + checkArgument(childOp instanceof AugmentationNormalization, childPathArgument); + } else { + childNodeType = childPathArgument.getNodeType(); + childOp = getChild(childNodeType); + } + // We skip unknown nodes if this node is mixin since + // it's nodes and parent nodes are interleaved + if (childOp == null && isMixin()) { + continue; + } else if (childOp == null) { + logger.error( + "childOp is null and this operation is not a mixin : this = {}", + this.toString()); + } + + checkArgument(childOp != null, + "Node %s is not allowed inside %s", + childNodeType, getIdentifier()); + + if (childOp.isMixin()) { + if (usedMixins.contains(childOp)) { + // We already run / processed that mixin, so to avoid + // duplicate we are + // skipping next nodes. + continue; + } + // builder.addChild(childOp.normalize(nodeType, treeCacheNode)); + final NormalizedNode childNode = + childOp.normalize(childNodeType, nodeChild); + if (childNode != null) + builder.addChild(childNode); + usedMixins.add(childOp); + } else { + final NormalizedNode childNode = + childOp.normalize(childNodeType, nodeChild); + if (childNode != null) + builder.addChild(childNode); + } + } + + + try { + return (NormalizedNodeContainer) builder.build(); + } catch (Exception e) { + return null; + } + + } + + private void logNode(Node node) { + //let us find out the type of the node + logger.debug("We got a {} , with identifier {} with {} children", + node.getType(), node.getPath(), + node.getChildList()); + } + + @SuppressWarnings("rawtypes") + protected abstract NormalizedNodeContainerBuilder createBuilder( + final Node node); + + } + + + private static abstract class DataContainerNormalizationOperation + extends NodeToNormalizationNodeOperation { + + private final DataNodeContainer schema; + private final Map> byQName; + private final Map> byArg; + + protected DataContainerNormalizationOperation(final T identifier, + final DataNodeContainer schema) { + super(identifier); + this.schema = schema; + this.byArg = new ConcurrentHashMap<>(); + this.byQName = new ConcurrentHashMap<>(); + } + + @Override + public NodeToNormalizedNodeBuilder getChild( + final PathArgument child) { + NodeToNormalizedNodeBuilder potential = byArg.get(child); + if (potential != null) { + return potential; + } + potential = fromSchema(schema, child); + return register(potential); + } + + @Override + public NodeToNormalizedNodeBuilder getChild(final QName child) { + if (child == null) { + return null; + } + + NodeToNormalizedNodeBuilder potential = byQName.get(child); + if (potential != null) { + return potential; + } + potential = fromSchemaAndPathArgument(schema, child); + return register(potential); + } + + private NodeToNormalizedNodeBuilder register( + final NodeToNormalizedNodeBuilder potential) { + if (potential != null) { + byArg.put(potential.getIdentifier(), potential); + for (QName qName : potential.getQNameIdentifiers()) { + byQName.put(qName, potential); + } + } + return potential; + } + + } + + + private static final class ListItemNormalization extends + DataContainerNormalizationOperation { + + private final List keyDefinition; + private final ListSchemaNode schemaNode; + + protected ListItemNormalization( + final NodeIdentifierWithPredicates identifier, + final ListSchemaNode schema) { + super(identifier, schema); + this.schemaNode = schema; + keyDefinition = schema.getKeyDefinition(); + } + + @Override + protected NormalizedNodeContainerBuilder createBuilder( + final Node node) { + NodeIdentifierWithPredicates nodeIdentifierWithPredicates = + (NodeIdentifierWithPredicates) NodeIdentifierFactory + .createPathArgument(node + .getPath(), schemaNode); + return Builders.mapEntryBuilder() + .withNodeIdentifier( + nodeIdentifierWithPredicates + ); + } + + @Override + public NormalizedNode createDefault( + final PathArgument currentArg) { + DataContainerNodeAttrBuilder + builder = + Builders.mapEntryBuilder().withNodeIdentifier( + (NodeIdentifierWithPredicates) currentArg); + for (Entry keyValue : ((NodeIdentifierWithPredicates) currentArg) + .getKeyValues().entrySet()) { + if (keyValue.getValue() == null) { + throw new NullPointerException( + "Null value found for path : " + + currentArg); + } + builder.addChild(Builders.leafBuilder() + // + .withNodeIdentifier(new NodeIdentifier(keyValue.getKey())) + .withValue(keyValue.getValue()).build()); + } + return builder.build(); + } + + + @Override + public boolean isKeyedEntry() { + return true; + } + } + + + private static final class ContainerNormalization extends + DataContainerNormalizationOperation { + + protected ContainerNormalization(final ContainerSchemaNode schema) { + super(new NodeIdentifier(schema.getQName()), schema); + } + + @Override + protected NormalizedNodeContainerBuilder createBuilder( + final Node node) { + return Builders.containerBuilder() + .withNodeIdentifier(getIdentifier()); + } + + @Override + public NormalizedNode createDefault( + final PathArgument currentArg) { + return Builders.containerBuilder() + .withNodeIdentifier((NodeIdentifier) currentArg).build(); + } + + } + + + private static abstract class MixinNormalizationOp + extends NodeToNormalizationNodeOperation { + + protected MixinNormalizationOp(final T identifier) { + super(identifier); + } + + @Override + public final boolean isMixin() { + return true; + } + + } + + + private static final class LeafListMixinNormalization extends + MixinNormalizationOp { + + private final NodeToNormalizedNodeBuilder innerOp; + + public LeafListMixinNormalization(final LeafListSchemaNode potential) { + super(new NodeIdentifier(potential.getQName())); + innerOp = new LeafListEntryNormalization(potential); + } + + @Override + protected NormalizedNodeContainerBuilder createBuilder( + final Node node) { + return Builders.leafSetBuilder() + .withNodeIdentifier(getIdentifier()); + } + + @Override + public NormalizedNode createDefault( + final PathArgument currentArg) { + return Builders.leafSetBuilder().withNodeIdentifier(getIdentifier()) + .build(); + } + + @Override + public NodeToNormalizedNodeBuilder getChild( + final PathArgument child) { + if (child instanceof NodeWithValue) { + return innerOp; + } + return null; + } + + @Override + public NodeToNormalizedNodeBuilder getChild(final QName child) { + if (getIdentifier().getNodeType().equals(child)) { + return innerOp; + } + return null; + } + + } + + + private static final class AugmentationNormalization extends + MixinNormalizationOp { + + private final Map> byQName; + private final Map> byArg; + + public AugmentationNormalization(final AugmentationSchema augmentation, + final DataNodeContainer schema) { + super(augmentationIdentifierFrom(augmentation)); + + ImmutableMap.Builder> + byQNameBuilder = + ImmutableMap.builder(); + ImmutableMap.Builder> + byArgBuilder = + ImmutableMap.builder(); + + for (DataSchemaNode augNode : augmentation.getChildNodes()) { + DataSchemaNode resolvedNode = + schema.getDataChildByName(augNode.getQName()); + NodeToNormalizedNodeBuilder resolvedOp = + fromDataSchemaNode(resolvedNode); + byArgBuilder.put(resolvedOp.getIdentifier(), resolvedOp); + for (QName resQName : resolvedOp.getQNameIdentifiers()) { + byQNameBuilder.put(resQName, resolvedOp); + } + } + byQName = byQNameBuilder.build(); + byArg = byArgBuilder.build(); + + } + + @Override + public NodeToNormalizedNodeBuilder getChild( + final PathArgument child) { + return byArg.get(child); + } + + @Override + public NodeToNormalizedNodeBuilder getChild(final QName child) { + return byQName.get(child); + } + + @Override + protected Set getQNameIdentifiers() { + return getIdentifier().getPossibleChildNames(); + } + + @SuppressWarnings("rawtypes") + @Override + protected NormalizedNodeContainerBuilder createBuilder( + final Node node) { + return Builders.augmentationBuilder() + .withNodeIdentifier(getIdentifier()); + } + + @Override + public NormalizedNode createDefault( + final PathArgument currentArg) { + return Builders.augmentationBuilder() + .withNodeIdentifier(getIdentifier()) + .build(); + } + + } + + + private static final class ListMixinNormalization extends + MixinNormalizationOp { + + private final ListItemNormalization innerNode; + + public ListMixinNormalization(final ListSchemaNode list) { + super(new NodeIdentifier(list.getQName())); + this.innerNode = + new ListItemNormalization(new NodeIdentifierWithPredicates( + list.getQName(), Collections.emptyMap()), + list); + } + + @SuppressWarnings("rawtypes") + @Override + protected NormalizedNodeContainerBuilder createBuilder( + final Node node) { + return Builders.mapBuilder().withNodeIdentifier(getIdentifier()); + } + + @Override + public NormalizedNode createDefault( + final PathArgument currentArg) { + return Builders.mapBuilder().withNodeIdentifier(getIdentifier()) + .build(); + } + + @Override + public NodeToNormalizedNodeBuilder getChild( + final PathArgument child) { + if (child.getNodeType().equals(getIdentifier().getNodeType())) { + return innerNode; + } + return null; + } + + @Override + public NodeToNormalizedNodeBuilder getChild(final QName child) { + if (getIdentifier().getNodeType().equals(child)) { + return innerNode; + } + return null; + } + + } + + + private static class ChoiceNodeNormalization extends + MixinNormalizationOp { + + private final ImmutableMap> + byQName; + private final ImmutableMap> + byArg; + + protected ChoiceNodeNormalization( + final org.opendaylight.yangtools.yang.model.api.ChoiceNode schema) { + super(new NodeIdentifier(schema.getQName())); + ImmutableMap.Builder> + byQNameBuilder = + ImmutableMap.builder(); + ImmutableMap.Builder> + byArgBuilder = + ImmutableMap.builder(); + + for (ChoiceCaseNode caze : schema.getCases()) { + for (DataSchemaNode cazeChild : caze.getChildNodes()) { + NodeToNormalizedNodeBuilder childOp = + fromDataSchemaNode(cazeChild); + byArgBuilder.put(childOp.getIdentifier(), childOp); + for (QName qname : childOp.getQNameIdentifiers()) { + byQNameBuilder.put(qname, childOp); + } + } + } + byQName = byQNameBuilder.build(); + byArg = byArgBuilder.build(); + } + + @Override + public NodeToNormalizedNodeBuilder getChild( + final PathArgument child) { + return byArg.get(child); + } + + @Override + public NodeToNormalizedNodeBuilder getChild(final QName child) { + return byQName.get(child); + } + + @Override + protected NormalizedNodeContainerBuilder createBuilder( + final Node node) { + return Builders.choiceBuilder().withNodeIdentifier(getIdentifier()); + } + + @Override + public NormalizedNode createDefault( + final PathArgument currentArg) { + return Builders.choiceBuilder().withNodeIdentifier(getIdentifier()) + .build(); + } + } + + /** + * Find an appropriate NormalizedNodeBuilder using both the schema and the + * Path Argument + * + * @param schema + * @param child + * @return + */ + public static NodeToNormalizedNodeBuilder fromSchemaAndPathArgument( + final DataNodeContainer schema, final QName child) { + DataSchemaNode potential = schema.getDataChildByName(child); + if (potential == null) { + Iterable + choices = + FluentIterable.from(schema.getChildNodes()).filter( + org.opendaylight.yangtools.yang.model.api.ChoiceNode.class); + potential = findChoice(choices, child); + } + if (potential == null) { + if (logger.isTraceEnabled()) { + logger.trace("BAD CHILD = {}", child.toString()); + } + } + + checkArgument(potential != null, + "Supplied QName %s is not valid according to schema %s", child, + schema); + + // If the schema in an instance of DataSchemaNode and the potential + // is augmenting something then there is a chance that this may be + // and augmentation node + if ((schema instanceof DataSchemaNode) + && potential.isAugmenting()) { + + AugmentationNormalization augmentation = + fromAugmentation(schema, (AugmentationTarget) schema, + potential); + + // If an augmentation normalization (builder) is not found then + // we fall through to the regular processing + if(augmentation != null){ + return augmentation; + } + } + return fromDataSchemaNode(potential); + } + + /** + * Given a bunch of choice nodes and a the name of child find a choice node for that child which + * has a non-null value + * + * @param choices + * @param child + * @return + */ + private static org.opendaylight.yangtools.yang.model.api.ChoiceNode findChoice( + final Iterable choices, + final QName child) { + org.opendaylight.yangtools.yang.model.api.ChoiceNode foundChoice = null; + choiceLoop: + for (org.opendaylight.yangtools.yang.model.api.ChoiceNode choice : choices) { + for (ChoiceCaseNode caze : choice.getCases()) { + if (caze.getDataChildByName(child) != null) { + foundChoice = choice; + break choiceLoop; + } + } + } + return foundChoice; + } + + + /** + * Create an AugmentationIdentifier based on the AugmentationSchema + * + * @param augmentation + * @return + */ + public static AugmentationIdentifier augmentationIdentifierFrom( + final AugmentationSchema augmentation) { + ImmutableSet.Builder potentialChildren = ImmutableSet.builder(); + for (DataSchemaNode child : augmentation.getChildNodes()) { + potentialChildren.add(child.getQName()); + } + return new AugmentationIdentifier(potentialChildren.build()); + } + + /** + * Create an AugmentationNormalization based on the schema of the DataContainer, the + * AugmentationTarget and the potential schema node + * + * @param schema + * @param augments + * @param potential + * @return + */ + private static AugmentationNormalization fromAugmentation( + final DataNodeContainer schema, final AugmentationTarget augments, + final DataSchemaNode potential) { + AugmentationSchema augmentation = null; + for (AugmentationSchema aug : augments.getAvailableAugmentations()) { + DataSchemaNode child = aug.getDataChildByName(potential.getQName()); + if (child != null) { + augmentation = aug; + break; + } + + } + if (augmentation != null) { + return new AugmentationNormalization(augmentation, schema); + } else { + return null; + } + } + + /** + * @param schema + * @param child + * @return + */ + private static NodeToNormalizedNodeBuilder fromSchema( + final DataNodeContainer schema, final PathArgument child) { + if (child instanceof AugmentationIdentifier) { + QName childQName = ((AugmentationIdentifier) child) + .getPossibleChildNames().iterator().next(); + + return fromSchemaAndPathArgument(schema, childQName); + } + return fromSchemaAndPathArgument(schema, child.getNodeType()); + } + + public static NodeToNormalizedNodeBuilder fromDataSchemaNode( + final DataSchemaNode potential) { + if (potential instanceof ContainerSchemaNode) { + return new ContainerNormalization((ContainerSchemaNode) potential); + } else if (potential instanceof ListSchemaNode) { + return new ListMixinNormalization((ListSchemaNode) potential); + } else if (potential instanceof LeafSchemaNode) { + return new LeafNormalization((LeafSchemaNode) potential, + new NodeIdentifier(potential.getQName())); + } else if (potential instanceof org.opendaylight.yangtools.yang.model.api.ChoiceNode) { + return new ChoiceNodeNormalization( + (org.opendaylight.yangtools.yang.model.api.ChoiceNode) potential); + } else if (potential instanceof LeafListSchemaNode) { + return new LeafListMixinNormalization( + (LeafListSchemaNode) potential); + } + return null; + } + + public static NodeToNormalizedNodeBuilder from(final SchemaContext ctx) { + return new ContainerNormalization(ctx); + } + + public abstract NormalizedNode createDefault(PathArgument currentArg); + +} 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-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NodeValueCodec.java new file mode 100644 index 0000000000..7b6f5c46d2 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NodeValueCodec.java @@ -0,0 +1,67 @@ +/* + * 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.node; + +import org.opendaylight.controller.cluster.datastore.node.utils.QNameFactory; +import org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils; +import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages; +import org.opendaylight.yangtools.yang.data.api.codec.BitsCodec; +import org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec; +import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; +import org.opendaylight.yangtools.yang.model.api.TypeDefinition; +import org.opendaylight.yangtools.yang.model.util.IdentityrefType; +import org.opendaylight.yangtools.yang.model.util.InstanceIdentifier; +import org.opendaylight.yangtools.yang.model.util.Leafref; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class NodeValueCodec { + protected static final Logger logger = LoggerFactory + .getLogger(NodeValueCodec.class); + + public static Object toTypeSafeValue(DataSchemaNode schema, TypeDefinition type, NormalizedNodeMessages.Node node){ + + String value = node.getValue(); + + if(schema != null && value != null){ + TypeDefinition baseType = type; + + while (baseType.getBaseType() != null) { + baseType = baseType.getBaseType(); + } + + TypeDefinitionAwareCodec> codec = + TypeDefinitionAwareCodec.from(type); + + if(codec instanceof BitsCodec){ + if(value.contains("[]")){ + value = ""; + } else { + value = value.replace("[", ""); + value = value.replace("]", ""); + value = value.replace(",", " "); + } + } + + if (codec != null) { + return codec.deserialize(value); + } else if(baseType instanceof Leafref) { + return value; + } else if(baseType instanceof IdentityrefType) { + return QNameFactory.create(value); + } else if(baseType instanceof InstanceIdentifier) { + return InstanceIdentifierUtils.fromSerializable(node.getInstanceIdentifierValue()); + } else { + logger.error("Could not figure out how to transform value " + value + " for schemaType " + type); + } + } + + return value; + } +} 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-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodec.java new file mode 100644 index 0000000000..fc4b3954c5 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodec.java @@ -0,0 +1,64 @@ +package org.opendaylight.controller.cluster.datastore.node; + +import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages; +import org.opendaylight.controller.cluster.datastore.node.utils.PathUtils; +import org.opendaylight.yangtools.yang.common.QName; +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 org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class NormalizedNodeToNodeCodec { + private final SchemaContext ctx; + private static final Logger logger = LoggerFactory.getLogger(NormalizedNodeToNodeCodec.class); + + public NormalizedNodeToNodeCodec(final SchemaContext ctx){ + this.ctx = ctx; + + } + + public NormalizedNodeMessages.Container encode(YangInstanceIdentifier id, NormalizedNode node){ + String parentPath = ""; + + if(id != null){ + parentPath = PathUtils.getParentPath(id.toString()); + } + + + NormalizedNodeToProtocolBufferNode encoder = new NormalizedNodeToProtocolBufferNode(); + encoder.encode(parentPath, node); + + return encoder.getContainer(); + + + } + + public NormalizedNode decode(YangInstanceIdentifier id, NormalizedNodeMessages.Node node){ + NodeToNormalizedNodeBuilder currentOp = NodeToNormalizedNodeBuilder.from(ctx); + + for(YangInstanceIdentifier.PathArgument pathArgument : id.getPathArguments()){ + currentOp = currentOp.getChild(pathArgument); + } + + QName nodeType = null; + + if(id.getPath().size() < 1){ + nodeType = null; + } else { + final YangInstanceIdentifier.PathArgument pathArgument = id.getPath().get(id.getPath().size() - 1); + if(pathArgument instanceof YangInstanceIdentifier.AugmentationIdentifier){ + nodeType = null; + } else { + nodeType = pathArgument.getNodeType(); + } + } + if((node != null)&& (!node.getType().isEmpty())){ + return currentOp.normalize(nodeType, node); + } else{ + return null; + } + } + + +} 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-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToProtocolBufferNode.java new file mode 100644 index 0000000000..fb15312665 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToProtocolBufferNode.java @@ -0,0 +1,254 @@ +package org.opendaylight.controller.cluster.datastore.node; + +import com.google.common.base.Preconditions; +import org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils; +import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages; +import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode; +import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode; +import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; +import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; +import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode; +import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; +import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; +import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode; +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.MixinNode; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer; +import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode; + +import java.util.Map; + +/** + * NormalizedNodeToProtocolBufferNode walks the NormalizedNode tree converting it to the + * NormalizedMessage.Node + *

+ * {@link org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode } is a tree like structure that provides a generic structure for a yang data + * model + */ +public class NormalizedNodeToProtocolBufferNode { + + + private final Node.Builder builderRoot; + private NormalizedNodeMessages.Container container; + + public NormalizedNodeToProtocolBufferNode() { + + builderRoot = Node.newBuilder(); + } + + public void encode(String parentPath, NormalizedNode normalizedNode) { + if (parentPath == null) { + parentPath = ""; + } + + NormalizedNodeMessages.Container.Builder containerBuilder = + NormalizedNodeMessages.Container.newBuilder(); + + if (normalizedNode != null) { + + navigateNormalizedNode(0, parentPath, normalizedNode, builderRoot); + // here we need to put back the Node Tree in Container + + container = + containerBuilder.setParentPath(parentPath).setNormalizedNode( + builderRoot.build()).build(); + } else { + //this can happen when an attempt was made to read from datastore and normalized node was null. + container = containerBuilder.setParentPath(parentPath).build(); + + } + + } + + + private void navigateDataContainerNode(int level, final String parentPath, + final DataContainerNode dataContainerNode, + Node.Builder builderParent) { + + String newParentPath = + parentPath + "/" + dataContainerNode.getIdentifier().toString(); + String type = getDataContainerType(dataContainerNode).getSimpleName(); + builderParent.setPath(dataContainerNode.getIdentifier().toString()) + .setType(type); + + final Iterable> + value = + dataContainerNode.getValue(); + for (NormalizedNode node : value) { + Node.Builder builderChild = Node.newBuilder(); + if (node instanceof MixinNode + && node instanceof NormalizedNodeContainer) { + + navigateNormalizedNodeContainerMixin(level, newParentPath, + (NormalizedNodeContainer) node, builderChild); + } else { + navigateNormalizedNode(level, newParentPath, node, + builderChild); + } + builderParent.addChild(builderChild); + } + } + + private Class getDataContainerType( + NormalizedNodeContainer dataContainerNode) { + if (dataContainerNode instanceof ChoiceNode) { + return ChoiceNode.class; + } else if (dataContainerNode instanceof AugmentationNode) { + return AugmentationNode.class; + } else if (dataContainerNode instanceof ContainerNode) { + return ContainerNode.class; + } else if (dataContainerNode instanceof MapEntryNode) { + return MapEntryNode.class; + } else if (dataContainerNode instanceof UnkeyedListEntryNode) { + return UnkeyedListEntryNode.class; + } else if (dataContainerNode instanceof MapNode) { + return MapNode.class; + } else if (dataContainerNode instanceof LeafSetNode) { + return LeafSetNode.class; + } + throw new IllegalArgumentException( + "could not find the data container node type " + + dataContainerNode.toString() + ); + } + + private void navigateNormalizedNodeContainerMixin(int level, + final String parentPath, + NormalizedNodeContainer node, Node.Builder builderParent) { + String newParentPath = + parentPath + "/" + node.getIdentifier().toString(); + + builderParent.setPath(node.getIdentifier().toString()).setType( + this.getDataContainerType(node).getSimpleName()); + final Iterable> value = node.getValue(); + for (NormalizedNode normalizedNode : value) { + // child node builder + Node.Builder builderChild = Node.newBuilder(); + if (normalizedNode instanceof MixinNode + && normalizedNode instanceof NormalizedNodeContainer) { + navigateNormalizedNodeContainerMixin(level + 1, newParentPath, + (NormalizedNodeContainer) normalizedNode, builderChild); + } else { + navigateNormalizedNode(level, newParentPath, normalizedNode, + builderChild); + } + builderParent.addChild(builderChild); + + } + + + + } + + + private void navigateNormalizedNode(int level, + String parentPath, NormalizedNode normalizedNode, + Node.Builder builderParent) { + + if (normalizedNode instanceof DataContainerNode) { + + final DataContainerNode dataContainerNode = + (DataContainerNode) normalizedNode; + + navigateDataContainerNode(level + 1, parentPath, dataContainerNode, + builderParent); + } else if (normalizedNode instanceof MixinNode + && normalizedNode instanceof NormalizedNodeContainer) { + + navigateNormalizedNodeContainerMixin(level, parentPath, + (NormalizedNodeContainer) normalizedNode, + builderParent); + } else { + if (normalizedNode instanceof LeafNode) { + buildLeafNode(parentPath, normalizedNode, builderParent); + } else if (normalizedNode instanceof LeafSetEntryNode) { + buildLeafSetEntryNode(parentPath, normalizedNode, + builderParent); + } + + } + + } + + private void buildLeafSetEntryNode(String parentPath, + NormalizedNode normalizedNode, + Node.Builder builderParent) { + String path = + parentPath + "/" + normalizedNode.getIdentifier().toString(); + LeafSetEntryNode leafSetEntryNode = (LeafSetEntryNode) normalizedNode; + Map attributes = leafSetEntryNode.getAttributes(); + if (!attributes.isEmpty()) { + NormalizedNodeMessages.Attribute.Builder builder = null; + for (Map.Entry attribute : attributes.entrySet()) { + builder = NormalizedNodeMessages.Attribute.newBuilder(); + + builder + .setName(attribute.getKey().toString()) + .setValue(normalizedNode.getValue().toString()); + + builderParent.addAttributes(builder.build()); + } + } + buildNodeValue(normalizedNode, builderParent); + } + + private void buildLeafNode(String parentPath, + NormalizedNode normalizedNode, + Node.Builder builderParent) { + Preconditions.checkNotNull(parentPath); + Preconditions.checkNotNull(normalizedNode); + String path = + parentPath + "/" + normalizedNode.getIdentifier().toString(); + LeafNode leafNode = (LeafNode) normalizedNode; + Map attributes = leafNode.getAttributes(); + if (!attributes.isEmpty()) { + NormalizedNodeMessages.Attribute.Builder builder = null; + for (Map.Entry attribute : attributes.entrySet()) { + builder = NormalizedNodeMessages.Attribute.newBuilder(); + builder + .setName(attribute.getKey().toString()) + .setValue(attribute.getValue().toString()); + + builderParent.addAttributes(builder.build()); + } + } + + Object value = normalizedNode.getValue(); + if (value == null) { + builderParent + .setPath(normalizedNode.getIdentifier().toString()) + .setType(LeafNode.class.getSimpleName()) + .setValueType(String.class.getSimpleName()) + .setValue(""); + } else { + buildNodeValue(normalizedNode, builderParent); + } + } + + private void buildNodeValue(NormalizedNode normalizedNode, + Node.Builder builderParent) { + + Object value = normalizedNode.getValue(); + + builderParent + .setPath(normalizedNode.getIdentifier().toString()) + .setType(LeafNode.class.getSimpleName()) + .setValueType((value.getClass().getSimpleName())) + .setValue(value.toString()); + + if(value.getClass().equals(YangInstanceIdentifier.class)){ + builderParent.setInstanceIdentifierValue( + InstanceIdentifierUtils + .toSerializable((YangInstanceIdentifier) value)); + } + } + + public NormalizedNodeMessages.Container getContainer() { + return container; + } +} 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-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/AugmentationIdentifierGenerator.java new file mode 100644 index 0000000000..a34307f6b4 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/AugmentationIdentifierGenerator.java @@ -0,0 +1,42 @@ +package org.opendaylight.controller.cluster.datastore.node.utils; + +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; + +import java.util.HashSet; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class AugmentationIdentifierGenerator { + private final String id; + private static final Pattern pattern = Pattern.compile("AugmentationIdentifier\\Q{\\EchildNames=\\Q[\\E(.*)\\Q]}\\E"); + private final Matcher matcher; + private final boolean doesMatch; + + public AugmentationIdentifierGenerator(String id){ + this.id = id; + matcher = pattern.matcher(this.id); + doesMatch = matcher.matches(); + } + + public boolean matches(){ + return doesMatch; + } + + public YangInstanceIdentifier.AugmentationIdentifier getPathArgument(){ + Set childNames = new HashSet(); + final String childQNames = matcher.group(1); + + final String[] splitChildQNames = childQNames.split(","); + + for(String name : splitChildQNames){ + childNames.add( + org.opendaylight.controller.cluster.datastore.node.utils.QNameFactory + .create(name.trim())); + } + + return new YangInstanceIdentifier.AugmentationIdentifier(null, childNames); + } + +} 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-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierFactory.java new file mode 100644 index 0000000000..175e242a11 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierFactory.java @@ -0,0 +1,59 @@ +package org.opendaylight.controller.cluster.datastore.node.utils; + +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; + +import java.util.HashMap; +import java.util.Map; + +public class NodeIdentifierFactory { + private static final Map cache = new HashMap<>(); + public static YangInstanceIdentifier.PathArgument getArgument(String id){ + YangInstanceIdentifier.PathArgument value = cache.get(id); + if(value == null){ + synchronized (cache){ + value = cache.get(id); + if(value == null) { + value = createPathArgument(id, null); + cache.put(id, value); + } + } + } + return value; + } + + public static YangInstanceIdentifier.PathArgument getArgument(String id, DataSchemaNode schemaNode){ + YangInstanceIdentifier.PathArgument value = cache.get(id); + if(value == null){ + synchronized (cache){ + value = cache.get(id); + if(value == null) { + value = createPathArgument(id, schemaNode); + cache.put(id, value); + } + } + } + return value; + } + + public static YangInstanceIdentifier.PathArgument createPathArgument(String id, DataSchemaNode schemaNode){ + final NodeIdentifierWithPredicatesGenerator + nodeIdentifierWithPredicatesGenerator = new NodeIdentifierWithPredicatesGenerator(id, schemaNode); + if(nodeIdentifierWithPredicatesGenerator.matches()){ + return nodeIdentifierWithPredicatesGenerator.getPathArgument(); + } + + final NodeIdentifierWithValueGenerator + nodeWithValueGenerator = new NodeIdentifierWithValueGenerator(id, schemaNode); + if(nodeWithValueGenerator.matches()){ + return nodeWithValueGenerator.getPathArgument(); + } + + final AugmentationIdentifierGenerator augmentationIdentifierGenerator = new AugmentationIdentifierGenerator(id); + if(augmentationIdentifierGenerator.matches()){ + return augmentationIdentifierGenerator.getPathArgument(); + } + + return new NodeIdentifierGenerator(id).getArgument(); + } +} 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-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierGenerator.java new file mode 100644 index 0000000000..9edec1e230 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierGenerator.java @@ -0,0 +1,18 @@ +package org.opendaylight.controller.cluster.datastore.node.utils; + +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; + +public class NodeIdentifierGenerator { + private final String id; + private final QName qName; + + public NodeIdentifierGenerator(String id){ + this.id = id; + this.qName = QNameFactory.create(id); + } + + public YangInstanceIdentifier.PathArgument getArgument(){ + return new YangInstanceIdentifier.NodeIdentifier(qName); + } +} 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-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierWithPredicatesGenerator.java new file mode 100644 index 0000000000..4bfcf391dd --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierWithPredicatesGenerator.java @@ -0,0 +1,70 @@ +package org.opendaylight.controller.cluster.datastore.node.utils; + +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec; +import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; +import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; +import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; + +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class NodeIdentifierWithPredicatesGenerator{ + private final String id; + private static final Pattern pattern = Pattern.compile("(.*)\\Q[{\\E(.*)\\Q}]\\E"); + private final Matcher matcher; + private final boolean doesMatch; + private final ListSchemaNode listSchemaNode; + + public NodeIdentifierWithPredicatesGenerator(String id, DataSchemaNode schemaNode){ + this.id = id; + matcher = pattern.matcher(this.id); + doesMatch = matcher.matches(); + + if(schemaNode instanceof ListSchemaNode){ + this.listSchemaNode = (ListSchemaNode) schemaNode; + } else { + this.listSchemaNode = null; + } + } + + + public boolean matches(){ + return doesMatch; + } + + public YangInstanceIdentifier.NodeIdentifierWithPredicates getPathArgument(){ + final String group = matcher.group(2); + final String[] keyValues = group.split(","); + Map nameValues = new HashMap<>(); + + for(String keyValue : keyValues){ + int eqIndex = keyValue.lastIndexOf('='); + try { + final QName key = QNameFactory + .create(keyValue.substring(0, eqIndex)); + nameValues.put(key, getValue(key, keyValue.substring(eqIndex + 1))); + } catch(IllegalArgumentException e){ + System.out.println("Error processing identifier : " + id); + throw e; + } + } + + return new YangInstanceIdentifier.NodeIdentifierWithPredicates(QNameFactory.create(matcher.group(1)), nameValues); + } + + + private Object getValue(QName key, String value){ + if(listSchemaNode != null){ + for(DataSchemaNode node : listSchemaNode.getChildNodes()){ + if(node instanceof LeafSchemaNode && node.getQName().equals(key)){ + return TypeDefinitionAwareCodec.from(LeafSchemaNode.class.cast(node).getType()).deserialize(value); + } + } + } + return value; + } +} 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-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierWithValueGenerator.java new file mode 100644 index 0000000000..b2ec5644d4 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierWithValueGenerator.java @@ -0,0 +1,48 @@ +package org.opendaylight.controller.cluster.datastore.node.utils; + +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec; +import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; +import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class NodeIdentifierWithValueGenerator{ + private final String id; + private final DataSchemaNode schemaNode; + private static final Pattern pattern = Pattern.compile("(.*)\\Q[\\E(.*)\\Q]\\E"); + private final Matcher matcher; + private final boolean doesMatch; + + public NodeIdentifierWithValueGenerator(String id, DataSchemaNode schemaNode){ + this.id = id; + this.schemaNode = schemaNode; + matcher = pattern.matcher(this.id); + doesMatch = matcher.matches(); + } + + public boolean matches(){ + return doesMatch; + } + + public YangInstanceIdentifier.PathArgument getPathArgument(){ + final String name = matcher.group(1); + final String value = matcher.group(2); + + return new YangInstanceIdentifier.NodeWithValue( + QNameFactory.create(name), getValue(value)); + } + + private Object getValue(String value){ + if(schemaNode != null){ + if(schemaNode instanceof LeafListSchemaNode){ + return TypeDefinitionAwareCodec + .from(LeafListSchemaNode.class.cast(schemaNode).getType()).deserialize(value); + + } + } + return value; + } + + } 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-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeGetter.java new file mode 100644 index 0000000000..e82a23d37f --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeGetter.java @@ -0,0 +1,28 @@ +package org.opendaylight.controller.cluster.datastore.node.utils; + +import com.google.common.base.Preconditions; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; + +public class NormalizedNodeGetter implements + NormalizedNodeVisitor { + private final String path; + NormalizedNode output; + + public NormalizedNodeGetter(String path){ + Preconditions.checkNotNull(path); + this.path = path; + } + + @Override + public void visitNode(int level, String parentPath, NormalizedNode normalizedNode) { + String nodePath = parentPath + "/"+ normalizedNode.getIdentifier().toString(); + + if(nodePath.toString().equals(path)){ + output = normalizedNode; + } + } + + public NormalizedNode getOutput(){ + return output; + } +} 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-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeNavigator.java new file mode 100644 index 0000000000..4ccc7076ff --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeNavigator.java @@ -0,0 +1,81 @@ +package org.opendaylight.controller.cluster.datastore.node.utils; + +import com.google.common.base.Preconditions; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; +import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode; +import org.opendaylight.yangtools.yang.data.api.schema.MixinNode; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer; + +/** + * NormalizedNodeNavigator walks a {@link NormalizedNodeVisitor} through the NormalizedNode + * + * {@link NormalizedNode } is a tree like structure that provides a generic structure for a yang data model + * + * For examples of visitors + * @see NormalizedNodePrinter + * + * + */ +public class NormalizedNodeNavigator { + + private final org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeVisitor + visitor; + + public NormalizedNodeNavigator( + org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeVisitor visitor){ + Preconditions.checkNotNull(visitor, "visitor should not be null"); + this.visitor = visitor; + } + public void navigate(String parentPath, NormalizedNode normalizedNode){ + if(parentPath == null){ + parentPath = ""; + } + navigateNormalizedNode(0, parentPath, normalizedNode); + } + + private void navigateDataContainerNode(int level, final String parentPath, final DataContainerNode dataContainerNode){ + visitor.visitNode(level, parentPath ,dataContainerNode); + + String newParentPath = parentPath + "/" + dataContainerNode.getIdentifier().toString(); + + final Iterable> value = dataContainerNode.getValue(); + for(NormalizedNode node : value){ + if(node instanceof MixinNode && node instanceof NormalizedNodeContainer){ + navigateNormalizedNodeContainerMixin(level, newParentPath, (NormalizedNodeContainer) node); + } else { + navigateNormalizedNode(level, newParentPath, node); + } + } + + } + + private void navigateNormalizedNodeContainerMixin(int level, final String parentPath, NormalizedNodeContainer node) { + visitor.visitNode(level, parentPath, node); + + String newParentPath = parentPath + "/" + node.getIdentifier().toString(); + + final Iterable> value = node.getValue(); + for(NormalizedNode normalizedNode : value){ + if(normalizedNode instanceof MixinNode && normalizedNode instanceof NormalizedNodeContainer){ + navigateNormalizedNodeContainerMixin(level + 1, newParentPath, (NormalizedNodeContainer) normalizedNode); + } else { + navigateNormalizedNode(level, newParentPath, normalizedNode); + } + } + + } + + + private void navigateNormalizedNode(int level, String parentPath, NormalizedNode normalizedNode){ + if(normalizedNode instanceof DataContainerNode){ + + final DataContainerNode dataContainerNode = (DataContainerNode) normalizedNode; + + navigateDataContainerNode(level + 1, parentPath, dataContainerNode); + } else { + visitor.visitNode(level+1, parentPath, normalizedNode); + } + } +} 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-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodePrinter.java new file mode 100644 index 0000000000..7735a12a8b --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodePrinter.java @@ -0,0 +1,26 @@ +package org.opendaylight.controller.cluster.datastore.node.utils; + +import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; +import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; + +public class NormalizedNodePrinter implements NormalizedNodeVisitor { + + private String spaces(int n){ + StringBuilder builder = new StringBuilder(); + for(int i=0;i 2){ + for(int i=0;i 0){ + parentPath += "/" + parentPaths[i]; + } + } + } + } + return parentPath; + } +} 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-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/QNameFactory.java new file mode 100644 index 0000000000..8dba0563bd --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/QNameFactory.java @@ -0,0 +1,24 @@ +package org.opendaylight.controller.cluster.datastore.node.utils; + +import org.opendaylight.yangtools.yang.common.QName; + +import java.util.HashMap; +import java.util.Map; + +public class QNameFactory { + private static final Map cache = new HashMap<>(); + + public static QName create(String name){ + QName value = cache.get(name); + if(value == null){ + synchronized (cache){ + value = cache.get(name); + if(value == null) { + value = QName.create(name); + cache.put(name, value); + } + } + } + return value; + } +} 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-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/util/EncoderDecoderUtil.java index 8e0e85cabb..d9a067b573 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/util/EncoderDecoderUtil.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/util/EncoderDecoderUtil.java @@ -4,16 +4,26 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage; import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; +import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; +import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; +import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode; +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.codec.xml.XmlDocumentUtils; import org.opendaylight.yangtools.yang.data.impl.schema.transform.dom.DomUtils; import org.opendaylight.yangtools.yang.data.impl.schema.transform.dom.parser.DomToNormalizedNodeParserFactory; import org.opendaylight.yangtools.yang.data.impl.schema.transform.dom.serializer.DomFromNormalizedNodeSerializerFactory; +import org.opendaylight.yangtools.yang.model.api.AugmentationSchema; import org.opendaylight.yangtools.yang.model.api.ChoiceNode; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; +import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; +import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; +import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.w3c.dom.Document; @@ -29,7 +39,9 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import java.io.ByteArrayInputStream; import java.io.StringWriter; +import java.util.Collection; import java.util.Collections; +import java.util.Iterator; import java.util.List; /* @@ -47,142 +59,271 @@ import java.util.List; * @author: syedbahm */ public class EncoderDecoderUtil { - static DocumentBuilderFactory factory; - static { - factory = DocumentBuilderFactory.newInstance(); - factory.setNamespaceAware(true); - factory.setCoalescing(true); - factory.setIgnoringElementContentWhitespace(true); - factory.setIgnoringComments(true); - } + static DocumentBuilderFactory factory; - private static DataSchemaNode findChildNode(Iterable children, - String name) { - List containers = Lists.newArrayList(); - - for (DataSchemaNode dataSchemaNode : children) { - if (dataSchemaNode.getQName().getLocalName().equals(name)) - return dataSchemaNode; - if (dataSchemaNode instanceof DataNodeContainer) { - containers.add((DataNodeContainer) dataSchemaNode); - } else if (dataSchemaNode instanceof ChoiceNode) { - containers.addAll(((ChoiceNode) dataSchemaNode).getCases()); - } + private static DomFromNormalizedNodeSerializerFactory serializerFactory = + DomFromNormalizedNodeSerializerFactory + .getInstance(XmlDocumentUtils.getDocument(), + DomUtils.defaultValueCodecProvider()); + + private static DomToNormalizedNodeParserFactory parserFactory = + DomToNormalizedNodeParserFactory + .getInstance(DomUtils.defaultValueCodecProvider()); + + static { + factory = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(true); + factory.setCoalescing(true); + factory.setIgnoringElementContentWhitespace(true); + factory.setIgnoringComments(true); } - for (DataNodeContainer container : containers) { - DataSchemaNode retVal = findChildNode(container.getChildNodes(), name); - if (retVal != null) { - return retVal; - } + private static DataSchemaNode findChildNode(Collection children, + String name) { + List containers = Lists.newArrayList(); + + for (DataSchemaNode dataSchemaNode : children) { + if (dataSchemaNode.getQName().getLocalName().equals(name)) + return dataSchemaNode; + if (dataSchemaNode instanceof DataNodeContainer) { + containers.add((DataNodeContainer) dataSchemaNode); + } else if (dataSchemaNode instanceof ChoiceNode) { + containers.addAll(((ChoiceNode) dataSchemaNode).getCases()); + } + } + + for (DataNodeContainer container : containers) { + DataSchemaNode retVal = + findChildNode(container.getChildNodes(), name); + if (retVal != null) { + return retVal; + } + } + + return null; } - return null; - } + private static DataSchemaNode getSchemaNode(SchemaContext context, + QName qname) { - private static DataSchemaNode getSchemaNode(SchemaContext context, QName qname) { + for (Module module : context + .findModuleByNamespace(qname.getNamespace())) { + // we will take the first child as the start of the + if (module.getChildNodes() != null || !module.getChildNodes() + .isEmpty()) { - for (Module module : context.findModuleByNamespace(qname.getNamespace())) { - // we will take the first child as the start of the - if (module.getChildNodes() != null || !module.getChildNodes().isEmpty()) { + DataSchemaNode found = + findChildNode(module.getChildNodes(), qname.getLocalName()); + return found; + } + } + return null; + } - DataSchemaNode found = - findChildNode(module.getChildNodes(), qname.getLocalName()); - return found; - } + private static String toString(Element xml) { + try { + Transformer transformer = + TransformerFactory.newInstance().newTransformer(); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + + StreamResult result = new StreamResult(new StringWriter()); + DOMSource source = new DOMSource(xml); + transformer.transform(source, result); + + return result.getWriter().toString(); + } catch (IllegalArgumentException | TransformerFactoryConfigurationError + | TransformerException e) { + throw new RuntimeException("Unable to serialize xml element " + xml, + e); + } } - return null; - } - private static String toString(Element xml) { + private static String toString(Iterable xmlIterable) { try { Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); StreamResult result = new StreamResult(new StringWriter()); - DOMSource source = new DOMSource(xml); - transformer.transform(source, result); + Iterator iterator = xmlIterable.iterator(); + DOMSource source; + if(iterator.hasNext()) { + source = new DOMSource((org.w3c.dom.Node) iterator.next()); + transformer.transform(source, result); + transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); + } + while(iterator.hasNext()) { + source = new DOMSource((org.w3c.dom.Node) iterator.next()); + transformer.transform(source, result); + } + System.out.println(result.getWriter().toString()); return result.getWriter().toString(); } catch (IllegalArgumentException | TransformerFactoryConfigurationError | TransformerException e) { - throw new RuntimeException("Unable to serialize xml element " + xml, e); + throw new RuntimeException("Unable to serialize xml element(s) " + xmlIterable.toString(), + e); } } - /** - * Helps in generation of NormalizedNodeXml message for the supplied NormalizedNode - * - * @param sc --SchemaContext - * @param normalizedNode -- Normalized Node to be encoded - * @return SimpleNormalizedNodeMessage.NormalizedNodeXml - */ - public static SimpleNormalizedNodeMessage.NormalizedNodeXml encode( - SchemaContext sc, NormalizedNode normalizedNode) { - Preconditions.checkArgument(sc != null, "Schema context found null"); - Preconditions.checkArgument(normalizedNode != null, - "normalized node found null"); - ContainerSchemaNode containerNode = - (ContainerSchemaNode) getSchemaNode(sc, normalizedNode.getIdentifier() - .getNodeType()); - Preconditions.checkState(containerNode != null, - "Couldn't find schema node for " + normalizedNode.getIdentifier()); - Iterable els = - DomFromNormalizedNodeSerializerFactory - .getInstance(XmlDocumentUtils.getDocument(), - DomUtils.defaultValueCodecProvider()) - .getContainerNodeSerializer() - .serialize(containerNode, (ContainerNode) normalizedNode); - String xmlString = toString(els.iterator().next()); - SimpleNormalizedNodeMessage.NormalizedNodeXml.Builder builder = - SimpleNormalizedNodeMessage.NormalizedNodeXml.newBuilder(); - builder.setXmlString(xmlString); - builder.setNodeIdentifier(((ContainerNode) normalizedNode).getIdentifier() - .getNodeType().toString()); - return builder.build(); + private static Iterable serialize(DataSchemaNode schemaNode, NormalizedNode normalizedNode){ + if(schemaNode instanceof ContainerSchemaNode){ //1 + return serializerFactory + .getContainerNodeSerializer() + .serialize((ContainerSchemaNode) schemaNode, + (ContainerNode) normalizedNode); + } else if(schemaNode instanceof ChoiceNode){ //2 + return serializerFactory + .getChoiceNodeSerializer() + .serialize((ChoiceNode) schemaNode, + (org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) normalizedNode); + } else if(schemaNode instanceof LeafSchemaNode){ //3 + return serializerFactory + .getLeafNodeSerializer() + .serialize((LeafSchemaNode) schemaNode, (LeafNode) normalizedNode); + } else if(schemaNode instanceof ListSchemaNode){ //4 + return serializerFactory + .getMapNodeSerializer() + .serialize((ListSchemaNode) schemaNode, (MapNode) normalizedNode); + } else if(schemaNode instanceof LeafListSchemaNode){ //5 + return serializerFactory + .getLeafSetNodeSerializer() + .serialize((LeafListSchemaNode) schemaNode, (LeafSetNode) normalizedNode); + } else if(schemaNode instanceof AugmentationSchema){//6 + return serializerFactory + .getAugmentationNodeSerializer() + .serialize((AugmentationSchema) schemaNode, (AugmentationNode) normalizedNode); + } else if(schemaNode instanceof ListSchemaNode && normalizedNode instanceof LeafSetEntryNode){ //7 + return serializerFactory + .getLeafSetEntryNodeSerializer() + .serialize((LeafListSchemaNode) schemaNode, (LeafSetEntryNode) normalizedNode); + } else if(schemaNode instanceof ListSchemaNode){ //8 + return serializerFactory + .getMapEntryNodeSerializer() + .serialize((ListSchemaNode) schemaNode, (MapEntryNode) normalizedNode); + } - } - /** - * Utilizes the SimpleNormalizedNodeMessage.NormalizedNodeXml to convert into NormalizedNode - * - * @param sc -- schema context - * @param normalizedNodeXml -- containing the normalized Node XML - * @return NormalizedNode return - * @throws Exception - */ - - public static NormalizedNode decode(SchemaContext sc, - SimpleNormalizedNodeMessage.NormalizedNodeXml normalizedNodeXml) - throws Exception { - Preconditions.checkArgument(sc != null, "schema context seems to be null"); - Preconditions.checkArgument(normalizedNodeXml != null, - "SimpleNormalizedNodeMessage.NormalizedNodeXml found to be null"); - QName qname = QName.create(normalizedNodeXml.getNodeIdentifier()); - - // here we will try to get back the NormalizedNode - ContainerSchemaNode containerSchemaNode = - (ContainerSchemaNode) getSchemaNode(sc, qname); - - // now we need to read the XML - - Document doc = - factory.newDocumentBuilder().parse( - new ByteArrayInputStream(normalizedNodeXml.getXmlString().getBytes( - "utf-8"))); - doc.getDocumentElement().normalize(); - - ContainerNode result = - DomToNormalizedNodeParserFactory - .getInstance(DomUtils.defaultValueCodecProvider()) - .getContainerNodeParser() - .parse(Collections.singletonList(doc.getDocumentElement()), - containerSchemaNode); - return (NormalizedNode) result; + throw new UnsupportedOperationException(schemaNode.getClass().toString()); + } - } + private static NormalizedNode parse(Document doc, DataSchemaNode schemaNode){ + if(schemaNode instanceof ContainerSchemaNode){ + return parserFactory + .getContainerNodeParser() + .parse(Collections.singletonList(doc.getDocumentElement()), + (ContainerSchemaNode) schemaNode); + + } else if(schemaNode instanceof ChoiceNode){ + return parserFactory + .getChoiceNodeParser() + .parse(Collections.singletonList(doc.getDocumentElement()), + (ChoiceNode) schemaNode); + } else if(schemaNode instanceof LeafNode){ + return parserFactory + .getLeafNodeParser() + .parse(Collections.singletonList(doc.getDocumentElement()), + (LeafSchemaNode) schemaNode); + } else if(schemaNode instanceof ListSchemaNode){ + return parserFactory + .getMapNodeParser() + .parse(Collections.singletonList(doc.getDocumentElement()), + (ListSchemaNode) schemaNode); + } else if(schemaNode instanceof LeafListSchemaNode){ + return parserFactory + .getLeafSetNodeParser() + .parse(Collections.singletonList(doc.getDocumentElement()), + (LeafListSchemaNode) schemaNode); + } else if(schemaNode instanceof AugmentationSchema){ + return parserFactory + .getAugmentationNodeParser() + .parse(Collections.singletonList(doc.getDocumentElement()), + (AugmentationSchema) schemaNode); + } else if(schemaNode instanceof ListSchemaNode){ + return parserFactory + .getMapEntryNodeParser() + .parse(Collections.singletonList(doc.getDocumentElement()), + (ListSchemaNode) schemaNode); + + } + + throw new UnsupportedOperationException(schemaNode.getClass().toString()); + } + + + /** + * Helps in generation of NormalizedNodeXml message for the supplied NormalizedNode + * + * @param sc --SchemaContext + * @param normalizedNode -- Normalized Node to be encoded + * @return SimpleNormalizedNodeMessage.NormalizedNodeXml + */ + public static SimpleNormalizedNodeMessage.NormalizedNodeXml encode( + SchemaContext sc, NormalizedNode normalizedNode) { + + Preconditions.checkArgument(sc != null, "Schema context found null"); + + Preconditions.checkArgument(normalizedNode != null, + "normalized node found null"); + + DataSchemaNode schemaNode = getSchemaNode(sc, + normalizedNode.getIdentifier() + .getNodeType() + ); + + Preconditions.checkState(schemaNode != null, + "Couldn't find schema node for " + normalizedNode.getIdentifier()); + + Iterable els = serialize(schemaNode, normalizedNode); + + String xmlString = toString(els.iterator().next()); + SimpleNormalizedNodeMessage.NormalizedNodeXml.Builder builder = + SimpleNormalizedNodeMessage.NormalizedNodeXml.newBuilder(); + builder.setXmlString(xmlString); + builder + .setNodeIdentifier(normalizedNode.getIdentifier() + .getNodeType().toString()); + return builder.build(); + + } + + /** + * Utilizes the SimpleNormalizedNodeMessage.NormalizedNodeXml to convert into NormalizedNode + * + * @param sc -- schema context + * @param normalizedNodeXml -- containing the normalized Node XML + * @return NormalizedNode return + * @throws Exception + */ + + public static NormalizedNode decode(SchemaContext sc, + SimpleNormalizedNodeMessage.NormalizedNodeXml normalizedNodeXml) + throws Exception { + + Preconditions + .checkArgument(sc != null, "schema context seems to be null"); + + Preconditions.checkArgument(normalizedNodeXml != null, + "SimpleNormalizedNodeMessage.NormalizedNodeXml found to be null"); + QName qname = QName.create(normalizedNodeXml.getNodeIdentifier()); + + // here we will try to get back the NormalizedNode + DataSchemaNode schemaNode = getSchemaNode(sc, qname); + + // now we need to read the XML + Document doc = + factory.newDocumentBuilder().parse( + new ByteArrayInputStream( + normalizedNodeXml.getXmlString().getBytes( + "utf-8")) + ); + + doc.getDocumentElement().normalize(); + + + return parse(doc, schemaNode); + } 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-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtils.java new file mode 100644 index 0000000000..5b459e7e7c --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtils.java @@ -0,0 +1,277 @@ +package org.opendaylight.controller.cluster.datastore.util; + +import org.opendaylight.controller.cluster.datastore.node.utils.NodeIdentifierFactory; +import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * This class contains utility methods for converting an MD-SAL + * YangInstanceIdentifier to and from other representations. + *

+ * The representations convered for now are, + * + *

    + *
  • String
  • + *
  • Protocol Buffer
  • + *
+ */ +public class InstanceIdentifierUtils { + + protected static final Logger logger = LoggerFactory + .getLogger(InstanceIdentifierUtils.class); + + @Deprecated + public static YangInstanceIdentifier from(String path) { + String[] ids = path.split("/"); + + List pathArguments = + new ArrayList<>(); + for (String nodeId : ids) { + if (!"".equals(nodeId)) { + pathArguments + .add(NodeIdentifierFactory.getArgument(nodeId)); + } + } + final YangInstanceIdentifier instanceIdentifier = + YangInstanceIdentifier.create(pathArguments); + return instanceIdentifier; + } + + + /** + * Convert an MD-SAL YangInstanceIdentifier into a protocol buffer version of it + * + * @param path an MD-SAL YangInstanceIdentifier + * @return a protocol buffer version of the MD-SAL YangInstanceIdentifier + */ + public static NormalizedNodeMessages.InstanceIdentifier toSerializable(YangInstanceIdentifier path){ + NormalizedNodeMessages.InstanceIdentifier.Builder builder = + NormalizedNodeMessages.InstanceIdentifier.newBuilder(); + + try { + + for (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument pathArgument : path + .getPathArguments()) { + + String nodeType = ""; + if(!(pathArgument instanceof YangInstanceIdentifier.AugmentationIdentifier)){ + nodeType = pathArgument.getNodeType().toString(); + } + + NormalizedNodeMessages.PathArgument serializablePathArgument = + NormalizedNodeMessages.PathArgument.newBuilder() + .setValue(pathArgument.toString()) + .setType(pathArgument.getClass().getSimpleName()) + .setNodeType(NormalizedNodeMessages.QName.newBuilder() + .setValue(nodeType)) + .addAllAttributes(getPathArgumentAttributes( + pathArgument)) + .build(); + + builder.addArguments(serializablePathArgument); + } + + } catch(Exception e){ + logger.error("An exception occurred", e); + } + return builder.build(); + } + + + /** + * Convert a protocol buffer version of the MD-SAL YangInstanceIdentifier into + * the MD-SAL version of the YangInstanceIdentifier + * + * @param path a protocol buffer version of the MD-SAL YangInstanceIdentifier + * @return an MD-SAL YangInstanceIdentifier + */ + public static YangInstanceIdentifier fromSerializable(NormalizedNodeMessages.InstanceIdentifier path){ + + List pathArguments = + new ArrayList<>(); + + for(NormalizedNodeMessages.PathArgument pathArgument : path.getArgumentsList()){ + + pathArguments + .add(parsePathArgument(pathArgument)); + + } + + final YangInstanceIdentifier instanceIdentifier = YangInstanceIdentifier.create(pathArguments); + + return instanceIdentifier; + } + + /** + * Take the various attributes of a PathArgument and package them up as + * protocol buffer attributes. + *

+ * + * PathArguments have 4 subtypes and each of the various subtypes have + * different attributes + *

    + *
  • + * NodeIdentifier is the most basic PathArgument. It is used for + * ContainerNode, LeafNode etc and has no attributes + *
  • + *
  • + * NodeWithValue has only a single attribute. It is used for + * LeafListEntryNodes and the attribute it contains is the value + * of the entry + *
  • + *
  • + * NodeIdentifierWithPredicates has a map of attributes. + * It is used to represent a ListItemNode. Each entry + * in the map of attributes represents the key and value of the + * keys in that entry. + *
  • + *
  • + * AugmentationIdentifier has a list of unnamed attributes. Each + * attribute represents the possible children that can go within + * an augmentation entry. + *
  • + *
+ * @param pathArgument + * @return + */ + private static Iterable getPathArgumentAttributes( + YangInstanceIdentifier.PathArgument pathArgument) { + List attributes = new ArrayList<>(); + + + + if (pathArgument instanceof YangInstanceIdentifier.NodeWithValue) { + YangInstanceIdentifier.NodeWithValue identifier + = (YangInstanceIdentifier.NodeWithValue) pathArgument; + + NormalizedNodeMessages.Attribute attribute = + NormalizedNodeMessages.Attribute.newBuilder() + .setName("name") + .setValue(identifier.getValue().toString()) + .setType(identifier.getValue().getClass().getSimpleName()) + .build(); + + attributes.add(attribute); + } else if (pathArgument instanceof YangInstanceIdentifier.NodeIdentifierWithPredicates) { + YangInstanceIdentifier.NodeIdentifierWithPredicates identifier + = (YangInstanceIdentifier.NodeIdentifierWithPredicates) pathArgument; + + for (QName key : identifier.getKeyValues().keySet()) { + Object value = identifier.getKeyValues().get(key); + NormalizedNodeMessages.Attribute attribute = + NormalizedNodeMessages.Attribute.newBuilder() + .setName(key.toString()) + .setValue(value.toString()) + .setType(value.getClass().getSimpleName()) + .build(); + + attributes.add(attribute); + + } + + } else if(pathArgument instanceof YangInstanceIdentifier.AugmentationIdentifier) { + YangInstanceIdentifier.AugmentationIdentifier identifier + = (YangInstanceIdentifier.AugmentationIdentifier) pathArgument; + + for (QName key : identifier.getPossibleChildNames()) { + Object value = key; + NormalizedNodeMessages.Attribute attribute = + NormalizedNodeMessages.Attribute.newBuilder() + .setName(key.toString()) + .setValue(value.toString()) + .setType(value.getClass().getSimpleName()) + .build(); + + attributes.add(attribute); + + } + } + + return attributes; + } + + + /** + * Parse a protocol buffer PathArgument and return an MD-SAL PathArgument + * + * @param pathArgument protocol buffer PathArgument + * @return MD-SAL PathArgument + */ + private static YangInstanceIdentifier.PathArgument parsePathArgument(NormalizedNodeMessages.PathArgument pathArgument) { + if (YangInstanceIdentifier.NodeWithValue.class.getSimpleName().equals(pathArgument.getType())) { + + YangInstanceIdentifier.NodeWithValue nodeWithValue = + new YangInstanceIdentifier.NodeWithValue( + QName.create(pathArgument.getNodeType().getValue()), + parseAttribute(pathArgument.getAttributes(0))); + + return nodeWithValue; + + } else if(YangInstanceIdentifier.NodeIdentifierWithPredicates.class.getSimpleName().equals(pathArgument.getType())){ + + YangInstanceIdentifier.NodeIdentifierWithPredicates + nodeIdentifierWithPredicates = + new YangInstanceIdentifier.NodeIdentifierWithPredicates( + QName.create(pathArgument.getNodeType().getValue()), toAttributesMap(pathArgument.getAttributesList())); + + return nodeIdentifierWithPredicates; + + } else if(YangInstanceIdentifier.AugmentationIdentifier.class.getSimpleName().equals(pathArgument.getType())){ + + Set qNameSet = new HashSet<>(); + + for(NormalizedNodeMessages.Attribute attribute : pathArgument.getAttributesList()){ + qNameSet.add(QName.create(attribute.getValue())); + } + + return new YangInstanceIdentifier.AugmentationIdentifier(qNameSet); + } + + return NodeIdentifierFactory.getArgument(pathArgument.getValue()); + } + + private static Map toAttributesMap( + List attributesList) { + + Map map = new HashMap<>(); + + for(NormalizedNodeMessages.Attribute attribute : attributesList){ + String name = attribute.getName(); + Object value = parseAttribute(attribute); + + map.put(QName.create(name), value); + } + + return map; + } + + /** + * FIXME: This method only covers a subset of values that may go in an InstanceIdentifier + * + * @param attribute + * @return + */ + private static Object parseAttribute(NormalizedNodeMessages.Attribute attribute){ + if(Short.class.getSimpleName().equals(attribute.getType())) { + return Short.parseShort(attribute.getValue()); + } else if(Long.class.getSimpleName().equals(attribute.getType())){ + return Long.parseLong(attribute.getValue()); + } else if(Boolean.class.getSimpleName().equals(attribute.getType())){ + return Boolean.parseBoolean(attribute.getValue()); + } else if(Integer.class.getSimpleName().equals(attribute.getType())){ + return Integer.parseInt(attribute.getValue()); + } + + return attribute.getValue(); + } +} diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/mdsal/CompositeModificationPayload.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/mdsal/CompositeModificationPayload.java new file mode 100644 index 0000000000..87b246bd7e --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/mdsal/CompositeModificationPayload.java @@ -0,0 +1,60 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: CompositeModificationPayload.proto + +package org.opendaylight.controller.mdsal; + +public final class CompositeModificationPayload { + private CompositeModificationPayload() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registry.add(org.opendaylight.controller.mdsal.CompositeModificationPayload.modification); + } + public static final int MODIFICATION_FIELD_NUMBER = 2; + /** + * extend .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload { ... } + */ + public static final + com.google.protobuf.GeneratedMessage.GeneratedExtension< + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload, + org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification> modification = com.google.protobuf.GeneratedMessage + .newFileScopedGeneratedExtension( + org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification.class, + org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification.getDefaultInstance()); + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\"CompositeModificationPayload.proto\022!or" + + "g.opendaylight.controller.mdsal\032\033AppendE" + + "ntriesMessages.proto\032\014Common.proto\032\020Pers" + + "istent.proto:\242\001\n\014modification\022R.org.open" + + "daylight.controller.cluster.raft.AppendE" + + "ntries.ReplicatedLogEntry.Payload\030\002 \001(\0132" + + "8.org.opendaylight.controller.mdsal.Comp" + + "ositeModification" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + modification.internalInit(descriptor.getExtensions().get(0)); + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.getDescriptor(), + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.getDescriptor(), + org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.getDescriptor(), + }, assigner); + } + + // @@protoc_insertion_point(outer_class_scope) +} 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-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/cohort3pc/ThreePhaseCommitCohortMessages.java new file mode 100644 index 0000000000..ac0701a6d8 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/cohort3pc/ThreePhaseCommitCohortMessages.java @@ -0,0 +1,2700 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: Cohort.proto + +package org.opendaylight.controller.protobuff.messages.cohort3pc; + +public final class ThreePhaseCommitCohortMessages { + private ThreePhaseCommitCohortMessages() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + public interface CanCommitTransactionOrBuilder + extends com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CanCommitTransaction} + */ + public static final class CanCommitTransaction extends + com.google.protobuf.GeneratedMessage + implements CanCommitTransactionOrBuilder { + // Use CanCommitTransaction.newBuilder() to construct. + private CanCommitTransaction(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private CanCommitTransaction(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final CanCommitTransaction defaultInstance; + public static CanCommitTransaction getDefaultInstance() { + return defaultInstance; + } + + public CanCommitTransaction getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private CanCommitTransaction( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_CanCommitTransaction_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_CanCommitTransaction_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction.class, org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public CanCommitTransaction parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new CanCommitTransaction(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private void initFields() { + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CanCommitTransaction} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_CanCommitTransaction_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_CanCommitTransaction_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction.class, org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction.Builder.class); + } + + // Construct using org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_CanCommitTransaction_descriptor; + } + + public org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction getDefaultInstanceForType() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction.getDefaultInstance(); + } + + public org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction build() { + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction buildPartial() { + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction result = new org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction(this); + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction) { + return mergeFrom((org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction other) { + if (other == org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction.getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransaction) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.CanCommitTransaction) + } + + static { + defaultInstance = new CanCommitTransaction(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.CanCommitTransaction) + } + + public interface CanCommitTransactionReplyOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required bool canCommit = 1; + /** + * required bool canCommit = 1; + */ + boolean hasCanCommit(); + /** + * required bool canCommit = 1; + */ + boolean getCanCommit(); + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CanCommitTransactionReply} + */ + public static final class CanCommitTransactionReply extends + com.google.protobuf.GeneratedMessage + implements CanCommitTransactionReplyOrBuilder { + // Use CanCommitTransactionReply.newBuilder() to construct. + private CanCommitTransactionReply(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private CanCommitTransactionReply(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final CanCommitTransactionReply defaultInstance; + public static CanCommitTransactionReply getDefaultInstance() { + return defaultInstance; + } + + public CanCommitTransactionReply getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private CanCommitTransactionReply( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + bitField0_ |= 0x00000001; + canCommit_ = input.readBool(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_CanCommitTransactionReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_CanCommitTransactionReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply.class, org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public CanCommitTransactionReply parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new CanCommitTransactionReply(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // required bool canCommit = 1; + public static final int CANCOMMIT_FIELD_NUMBER = 1; + private boolean canCommit_; + /** + * required bool canCommit = 1; + */ + public boolean hasCanCommit() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required bool canCommit = 1; + */ + public boolean getCanCommit() { + return canCommit_; + } + + private void initFields() { + canCommit_ = false; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasCanCommit()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBool(1, canCommit_); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(1, canCommit_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CanCommitTransactionReply} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReplyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_CanCommitTransactionReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_CanCommitTransactionReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply.class, org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply.Builder.class); + } + + // Construct using org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + canCommit_ = false; + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_CanCommitTransactionReply_descriptor; + } + + public org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply getDefaultInstanceForType() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply.getDefaultInstance(); + } + + public org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply build() { + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply buildPartial() { + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply result = new org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.canCommit_ = canCommit_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply) { + return mergeFrom((org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply other) { + if (other == org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply.getDefaultInstance()) return this; + if (other.hasCanCommit()) { + setCanCommit(other.getCanCommit()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasCanCommit()) { + + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CanCommitTransactionReply) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required bool canCommit = 1; + private boolean canCommit_ ; + /** + * required bool canCommit = 1; + */ + public boolean hasCanCommit() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required bool canCommit = 1; + */ + public boolean getCanCommit() { + return canCommit_; + } + /** + * required bool canCommit = 1; + */ + public Builder setCanCommit(boolean value) { + bitField0_ |= 0x00000001; + canCommit_ = value; + onChanged(); + return this; + } + /** + * required bool canCommit = 1; + */ + public Builder clearCanCommit() { + bitField0_ = (bitField0_ & ~0x00000001); + canCommit_ = false; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.CanCommitTransactionReply) + } + + static { + defaultInstance = new CanCommitTransactionReply(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.CanCommitTransactionReply) + } + + public interface AbortTransactionOrBuilder + extends com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.AbortTransaction} + */ + public static final class AbortTransaction extends + com.google.protobuf.GeneratedMessage + implements AbortTransactionOrBuilder { + // Use AbortTransaction.newBuilder() to construct. + private AbortTransaction(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private AbortTransaction(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final AbortTransaction defaultInstance; + public static AbortTransaction getDefaultInstance() { + return defaultInstance; + } + + public AbortTransaction getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private AbortTransaction( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_AbortTransaction_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_AbortTransaction_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction.class, org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public AbortTransaction parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new AbortTransaction(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private void initFields() { + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.AbortTransaction} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_AbortTransaction_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_AbortTransaction_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction.class, org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction.Builder.class); + } + + // Construct using org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_AbortTransaction_descriptor; + } + + public org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction getDefaultInstanceForType() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction.getDefaultInstance(); + } + + public org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction build() { + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction buildPartial() { + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction result = new org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction(this); + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction) { + return mergeFrom((org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction other) { + if (other == org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction.getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransaction) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.AbortTransaction) + } + + static { + defaultInstance = new AbortTransaction(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.AbortTransaction) + } + + public interface AbortTransactionReplyOrBuilder + extends com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.AbortTransactionReply} + */ + public static final class AbortTransactionReply extends + com.google.protobuf.GeneratedMessage + implements AbortTransactionReplyOrBuilder { + // Use AbortTransactionReply.newBuilder() to construct. + private AbortTransactionReply(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private AbortTransactionReply(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final AbortTransactionReply defaultInstance; + public static AbortTransactionReply getDefaultInstance() { + return defaultInstance; + } + + public AbortTransactionReply getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private AbortTransactionReply( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_AbortTransactionReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_AbortTransactionReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply.class, org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public AbortTransactionReply parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new AbortTransactionReply(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private void initFields() { + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.AbortTransactionReply} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReplyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_AbortTransactionReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_AbortTransactionReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply.class, org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply.Builder.class); + } + + // Construct using org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_AbortTransactionReply_descriptor; + } + + public org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply getDefaultInstanceForType() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply.getDefaultInstance(); + } + + public org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply build() { + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply buildPartial() { + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply result = new org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply(this); + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply) { + return mergeFrom((org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply other) { + if (other == org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply.getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.AbortTransactionReply) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.AbortTransactionReply) + } + + static { + defaultInstance = new AbortTransactionReply(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.AbortTransactionReply) + } + + public interface CommitTransactionOrBuilder + extends com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CommitTransaction} + */ + public static final class CommitTransaction extends + com.google.protobuf.GeneratedMessage + implements CommitTransactionOrBuilder { + // Use CommitTransaction.newBuilder() to construct. + private CommitTransaction(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private CommitTransaction(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final CommitTransaction defaultInstance; + public static CommitTransaction getDefaultInstance() { + return defaultInstance; + } + + public CommitTransaction getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private CommitTransaction( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_CommitTransaction_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_CommitTransaction_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction.class, org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public CommitTransaction parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new CommitTransaction(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private void initFields() { + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CommitTransaction} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_CommitTransaction_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_CommitTransaction_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction.class, org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction.Builder.class); + } + + // Construct using org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_CommitTransaction_descriptor; + } + + public org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction getDefaultInstanceForType() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction.getDefaultInstance(); + } + + public org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction build() { + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction buildPartial() { + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction result = new org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction(this); + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction) { + return mergeFrom((org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction other) { + if (other == org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction.getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransaction) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.CommitTransaction) + } + + static { + defaultInstance = new CommitTransaction(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.CommitTransaction) + } + + public interface CommitTransactionReplyOrBuilder + extends com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CommitTransactionReply} + */ + public static final class CommitTransactionReply extends + com.google.protobuf.GeneratedMessage + implements CommitTransactionReplyOrBuilder { + // Use CommitTransactionReply.newBuilder() to construct. + private CommitTransactionReply(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private CommitTransactionReply(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final CommitTransactionReply defaultInstance; + public static CommitTransactionReply getDefaultInstance() { + return defaultInstance; + } + + public CommitTransactionReply getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private CommitTransactionReply( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_CommitTransactionReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_CommitTransactionReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply.class, org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public CommitTransactionReply parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new CommitTransactionReply(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private void initFields() { + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CommitTransactionReply} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReplyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_CommitTransactionReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_CommitTransactionReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply.class, org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply.Builder.class); + } + + // Construct using org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_CommitTransactionReply_descriptor; + } + + public org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply getDefaultInstanceForType() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply.getDefaultInstance(); + } + + public org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply build() { + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply buildPartial() { + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply result = new org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply(this); + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply) { + return mergeFrom((org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply other) { + if (other == org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply.getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.CommitTransactionReply) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.CommitTransactionReply) + } + + static { + defaultInstance = new CommitTransactionReply(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.CommitTransactionReply) + } + + public interface PreCommitTransactionOrBuilder + extends com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.PreCommitTransaction} + */ + public static final class PreCommitTransaction extends + com.google.protobuf.GeneratedMessage + implements PreCommitTransactionOrBuilder { + // Use PreCommitTransaction.newBuilder() to construct. + private PreCommitTransaction(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private PreCommitTransaction(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final PreCommitTransaction defaultInstance; + public static PreCommitTransaction getDefaultInstance() { + return defaultInstance; + } + + public PreCommitTransaction getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private PreCommitTransaction( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_PreCommitTransaction_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_PreCommitTransaction_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction.class, org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public PreCommitTransaction parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new PreCommitTransaction(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private void initFields() { + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.PreCommitTransaction} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_PreCommitTransaction_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_PreCommitTransaction_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction.class, org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction.Builder.class); + } + + // Construct using org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_PreCommitTransaction_descriptor; + } + + public org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction getDefaultInstanceForType() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction.getDefaultInstance(); + } + + public org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction build() { + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction buildPartial() { + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction result = new org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction(this); + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction) { + return mergeFrom((org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction other) { + if (other == org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction.getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransaction) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.PreCommitTransaction) + } + + static { + defaultInstance = new PreCommitTransaction(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.PreCommitTransaction) + } + + public interface PreCommitTransactionReplyOrBuilder + extends com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.PreCommitTransactionReply} + */ + public static final class PreCommitTransactionReply extends + com.google.protobuf.GeneratedMessage + implements PreCommitTransactionReplyOrBuilder { + // Use PreCommitTransactionReply.newBuilder() to construct. + private PreCommitTransactionReply(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private PreCommitTransactionReply(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final PreCommitTransactionReply defaultInstance; + public static PreCommitTransactionReply getDefaultInstance() { + return defaultInstance; + } + + public PreCommitTransactionReply getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private PreCommitTransactionReply( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_PreCommitTransactionReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_PreCommitTransactionReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply.class, org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public PreCommitTransactionReply parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new PreCommitTransactionReply(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private void initFields() { + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.PreCommitTransactionReply} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReplyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_PreCommitTransactionReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_PreCommitTransactionReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply.class, org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply.Builder.class); + } + + // Construct using org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.internal_static_org_opendaylight_controller_mdsal_PreCommitTransactionReply_descriptor; + } + + public org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply getDefaultInstanceForType() { + return org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply.getDefaultInstance(); + } + + public org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply build() { + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply buildPartial() { + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply result = new org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply(this); + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply) { + return mergeFrom((org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply other) { + if (other == org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply.getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages.PreCommitTransactionReply) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.PreCommitTransactionReply) + } + + static { + defaultInstance = new PreCommitTransactionReply(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.PreCommitTransactionReply) + } + + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_CanCommitTransaction_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_CanCommitTransaction_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_CanCommitTransactionReply_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_CanCommitTransactionReply_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_AbortTransaction_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_AbortTransaction_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_AbortTransactionReply_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_AbortTransactionReply_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_CommitTransaction_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_CommitTransaction_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_CommitTransactionReply_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_CommitTransactionReply_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_PreCommitTransaction_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_PreCommitTransaction_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_PreCommitTransactionReply_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_PreCommitTransactionReply_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\014Cohort.proto\022!org.opendaylight.control" + + "ler.mdsal\"\026\n\024CanCommitTransaction\".\n\031Can" + + "CommitTransactionReply\022\021\n\tcanCommit\030\001 \002(" + + "\010\"\022\n\020AbortTransaction\"\027\n\025AbortTransactio" + + "nReply\"\023\n\021CommitTransaction\"\030\n\026CommitTra" + + "nsactionReply\"\026\n\024PreCommitTransaction\"\033\n" + + "\031PreCommitTransactionReplyBZ\n8org.openda" + + "ylight.controller.protobuff.messages.coh" + + "ort3pcB\036ThreePhaseCommitCohortMessages" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + internal_static_org_opendaylight_controller_mdsal_CanCommitTransaction_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_org_opendaylight_controller_mdsal_CanCommitTransaction_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_CanCommitTransaction_descriptor, + new java.lang.String[] { }); + internal_static_org_opendaylight_controller_mdsal_CanCommitTransactionReply_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_org_opendaylight_controller_mdsal_CanCommitTransactionReply_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_CanCommitTransactionReply_descriptor, + new java.lang.String[] { "CanCommit", }); + internal_static_org_opendaylight_controller_mdsal_AbortTransaction_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_org_opendaylight_controller_mdsal_AbortTransaction_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_AbortTransaction_descriptor, + new java.lang.String[] { }); + internal_static_org_opendaylight_controller_mdsal_AbortTransactionReply_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_org_opendaylight_controller_mdsal_AbortTransactionReply_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_AbortTransactionReply_descriptor, + new java.lang.String[] { }); + internal_static_org_opendaylight_controller_mdsal_CommitTransaction_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_org_opendaylight_controller_mdsal_CommitTransaction_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_CommitTransaction_descriptor, + new java.lang.String[] { }); + internal_static_org_opendaylight_controller_mdsal_CommitTransactionReply_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_org_opendaylight_controller_mdsal_CommitTransactionReply_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_CommitTransactionReply_descriptor, + new java.lang.String[] { }); + internal_static_org_opendaylight_controller_mdsal_PreCommitTransaction_descriptor = + getDescriptor().getMessageTypes().get(6); + internal_static_org_opendaylight_controller_mdsal_PreCommitTransaction_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_PreCommitTransaction_descriptor, + new java.lang.String[] { }); + internal_static_org_opendaylight_controller_mdsal_PreCommitTransactionReply_descriptor = + getDescriptor().getMessageTypes().get(7); + internal_static_org_opendaylight_controller_mdsal_PreCommitTransactionReply_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_PreCommitTransactionReply_descriptor, + new java.lang.String[] { }); + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + } + + // @@protoc_insertion_point(outer_class_scope) +} 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-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/common/NormalizedNodeMessages.java new file mode 100644 index 0000000000..81e5b462cc --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/common/NormalizedNodeMessages.java @@ -0,0 +1,7541 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: Common.proto + +package org.opendaylight.controller.protobuff.messages.common; + +public final class NormalizedNodeMessages { + private NormalizedNodeMessages() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + public interface AttributeOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required string name = 1; + /** + * required string name = 1; + */ + boolean hasName(); + /** + * required string name = 1; + */ + java.lang.String getName(); + /** + * required string name = 1; + */ + com.google.protobuf.ByteString + getNameBytes(); + + // optional string value = 2; + /** + * optional string value = 2; + */ + boolean hasValue(); + /** + * optional string value = 2; + */ + java.lang.String getValue(); + /** + * optional string value = 2; + */ + com.google.protobuf.ByteString + getValueBytes(); + + // optional string type = 3; + /** + * optional string type = 3; + */ + boolean hasType(); + /** + * optional string type = 3; + */ + java.lang.String getType(); + /** + * optional string type = 3; + */ + com.google.protobuf.ByteString + getTypeBytes(); + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.Attribute} + */ + public static final class Attribute extends + com.google.protobuf.GeneratedMessage + implements AttributeOrBuilder { + // Use Attribute.newBuilder() to construct. + private Attribute(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private Attribute(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final Attribute defaultInstance; + public static Attribute getDefaultInstance() { + return defaultInstance; + } + + public Attribute getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Attribute( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + bitField0_ |= 0x00000001; + name_ = input.readBytes(); + break; + } + case 18: { + bitField0_ |= 0x00000002; + value_ = input.readBytes(); + break; + } + case 26: { + bitField0_ |= 0x00000004; + type_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_Attribute_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_Attribute_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.class, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public Attribute parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Attribute(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // required string name = 1; + public static final int NAME_FIELD_NUMBER = 1; + private java.lang.Object name_; + /** + * required string name = 1; + */ + public boolean hasName() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string name = 1; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + name_ = s; + } + return s; + } + } + /** + * required string name = 1; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // optional string value = 2; + public static final int VALUE_FIELD_NUMBER = 2; + private java.lang.Object value_; + /** + * optional string value = 2; + */ + public boolean hasValue() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional string value = 2; + */ + public java.lang.String getValue() { + java.lang.Object ref = value_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + value_ = s; + } + return s; + } + } + /** + * optional string value = 2; + */ + public com.google.protobuf.ByteString + getValueBytes() { + java.lang.Object ref = value_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + value_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // optional string type = 3; + public static final int TYPE_FIELD_NUMBER = 3; + private java.lang.Object type_; + /** + * optional string type = 3; + */ + public boolean hasType() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional string type = 3; + */ + public java.lang.String getType() { + java.lang.Object ref = type_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + type_ = s; + } + return s; + } + } + /** + * optional string type = 3; + */ + public com.google.protobuf.ByteString + getTypeBytes() { + java.lang.Object ref = type_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + type_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private void initFields() { + name_ = ""; + value_ = ""; + type_ = ""; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasName()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getNameBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeBytes(2, getValueBytes()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeBytes(3, getTypeBytes()); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getNameBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, getValueBytes()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, getTypeBytes()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.Attribute} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_Attribute_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_Attribute_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.class, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder.class); + } + + // Construct using org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + name_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + value_ = ""; + bitField0_ = (bitField0_ & ~0x00000002); + type_ = ""; + bitField0_ = (bitField0_ & ~0x00000004); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_Attribute_descriptor; + } + + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute getDefaultInstanceForType() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.getDefaultInstance(); + } + + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute build() { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute buildPartial() { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute result = new org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.name_ = name_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.value_ = value_; + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000004; + } + result.type_ = type_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute) { + return mergeFrom((org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute other) { + if (other == org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.getDefaultInstance()) return this; + if (other.hasName()) { + bitField0_ |= 0x00000001; + name_ = other.name_; + onChanged(); + } + if (other.hasValue()) { + bitField0_ |= 0x00000002; + value_ = other.value_; + onChanged(); + } + if (other.hasType()) { + bitField0_ |= 0x00000004; + type_ = other.type_; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasName()) { + + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required string name = 1; + private java.lang.Object name_ = ""; + /** + * required string name = 1; + */ + public boolean hasName() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string name = 1; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string name = 1; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string name = 1; + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + name_ = value; + onChanged(); + return this; + } + /** + * required string name = 1; + */ + public Builder clearName() { + bitField0_ = (bitField0_ & ~0x00000001); + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * required string name = 1; + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + name_ = value; + onChanged(); + return this; + } + + // optional string value = 2; + private java.lang.Object value_ = ""; + /** + * optional string value = 2; + */ + public boolean hasValue() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional string value = 2; + */ + public java.lang.String getValue() { + java.lang.Object ref = value_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + value_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string value = 2; + */ + public com.google.protobuf.ByteString + getValueBytes() { + java.lang.Object ref = value_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + value_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string value = 2; + */ + public Builder setValue( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + value_ = value; + onChanged(); + return this; + } + /** + * optional string value = 2; + */ + public Builder clearValue() { + bitField0_ = (bitField0_ & ~0x00000002); + value_ = getDefaultInstance().getValue(); + onChanged(); + return this; + } + /** + * optional string value = 2; + */ + public Builder setValueBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + value_ = value; + onChanged(); + return this; + } + + // optional string type = 3; + private java.lang.Object type_ = ""; + /** + * optional string type = 3; + */ + public boolean hasType() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional string type = 3; + */ + public java.lang.String getType() { + java.lang.Object ref = type_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + type_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string type = 3; + */ + public com.google.protobuf.ByteString + getTypeBytes() { + java.lang.Object ref = type_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + type_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string type = 3; + */ + public Builder setType( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + type_ = value; + onChanged(); + return this; + } + /** + * optional string type = 3; + */ + public Builder clearType() { + bitField0_ = (bitField0_ & ~0x00000004); + type_ = getDefaultInstance().getType(); + onChanged(); + return this; + } + /** + * optional string type = 3; + */ + public Builder setTypeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + type_ = value; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.Attribute) + } + + static { + defaultInstance = new Attribute(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.Attribute) + } + + public interface QNameOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required string value = 1; + /** + * required string value = 1; + */ + boolean hasValue(); + /** + * required string value = 1; + */ + java.lang.String getValue(); + /** + * required string value = 1; + */ + com.google.protobuf.ByteString + getValueBytes(); + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.QName} + */ + public static final class QName extends + com.google.protobuf.GeneratedMessage + implements QNameOrBuilder { + // Use QName.newBuilder() to construct. + private QName(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private QName(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final QName defaultInstance; + public static QName getDefaultInstance() { + return defaultInstance; + } + + public QName getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private QName( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + bitField0_ |= 0x00000001; + value_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_QName_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_QName_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.class, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public QName parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new QName(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // required string value = 1; + public static final int VALUE_FIELD_NUMBER = 1; + private java.lang.Object value_; + /** + * required string value = 1; + */ + public boolean hasValue() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string value = 1; + */ + public java.lang.String getValue() { + java.lang.Object ref = value_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + value_ = s; + } + return s; + } + } + /** + * required string value = 1; + */ + public com.google.protobuf.ByteString + getValueBytes() { + java.lang.Object ref = value_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + value_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private void initFields() { + value_ = ""; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasValue()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getValueBytes()); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getValueBytes()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.QName} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QNameOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_QName_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_QName_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.class, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.Builder.class); + } + + // Construct using org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + value_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_QName_descriptor; + } + + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName getDefaultInstanceForType() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.getDefaultInstance(); + } + + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName build() { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName buildPartial() { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName result = new org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.value_ = value_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName) { + return mergeFrom((org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName other) { + if (other == org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.getDefaultInstance()) return this; + if (other.hasValue()) { + bitField0_ |= 0x00000001; + value_ = other.value_; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasValue()) { + + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required string value = 1; + private java.lang.Object value_ = ""; + /** + * required string value = 1; + */ + public boolean hasValue() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string value = 1; + */ + public java.lang.String getValue() { + java.lang.Object ref = value_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + value_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string value = 1; + */ + public com.google.protobuf.ByteString + getValueBytes() { + java.lang.Object ref = value_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + value_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string value = 1; + */ + public Builder setValue( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + value_ = value; + onChanged(); + return this; + } + /** + * required string value = 1; + */ + public Builder clearValue() { + bitField0_ = (bitField0_ & ~0x00000001); + value_ = getDefaultInstance().getValue(); + onChanged(); + return this; + } + /** + * required string value = 1; + */ + public Builder setValueBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + value_ = value; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.QName) + } + + static { + defaultInstance = new QName(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.QName) + } + + public interface PathArgumentOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required string value = 1; + /** + * required string value = 1; + */ + boolean hasValue(); + /** + * required string value = 1; + */ + java.lang.String getValue(); + /** + * required string value = 1; + */ + com.google.protobuf.ByteString + getValueBytes(); + + // optional string type = 2; + /** + * optional string type = 2; + * + *
+     *NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates
+     * 
+ */ + boolean hasType(); + /** + * optional string type = 2; + * + *
+     *NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates
+     * 
+ */ + java.lang.String getType(); + /** + * optional string type = 2; + * + *
+     *NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates
+     * 
+ */ + com.google.protobuf.ByteString + getTypeBytes(); + + // optional .org.opendaylight.controller.mdsal.QName nodeType = 3; + /** + * optional .org.opendaylight.controller.mdsal.QName nodeType = 3; + */ + boolean hasNodeType(); + /** + * optional .org.opendaylight.controller.mdsal.QName nodeType = 3; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName getNodeType(); + /** + * optional .org.opendaylight.controller.mdsal.QName nodeType = 3; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QNameOrBuilder getNodeTypeOrBuilder(); + + // repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + java.util.List + getAttributesList(); + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute getAttributes(int index); + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + int getAttributesCount(); + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + java.util.List + getAttributesOrBuilderList(); + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder getAttributesOrBuilder( + int index); + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.PathArgument} + */ + public static final class PathArgument extends + com.google.protobuf.GeneratedMessage + implements PathArgumentOrBuilder { + // Use PathArgument.newBuilder() to construct. + private PathArgument(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private PathArgument(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final PathArgument defaultInstance; + public static PathArgument getDefaultInstance() { + return defaultInstance; + } + + public PathArgument getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private PathArgument( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + bitField0_ |= 0x00000001; + value_ = input.readBytes(); + break; + } + case 18: { + bitField0_ |= 0x00000002; + type_ = input.readBytes(); + break; + } + case 26: { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.Builder subBuilder = null; + if (((bitField0_ & 0x00000004) == 0x00000004)) { + subBuilder = nodeType_.toBuilder(); + } + nodeType_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(nodeType_); + nodeType_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000004; + break; + } + case 34: { + if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) { + attributes_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000008; + } + attributes_.add(input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.PARSER, extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000008) == 0x00000008)) { + attributes_ = java.util.Collections.unmodifiableList(attributes_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_PathArgument_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_PathArgument_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.class, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public PathArgument parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new PathArgument(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // required string value = 1; + public static final int VALUE_FIELD_NUMBER = 1; + private java.lang.Object value_; + /** + * required string value = 1; + */ + public boolean hasValue() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string value = 1; + */ + public java.lang.String getValue() { + java.lang.Object ref = value_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + value_ = s; + } + return s; + } + } + /** + * required string value = 1; + */ + public com.google.protobuf.ByteString + getValueBytes() { + java.lang.Object ref = value_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + value_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // optional string type = 2; + public static final int TYPE_FIELD_NUMBER = 2; + private java.lang.Object type_; + /** + * optional string type = 2; + * + *
+     *NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates
+     * 
+ */ + public boolean hasType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional string type = 2; + * + *
+     *NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates
+     * 
+ */ + public java.lang.String getType() { + java.lang.Object ref = type_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + type_ = s; + } + return s; + } + } + /** + * optional string type = 2; + * + *
+     *NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates
+     * 
+ */ + public com.google.protobuf.ByteString + getTypeBytes() { + java.lang.Object ref = type_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + type_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // optional .org.opendaylight.controller.mdsal.QName nodeType = 3; + public static final int NODETYPE_FIELD_NUMBER = 3; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName nodeType_; + /** + * optional .org.opendaylight.controller.mdsal.QName nodeType = 3; + */ + public boolean hasNodeType() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional .org.opendaylight.controller.mdsal.QName nodeType = 3; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName getNodeType() { + return nodeType_; + } + /** + * optional .org.opendaylight.controller.mdsal.QName nodeType = 3; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QNameOrBuilder getNodeTypeOrBuilder() { + return nodeType_; + } + + // repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + public static final int ATTRIBUTES_FIELD_NUMBER = 4; + private java.util.List attributes_; + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + public java.util.List getAttributesList() { + return attributes_; + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + public java.util.List + getAttributesOrBuilderList() { + return attributes_; + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + public int getAttributesCount() { + return attributes_.size(); + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute getAttributes(int index) { + return attributes_.get(index); + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder getAttributesOrBuilder( + int index) { + return attributes_.get(index); + } + + private void initFields() { + value_ = ""; + type_ = ""; + nodeType_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.getDefaultInstance(); + attributes_ = java.util.Collections.emptyList(); + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasValue()) { + memoizedIsInitialized = 0; + return false; + } + if (hasNodeType()) { + if (!getNodeType().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + for (int i = 0; i < getAttributesCount(); i++) { + if (!getAttributes(i).isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getValueBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeBytes(2, getTypeBytes()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeMessage(3, nodeType_); + } + for (int i = 0; i < attributes_.size(); i++) { + output.writeMessage(4, attributes_.get(i)); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getValueBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, getTypeBytes()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, nodeType_); + } + for (int i = 0; i < attributes_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, attributes_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.PathArgument} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_PathArgument_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_PathArgument_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.class, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.Builder.class); + } + + // Construct using org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getNodeTypeFieldBuilder(); + getAttributesFieldBuilder(); + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + value_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + type_ = ""; + bitField0_ = (bitField0_ & ~0x00000002); + if (nodeTypeBuilder_ == null) { + nodeType_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.getDefaultInstance(); + } else { + nodeTypeBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000004); + if (attributesBuilder_ == null) { + attributes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + } else { + attributesBuilder_.clear(); + } + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_PathArgument_descriptor; + } + + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument getDefaultInstanceForType() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.getDefaultInstance(); + } + + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument build() { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument buildPartial() { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument result = new org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.value_ = value_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.type_ = type_; + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000004; + } + if (nodeTypeBuilder_ == null) { + result.nodeType_ = nodeType_; + } else { + result.nodeType_ = nodeTypeBuilder_.build(); + } + if (attributesBuilder_ == null) { + if (((bitField0_ & 0x00000008) == 0x00000008)) { + attributes_ = java.util.Collections.unmodifiableList(attributes_); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.attributes_ = attributes_; + } else { + result.attributes_ = attributesBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument) { + return mergeFrom((org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument other) { + if (other == org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.getDefaultInstance()) return this; + if (other.hasValue()) { + bitField0_ |= 0x00000001; + value_ = other.value_; + onChanged(); + } + if (other.hasType()) { + bitField0_ |= 0x00000002; + type_ = other.type_; + onChanged(); + } + if (other.hasNodeType()) { + mergeNodeType(other.getNodeType()); + } + if (attributesBuilder_ == null) { + if (!other.attributes_.isEmpty()) { + if (attributes_.isEmpty()) { + attributes_ = other.attributes_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensureAttributesIsMutable(); + attributes_.addAll(other.attributes_); + } + onChanged(); + } + } else { + if (!other.attributes_.isEmpty()) { + if (attributesBuilder_.isEmpty()) { + attributesBuilder_.dispose(); + attributesBuilder_ = null; + attributes_ = other.attributes_; + bitField0_ = (bitField0_ & ~0x00000008); + attributesBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getAttributesFieldBuilder() : null; + } else { + attributesBuilder_.addAllMessages(other.attributes_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasValue()) { + + return false; + } + if (hasNodeType()) { + if (!getNodeType().isInitialized()) { + + return false; + } + } + for (int i = 0; i < getAttributesCount(); i++) { + if (!getAttributes(i).isInitialized()) { + + return false; + } + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required string value = 1; + private java.lang.Object value_ = ""; + /** + * required string value = 1; + */ + public boolean hasValue() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string value = 1; + */ + public java.lang.String getValue() { + java.lang.Object ref = value_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + value_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string value = 1; + */ + public com.google.protobuf.ByteString + getValueBytes() { + java.lang.Object ref = value_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + value_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string value = 1; + */ + public Builder setValue( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + value_ = value; + onChanged(); + return this; + } + /** + * required string value = 1; + */ + public Builder clearValue() { + bitField0_ = (bitField0_ & ~0x00000001); + value_ = getDefaultInstance().getValue(); + onChanged(); + return this; + } + /** + * required string value = 1; + */ + public Builder setValueBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + value_ = value; + onChanged(); + return this; + } + + // optional string type = 2; + private java.lang.Object type_ = ""; + /** + * optional string type = 2; + * + *
+       *NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates
+       * 
+ */ + public boolean hasType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional string type = 2; + * + *
+       *NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates
+       * 
+ */ + public java.lang.String getType() { + java.lang.Object ref = type_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + type_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string type = 2; + * + *
+       *NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates
+       * 
+ */ + public com.google.protobuf.ByteString + getTypeBytes() { + java.lang.Object ref = type_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + type_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string type = 2; + * + *
+       *NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates
+       * 
+ */ + public Builder setType( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + type_ = value; + onChanged(); + return this; + } + /** + * optional string type = 2; + * + *
+       *NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates
+       * 
+ */ + public Builder clearType() { + bitField0_ = (bitField0_ & ~0x00000002); + type_ = getDefaultInstance().getType(); + onChanged(); + return this; + } + /** + * optional string type = 2; + * + *
+       *NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates
+       * 
+ */ + public Builder setTypeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + type_ = value; + onChanged(); + return this; + } + + // optional .org.opendaylight.controller.mdsal.QName nodeType = 3; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName nodeType_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.getDefaultInstance(); + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QNameOrBuilder> nodeTypeBuilder_; + /** + * optional .org.opendaylight.controller.mdsal.QName nodeType = 3; + */ + public boolean hasNodeType() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional .org.opendaylight.controller.mdsal.QName nodeType = 3; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName getNodeType() { + if (nodeTypeBuilder_ == null) { + return nodeType_; + } else { + return nodeTypeBuilder_.getMessage(); + } + } + /** + * optional .org.opendaylight.controller.mdsal.QName nodeType = 3; + */ + public Builder setNodeType(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName value) { + if (nodeTypeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + nodeType_ = value; + onChanged(); + } else { + nodeTypeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.QName nodeType = 3; + */ + public Builder setNodeType( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.Builder builderForValue) { + if (nodeTypeBuilder_ == null) { + nodeType_ = builderForValue.build(); + onChanged(); + } else { + nodeTypeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.QName nodeType = 3; + */ + public Builder mergeNodeType(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName value) { + if (nodeTypeBuilder_ == null) { + if (((bitField0_ & 0x00000004) == 0x00000004) && + nodeType_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.getDefaultInstance()) { + nodeType_ = + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.newBuilder(nodeType_).mergeFrom(value).buildPartial(); + } else { + nodeType_ = value; + } + onChanged(); + } else { + nodeTypeBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000004; + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.QName nodeType = 3; + */ + public Builder clearNodeType() { + if (nodeTypeBuilder_ == null) { + nodeType_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.getDefaultInstance(); + onChanged(); + } else { + nodeTypeBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000004); + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.QName nodeType = 3; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.Builder getNodeTypeBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getNodeTypeFieldBuilder().getBuilder(); + } + /** + * optional .org.opendaylight.controller.mdsal.QName nodeType = 3; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QNameOrBuilder getNodeTypeOrBuilder() { + if (nodeTypeBuilder_ != null) { + return nodeTypeBuilder_.getMessageOrBuilder(); + } else { + return nodeType_; + } + } + /** + * optional .org.opendaylight.controller.mdsal.QName nodeType = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QNameOrBuilder> + getNodeTypeFieldBuilder() { + if (nodeTypeBuilder_ == null) { + nodeTypeBuilder_ = new com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QNameOrBuilder>( + nodeType_, + getParentForChildren(), + isClean()); + nodeType_ = null; + } + return nodeTypeBuilder_; + } + + // repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + private java.util.List attributes_ = + java.util.Collections.emptyList(); + private void ensureAttributesIsMutable() { + if (!((bitField0_ & 0x00000008) == 0x00000008)) { + attributes_ = new java.util.ArrayList(attributes_); + bitField0_ |= 0x00000008; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder> attributesBuilder_; + + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + public java.util.List getAttributesList() { + if (attributesBuilder_ == null) { + return java.util.Collections.unmodifiableList(attributes_); + } else { + return attributesBuilder_.getMessageList(); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + public int getAttributesCount() { + if (attributesBuilder_ == null) { + return attributes_.size(); + } else { + return attributesBuilder_.getCount(); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute getAttributes(int index) { + if (attributesBuilder_ == null) { + return attributes_.get(index); + } else { + return attributesBuilder_.getMessage(index); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + public Builder setAttributes( + int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute value) { + if (attributesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAttributesIsMutable(); + attributes_.set(index, value); + onChanged(); + } else { + attributesBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + public Builder setAttributes( + int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder builderForValue) { + if (attributesBuilder_ == null) { + ensureAttributesIsMutable(); + attributes_.set(index, builderForValue.build()); + onChanged(); + } else { + attributesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + public Builder addAttributes(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute value) { + if (attributesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAttributesIsMutable(); + attributes_.add(value); + onChanged(); + } else { + attributesBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + public Builder addAttributes( + int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute value) { + if (attributesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAttributesIsMutable(); + attributes_.add(index, value); + onChanged(); + } else { + attributesBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + public Builder addAttributes( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder builderForValue) { + if (attributesBuilder_ == null) { + ensureAttributesIsMutable(); + attributes_.add(builderForValue.build()); + onChanged(); + } else { + attributesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + public Builder addAttributes( + int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder builderForValue) { + if (attributesBuilder_ == null) { + ensureAttributesIsMutable(); + attributes_.add(index, builderForValue.build()); + onChanged(); + } else { + attributesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + public Builder addAllAttributes( + java.lang.Iterable values) { + if (attributesBuilder_ == null) { + ensureAttributesIsMutable(); + super.addAll(values, attributes_); + onChanged(); + } else { + attributesBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + public Builder clearAttributes() { + if (attributesBuilder_ == null) { + attributes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + } else { + attributesBuilder_.clear(); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + public Builder removeAttributes(int index) { + if (attributesBuilder_ == null) { + ensureAttributesIsMutable(); + attributes_.remove(index); + onChanged(); + } else { + attributesBuilder_.remove(index); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder getAttributesBuilder( + int index) { + return getAttributesFieldBuilder().getBuilder(index); + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder getAttributesOrBuilder( + int index) { + if (attributesBuilder_ == null) { + return attributes_.get(index); } else { + return attributesBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + public java.util.List + getAttributesOrBuilderList() { + if (attributesBuilder_ != null) { + return attributesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(attributes_); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder addAttributesBuilder() { + return getAttributesFieldBuilder().addBuilder( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.getDefaultInstance()); + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder addAttributesBuilder( + int index) { + return getAttributesFieldBuilder().addBuilder( + index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.getDefaultInstance()); + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; + */ + public java.util.List + getAttributesBuilderList() { + return getAttributesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder> + getAttributesFieldBuilder() { + if (attributesBuilder_ == null) { + attributesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder>( + attributes_, + ((bitField0_ & 0x00000008) == 0x00000008), + getParentForChildren(), + isClean()); + attributes_ = null; + } + return attributesBuilder_; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.PathArgument) + } + + static { + defaultInstance = new PathArgument(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.PathArgument) + } + + public interface InstanceIdentifierOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + java.util.List + getArgumentsList(); + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument getArguments(int index); + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + int getArgumentsCount(); + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + java.util.List + getArgumentsOrBuilderList(); + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentOrBuilder getArgumentsOrBuilder( + int index); + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.InstanceIdentifier} + */ + public static final class InstanceIdentifier extends + com.google.protobuf.GeneratedMessage + implements InstanceIdentifierOrBuilder { + // Use InstanceIdentifier.newBuilder() to construct. + private InstanceIdentifier(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private InstanceIdentifier(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final InstanceIdentifier defaultInstance; + public static InstanceIdentifier getDefaultInstance() { + return defaultInstance; + } + + public InstanceIdentifier getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private InstanceIdentifier( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + arguments_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + arguments_.add(input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.PARSER, extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + arguments_ = java.util.Collections.unmodifiableList(arguments_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_InstanceIdentifier_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_InstanceIdentifier_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.class, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public InstanceIdentifier parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new InstanceIdentifier(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + // repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + public static final int ARGUMENTS_FIELD_NUMBER = 1; + private java.util.List arguments_; + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + public java.util.List getArgumentsList() { + return arguments_; + } + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + public java.util.List + getArgumentsOrBuilderList() { + return arguments_; + } + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + public int getArgumentsCount() { + return arguments_.size(); + } + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument getArguments(int index) { + return arguments_.get(index); + } + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentOrBuilder getArgumentsOrBuilder( + int index) { + return arguments_.get(index); + } + + private void initFields() { + arguments_ = java.util.Collections.emptyList(); + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + for (int i = 0; i < getArgumentsCount(); i++) { + if (!getArguments(i).isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + for (int i = 0; i < arguments_.size(); i++) { + output.writeMessage(1, arguments_.get(i)); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < arguments_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, arguments_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.InstanceIdentifier} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_InstanceIdentifier_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_InstanceIdentifier_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.class, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder.class); + } + + // Construct using org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getArgumentsFieldBuilder(); + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + if (argumentsBuilder_ == null) { + arguments_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + argumentsBuilder_.clear(); + } + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_InstanceIdentifier_descriptor; + } + + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getDefaultInstanceForType() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + } + + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier build() { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier buildPartial() { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier result = new org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier(this); + int from_bitField0_ = bitField0_; + if (argumentsBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + arguments_ = java.util.Collections.unmodifiableList(arguments_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.arguments_ = arguments_; + } else { + result.arguments_ = argumentsBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier) { + return mergeFrom((org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier other) { + if (other == org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance()) return this; + if (argumentsBuilder_ == null) { + if (!other.arguments_.isEmpty()) { + if (arguments_.isEmpty()) { + arguments_ = other.arguments_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureArgumentsIsMutable(); + arguments_.addAll(other.arguments_); + } + onChanged(); + } + } else { + if (!other.arguments_.isEmpty()) { + if (argumentsBuilder_.isEmpty()) { + argumentsBuilder_.dispose(); + argumentsBuilder_ = null; + arguments_ = other.arguments_; + bitField0_ = (bitField0_ & ~0x00000001); + argumentsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getArgumentsFieldBuilder() : null; + } else { + argumentsBuilder_.addAllMessages(other.arguments_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + for (int i = 0; i < getArgumentsCount(); i++) { + if (!getArguments(i).isInitialized()) { + + return false; + } + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + private java.util.List arguments_ = + java.util.Collections.emptyList(); + private void ensureArgumentsIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + arguments_ = new java.util.ArrayList(arguments_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentOrBuilder> argumentsBuilder_; + + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + public java.util.List getArgumentsList() { + if (argumentsBuilder_ == null) { + return java.util.Collections.unmodifiableList(arguments_); + } else { + return argumentsBuilder_.getMessageList(); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + public int getArgumentsCount() { + if (argumentsBuilder_ == null) { + return arguments_.size(); + } else { + return argumentsBuilder_.getCount(); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument getArguments(int index) { + if (argumentsBuilder_ == null) { + return arguments_.get(index); + } else { + return argumentsBuilder_.getMessage(index); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + public Builder setArguments( + int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument value) { + if (argumentsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureArgumentsIsMutable(); + arguments_.set(index, value); + onChanged(); + } else { + argumentsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + public Builder setArguments( + int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.Builder builderForValue) { + if (argumentsBuilder_ == null) { + ensureArgumentsIsMutable(); + arguments_.set(index, builderForValue.build()); + onChanged(); + } else { + argumentsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + public Builder addArguments(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument value) { + if (argumentsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureArgumentsIsMutable(); + arguments_.add(value); + onChanged(); + } else { + argumentsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + public Builder addArguments( + int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument value) { + if (argumentsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureArgumentsIsMutable(); + arguments_.add(index, value); + onChanged(); + } else { + argumentsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + public Builder addArguments( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.Builder builderForValue) { + if (argumentsBuilder_ == null) { + ensureArgumentsIsMutable(); + arguments_.add(builderForValue.build()); + onChanged(); + } else { + argumentsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + public Builder addArguments( + int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.Builder builderForValue) { + if (argumentsBuilder_ == null) { + ensureArgumentsIsMutable(); + arguments_.add(index, builderForValue.build()); + onChanged(); + } else { + argumentsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + public Builder addAllArguments( + java.lang.Iterable values) { + if (argumentsBuilder_ == null) { + ensureArgumentsIsMutable(); + super.addAll(values, arguments_); + onChanged(); + } else { + argumentsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + public Builder clearArguments() { + if (argumentsBuilder_ == null) { + arguments_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + argumentsBuilder_.clear(); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + public Builder removeArguments(int index) { + if (argumentsBuilder_ == null) { + ensureArgumentsIsMutable(); + arguments_.remove(index); + onChanged(); + } else { + argumentsBuilder_.remove(index); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.Builder getArgumentsBuilder( + int index) { + return getArgumentsFieldBuilder().getBuilder(index); + } + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentOrBuilder getArgumentsOrBuilder( + int index) { + if (argumentsBuilder_ == null) { + return arguments_.get(index); } else { + return argumentsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + public java.util.List + getArgumentsOrBuilderList() { + if (argumentsBuilder_ != null) { + return argumentsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(arguments_); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.Builder addArgumentsBuilder() { + return getArgumentsFieldBuilder().addBuilder( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.getDefaultInstance()); + } + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.Builder addArgumentsBuilder( + int index) { + return getArgumentsFieldBuilder().addBuilder( + index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.getDefaultInstance()); + } + /** + * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; + */ + public java.util.List + getArgumentsBuilderList() { + return getArgumentsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentOrBuilder> + getArgumentsFieldBuilder() { + if (argumentsBuilder_ == null) { + argumentsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentOrBuilder>( + arguments_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + arguments_ = null; + } + return argumentsBuilder_; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.InstanceIdentifier) + } + + static { + defaultInstance = new InstanceIdentifier(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.InstanceIdentifier) + } + + public interface NodeOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // optional string path = 1; + /** + * optional string path = 1; + */ + boolean hasPath(); + /** + * optional string path = 1; + */ + java.lang.String getPath(); + /** + * optional string path = 1; + */ + com.google.protobuf.ByteString + getPathBytes(); + + // optional string type = 2; + /** + * optional string type = 2; + */ + boolean hasType(); + /** + * optional string type = 2; + */ + java.lang.String getType(); + /** + * optional string type = 2; + */ + com.google.protobuf.ByteString + getTypeBytes(); + + // repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + java.util.List + getAttributesList(); + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute getAttributes(int index); + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + int getAttributesCount(); + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + java.util.List + getAttributesOrBuilderList(); + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder getAttributesOrBuilder( + int index); + + // repeated .org.opendaylight.controller.mdsal.Node child = 4; + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + java.util.List + getChildList(); + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getChild(int index); + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + int getChildCount(); + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + java.util.List + getChildOrBuilderList(); + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getChildOrBuilder( + int index); + + // optional string value = 5; + /** + * optional string value = 5; + */ + boolean hasValue(); + /** + * optional string value = 5; + */ + java.lang.String getValue(); + /** + * optional string value = 5; + */ + com.google.protobuf.ByteString + getValueBytes(); + + // optional string valueType = 6; + /** + * optional string valueType = 6; + */ + boolean hasValueType(); + /** + * optional string valueType = 6; + */ + java.lang.String getValueType(); + /** + * optional string valueType = 6; + */ + com.google.protobuf.ByteString + getValueTypeBytes(); + + // repeated string bitsValue = 7; + /** + * repeated string bitsValue = 7; + */ + java.util.List + getBitsValueList(); + /** + * repeated string bitsValue = 7; + */ + int getBitsValueCount(); + /** + * repeated string bitsValue = 7; + */ + java.lang.String getBitsValue(int index); + /** + * repeated string bitsValue = 7; + */ + com.google.protobuf.ByteString + getBitsValueBytes(int index); + + // optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8; + /** + * optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8; + */ + boolean hasInstanceIdentifierValue(); + /** + * optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierValue(); + /** + * optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierValueOrBuilder(); + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.Node} + */ + public static final class Node extends + com.google.protobuf.GeneratedMessage + implements NodeOrBuilder { + // Use Node.newBuilder() to construct. + private Node(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private Node(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final Node defaultInstance; + public static Node getDefaultInstance() { + return defaultInstance; + } + + public Node getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Node( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + bitField0_ |= 0x00000001; + path_ = input.readBytes(); + break; + } + case 18: { + bitField0_ |= 0x00000002; + type_ = input.readBytes(); + break; + } + case 26: { + if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + attributes_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000004; + } + attributes_.add(input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.PARSER, extensionRegistry)); + break; + } + case 34: { + if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) { + child_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000008; + } + child_.add(input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.PARSER, extensionRegistry)); + break; + } + case 42: { + bitField0_ |= 0x00000004; + value_ = input.readBytes(); + break; + } + case 50: { + bitField0_ |= 0x00000008; + valueType_ = input.readBytes(); + break; + } + case 58: { + if (!((mutable_bitField0_ & 0x00000040) == 0x00000040)) { + bitsValue_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000040; + } + bitsValue_.add(input.readBytes()); + break; + } + case 66: { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder subBuilder = null; + if (((bitField0_ & 0x00000010) == 0x00000010)) { + subBuilder = instanceIdentifierValue_.toBuilder(); + } + instanceIdentifierValue_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(instanceIdentifierValue_); + instanceIdentifierValue_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000010; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + attributes_ = java.util.Collections.unmodifiableList(attributes_); + } + if (((mutable_bitField0_ & 0x00000008) == 0x00000008)) { + child_ = java.util.Collections.unmodifiableList(child_); + } + if (((mutable_bitField0_ & 0x00000040) == 0x00000040)) { + bitsValue_ = new com.google.protobuf.UnmodifiableLazyStringList(bitsValue_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_Node_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_Node_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.class, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public Node parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Node(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // optional string path = 1; + public static final int PATH_FIELD_NUMBER = 1; + private java.lang.Object path_; + /** + * optional string path = 1; + */ + public boolean hasPath() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional string path = 1; + */ + public java.lang.String getPath() { + java.lang.Object ref = path_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + path_ = s; + } + return s; + } + } + /** + * optional string path = 1; + */ + public com.google.protobuf.ByteString + getPathBytes() { + java.lang.Object ref = path_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + path_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // optional string type = 2; + public static final int TYPE_FIELD_NUMBER = 2; + private java.lang.Object type_; + /** + * optional string type = 2; + */ + public boolean hasType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional string type = 2; + */ + public java.lang.String getType() { + java.lang.Object ref = type_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + type_ = s; + } + return s; + } + } + /** + * optional string type = 2; + */ + public com.google.protobuf.ByteString + getTypeBytes() { + java.lang.Object ref = type_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + type_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + public static final int ATTRIBUTES_FIELD_NUMBER = 3; + private java.util.List attributes_; + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + public java.util.List getAttributesList() { + return attributes_; + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + public java.util.List + getAttributesOrBuilderList() { + return attributes_; + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + public int getAttributesCount() { + return attributes_.size(); + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute getAttributes(int index) { + return attributes_.get(index); + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder getAttributesOrBuilder( + int index) { + return attributes_.get(index); + } + + // repeated .org.opendaylight.controller.mdsal.Node child = 4; + public static final int CHILD_FIELD_NUMBER = 4; + private java.util.List child_; + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + public java.util.List getChildList() { + return child_; + } + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + public java.util.List + getChildOrBuilderList() { + return child_; + } + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + public int getChildCount() { + return child_.size(); + } + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getChild(int index) { + return child_.get(index); + } + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getChildOrBuilder( + int index) { + return child_.get(index); + } + + // optional string value = 5; + public static final int VALUE_FIELD_NUMBER = 5; + private java.lang.Object value_; + /** + * optional string value = 5; + */ + public boolean hasValue() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional string value = 5; + */ + public java.lang.String getValue() { + java.lang.Object ref = value_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + value_ = s; + } + return s; + } + } + /** + * optional string value = 5; + */ + public com.google.protobuf.ByteString + getValueBytes() { + java.lang.Object ref = value_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + value_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // optional string valueType = 6; + public static final int VALUETYPE_FIELD_NUMBER = 6; + private java.lang.Object valueType_; + /** + * optional string valueType = 6; + */ + public boolean hasValueType() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * optional string valueType = 6; + */ + public java.lang.String getValueType() { + java.lang.Object ref = valueType_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + valueType_ = s; + } + return s; + } + } + /** + * optional string valueType = 6; + */ + public com.google.protobuf.ByteString + getValueTypeBytes() { + java.lang.Object ref = valueType_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + valueType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // repeated string bitsValue = 7; + public static final int BITSVALUE_FIELD_NUMBER = 7; + private com.google.protobuf.LazyStringList bitsValue_; + /** + * repeated string bitsValue = 7; + */ + public java.util.List + getBitsValueList() { + return bitsValue_; + } + /** + * repeated string bitsValue = 7; + */ + public int getBitsValueCount() { + return bitsValue_.size(); + } + /** + * repeated string bitsValue = 7; + */ + public java.lang.String getBitsValue(int index) { + return bitsValue_.get(index); + } + /** + * repeated string bitsValue = 7; + */ + public com.google.protobuf.ByteString + getBitsValueBytes(int index) { + return bitsValue_.getByteString(index); + } + + // optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8; + public static final int INSTANCEIDENTIFIERVALUE_FIELD_NUMBER = 8; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier instanceIdentifierValue_; + /** + * optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8; + */ + public boolean hasInstanceIdentifierValue() { + return ((bitField0_ & 0x00000010) == 0x00000010); + } + /** + * optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierValue() { + return instanceIdentifierValue_; + } + /** + * optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierValueOrBuilder() { + return instanceIdentifierValue_; + } + + private void initFields() { + path_ = ""; + type_ = ""; + attributes_ = java.util.Collections.emptyList(); + child_ = java.util.Collections.emptyList(); + value_ = ""; + valueType_ = ""; + bitsValue_ = com.google.protobuf.LazyStringArrayList.EMPTY; + instanceIdentifierValue_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + for (int i = 0; i < getAttributesCount(); i++) { + if (!getAttributes(i).isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + for (int i = 0; i < getChildCount(); i++) { + if (!getChild(i).isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + if (hasInstanceIdentifierValue()) { + if (!getInstanceIdentifierValue().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getPathBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeBytes(2, getTypeBytes()); + } + for (int i = 0; i < attributes_.size(); i++) { + output.writeMessage(3, attributes_.get(i)); + } + for (int i = 0; i < child_.size(); i++) { + output.writeMessage(4, child_.get(i)); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeBytes(5, getValueBytes()); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + output.writeBytes(6, getValueTypeBytes()); + } + for (int i = 0; i < bitsValue_.size(); i++) { + output.writeBytes(7, bitsValue_.getByteString(i)); + } + if (((bitField0_ & 0x00000010) == 0x00000010)) { + output.writeMessage(8, instanceIdentifierValue_); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getPathBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, getTypeBytes()); + } + for (int i = 0; i < attributes_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, attributes_.get(i)); + } + for (int i = 0; i < child_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, child_.get(i)); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(5, getValueBytes()); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(6, getValueTypeBytes()); + } + { + int dataSize = 0; + for (int i = 0; i < bitsValue_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeBytesSizeNoTag(bitsValue_.getByteString(i)); + } + size += dataSize; + size += 1 * getBitsValueList().size(); + } + if (((bitField0_ & 0x00000010) == 0x00000010)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(8, instanceIdentifierValue_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.Node} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_Node_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_Node_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.class, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder.class); + } + + // Construct using org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getAttributesFieldBuilder(); + getChildFieldBuilder(); + getInstanceIdentifierValueFieldBuilder(); + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + path_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + type_ = ""; + bitField0_ = (bitField0_ & ~0x00000002); + if (attributesBuilder_ == null) { + attributes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + } else { + attributesBuilder_.clear(); + } + if (childBuilder_ == null) { + child_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + } else { + childBuilder_.clear(); + } + value_ = ""; + bitField0_ = (bitField0_ & ~0x00000010); + valueType_ = ""; + bitField0_ = (bitField0_ & ~0x00000020); + bitsValue_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000040); + if (instanceIdentifierValueBuilder_ == null) { + instanceIdentifierValue_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + } else { + instanceIdentifierValueBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000080); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_Node_descriptor; + } + + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getDefaultInstanceForType() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); + } + + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node build() { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node buildPartial() { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node result = new org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.path_ = path_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.type_ = type_; + if (attributesBuilder_ == null) { + if (((bitField0_ & 0x00000004) == 0x00000004)) { + attributes_ = java.util.Collections.unmodifiableList(attributes_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.attributes_ = attributes_; + } else { + result.attributes_ = attributesBuilder_.build(); + } + if (childBuilder_ == null) { + if (((bitField0_ & 0x00000008) == 0x00000008)) { + child_ = java.util.Collections.unmodifiableList(child_); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.child_ = child_; + } else { + result.child_ = childBuilder_.build(); + } + if (((from_bitField0_ & 0x00000010) == 0x00000010)) { + to_bitField0_ |= 0x00000004; + } + result.value_ = value_; + if (((from_bitField0_ & 0x00000020) == 0x00000020)) { + to_bitField0_ |= 0x00000008; + } + result.valueType_ = valueType_; + if (((bitField0_ & 0x00000040) == 0x00000040)) { + bitsValue_ = new com.google.protobuf.UnmodifiableLazyStringList( + bitsValue_); + bitField0_ = (bitField0_ & ~0x00000040); + } + result.bitsValue_ = bitsValue_; + if (((from_bitField0_ & 0x00000080) == 0x00000080)) { + to_bitField0_ |= 0x00000010; + } + if (instanceIdentifierValueBuilder_ == null) { + result.instanceIdentifierValue_ = instanceIdentifierValue_; + } else { + result.instanceIdentifierValue_ = instanceIdentifierValueBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node) { + return mergeFrom((org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node other) { + if (other == org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance()) return this; + if (other.hasPath()) { + bitField0_ |= 0x00000001; + path_ = other.path_; + onChanged(); + } + if (other.hasType()) { + bitField0_ |= 0x00000002; + type_ = other.type_; + onChanged(); + } + if (attributesBuilder_ == null) { + if (!other.attributes_.isEmpty()) { + if (attributes_.isEmpty()) { + attributes_ = other.attributes_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensureAttributesIsMutable(); + attributes_.addAll(other.attributes_); + } + onChanged(); + } + } else { + if (!other.attributes_.isEmpty()) { + if (attributesBuilder_.isEmpty()) { + attributesBuilder_.dispose(); + attributesBuilder_ = null; + attributes_ = other.attributes_; + bitField0_ = (bitField0_ & ~0x00000004); + attributesBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getAttributesFieldBuilder() : null; + } else { + attributesBuilder_.addAllMessages(other.attributes_); + } + } + } + if (childBuilder_ == null) { + if (!other.child_.isEmpty()) { + if (child_.isEmpty()) { + child_ = other.child_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensureChildIsMutable(); + child_.addAll(other.child_); + } + onChanged(); + } + } else { + if (!other.child_.isEmpty()) { + if (childBuilder_.isEmpty()) { + childBuilder_.dispose(); + childBuilder_ = null; + child_ = other.child_; + bitField0_ = (bitField0_ & ~0x00000008); + childBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getChildFieldBuilder() : null; + } else { + childBuilder_.addAllMessages(other.child_); + } + } + } + if (other.hasValue()) { + bitField0_ |= 0x00000010; + value_ = other.value_; + onChanged(); + } + if (other.hasValueType()) { + bitField0_ |= 0x00000020; + valueType_ = other.valueType_; + onChanged(); + } + if (!other.bitsValue_.isEmpty()) { + if (bitsValue_.isEmpty()) { + bitsValue_ = other.bitsValue_; + bitField0_ = (bitField0_ & ~0x00000040); + } else { + ensureBitsValueIsMutable(); + bitsValue_.addAll(other.bitsValue_); + } + onChanged(); + } + if (other.hasInstanceIdentifierValue()) { + mergeInstanceIdentifierValue(other.getInstanceIdentifierValue()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + for (int i = 0; i < getAttributesCount(); i++) { + if (!getAttributes(i).isInitialized()) { + + return false; + } + } + for (int i = 0; i < getChildCount(); i++) { + if (!getChild(i).isInitialized()) { + + return false; + } + } + if (hasInstanceIdentifierValue()) { + if (!getInstanceIdentifierValue().isInitialized()) { + + return false; + } + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // optional string path = 1; + private java.lang.Object path_ = ""; + /** + * optional string path = 1; + */ + public boolean hasPath() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional string path = 1; + */ + public java.lang.String getPath() { + java.lang.Object ref = path_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + path_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string path = 1; + */ + public com.google.protobuf.ByteString + getPathBytes() { + java.lang.Object ref = path_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + path_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string path = 1; + */ + public Builder setPath( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + path_ = value; + onChanged(); + return this; + } + /** + * optional string path = 1; + */ + public Builder clearPath() { + bitField0_ = (bitField0_ & ~0x00000001); + path_ = getDefaultInstance().getPath(); + onChanged(); + return this; + } + /** + * optional string path = 1; + */ + public Builder setPathBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + path_ = value; + onChanged(); + return this; + } + + // optional string type = 2; + private java.lang.Object type_ = ""; + /** + * optional string type = 2; + */ + public boolean hasType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional string type = 2; + */ + public java.lang.String getType() { + java.lang.Object ref = type_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + type_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string type = 2; + */ + public com.google.protobuf.ByteString + getTypeBytes() { + java.lang.Object ref = type_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + type_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string type = 2; + */ + public Builder setType( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + type_ = value; + onChanged(); + return this; + } + /** + * optional string type = 2; + */ + public Builder clearType() { + bitField0_ = (bitField0_ & ~0x00000002); + type_ = getDefaultInstance().getType(); + onChanged(); + return this; + } + /** + * optional string type = 2; + */ + public Builder setTypeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + type_ = value; + onChanged(); + return this; + } + + // repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + private java.util.List attributes_ = + java.util.Collections.emptyList(); + private void ensureAttributesIsMutable() { + if (!((bitField0_ & 0x00000004) == 0x00000004)) { + attributes_ = new java.util.ArrayList(attributes_); + bitField0_ |= 0x00000004; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder> attributesBuilder_; + + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + public java.util.List getAttributesList() { + if (attributesBuilder_ == null) { + return java.util.Collections.unmodifiableList(attributes_); + } else { + return attributesBuilder_.getMessageList(); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + public int getAttributesCount() { + if (attributesBuilder_ == null) { + return attributes_.size(); + } else { + return attributesBuilder_.getCount(); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute getAttributes(int index) { + if (attributesBuilder_ == null) { + return attributes_.get(index); + } else { + return attributesBuilder_.getMessage(index); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + public Builder setAttributes( + int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute value) { + if (attributesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAttributesIsMutable(); + attributes_.set(index, value); + onChanged(); + } else { + attributesBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + public Builder setAttributes( + int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder builderForValue) { + if (attributesBuilder_ == null) { + ensureAttributesIsMutable(); + attributes_.set(index, builderForValue.build()); + onChanged(); + } else { + attributesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + public Builder addAttributes(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute value) { + if (attributesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAttributesIsMutable(); + attributes_.add(value); + onChanged(); + } else { + attributesBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + public Builder addAttributes( + int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute value) { + if (attributesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAttributesIsMutable(); + attributes_.add(index, value); + onChanged(); + } else { + attributesBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + public Builder addAttributes( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder builderForValue) { + if (attributesBuilder_ == null) { + ensureAttributesIsMutable(); + attributes_.add(builderForValue.build()); + onChanged(); + } else { + attributesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + public Builder addAttributes( + int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder builderForValue) { + if (attributesBuilder_ == null) { + ensureAttributesIsMutable(); + attributes_.add(index, builderForValue.build()); + onChanged(); + } else { + attributesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + public Builder addAllAttributes( + java.lang.Iterable values) { + if (attributesBuilder_ == null) { + ensureAttributesIsMutable(); + super.addAll(values, attributes_); + onChanged(); + } else { + attributesBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + public Builder clearAttributes() { + if (attributesBuilder_ == null) { + attributes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + attributesBuilder_.clear(); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + public Builder removeAttributes(int index) { + if (attributesBuilder_ == null) { + ensureAttributesIsMutable(); + attributes_.remove(index); + onChanged(); + } else { + attributesBuilder_.remove(index); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder getAttributesBuilder( + int index) { + return getAttributesFieldBuilder().getBuilder(index); + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder getAttributesOrBuilder( + int index) { + if (attributesBuilder_ == null) { + return attributes_.get(index); } else { + return attributesBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + public java.util.List + getAttributesOrBuilderList() { + if (attributesBuilder_ != null) { + return attributesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(attributes_); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder addAttributesBuilder() { + return getAttributesFieldBuilder().addBuilder( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.getDefaultInstance()); + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder addAttributesBuilder( + int index) { + return getAttributesFieldBuilder().addBuilder( + index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.getDefaultInstance()); + } + /** + * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; + */ + public java.util.List + getAttributesBuilderList() { + return getAttributesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder> + getAttributesFieldBuilder() { + if (attributesBuilder_ == null) { + attributesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder>( + attributes_, + ((bitField0_ & 0x00000004) == 0x00000004), + getParentForChildren(), + isClean()); + attributes_ = null; + } + return attributesBuilder_; + } + + // repeated .org.opendaylight.controller.mdsal.Node child = 4; + private java.util.List child_ = + java.util.Collections.emptyList(); + private void ensureChildIsMutable() { + if (!((bitField0_ & 0x00000008) == 0x00000008)) { + child_ = new java.util.ArrayList(child_); + bitField0_ |= 0x00000008; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> childBuilder_; + + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + public java.util.List getChildList() { + if (childBuilder_ == null) { + return java.util.Collections.unmodifiableList(child_); + } else { + return childBuilder_.getMessageList(); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + public int getChildCount() { + if (childBuilder_ == null) { + return child_.size(); + } else { + return childBuilder_.getCount(); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getChild(int index) { + if (childBuilder_ == null) { + return child_.get(index); + } else { + return childBuilder_.getMessage(index); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + public Builder setChild( + int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node value) { + if (childBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureChildIsMutable(); + child_.set(index, value); + onChanged(); + } else { + childBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + public Builder setChild( + int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder builderForValue) { + if (childBuilder_ == null) { + ensureChildIsMutable(); + child_.set(index, builderForValue.build()); + onChanged(); + } else { + childBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + public Builder addChild(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node value) { + if (childBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureChildIsMutable(); + child_.add(value); + onChanged(); + } else { + childBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + public Builder addChild( + int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node value) { + if (childBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureChildIsMutable(); + child_.add(index, value); + onChanged(); + } else { + childBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + public Builder addChild( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder builderForValue) { + if (childBuilder_ == null) { + ensureChildIsMutable(); + child_.add(builderForValue.build()); + onChanged(); + } else { + childBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + public Builder addChild( + int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder builderForValue) { + if (childBuilder_ == null) { + ensureChildIsMutable(); + child_.add(index, builderForValue.build()); + onChanged(); + } else { + childBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + public Builder addAllChild( + java.lang.Iterable values) { + if (childBuilder_ == null) { + ensureChildIsMutable(); + super.addAll(values, child_); + onChanged(); + } else { + childBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + public Builder clearChild() { + if (childBuilder_ == null) { + child_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + } else { + childBuilder_.clear(); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + public Builder removeChild(int index) { + if (childBuilder_ == null) { + ensureChildIsMutable(); + child_.remove(index); + onChanged(); + } else { + childBuilder_.remove(index); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder getChildBuilder( + int index) { + return getChildFieldBuilder().getBuilder(index); + } + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getChildOrBuilder( + int index) { + if (childBuilder_ == null) { + return child_.get(index); } else { + return childBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + public java.util.List + getChildOrBuilderList() { + if (childBuilder_ != null) { + return childBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(child_); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder addChildBuilder() { + return getChildFieldBuilder().addBuilder( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance()); + } + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder addChildBuilder( + int index) { + return getChildFieldBuilder().addBuilder( + index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance()); + } + /** + * repeated .org.opendaylight.controller.mdsal.Node child = 4; + */ + public java.util.List + getChildBuilderList() { + return getChildFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> + getChildFieldBuilder() { + if (childBuilder_ == null) { + childBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder>( + child_, + ((bitField0_ & 0x00000008) == 0x00000008), + getParentForChildren(), + isClean()); + child_ = null; + } + return childBuilder_; + } + + // optional string value = 5; + private java.lang.Object value_ = ""; + /** + * optional string value = 5; + */ + public boolean hasValue() { + return ((bitField0_ & 0x00000010) == 0x00000010); + } + /** + * optional string value = 5; + */ + public java.lang.String getValue() { + java.lang.Object ref = value_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + value_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string value = 5; + */ + public com.google.protobuf.ByteString + getValueBytes() { + java.lang.Object ref = value_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + value_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string value = 5; + */ + public Builder setValue( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000010; + value_ = value; + onChanged(); + return this; + } + /** + * optional string value = 5; + */ + public Builder clearValue() { + bitField0_ = (bitField0_ & ~0x00000010); + value_ = getDefaultInstance().getValue(); + onChanged(); + return this; + } + /** + * optional string value = 5; + */ + public Builder setValueBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000010; + value_ = value; + onChanged(); + return this; + } + + // optional string valueType = 6; + private java.lang.Object valueType_ = ""; + /** + * optional string valueType = 6; + */ + public boolean hasValueType() { + return ((bitField0_ & 0x00000020) == 0x00000020); + } + /** + * optional string valueType = 6; + */ + public java.lang.String getValueType() { + java.lang.Object ref = valueType_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + valueType_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string valueType = 6; + */ + public com.google.protobuf.ByteString + getValueTypeBytes() { + java.lang.Object ref = valueType_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + valueType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string valueType = 6; + */ + public Builder setValueType( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000020; + valueType_ = value; + onChanged(); + return this; + } + /** + * optional string valueType = 6; + */ + public Builder clearValueType() { + bitField0_ = (bitField0_ & ~0x00000020); + valueType_ = getDefaultInstance().getValueType(); + onChanged(); + return this; + } + /** + * optional string valueType = 6; + */ + public Builder setValueTypeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000020; + valueType_ = value; + onChanged(); + return this; + } + + // repeated string bitsValue = 7; + private com.google.protobuf.LazyStringList bitsValue_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureBitsValueIsMutable() { + if (!((bitField0_ & 0x00000040) == 0x00000040)) { + bitsValue_ = new com.google.protobuf.LazyStringArrayList(bitsValue_); + bitField0_ |= 0x00000040; + } + } + /** + * repeated string bitsValue = 7; + */ + public java.util.List + getBitsValueList() { + return java.util.Collections.unmodifiableList(bitsValue_); + } + /** + * repeated string bitsValue = 7; + */ + public int getBitsValueCount() { + return bitsValue_.size(); + } + /** + * repeated string bitsValue = 7; + */ + public java.lang.String getBitsValue(int index) { + return bitsValue_.get(index); + } + /** + * repeated string bitsValue = 7; + */ + public com.google.protobuf.ByteString + getBitsValueBytes(int index) { + return bitsValue_.getByteString(index); + } + /** + * repeated string bitsValue = 7; + */ + public Builder setBitsValue( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureBitsValueIsMutable(); + bitsValue_.set(index, value); + onChanged(); + return this; + } + /** + * repeated string bitsValue = 7; + */ + public Builder addBitsValue( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureBitsValueIsMutable(); + bitsValue_.add(value); + onChanged(); + return this; + } + /** + * repeated string bitsValue = 7; + */ + public Builder addAllBitsValue( + java.lang.Iterable values) { + ensureBitsValueIsMutable(); + super.addAll(values, bitsValue_); + onChanged(); + return this; + } + /** + * repeated string bitsValue = 7; + */ + public Builder clearBitsValue() { + bitsValue_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000040); + onChanged(); + return this; + } + /** + * repeated string bitsValue = 7; + */ + public Builder addBitsValueBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureBitsValueIsMutable(); + bitsValue_.add(value); + onChanged(); + return this; + } + + // optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier instanceIdentifierValue_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> instanceIdentifierValueBuilder_; + /** + * optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8; + */ + public boolean hasInstanceIdentifierValue() { + return ((bitField0_ & 0x00000080) == 0x00000080); + } + /** + * optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierValue() { + if (instanceIdentifierValueBuilder_ == null) { + return instanceIdentifierValue_; + } else { + return instanceIdentifierValueBuilder_.getMessage(); + } + } + /** + * optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8; + */ + public Builder setInstanceIdentifierValue(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier value) { + if (instanceIdentifierValueBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + instanceIdentifierValue_ = value; + onChanged(); + } else { + instanceIdentifierValueBuilder_.setMessage(value); + } + bitField0_ |= 0x00000080; + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8; + */ + public Builder setInstanceIdentifierValue( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder builderForValue) { + if (instanceIdentifierValueBuilder_ == null) { + instanceIdentifierValue_ = builderForValue.build(); + onChanged(); + } else { + instanceIdentifierValueBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000080; + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8; + */ + public Builder mergeInstanceIdentifierValue(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier value) { + if (instanceIdentifierValueBuilder_ == null) { + if (((bitField0_ & 0x00000080) == 0x00000080) && + instanceIdentifierValue_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance()) { + instanceIdentifierValue_ = + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.newBuilder(instanceIdentifierValue_).mergeFrom(value).buildPartial(); + } else { + instanceIdentifierValue_ = value; + } + onChanged(); + } else { + instanceIdentifierValueBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000080; + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8; + */ + public Builder clearInstanceIdentifierValue() { + if (instanceIdentifierValueBuilder_ == null) { + instanceIdentifierValue_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + onChanged(); + } else { + instanceIdentifierValueBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000080); + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder getInstanceIdentifierValueBuilder() { + bitField0_ |= 0x00000080; + onChanged(); + return getInstanceIdentifierValueFieldBuilder().getBuilder(); + } + /** + * optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierValueOrBuilder() { + if (instanceIdentifierValueBuilder_ != null) { + return instanceIdentifierValueBuilder_.getMessageOrBuilder(); + } else { + return instanceIdentifierValue_; + } + } + /** + * optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8; + */ + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> + getInstanceIdentifierValueFieldBuilder() { + if (instanceIdentifierValueBuilder_ == null) { + instanceIdentifierValueBuilder_ = new com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder>( + instanceIdentifierValue_, + getParentForChildren(), + isClean()); + instanceIdentifierValue_ = null; + } + return instanceIdentifierValueBuilder_; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.Node) + } + + static { + defaultInstance = new Node(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.Node) + } + + public interface ContainerOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required string parentPath = 1; + /** + * required string parentPath = 1; + */ + boolean hasParentPath(); + /** + * required string parentPath = 1; + */ + java.lang.String getParentPath(); + /** + * required string parentPath = 1; + */ + com.google.protobuf.ByteString + getParentPathBytes(); + + // optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + boolean hasNormalizedNode(); + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getNormalizedNode(); + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getNormalizedNodeOrBuilder(); + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.Container} + */ + public static final class Container extends + com.google.protobuf.GeneratedMessage + implements ContainerOrBuilder { + // Use Container.newBuilder() to construct. + private Container(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private Container(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final Container defaultInstance; + public static Container getDefaultInstance() { + return defaultInstance; + } + + public Container getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Container( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + bitField0_ |= 0x00000001; + parentPath_ = input.readBytes(); + break; + } + case 18: { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder subBuilder = null; + if (((bitField0_ & 0x00000002) == 0x00000002)) { + subBuilder = normalizedNode_.toBuilder(); + } + normalizedNode_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(normalizedNode_); + normalizedNode_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000002; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_Container_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_Container_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container.class, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public Container parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Container(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // required string parentPath = 1; + public static final int PARENTPATH_FIELD_NUMBER = 1; + private java.lang.Object parentPath_; + /** + * required string parentPath = 1; + */ + public boolean hasParentPath() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string parentPath = 1; + */ + public java.lang.String getParentPath() { + java.lang.Object ref = parentPath_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + parentPath_ = s; + } + return s; + } + } + /** + * required string parentPath = 1; + */ + public com.google.protobuf.ByteString + getParentPathBytes() { + java.lang.Object ref = parentPath_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + parentPath_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + public static final int NORMALIZEDNODE_FIELD_NUMBER = 2; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node normalizedNode_; + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public boolean hasNormalizedNode() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getNormalizedNode() { + return normalizedNode_; + } + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getNormalizedNodeOrBuilder() { + return normalizedNode_; + } + + private void initFields() { + parentPath_ = ""; + normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasParentPath()) { + memoizedIsInitialized = 0; + return false; + } + if (hasNormalizedNode()) { + if (!getNormalizedNode().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getParentPathBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeMessage(2, normalizedNode_); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getParentPathBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, normalizedNode_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.Container} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.ContainerOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_Container_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_Container_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container.class, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container.Builder.class); + } + + // Construct using org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getNormalizedNodeFieldBuilder(); + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + parentPath_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + if (normalizedNodeBuilder_ == null) { + normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); + } else { + normalizedNodeBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_Container_descriptor; + } + + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container getDefaultInstanceForType() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container.getDefaultInstance(); + } + + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container build() { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container buildPartial() { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container result = new org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.parentPath_ = parentPath_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + if (normalizedNodeBuilder_ == null) { + result.normalizedNode_ = normalizedNode_; + } else { + result.normalizedNode_ = normalizedNodeBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container) { + return mergeFrom((org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container other) { + if (other == org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container.getDefaultInstance()) return this; + if (other.hasParentPath()) { + bitField0_ |= 0x00000001; + parentPath_ = other.parentPath_; + onChanged(); + } + if (other.hasNormalizedNode()) { + mergeNormalizedNode(other.getNormalizedNode()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasParentPath()) { + + return false; + } + if (hasNormalizedNode()) { + if (!getNormalizedNode().isInitialized()) { + + return false; + } + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required string parentPath = 1; + private java.lang.Object parentPath_ = ""; + /** + * required string parentPath = 1; + */ + public boolean hasParentPath() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string parentPath = 1; + */ + public java.lang.String getParentPath() { + java.lang.Object ref = parentPath_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + parentPath_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string parentPath = 1; + */ + public com.google.protobuf.ByteString + getParentPathBytes() { + java.lang.Object ref = parentPath_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + parentPath_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string parentPath = 1; + */ + public Builder setParentPath( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + parentPath_ = value; + onChanged(); + return this; + } + /** + * required string parentPath = 1; + */ + public Builder clearParentPath() { + bitField0_ = (bitField0_ & ~0x00000001); + parentPath_ = getDefaultInstance().getParentPath(); + onChanged(); + return this; + } + /** + * required string parentPath = 1; + */ + public Builder setParentPathBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + parentPath_ = value; + onChanged(); + return this; + } + + // optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> normalizedNodeBuilder_; + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public boolean hasNormalizedNode() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getNormalizedNode() { + if (normalizedNodeBuilder_ == null) { + return normalizedNode_; + } else { + return normalizedNodeBuilder_.getMessage(); + } + } + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public Builder setNormalizedNode(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node value) { + if (normalizedNodeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + normalizedNode_ = value; + onChanged(); + } else { + normalizedNodeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public Builder setNormalizedNode( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder builderForValue) { + if (normalizedNodeBuilder_ == null) { + normalizedNode_ = builderForValue.build(); + onChanged(); + } else { + normalizedNodeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public Builder mergeNormalizedNode(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node value) { + if (normalizedNodeBuilder_ == null) { + if (((bitField0_ & 0x00000002) == 0x00000002) && + normalizedNode_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance()) { + normalizedNode_ = + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.newBuilder(normalizedNode_).mergeFrom(value).buildPartial(); + } else { + normalizedNode_ = value; + } + onChanged(); + } else { + normalizedNodeBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000002; + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public Builder clearNormalizedNode() { + if (normalizedNodeBuilder_ == null) { + normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); + onChanged(); + } else { + normalizedNodeBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder getNormalizedNodeBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getNormalizedNodeFieldBuilder().getBuilder(); + } + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getNormalizedNodeOrBuilder() { + if (normalizedNodeBuilder_ != null) { + return normalizedNodeBuilder_.getMessageOrBuilder(); + } else { + return normalizedNode_; + } + } + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> + getNormalizedNodeFieldBuilder() { + if (normalizedNodeBuilder_ == null) { + normalizedNodeBuilder_ = new com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder>( + normalizedNode_, + getParentForChildren(), + isClean()); + normalizedNode_ = null; + } + return normalizedNodeBuilder_; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.Container) + } + + static { + defaultInstance = new Container(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.Container) + } + + public interface NodeMapEntryOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + boolean hasInstanceIdentifierPath(); + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierPath(); + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierPathOrBuilder(); + + // optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + boolean hasNormalizedNode(); + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getNormalizedNode(); + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getNormalizedNodeOrBuilder(); + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.NodeMapEntry} + */ + public static final class NodeMapEntry extends + com.google.protobuf.GeneratedMessage + implements NodeMapEntryOrBuilder { + // Use NodeMapEntry.newBuilder() to construct. + private NodeMapEntry(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private NodeMapEntry(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final NodeMapEntry defaultInstance; + public static NodeMapEntry getDefaultInstance() { + return defaultInstance; + } + + public NodeMapEntry getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private NodeMapEntry( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder subBuilder = null; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + subBuilder = instanceIdentifierPath_.toBuilder(); + } + instanceIdentifierPath_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(instanceIdentifierPath_); + instanceIdentifierPath_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000001; + break; + } + case 18: { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder subBuilder = null; + if (((bitField0_ & 0x00000002) == 0x00000002)) { + subBuilder = normalizedNode_.toBuilder(); + } + normalizedNode_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(normalizedNode_); + normalizedNode_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000002; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_NodeMapEntry_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_NodeMapEntry_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry.class, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public NodeMapEntry parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new NodeMapEntry(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + public static final int INSTANCEIDENTIFIERPATH_FIELD_NUMBER = 1; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier instanceIdentifierPath_; + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + public boolean hasInstanceIdentifierPath() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierPath() { + return instanceIdentifierPath_; + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierPathOrBuilder() { + return instanceIdentifierPath_; + } + + // optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + public static final int NORMALIZEDNODE_FIELD_NUMBER = 2; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node normalizedNode_; + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public boolean hasNormalizedNode() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getNormalizedNode() { + return normalizedNode_; + } + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getNormalizedNodeOrBuilder() { + return normalizedNode_; + } + + private void initFields() { + instanceIdentifierPath_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasInstanceIdentifierPath()) { + memoizedIsInitialized = 0; + return false; + } + if (!getInstanceIdentifierPath().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + if (hasNormalizedNode()) { + if (!getNormalizedNode().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeMessage(1, instanceIdentifierPath_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeMessage(2, normalizedNode_); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, instanceIdentifierPath_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, normalizedNode_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.NodeMapEntry} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntryOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_NodeMapEntry_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_NodeMapEntry_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry.class, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry.Builder.class); + } + + // Construct using org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getInstanceIdentifierPathFieldBuilder(); + getNormalizedNodeFieldBuilder(); + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + if (instanceIdentifierPathBuilder_ == null) { + instanceIdentifierPath_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + } else { + instanceIdentifierPathBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + if (normalizedNodeBuilder_ == null) { + normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); + } else { + normalizedNodeBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_NodeMapEntry_descriptor; + } + + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry getDefaultInstanceForType() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry.getDefaultInstance(); + } + + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry build() { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry buildPartial() { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry result = new org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + if (instanceIdentifierPathBuilder_ == null) { + result.instanceIdentifierPath_ = instanceIdentifierPath_; + } else { + result.instanceIdentifierPath_ = instanceIdentifierPathBuilder_.build(); + } + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + if (normalizedNodeBuilder_ == null) { + result.normalizedNode_ = normalizedNode_; + } else { + result.normalizedNode_ = normalizedNodeBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry) { + return mergeFrom((org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry other) { + if (other == org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry.getDefaultInstance()) return this; + if (other.hasInstanceIdentifierPath()) { + mergeInstanceIdentifierPath(other.getInstanceIdentifierPath()); + } + if (other.hasNormalizedNode()) { + mergeNormalizedNode(other.getNormalizedNode()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasInstanceIdentifierPath()) { + + return false; + } + if (!getInstanceIdentifierPath().isInitialized()) { + + return false; + } + if (hasNormalizedNode()) { + if (!getNormalizedNode().isInitialized()) { + + return false; + } + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier instanceIdentifierPath_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> instanceIdentifierPathBuilder_; + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + public boolean hasInstanceIdentifierPath() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierPath() { + if (instanceIdentifierPathBuilder_ == null) { + return instanceIdentifierPath_; + } else { + return instanceIdentifierPathBuilder_.getMessage(); + } + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + public Builder setInstanceIdentifierPath(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier value) { + if (instanceIdentifierPathBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + instanceIdentifierPath_ = value; + onChanged(); + } else { + instanceIdentifierPathBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + return this; + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + public Builder setInstanceIdentifierPath( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder builderForValue) { + if (instanceIdentifierPathBuilder_ == null) { + instanceIdentifierPath_ = builderForValue.build(); + onChanged(); + } else { + instanceIdentifierPathBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + return this; + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + public Builder mergeInstanceIdentifierPath(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier value) { + if (instanceIdentifierPathBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001) && + instanceIdentifierPath_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance()) { + instanceIdentifierPath_ = + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.newBuilder(instanceIdentifierPath_).mergeFrom(value).buildPartial(); + } else { + instanceIdentifierPath_ = value; + } + onChanged(); + } else { + instanceIdentifierPathBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000001; + return this; + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + public Builder clearInstanceIdentifierPath() { + if (instanceIdentifierPathBuilder_ == null) { + instanceIdentifierPath_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + onChanged(); + } else { + instanceIdentifierPathBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder getInstanceIdentifierPathBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getInstanceIdentifierPathFieldBuilder().getBuilder(); + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierPathOrBuilder() { + if (instanceIdentifierPathBuilder_ != null) { + return instanceIdentifierPathBuilder_.getMessageOrBuilder(); + } else { + return instanceIdentifierPath_; + } + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> + getInstanceIdentifierPathFieldBuilder() { + if (instanceIdentifierPathBuilder_ == null) { + instanceIdentifierPathBuilder_ = new com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder>( + instanceIdentifierPath_, + getParentForChildren(), + isClean()); + instanceIdentifierPath_ = null; + } + return instanceIdentifierPathBuilder_; + } + + // optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> normalizedNodeBuilder_; + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public boolean hasNormalizedNode() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getNormalizedNode() { + if (normalizedNodeBuilder_ == null) { + return normalizedNode_; + } else { + return normalizedNodeBuilder_.getMessage(); + } + } + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public Builder setNormalizedNode(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node value) { + if (normalizedNodeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + normalizedNode_ = value; + onChanged(); + } else { + normalizedNodeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public Builder setNormalizedNode( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder builderForValue) { + if (normalizedNodeBuilder_ == null) { + normalizedNode_ = builderForValue.build(); + onChanged(); + } else { + normalizedNodeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public Builder mergeNormalizedNode(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node value) { + if (normalizedNodeBuilder_ == null) { + if (((bitField0_ & 0x00000002) == 0x00000002) && + normalizedNode_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance()) { + normalizedNode_ = + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.newBuilder(normalizedNode_).mergeFrom(value).buildPartial(); + } else { + normalizedNode_ = value; + } + onChanged(); + } else { + normalizedNodeBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000002; + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public Builder clearNormalizedNode() { + if (normalizedNodeBuilder_ == null) { + normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); + onChanged(); + } else { + normalizedNodeBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder getNormalizedNodeBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getNormalizedNodeFieldBuilder().getBuilder(); + } + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getNormalizedNodeOrBuilder() { + if (normalizedNodeBuilder_ != null) { + return normalizedNodeBuilder_.getMessageOrBuilder(); + } else { + return normalizedNode_; + } + } + /** + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> + getNormalizedNodeFieldBuilder() { + if (normalizedNodeBuilder_ == null) { + normalizedNodeBuilder_ = new com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder>( + normalizedNode_, + getParentForChildren(), + isClean()); + normalizedNode_ = null; + } + return normalizedNodeBuilder_; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.NodeMapEntry) + } + + static { + defaultInstance = new NodeMapEntry(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.NodeMapEntry) + } + + public interface NodeMapOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + java.util.List + getMapEntriesList(); + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry getMapEntries(int index); + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + int getMapEntriesCount(); + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + java.util.List + getMapEntriesOrBuilderList(); + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntryOrBuilder getMapEntriesOrBuilder( + int index); + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.NodeMap} + */ + public static final class NodeMap extends + com.google.protobuf.GeneratedMessage + implements NodeMapOrBuilder { + // Use NodeMap.newBuilder() to construct. + private NodeMap(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private NodeMap(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final NodeMap defaultInstance; + public static NodeMap getDefaultInstance() { + return defaultInstance; + } + + public NodeMap getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private NodeMap( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + mapEntries_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + mapEntries_.add(input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry.PARSER, extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + mapEntries_ = java.util.Collections.unmodifiableList(mapEntries_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_NodeMap_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_NodeMap_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.class, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public NodeMap parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new NodeMap(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + // repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + public static final int MAPENTRIES_FIELD_NUMBER = 1; + private java.util.List mapEntries_; + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + public java.util.List getMapEntriesList() { + return mapEntries_; + } + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + public java.util.List + getMapEntriesOrBuilderList() { + return mapEntries_; + } + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + public int getMapEntriesCount() { + return mapEntries_.size(); + } + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry getMapEntries(int index) { + return mapEntries_.get(index); + } + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntryOrBuilder getMapEntriesOrBuilder( + int index) { + return mapEntries_.get(index); + } + + private void initFields() { + mapEntries_ = java.util.Collections.emptyList(); + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + for (int i = 0; i < getMapEntriesCount(); i++) { + if (!getMapEntries(i).isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + for (int i = 0; i < mapEntries_.size(); i++) { + output.writeMessage(1, mapEntries_.get(i)); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < mapEntries_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, mapEntries_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.NodeMap} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_NodeMap_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_NodeMap_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.class, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder.class); + } + + // Construct using org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getMapEntriesFieldBuilder(); + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + if (mapEntriesBuilder_ == null) { + mapEntries_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + mapEntriesBuilder_.clear(); + } + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_NodeMap_descriptor; + } + + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap getDefaultInstanceForType() { + return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.getDefaultInstance(); + } + + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap build() { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap buildPartial() { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap result = new org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap(this); + int from_bitField0_ = bitField0_; + if (mapEntriesBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + mapEntries_ = java.util.Collections.unmodifiableList(mapEntries_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.mapEntries_ = mapEntries_; + } else { + result.mapEntries_ = mapEntriesBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap) { + return mergeFrom((org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap other) { + if (other == org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.getDefaultInstance()) return this; + if (mapEntriesBuilder_ == null) { + if (!other.mapEntries_.isEmpty()) { + if (mapEntries_.isEmpty()) { + mapEntries_ = other.mapEntries_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureMapEntriesIsMutable(); + mapEntries_.addAll(other.mapEntries_); + } + onChanged(); + } + } else { + if (!other.mapEntries_.isEmpty()) { + if (mapEntriesBuilder_.isEmpty()) { + mapEntriesBuilder_.dispose(); + mapEntriesBuilder_ = null; + mapEntries_ = other.mapEntries_; + bitField0_ = (bitField0_ & ~0x00000001); + mapEntriesBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getMapEntriesFieldBuilder() : null; + } else { + mapEntriesBuilder_.addAllMessages(other.mapEntries_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + for (int i = 0; i < getMapEntriesCount(); i++) { + if (!getMapEntries(i).isInitialized()) { + + return false; + } + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + private java.util.List mapEntries_ = + java.util.Collections.emptyList(); + private void ensureMapEntriesIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + mapEntries_ = new java.util.ArrayList(mapEntries_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntryOrBuilder> mapEntriesBuilder_; + + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + public java.util.List getMapEntriesList() { + if (mapEntriesBuilder_ == null) { + return java.util.Collections.unmodifiableList(mapEntries_); + } else { + return mapEntriesBuilder_.getMessageList(); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + public int getMapEntriesCount() { + if (mapEntriesBuilder_ == null) { + return mapEntries_.size(); + } else { + return mapEntriesBuilder_.getCount(); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry getMapEntries(int index) { + if (mapEntriesBuilder_ == null) { + return mapEntries_.get(index); + } else { + return mapEntriesBuilder_.getMessage(index); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + public Builder setMapEntries( + int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry value) { + if (mapEntriesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMapEntriesIsMutable(); + mapEntries_.set(index, value); + onChanged(); + } else { + mapEntriesBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + public Builder setMapEntries( + int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry.Builder builderForValue) { + if (mapEntriesBuilder_ == null) { + ensureMapEntriesIsMutable(); + mapEntries_.set(index, builderForValue.build()); + onChanged(); + } else { + mapEntriesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + public Builder addMapEntries(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry value) { + if (mapEntriesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMapEntriesIsMutable(); + mapEntries_.add(value); + onChanged(); + } else { + mapEntriesBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + public Builder addMapEntries( + int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry value) { + if (mapEntriesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMapEntriesIsMutable(); + mapEntries_.add(index, value); + onChanged(); + } else { + mapEntriesBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + public Builder addMapEntries( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry.Builder builderForValue) { + if (mapEntriesBuilder_ == null) { + ensureMapEntriesIsMutable(); + mapEntries_.add(builderForValue.build()); + onChanged(); + } else { + mapEntriesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + public Builder addMapEntries( + int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry.Builder builderForValue) { + if (mapEntriesBuilder_ == null) { + ensureMapEntriesIsMutable(); + mapEntries_.add(index, builderForValue.build()); + onChanged(); + } else { + mapEntriesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + public Builder addAllMapEntries( + java.lang.Iterable values) { + if (mapEntriesBuilder_ == null) { + ensureMapEntriesIsMutable(); + super.addAll(values, mapEntries_); + onChanged(); + } else { + mapEntriesBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + public Builder clearMapEntries() { + if (mapEntriesBuilder_ == null) { + mapEntries_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + mapEntriesBuilder_.clear(); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + public Builder removeMapEntries(int index) { + if (mapEntriesBuilder_ == null) { + ensureMapEntriesIsMutable(); + mapEntries_.remove(index); + onChanged(); + } else { + mapEntriesBuilder_.remove(index); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry.Builder getMapEntriesBuilder( + int index) { + return getMapEntriesFieldBuilder().getBuilder(index); + } + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntryOrBuilder getMapEntriesOrBuilder( + int index) { + if (mapEntriesBuilder_ == null) { + return mapEntries_.get(index); } else { + return mapEntriesBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + public java.util.List + getMapEntriesOrBuilderList() { + if (mapEntriesBuilder_ != null) { + return mapEntriesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(mapEntries_); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry.Builder addMapEntriesBuilder() { + return getMapEntriesFieldBuilder().addBuilder( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry.getDefaultInstance()); + } + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry.Builder addMapEntriesBuilder( + int index) { + return getMapEntriesFieldBuilder().addBuilder( + index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry.getDefaultInstance()); + } + /** + * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; + */ + public java.util.List + getMapEntriesBuilderList() { + return getMapEntriesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntryOrBuilder> + getMapEntriesFieldBuilder() { + if (mapEntriesBuilder_ == null) { + mapEntriesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntryOrBuilder>( + mapEntries_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + mapEntries_ = null; + } + return mapEntriesBuilder_; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.NodeMap) + } + + static { + defaultInstance = new NodeMap(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.NodeMap) + } + + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_Attribute_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_Attribute_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_QName_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_QName_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_PathArgument_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_PathArgument_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_InstanceIdentifier_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_InstanceIdentifier_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_Node_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_Node_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_Container_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_Container_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_NodeMapEntry_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_NodeMapEntry_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_NodeMap_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_NodeMap_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\014Common.proto\022!org.opendaylight.control" + + "ler.mdsal\"6\n\tAttribute\022\014\n\004name\030\001 \002(\t\022\r\n\005" + + "value\030\002 \001(\t\022\014\n\004type\030\003 \001(\t\"\026\n\005QName\022\r\n\005va" + + "lue\030\001 \002(\t\"\251\001\n\014PathArgument\022\r\n\005value\030\001 \002(" + + "\t\022\014\n\004type\030\002 \001(\t\022:\n\010nodeType\030\003 \001(\0132(.org." + + "opendaylight.controller.mdsal.QName\022@\n\na" + + "ttributes\030\004 \003(\0132,.org.opendaylight.contr" + + "oller.mdsal.Attribute\"X\n\022InstanceIdentif" + + "ier\022B\n\targuments\030\001 \003(\0132/.org.opendayligh" + + "t.controller.mdsal.PathArgument\"\251\002\n\004Node", + "\022\014\n\004path\030\001 \001(\t\022\014\n\004type\030\002 \001(\t\022@\n\nattribut" + + "es\030\003 \003(\0132,.org.opendaylight.controller.m" + + "dsal.Attribute\0226\n\005child\030\004 \003(\0132\'.org.open" + + "daylight.controller.mdsal.Node\022\r\n\005value\030" + + "\005 \001(\t\022\021\n\tvalueType\030\006 \001(\t\022\021\n\tbitsValue\030\007 " + + "\003(\t\022V\n\027instanceIdentifierValue\030\010 \001(\01325.o" + + "rg.opendaylight.controller.mdsal.Instanc" + + "eIdentifier\"`\n\tContainer\022\022\n\nparentPath\030\001" + + " \002(\t\022?\n\016normalizedNode\030\002 \001(\0132\'.org.opend" + + "aylight.controller.mdsal.Node\"\246\001\n\014NodeMa", + "pEntry\022U\n\026instanceIdentifierPath\030\001 \002(\01325" + + ".org.opendaylight.controller.mdsal.Insta" + + "nceIdentifier\022?\n\016normalizedNode\030\002 \001(\0132\'." + + "org.opendaylight.controller.mdsal.Node\"N" + + "\n\007NodeMap\022C\n\nmapEntries\030\001 \003(\0132/.org.open" + + "daylight.controller.mdsal.NodeMapEntryBO" + + "\n5org.opendaylight.controller.protobuff." + + "messages.commonB\026NormalizedNodeMessages" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + internal_static_org_opendaylight_controller_mdsal_Attribute_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_org_opendaylight_controller_mdsal_Attribute_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_Attribute_descriptor, + new java.lang.String[] { "Name", "Value", "Type", }); + internal_static_org_opendaylight_controller_mdsal_QName_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_org_opendaylight_controller_mdsal_QName_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_QName_descriptor, + new java.lang.String[] { "Value", }); + internal_static_org_opendaylight_controller_mdsal_PathArgument_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_org_opendaylight_controller_mdsal_PathArgument_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_PathArgument_descriptor, + new java.lang.String[] { "Value", "Type", "NodeType", "Attributes", }); + internal_static_org_opendaylight_controller_mdsal_InstanceIdentifier_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_org_opendaylight_controller_mdsal_InstanceIdentifier_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_InstanceIdentifier_descriptor, + new java.lang.String[] { "Arguments", }); + internal_static_org_opendaylight_controller_mdsal_Node_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_org_opendaylight_controller_mdsal_Node_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_Node_descriptor, + new java.lang.String[] { "Path", "Type", "Attributes", "Child", "Value", "ValueType", "BitsValue", "InstanceIdentifierValue", }); + internal_static_org_opendaylight_controller_mdsal_Container_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_org_opendaylight_controller_mdsal_Container_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_Container_descriptor, + new java.lang.String[] { "ParentPath", "NormalizedNode", }); + internal_static_org_opendaylight_controller_mdsal_NodeMapEntry_descriptor = + getDescriptor().getMessageTypes().get(6); + internal_static_org_opendaylight_controller_mdsal_NodeMapEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_NodeMapEntry_descriptor, + new java.lang.String[] { "InstanceIdentifierPath", "NormalizedNode", }); + internal_static_org_opendaylight_controller_mdsal_NodeMap_descriptor = + getDescriptor().getMessageTypes().get(7); + internal_static_org_opendaylight_controller_mdsal_NodeMap_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_NodeMap_descriptor, + new java.lang.String[] { "MapEntries", }); + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + } + + // @@protoc_insertion_point(outer_class_scope) +} 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-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/common/SimpleNormalizedNodeMessage.java index 67ab472d0c..29e54571d3 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/common/SimpleNormalizedNodeMessage.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/common/SimpleNormalizedNodeMessage.java @@ -159,7 +159,7 @@ public final class SimpleNormalizedNodeMessage { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -175,7 +175,7 @@ public final class SimpleNormalizedNodeMessage { getNodeIdentifierBytes() { java.lang.Object ref = nodeIdentifier_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); nodeIdentifier_ = b; @@ -202,7 +202,7 @@ public final class SimpleNormalizedNodeMessage { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -218,7 +218,7 @@ public final class SimpleNormalizedNodeMessage { getXmlStringBytes() { java.lang.Object ref = xmlString_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); xmlString_ = b; @@ -463,11 +463,11 @@ public final class SimpleNormalizedNodeMessage { public final boolean isInitialized() { if (!hasNodeIdentifier()) { - + return false; } if (!hasXmlString()) { - + return false; } return true; @@ -521,7 +521,7 @@ public final class SimpleNormalizedNodeMessage { getNodeIdentifierBytes() { java.lang.Object ref = nodeIdentifier_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); nodeIdentifier_ = b; @@ -595,7 +595,7 @@ public final class SimpleNormalizedNodeMessage { getXmlStringBytes() { java.lang.Object ref = xmlString_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); xmlString_ = b; 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-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/datachange/notification/DataChangeListenerMessages.java index 391107e2b7..2018834768 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-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/datachange/notification/DataChangeListenerMessages.java @@ -11,39 +11,100 @@ public final class DataChangeListenerMessages { public interface DataChangedOrBuilder extends com.google.protobuf.MessageOrBuilder { - // repeated string instanceIdentifierPathArguments = 1; + // optional .org.opendaylight.controller.mdsal.Node originalSubTree = 1; /** - * repeated string instanceIdentifierPathArguments = 1; + * optional .org.opendaylight.controller.mdsal.Node originalSubTree = 1; */ - java.util.List - getInstanceIdentifierPathArgumentsList(); + boolean hasOriginalSubTree(); /** - * repeated string instanceIdentifierPathArguments = 1; + * optional .org.opendaylight.controller.mdsal.Node originalSubTree = 1; */ - int getInstanceIdentifierPathArgumentsCount(); + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getOriginalSubTree(); /** - * repeated string instanceIdentifierPathArguments = 1; + * optional .org.opendaylight.controller.mdsal.Node originalSubTree = 1; */ - java.lang.String getInstanceIdentifierPathArguments(int index); + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getOriginalSubTreeOrBuilder(); + + // optional .org.opendaylight.controller.mdsal.Node updatedSubTree = 2; + /** + * optional .org.opendaylight.controller.mdsal.Node updatedSubTree = 2; + */ + boolean hasUpdatedSubTree(); + /** + * optional .org.opendaylight.controller.mdsal.Node updatedSubTree = 2; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getUpdatedSubTree(); + /** + * optional .org.opendaylight.controller.mdsal.Node updatedSubTree = 2; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getUpdatedSubTreeOrBuilder(); + + // optional .org.opendaylight.controller.mdsal.NodeMap originalData = 3; + /** + * optional .org.opendaylight.controller.mdsal.NodeMap originalData = 3; + */ + boolean hasOriginalData(); + /** + * optional .org.opendaylight.controller.mdsal.NodeMap originalData = 3; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap getOriginalData(); + /** + * optional .org.opendaylight.controller.mdsal.NodeMap originalData = 3; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapOrBuilder getOriginalDataOrBuilder(); + + // optional .org.opendaylight.controller.mdsal.NodeMap updatedData = 4; + /** + * optional .org.opendaylight.controller.mdsal.NodeMap updatedData = 4; + */ + boolean hasUpdatedData(); + /** + * optional .org.opendaylight.controller.mdsal.NodeMap updatedData = 4; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap getUpdatedData(); + /** + * optional .org.opendaylight.controller.mdsal.NodeMap updatedData = 4; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapOrBuilder getUpdatedDataOrBuilder(); + + // optional .org.opendaylight.controller.mdsal.NodeMap createdData = 5; + /** + * optional .org.opendaylight.controller.mdsal.NodeMap createdData = 5; + */ + boolean hasCreatedData(); /** - * repeated string instanceIdentifierPathArguments = 1; + * optional .org.opendaylight.controller.mdsal.NodeMap createdData = 5; */ - com.google.protobuf.ByteString - getInstanceIdentifierPathArgumentsBytes(int index); + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap getCreatedData(); + /** + * optional .org.opendaylight.controller.mdsal.NodeMap createdData = 5; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapOrBuilder getCreatedDataOrBuilder(); - // required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNodeXml = 2; + // repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + /** + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + */ + java.util.List + getRemovedPathsList(); /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNodeXml = 2; + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; */ - boolean hasNormalizedNodeXml(); + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getRemovedPaths(int index); /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNodeXml = 2; + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; */ - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml getNormalizedNodeXml(); + int getRemovedPathsCount(); /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNodeXml = 2; + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; */ - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXmlOrBuilder getNormalizedNodeXmlOrBuilder(); + java.util.List + getRemovedPathsOrBuilderList(); + /** + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getRemovedPathsOrBuilder( + int index); } /** * Protobuf type {@code org.opendaylight.controller.mdsal.DataChanged} @@ -97,24 +158,76 @@ public final class DataChangeListenerMessages { break; } case 10: { - if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - instanceIdentifierPathArguments_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000001; + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder subBuilder = null; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + subBuilder = originalSubTree_.toBuilder(); + } + originalSubTree_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(originalSubTree_); + originalSubTree_ = subBuilder.buildPartial(); } - instanceIdentifierPathArguments_.add(input.readBytes()); + bitField0_ |= 0x00000001; break; } case 18: { - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.Builder subBuilder = null; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - subBuilder = normalizedNodeXml_.toBuilder(); + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder subBuilder = null; + if (((bitField0_ & 0x00000002) == 0x00000002)) { + subBuilder = updatedSubTree_.toBuilder(); } - normalizedNodeXml_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.PARSER, extensionRegistry); + updatedSubTree_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.PARSER, extensionRegistry); if (subBuilder != null) { - subBuilder.mergeFrom(normalizedNodeXml_); - normalizedNodeXml_ = subBuilder.buildPartial(); + subBuilder.mergeFrom(updatedSubTree_); + updatedSubTree_ = subBuilder.buildPartial(); } - bitField0_ |= 0x00000001; + bitField0_ |= 0x00000002; + break; + } + case 26: { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder subBuilder = null; + if (((bitField0_ & 0x00000004) == 0x00000004)) { + subBuilder = originalData_.toBuilder(); + } + originalData_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(originalData_); + originalData_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000004; + break; + } + case 34: { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder subBuilder = null; + if (((bitField0_ & 0x00000008) == 0x00000008)) { + subBuilder = updatedData_.toBuilder(); + } + updatedData_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(updatedData_); + updatedData_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000008; + break; + } + case 42: { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder subBuilder = null; + if (((bitField0_ & 0x00000010) == 0x00000010)) { + subBuilder = createdData_.toBuilder(); + } + createdData_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(createdData_); + createdData_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000010; + break; + } + case 50: { + if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) { + removedPaths_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000020; + } + removedPaths_.add(input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.PARSER, extensionRegistry)); break; } } @@ -125,8 +238,8 @@ public final class DataChangeListenerMessages { throw new com.google.protobuf.InvalidProtocolBufferException( e.getMessage()).setUnfinishedMessage(this); } finally { - if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - instanceIdentifierPathArguments_ = new com.google.protobuf.UnmodifiableLazyStringList(instanceIdentifierPathArguments_); + if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) { + removedPaths_ = java.util.Collections.unmodifiableList(removedPaths_); } this.unknownFields = unknownFields.build(); makeExtensionsImmutable(); @@ -160,74 +273,200 @@ public final class DataChangeListenerMessages { } private int bitField0_; - // repeated string instanceIdentifierPathArguments = 1; - public static final int INSTANCEIDENTIFIERPATHARGUMENTS_FIELD_NUMBER = 1; - private com.google.protobuf.LazyStringList instanceIdentifierPathArguments_; + // optional .org.opendaylight.controller.mdsal.Node originalSubTree = 1; + public static final int ORIGINALSUBTREE_FIELD_NUMBER = 1; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node originalSubTree_; + /** + * optional .org.opendaylight.controller.mdsal.Node originalSubTree = 1; + */ + public boolean hasOriginalSubTree() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional .org.opendaylight.controller.mdsal.Node originalSubTree = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getOriginalSubTree() { + return originalSubTree_; + } /** - * repeated string instanceIdentifierPathArguments = 1; + * optional .org.opendaylight.controller.mdsal.Node originalSubTree = 1; */ - public java.util.List - getInstanceIdentifierPathArgumentsList() { - return instanceIdentifierPathArguments_; + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getOriginalSubTreeOrBuilder() { + return originalSubTree_; } + + // optional .org.opendaylight.controller.mdsal.Node updatedSubTree = 2; + public static final int UPDATEDSUBTREE_FIELD_NUMBER = 2; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node updatedSubTree_; /** - * repeated string instanceIdentifierPathArguments = 1; + * optional .org.opendaylight.controller.mdsal.Node updatedSubTree = 2; */ - public int getInstanceIdentifierPathArgumentsCount() { - return instanceIdentifierPathArguments_.size(); + public boolean hasUpdatedSubTree() { + return ((bitField0_ & 0x00000002) == 0x00000002); } /** - * repeated string instanceIdentifierPathArguments = 1; + * optional .org.opendaylight.controller.mdsal.Node updatedSubTree = 2; */ - public java.lang.String getInstanceIdentifierPathArguments(int index) { - return instanceIdentifierPathArguments_.get(index); + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getUpdatedSubTree() { + return updatedSubTree_; } /** - * repeated string instanceIdentifierPathArguments = 1; + * optional .org.opendaylight.controller.mdsal.Node updatedSubTree = 2; */ - public com.google.protobuf.ByteString - getInstanceIdentifierPathArgumentsBytes(int index) { - return instanceIdentifierPathArguments_.getByteString(index); + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getUpdatedSubTreeOrBuilder() { + return updatedSubTree_; } - // required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNodeXml = 2; - public static final int NORMALIZEDNODEXML_FIELD_NUMBER = 2; - private org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml normalizedNodeXml_; + // optional .org.opendaylight.controller.mdsal.NodeMap originalData = 3; + public static final int ORIGINALDATA_FIELD_NUMBER = 3; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap originalData_; /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNodeXml = 2; + * optional .org.opendaylight.controller.mdsal.NodeMap originalData = 3; */ - public boolean hasNormalizedNodeXml() { - return ((bitField0_ & 0x00000001) == 0x00000001); + public boolean hasOriginalData() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap originalData = 3; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap getOriginalData() { + return originalData_; + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap originalData = 3; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapOrBuilder getOriginalDataOrBuilder() { + return originalData_; + } + + // optional .org.opendaylight.controller.mdsal.NodeMap updatedData = 4; + public static final int UPDATEDDATA_FIELD_NUMBER = 4; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap updatedData_; + /** + * optional .org.opendaylight.controller.mdsal.NodeMap updatedData = 4; + */ + public boolean hasUpdatedData() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap updatedData = 4; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap getUpdatedData() { + return updatedData_; + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap updatedData = 4; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapOrBuilder getUpdatedDataOrBuilder() { + return updatedData_; + } + + // optional .org.opendaylight.controller.mdsal.NodeMap createdData = 5; + public static final int CREATEDDATA_FIELD_NUMBER = 5; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap createdData_; + /** + * optional .org.opendaylight.controller.mdsal.NodeMap createdData = 5; + */ + public boolean hasCreatedData() { + return ((bitField0_ & 0x00000010) == 0x00000010); + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap createdData = 5; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap getCreatedData() { + return createdData_; + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap createdData = 5; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapOrBuilder getCreatedDataOrBuilder() { + return createdData_; + } + + // repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + public static final int REMOVEDPATHS_FIELD_NUMBER = 6; + private java.util.List removedPaths_; + /** + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + */ + public java.util.List getRemovedPathsList() { + return removedPaths_; + } + /** + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + */ + public java.util.List + getRemovedPathsOrBuilderList() { + return removedPaths_; } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNodeXml = 2; + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; */ - public org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml getNormalizedNodeXml() { - return normalizedNodeXml_; + public int getRemovedPathsCount() { + return removedPaths_.size(); } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNodeXml = 2; + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; */ - public org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXmlOrBuilder getNormalizedNodeXmlOrBuilder() { - return normalizedNodeXml_; + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getRemovedPaths(int index) { + return removedPaths_.get(index); + } + /** + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getRemovedPathsOrBuilder( + int index) { + return removedPaths_.get(index); } private void initFields() { - instanceIdentifierPathArguments_ = com.google.protobuf.LazyStringArrayList.EMPTY; - normalizedNodeXml_ = org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.getDefaultInstance(); + originalSubTree_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); + updatedSubTree_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); + originalData_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.getDefaultInstance(); + updatedData_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.getDefaultInstance(); + createdData_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.getDefaultInstance(); + removedPaths_ = java.util.Collections.emptyList(); } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized != -1) return isInitialized == 1; - if (!hasNormalizedNodeXml()) { - memoizedIsInitialized = 0; - return false; + if (hasOriginalSubTree()) { + if (!getOriginalSubTree().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + if (hasUpdatedSubTree()) { + if (!getUpdatedSubTree().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + if (hasOriginalData()) { + if (!getOriginalData().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + if (hasUpdatedData()) { + if (!getUpdatedData().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + if (hasCreatedData()) { + if (!getCreatedData().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } } - if (!getNormalizedNodeXml().isInitialized()) { - memoizedIsInitialized = 0; - return false; + for (int i = 0; i < getRemovedPathsCount(); i++) { + if (!getRemovedPaths(i).isInitialized()) { + memoizedIsInitialized = 0; + return false; + } } memoizedIsInitialized = 1; return true; @@ -236,11 +475,23 @@ public final class DataChangeListenerMessages { public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { getSerializedSize(); - for (int i = 0; i < instanceIdentifierPathArguments_.size(); i++) { - output.writeBytes(1, instanceIdentifierPathArguments_.getByteString(i)); - } if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeMessage(2, normalizedNodeXml_); + output.writeMessage(1, originalSubTree_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeMessage(2, updatedSubTree_); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeMessage(3, originalData_); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + output.writeMessage(4, updatedData_); + } + if (((bitField0_ & 0x00000010) == 0x00000010)) { + output.writeMessage(5, createdData_); + } + for (int i = 0; i < removedPaths_.size(); i++) { + output.writeMessage(6, removedPaths_.get(i)); } getUnknownFields().writeTo(output); } @@ -251,18 +502,29 @@ public final class DataChangeListenerMessages { if (size != -1) return size; size = 0; - { - int dataSize = 0; - for (int i = 0; i < instanceIdentifierPathArguments_.size(); i++) { - dataSize += com.google.protobuf.CodedOutputStream - .computeBytesSizeNoTag(instanceIdentifierPathArguments_.getByteString(i)); - } - size += dataSize; - size += 1 * getInstanceIdentifierPathArgumentsList().size(); - } if (((bitField0_ & 0x00000001) == 0x00000001)) { size += com.google.protobuf.CodedOutputStream - .computeMessageSize(2, normalizedNodeXml_); + .computeMessageSize(1, originalSubTree_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, updatedSubTree_); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, originalData_); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, updatedData_); + } + if (((bitField0_ & 0x00000010) == 0x00000010)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, createdData_); + } + for (int i = 0; i < removedPaths_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(6, removedPaths_.get(i)); } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; @@ -372,7 +634,12 @@ public final class DataChangeListenerMessages { } private void maybeForceBuilderInitialization() { if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getNormalizedNodeXmlFieldBuilder(); + getOriginalSubTreeFieldBuilder(); + getUpdatedSubTreeFieldBuilder(); + getOriginalDataFieldBuilder(); + getUpdatedDataFieldBuilder(); + getCreatedDataFieldBuilder(); + getRemovedPathsFieldBuilder(); } } private static Builder create() { @@ -381,14 +648,42 @@ public final class DataChangeListenerMessages { public Builder clear() { super.clear(); - instanceIdentifierPathArguments_ = com.google.protobuf.LazyStringArrayList.EMPTY; + if (originalSubTreeBuilder_ == null) { + originalSubTree_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); + } else { + originalSubTreeBuilder_.clear(); + } bitField0_ = (bitField0_ & ~0x00000001); - if (normalizedNodeXmlBuilder_ == null) { - normalizedNodeXml_ = org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.getDefaultInstance(); + if (updatedSubTreeBuilder_ == null) { + updatedSubTree_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); } else { - normalizedNodeXmlBuilder_.clear(); + updatedSubTreeBuilder_.clear(); } bitField0_ = (bitField0_ & ~0x00000002); + if (originalDataBuilder_ == null) { + originalData_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.getDefaultInstance(); + } else { + originalDataBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000004); + if (updatedDataBuilder_ == null) { + updatedData_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.getDefaultInstance(); + } else { + updatedDataBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000008); + if (createdDataBuilder_ == null) { + createdData_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.getDefaultInstance(); + } else { + createdDataBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000010); + if (removedPathsBuilder_ == null) { + removedPaths_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000020); + } else { + removedPathsBuilder_.clear(); + } return this; } @@ -417,19 +712,54 @@ public final class DataChangeListenerMessages { org.opendaylight.controller.protobuff.messages.datachange.notification.DataChangeListenerMessages.DataChanged result = new org.opendaylight.controller.protobuff.messages.datachange.notification.DataChangeListenerMessages.DataChanged(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - instanceIdentifierPathArguments_ = new com.google.protobuf.UnmodifiableLazyStringList( - instanceIdentifierPathArguments_); - bitField0_ = (bitField0_ & ~0x00000001); + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + if (originalSubTreeBuilder_ == null) { + result.originalSubTree_ = originalSubTree_; + } else { + result.originalSubTree_ = originalSubTreeBuilder_.build(); } - result.instanceIdentifierPathArguments_ = instanceIdentifierPathArguments_; if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000001; + to_bitField0_ |= 0x00000002; + } + if (updatedSubTreeBuilder_ == null) { + result.updatedSubTree_ = updatedSubTree_; + } else { + result.updatedSubTree_ = updatedSubTreeBuilder_.build(); + } + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000004; + } + if (originalDataBuilder_ == null) { + result.originalData_ = originalData_; + } else { + result.originalData_ = originalDataBuilder_.build(); } - if (normalizedNodeXmlBuilder_ == null) { - result.normalizedNodeXml_ = normalizedNodeXml_; + if (((from_bitField0_ & 0x00000008) == 0x00000008)) { + to_bitField0_ |= 0x00000008; + } + if (updatedDataBuilder_ == null) { + result.updatedData_ = updatedData_; + } else { + result.updatedData_ = updatedDataBuilder_.build(); + } + if (((from_bitField0_ & 0x00000010) == 0x00000010)) { + to_bitField0_ |= 0x00000010; + } + if (createdDataBuilder_ == null) { + result.createdData_ = createdData_; } else { - result.normalizedNodeXml_ = normalizedNodeXmlBuilder_.build(); + result.createdData_ = createdDataBuilder_.build(); + } + if (removedPathsBuilder_ == null) { + if (((bitField0_ & 0x00000020) == 0x00000020)) { + removedPaths_ = java.util.Collections.unmodifiableList(removedPaths_); + bitField0_ = (bitField0_ & ~0x00000020); + } + result.removedPaths_ = removedPaths_; + } else { + result.removedPaths_ = removedPathsBuilder_.build(); } result.bitField0_ = to_bitField0_; onBuilt(); @@ -447,31 +777,87 @@ public final class DataChangeListenerMessages { public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.datachange.notification.DataChangeListenerMessages.DataChanged other) { if (other == org.opendaylight.controller.protobuff.messages.datachange.notification.DataChangeListenerMessages.DataChanged.getDefaultInstance()) return this; - if (!other.instanceIdentifierPathArguments_.isEmpty()) { - if (instanceIdentifierPathArguments_.isEmpty()) { - instanceIdentifierPathArguments_ = other.instanceIdentifierPathArguments_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureInstanceIdentifierPathArgumentsIsMutable(); - instanceIdentifierPathArguments_.addAll(other.instanceIdentifierPathArguments_); - } - onChanged(); + if (other.hasOriginalSubTree()) { + mergeOriginalSubTree(other.getOriginalSubTree()); + } + if (other.hasUpdatedSubTree()) { + mergeUpdatedSubTree(other.getUpdatedSubTree()); + } + if (other.hasOriginalData()) { + mergeOriginalData(other.getOriginalData()); } - if (other.hasNormalizedNodeXml()) { - mergeNormalizedNodeXml(other.getNormalizedNodeXml()); + if (other.hasUpdatedData()) { + mergeUpdatedData(other.getUpdatedData()); + } + if (other.hasCreatedData()) { + mergeCreatedData(other.getCreatedData()); + } + if (removedPathsBuilder_ == null) { + if (!other.removedPaths_.isEmpty()) { + if (removedPaths_.isEmpty()) { + removedPaths_ = other.removedPaths_; + bitField0_ = (bitField0_ & ~0x00000020); + } else { + ensureRemovedPathsIsMutable(); + removedPaths_.addAll(other.removedPaths_); + } + onChanged(); + } + } else { + if (!other.removedPaths_.isEmpty()) { + if (removedPathsBuilder_.isEmpty()) { + removedPathsBuilder_.dispose(); + removedPathsBuilder_ = null; + removedPaths_ = other.removedPaths_; + bitField0_ = (bitField0_ & ~0x00000020); + removedPathsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getRemovedPathsFieldBuilder() : null; + } else { + removedPathsBuilder_.addAllMessages(other.removedPaths_); + } + } } this.mergeUnknownFields(other.getUnknownFields()); return this; } public final boolean isInitialized() { - if (!hasNormalizedNodeXml()) { - - return false; + if (hasOriginalSubTree()) { + if (!getOriginalSubTree().isInitialized()) { + + return false; + } } - if (!getNormalizedNodeXml().isInitialized()) { - - return false; + if (hasUpdatedSubTree()) { + if (!getUpdatedSubTree().isInitialized()) { + + return false; + } + } + if (hasOriginalData()) { + if (!getOriginalData().isInitialized()) { + + return false; + } + } + if (hasUpdatedData()) { + if (!getUpdatedData().isInitialized()) { + + return false; + } + } + if (hasCreatedData()) { + if (!getCreatedData().isInitialized()) { + + return false; + } + } + for (int i = 0; i < getRemovedPathsCount(); i++) { + if (!getRemovedPaths(i).isInitialized()) { + + return false; + } } return true; } @@ -495,214 +881,829 @@ public final class DataChangeListenerMessages { } private int bitField0_; - // repeated string instanceIdentifierPathArguments = 1; - private com.google.protobuf.LazyStringList instanceIdentifierPathArguments_ = com.google.protobuf.LazyStringArrayList.EMPTY; - private void ensureInstanceIdentifierPathArgumentsIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - instanceIdentifierPathArguments_ = new com.google.protobuf.LazyStringArrayList(instanceIdentifierPathArguments_); - bitField0_ |= 0x00000001; - } - } + // optional .org.opendaylight.controller.mdsal.Node originalSubTree = 1; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node originalSubTree_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> originalSubTreeBuilder_; /** - * repeated string instanceIdentifierPathArguments = 1; + * optional .org.opendaylight.controller.mdsal.Node originalSubTree = 1; */ - public java.util.List - getInstanceIdentifierPathArgumentsList() { - return java.util.Collections.unmodifiableList(instanceIdentifierPathArguments_); + public boolean hasOriginalSubTree() { + return ((bitField0_ & 0x00000001) == 0x00000001); } /** - * repeated string instanceIdentifierPathArguments = 1; + * optional .org.opendaylight.controller.mdsal.Node originalSubTree = 1; */ - public int getInstanceIdentifierPathArgumentsCount() { - return instanceIdentifierPathArguments_.size(); + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getOriginalSubTree() { + if (originalSubTreeBuilder_ == null) { + return originalSubTree_; + } else { + return originalSubTreeBuilder_.getMessage(); + } } /** - * repeated string instanceIdentifierPathArguments = 1; + * optional .org.opendaylight.controller.mdsal.Node originalSubTree = 1; */ - public java.lang.String getInstanceIdentifierPathArguments(int index) { - return instanceIdentifierPathArguments_.get(index); + public Builder setOriginalSubTree(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node value) { + if (originalSubTreeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + originalSubTree_ = value; + onChanged(); + } else { + originalSubTreeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + return this; } /** - * repeated string instanceIdentifierPathArguments = 1; + * optional .org.opendaylight.controller.mdsal.Node originalSubTree = 1; */ - public com.google.protobuf.ByteString - getInstanceIdentifierPathArgumentsBytes(int index) { - return instanceIdentifierPathArguments_.getByteString(index); + public Builder setOriginalSubTree( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder builderForValue) { + if (originalSubTreeBuilder_ == null) { + originalSubTree_ = builderForValue.build(); + onChanged(); + } else { + originalSubTreeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + return this; } /** - * repeated string instanceIdentifierPathArguments = 1; + * optional .org.opendaylight.controller.mdsal.Node originalSubTree = 1; */ - public Builder setInstanceIdentifierPathArguments( - int index, java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureInstanceIdentifierPathArgumentsIsMutable(); - instanceIdentifierPathArguments_.set(index, value); - onChanged(); + public Builder mergeOriginalSubTree(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node value) { + if (originalSubTreeBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001) && + originalSubTree_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance()) { + originalSubTree_ = + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.newBuilder(originalSubTree_).mergeFrom(value).buildPartial(); + } else { + originalSubTree_ = value; + } + onChanged(); + } else { + originalSubTreeBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000001; return this; } /** - * repeated string instanceIdentifierPathArguments = 1; + * optional .org.opendaylight.controller.mdsal.Node originalSubTree = 1; */ - public Builder addInstanceIdentifierPathArguments( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureInstanceIdentifierPathArgumentsIsMutable(); - instanceIdentifierPathArguments_.add(value); - onChanged(); + public Builder clearOriginalSubTree() { + if (originalSubTreeBuilder_ == null) { + originalSubTree_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); + onChanged(); + } else { + originalSubTreeBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); return this; } /** - * repeated string instanceIdentifierPathArguments = 1; + * optional .org.opendaylight.controller.mdsal.Node originalSubTree = 1; */ - public Builder addAllInstanceIdentifierPathArguments( - java.lang.Iterable values) { - ensureInstanceIdentifierPathArgumentsIsMutable(); - super.addAll(values, instanceIdentifierPathArguments_); + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder getOriginalSubTreeBuilder() { + bitField0_ |= 0x00000001; onChanged(); - return this; + return getOriginalSubTreeFieldBuilder().getBuilder(); } /** - * repeated string instanceIdentifierPathArguments = 1; + * optional .org.opendaylight.controller.mdsal.Node originalSubTree = 1; */ - public Builder clearInstanceIdentifierPathArguments() { - instanceIdentifierPathArguments_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - return this; + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getOriginalSubTreeOrBuilder() { + if (originalSubTreeBuilder_ != null) { + return originalSubTreeBuilder_.getMessageOrBuilder(); + } else { + return originalSubTree_; + } } /** - * repeated string instanceIdentifierPathArguments = 1; + * optional .org.opendaylight.controller.mdsal.Node originalSubTree = 1; */ - public Builder addInstanceIdentifierPathArgumentsBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - ensureInstanceIdentifierPathArgumentsIsMutable(); - instanceIdentifierPathArguments_.add(value); - onChanged(); - return this; + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> + getOriginalSubTreeFieldBuilder() { + if (originalSubTreeBuilder_ == null) { + originalSubTreeBuilder_ = new com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder>( + originalSubTree_, + getParentForChildren(), + isClean()); + originalSubTree_ = null; + } + return originalSubTreeBuilder_; } - // required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNodeXml = 2; - private org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml normalizedNodeXml_ = org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.getDefaultInstance(); + // optional .org.opendaylight.controller.mdsal.Node updatedSubTree = 2; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node updatedSubTree_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml, org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.Builder, org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXmlOrBuilder> normalizedNodeXmlBuilder_; + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> updatedSubTreeBuilder_; /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNodeXml = 2; + * optional .org.opendaylight.controller.mdsal.Node updatedSubTree = 2; */ - public boolean hasNormalizedNodeXml() { + public boolean hasUpdatedSubTree() { return ((bitField0_ & 0x00000002) == 0x00000002); } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNodeXml = 2; + * optional .org.opendaylight.controller.mdsal.Node updatedSubTree = 2; */ - public org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml getNormalizedNodeXml() { - if (normalizedNodeXmlBuilder_ == null) { - return normalizedNodeXml_; + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getUpdatedSubTree() { + if (updatedSubTreeBuilder_ == null) { + return updatedSubTree_; } else { - return normalizedNodeXmlBuilder_.getMessage(); + return updatedSubTreeBuilder_.getMessage(); } } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNodeXml = 2; + * optional .org.opendaylight.controller.mdsal.Node updatedSubTree = 2; */ - public Builder setNormalizedNodeXml(org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml value) { - if (normalizedNodeXmlBuilder_ == null) { + public Builder setUpdatedSubTree(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node value) { + if (updatedSubTreeBuilder_ == null) { if (value == null) { throw new NullPointerException(); } - normalizedNodeXml_ = value; + updatedSubTree_ = value; onChanged(); } else { - normalizedNodeXmlBuilder_.setMessage(value); + updatedSubTreeBuilder_.setMessage(value); } bitField0_ |= 0x00000002; return this; } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNodeXml = 2; + * optional .org.opendaylight.controller.mdsal.Node updatedSubTree = 2; */ - public Builder setNormalizedNodeXml( - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.Builder builderForValue) { - if (normalizedNodeXmlBuilder_ == null) { - normalizedNodeXml_ = builderForValue.build(); + public Builder setUpdatedSubTree( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder builderForValue) { + if (updatedSubTreeBuilder_ == null) { + updatedSubTree_ = builderForValue.build(); onChanged(); } else { - normalizedNodeXmlBuilder_.setMessage(builderForValue.build()); + updatedSubTreeBuilder_.setMessage(builderForValue.build()); } bitField0_ |= 0x00000002; return this; } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNodeXml = 2; + * optional .org.opendaylight.controller.mdsal.Node updatedSubTree = 2; */ - public Builder mergeNormalizedNodeXml(org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml value) { - if (normalizedNodeXmlBuilder_ == null) { + public Builder mergeUpdatedSubTree(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node value) { + if (updatedSubTreeBuilder_ == null) { if (((bitField0_ & 0x00000002) == 0x00000002) && - normalizedNodeXml_ != org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.getDefaultInstance()) { - normalizedNodeXml_ = - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.newBuilder(normalizedNodeXml_).mergeFrom(value).buildPartial(); + updatedSubTree_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance()) { + updatedSubTree_ = + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.newBuilder(updatedSubTree_).mergeFrom(value).buildPartial(); } else { - normalizedNodeXml_ = value; + updatedSubTree_ = value; } onChanged(); } else { - normalizedNodeXmlBuilder_.mergeFrom(value); + updatedSubTreeBuilder_.mergeFrom(value); } bitField0_ |= 0x00000002; return this; } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNodeXml = 2; + * optional .org.opendaylight.controller.mdsal.Node updatedSubTree = 2; */ - public Builder clearNormalizedNodeXml() { - if (normalizedNodeXmlBuilder_ == null) { - normalizedNodeXml_ = org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.getDefaultInstance(); + public Builder clearUpdatedSubTree() { + if (updatedSubTreeBuilder_ == null) { + updatedSubTree_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); onChanged(); } else { - normalizedNodeXmlBuilder_.clear(); + updatedSubTreeBuilder_.clear(); } bitField0_ = (bitField0_ & ~0x00000002); return this; } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNodeXml = 2; + * optional .org.opendaylight.controller.mdsal.Node updatedSubTree = 2; */ - public org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.Builder getNormalizedNodeXmlBuilder() { + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder getUpdatedSubTreeBuilder() { bitField0_ |= 0x00000002; onChanged(); - return getNormalizedNodeXmlFieldBuilder().getBuilder(); + return getUpdatedSubTreeFieldBuilder().getBuilder(); } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNodeXml = 2; + * optional .org.opendaylight.controller.mdsal.Node updatedSubTree = 2; */ - public org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXmlOrBuilder getNormalizedNodeXmlOrBuilder() { - if (normalizedNodeXmlBuilder_ != null) { - return normalizedNodeXmlBuilder_.getMessageOrBuilder(); + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getUpdatedSubTreeOrBuilder() { + if (updatedSubTreeBuilder_ != null) { + return updatedSubTreeBuilder_.getMessageOrBuilder(); } else { - return normalizedNodeXml_; + return updatedSubTree_; } } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNodeXml = 2; + * optional .org.opendaylight.controller.mdsal.Node updatedSubTree = 2; */ private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml, org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.Builder, org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXmlOrBuilder> - getNormalizedNodeXmlFieldBuilder() { - if (normalizedNodeXmlBuilder_ == null) { - normalizedNodeXmlBuilder_ = new com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml, org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.Builder, org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXmlOrBuilder>( - normalizedNodeXml_, + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> + getUpdatedSubTreeFieldBuilder() { + if (updatedSubTreeBuilder_ == null) { + updatedSubTreeBuilder_ = new com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder>( + updatedSubTree_, + getParentForChildren(), + isClean()); + updatedSubTree_ = null; + } + return updatedSubTreeBuilder_; + } + + // optional .org.opendaylight.controller.mdsal.NodeMap originalData = 3; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap originalData_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.getDefaultInstance(); + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapOrBuilder> originalDataBuilder_; + /** + * optional .org.opendaylight.controller.mdsal.NodeMap originalData = 3; + */ + public boolean hasOriginalData() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap originalData = 3; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap getOriginalData() { + if (originalDataBuilder_ == null) { + return originalData_; + } else { + return originalDataBuilder_.getMessage(); + } + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap originalData = 3; + */ + public Builder setOriginalData(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap value) { + if (originalDataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + originalData_ = value; + onChanged(); + } else { + originalDataBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap originalData = 3; + */ + public Builder setOriginalData( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder builderForValue) { + if (originalDataBuilder_ == null) { + originalData_ = builderForValue.build(); + onChanged(); + } else { + originalDataBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap originalData = 3; + */ + public Builder mergeOriginalData(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap value) { + if (originalDataBuilder_ == null) { + if (((bitField0_ & 0x00000004) == 0x00000004) && + originalData_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.getDefaultInstance()) { + originalData_ = + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.newBuilder(originalData_).mergeFrom(value).buildPartial(); + } else { + originalData_ = value; + } + onChanged(); + } else { + originalDataBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000004; + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap originalData = 3; + */ + public Builder clearOriginalData() { + if (originalDataBuilder_ == null) { + originalData_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.getDefaultInstance(); + onChanged(); + } else { + originalDataBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000004); + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap originalData = 3; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder getOriginalDataBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getOriginalDataFieldBuilder().getBuilder(); + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap originalData = 3; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapOrBuilder getOriginalDataOrBuilder() { + if (originalDataBuilder_ != null) { + return originalDataBuilder_.getMessageOrBuilder(); + } else { + return originalData_; + } + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap originalData = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapOrBuilder> + getOriginalDataFieldBuilder() { + if (originalDataBuilder_ == null) { + originalDataBuilder_ = new com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapOrBuilder>( + originalData_, + getParentForChildren(), + isClean()); + originalData_ = null; + } + return originalDataBuilder_; + } + + // optional .org.opendaylight.controller.mdsal.NodeMap updatedData = 4; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap updatedData_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.getDefaultInstance(); + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapOrBuilder> updatedDataBuilder_; + /** + * optional .org.opendaylight.controller.mdsal.NodeMap updatedData = 4; + */ + public boolean hasUpdatedData() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap updatedData = 4; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap getUpdatedData() { + if (updatedDataBuilder_ == null) { + return updatedData_; + } else { + return updatedDataBuilder_.getMessage(); + } + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap updatedData = 4; + */ + public Builder setUpdatedData(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap value) { + if (updatedDataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + updatedData_ = value; + onChanged(); + } else { + updatedDataBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap updatedData = 4; + */ + public Builder setUpdatedData( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder builderForValue) { + if (updatedDataBuilder_ == null) { + updatedData_ = builderForValue.build(); + onChanged(); + } else { + updatedDataBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap updatedData = 4; + */ + public Builder mergeUpdatedData(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap value) { + if (updatedDataBuilder_ == null) { + if (((bitField0_ & 0x00000008) == 0x00000008) && + updatedData_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.getDefaultInstance()) { + updatedData_ = + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.newBuilder(updatedData_).mergeFrom(value).buildPartial(); + } else { + updatedData_ = value; + } + onChanged(); + } else { + updatedDataBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000008; + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap updatedData = 4; + */ + public Builder clearUpdatedData() { + if (updatedDataBuilder_ == null) { + updatedData_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.getDefaultInstance(); + onChanged(); + } else { + updatedDataBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000008); + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap updatedData = 4; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder getUpdatedDataBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return getUpdatedDataFieldBuilder().getBuilder(); + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap updatedData = 4; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapOrBuilder getUpdatedDataOrBuilder() { + if (updatedDataBuilder_ != null) { + return updatedDataBuilder_.getMessageOrBuilder(); + } else { + return updatedData_; + } + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap updatedData = 4; + */ + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapOrBuilder> + getUpdatedDataFieldBuilder() { + if (updatedDataBuilder_ == null) { + updatedDataBuilder_ = new com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapOrBuilder>( + updatedData_, + getParentForChildren(), + isClean()); + updatedData_ = null; + } + return updatedDataBuilder_; + } + + // optional .org.opendaylight.controller.mdsal.NodeMap createdData = 5; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap createdData_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.getDefaultInstance(); + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapOrBuilder> createdDataBuilder_; + /** + * optional .org.opendaylight.controller.mdsal.NodeMap createdData = 5; + */ + public boolean hasCreatedData() { + return ((bitField0_ & 0x00000010) == 0x00000010); + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap createdData = 5; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap getCreatedData() { + if (createdDataBuilder_ == null) { + return createdData_; + } else { + return createdDataBuilder_.getMessage(); + } + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap createdData = 5; + */ + public Builder setCreatedData(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap value) { + if (createdDataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + createdData_ = value; + onChanged(); + } else { + createdDataBuilder_.setMessage(value); + } + bitField0_ |= 0x00000010; + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap createdData = 5; + */ + public Builder setCreatedData( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder builderForValue) { + if (createdDataBuilder_ == null) { + createdData_ = builderForValue.build(); + onChanged(); + } else { + createdDataBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000010; + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap createdData = 5; + */ + public Builder mergeCreatedData(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap value) { + if (createdDataBuilder_ == null) { + if (((bitField0_ & 0x00000010) == 0x00000010) && + createdData_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.getDefaultInstance()) { + createdData_ = + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.newBuilder(createdData_).mergeFrom(value).buildPartial(); + } else { + createdData_ = value; + } + onChanged(); + } else { + createdDataBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000010; + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap createdData = 5; + */ + public Builder clearCreatedData() { + if (createdDataBuilder_ == null) { + createdData_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.getDefaultInstance(); + onChanged(); + } else { + createdDataBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000010); + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap createdData = 5; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder getCreatedDataBuilder() { + bitField0_ |= 0x00000010; + onChanged(); + return getCreatedDataFieldBuilder().getBuilder(); + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap createdData = 5; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapOrBuilder getCreatedDataOrBuilder() { + if (createdDataBuilder_ != null) { + return createdDataBuilder_.getMessageOrBuilder(); + } else { + return createdData_; + } + } + /** + * optional .org.opendaylight.controller.mdsal.NodeMap createdData = 5; + */ + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapOrBuilder> + getCreatedDataFieldBuilder() { + if (createdDataBuilder_ == null) { + createdDataBuilder_ = new com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapOrBuilder>( + createdData_, + getParentForChildren(), + isClean()); + createdData_ = null; + } + return createdDataBuilder_; + } + + // repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + private java.util.List removedPaths_ = + java.util.Collections.emptyList(); + private void ensureRemovedPathsIsMutable() { + if (!((bitField0_ & 0x00000020) == 0x00000020)) { + removedPaths_ = new java.util.ArrayList(removedPaths_); + bitField0_ |= 0x00000020; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> removedPathsBuilder_; + + /** + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + */ + public java.util.List getRemovedPathsList() { + if (removedPathsBuilder_ == null) { + return java.util.Collections.unmodifiableList(removedPaths_); + } else { + return removedPathsBuilder_.getMessageList(); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + */ + public int getRemovedPathsCount() { + if (removedPathsBuilder_ == null) { + return removedPaths_.size(); + } else { + return removedPathsBuilder_.getCount(); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getRemovedPaths(int index) { + if (removedPathsBuilder_ == null) { + return removedPaths_.get(index); + } else { + return removedPathsBuilder_.getMessage(index); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + */ + public Builder setRemovedPaths( + int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier value) { + if (removedPathsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRemovedPathsIsMutable(); + removedPaths_.set(index, value); + onChanged(); + } else { + removedPathsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + */ + public Builder setRemovedPaths( + int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder builderForValue) { + if (removedPathsBuilder_ == null) { + ensureRemovedPathsIsMutable(); + removedPaths_.set(index, builderForValue.build()); + onChanged(); + } else { + removedPathsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + */ + public Builder addRemovedPaths(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier value) { + if (removedPathsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRemovedPathsIsMutable(); + removedPaths_.add(value); + onChanged(); + } else { + removedPathsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + */ + public Builder addRemovedPaths( + int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier value) { + if (removedPathsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRemovedPathsIsMutable(); + removedPaths_.add(index, value); + onChanged(); + } else { + removedPathsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + */ + public Builder addRemovedPaths( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder builderForValue) { + if (removedPathsBuilder_ == null) { + ensureRemovedPathsIsMutable(); + removedPaths_.add(builderForValue.build()); + onChanged(); + } else { + removedPathsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + */ + public Builder addRemovedPaths( + int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder builderForValue) { + if (removedPathsBuilder_ == null) { + ensureRemovedPathsIsMutable(); + removedPaths_.add(index, builderForValue.build()); + onChanged(); + } else { + removedPathsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + */ + public Builder addAllRemovedPaths( + java.lang.Iterable values) { + if (removedPathsBuilder_ == null) { + ensureRemovedPathsIsMutable(); + super.addAll(values, removedPaths_); + onChanged(); + } else { + removedPathsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + */ + public Builder clearRemovedPaths() { + if (removedPathsBuilder_ == null) { + removedPaths_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000020); + onChanged(); + } else { + removedPathsBuilder_.clear(); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + */ + public Builder removeRemovedPaths(int index) { + if (removedPathsBuilder_ == null) { + ensureRemovedPathsIsMutable(); + removedPaths_.remove(index); + onChanged(); + } else { + removedPathsBuilder_.remove(index); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder getRemovedPathsBuilder( + int index) { + return getRemovedPathsFieldBuilder().getBuilder(index); + } + /** + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getRemovedPathsOrBuilder( + int index) { + if (removedPathsBuilder_ == null) { + return removedPaths_.get(index); } else { + return removedPathsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + */ + public java.util.List + getRemovedPathsOrBuilderList() { + if (removedPathsBuilder_ != null) { + return removedPathsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(removedPaths_); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder addRemovedPathsBuilder() { + return getRemovedPathsFieldBuilder().addBuilder( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance()); + } + /** + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder addRemovedPathsBuilder( + int index) { + return getRemovedPathsFieldBuilder().addBuilder( + index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance()); + } + /** + * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; + */ + public java.util.List + getRemovedPathsBuilderList() { + return getRemovedPathsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> + getRemovedPathsFieldBuilder() { + if (removedPathsBuilder_ == null) { + removedPathsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder>( + removedPaths_, + ((bitField0_ & 0x00000020) == 0x00000020), getParentForChildren(), isClean()); - normalizedNodeXml_ = null; + removedPaths_ = null; } - return normalizedNodeXmlBuilder_; + return removedPathsBuilder_; } // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.DataChanged) @@ -1045,14 +2046,21 @@ public final class DataChangeListenerMessages { static { java.lang.String[] descriptorData = { "\n\030DataChangeListener.proto\022!org.opendayl" + - "ight.controller.mdsal\032\032SimpleNormalizedN" + - "ode.proto\"\207\001\n\013DataChanged\022\'\n\037instanceIde" + - "ntifierPathArguments\030\001 \003(\t\022O\n\021normalized" + - "NodeXml\030\002 \002(\01324.org.opendaylight.control" + - "ler.mdsal.NormalizedNodeXml\"\022\n\020DataChang" + - "edReplyBd\nForg.opendaylight.controller.p" + - "rotobuff.messages.datachange.notificatio" + - "nB\032DataChangeListenerMessages" + "ight.controller.mdsal\032\014Common.proto\"\241\003\n\013" + + "DataChanged\022@\n\017originalSubTree\030\001 \001(\0132\'.o" + + "rg.opendaylight.controller.mdsal.Node\022?\n" + + "\016updatedSubTree\030\002 \001(\0132\'.org.opendaylight" + + ".controller.mdsal.Node\022@\n\014originalData\030\003" + + " \001(\0132*.org.opendaylight.controller.mdsal" + + ".NodeMap\022?\n\013updatedData\030\004 \001(\0132*.org.open" + + "daylight.controller.mdsal.NodeMap\022?\n\013cre" + + "atedData\030\005 \001(\0132*.org.opendaylight.contro", + "ller.mdsal.NodeMap\022K\n\014removedPaths\030\006 \003(\013" + + "25.org.opendaylight.controller.mdsal.Ins" + + "tanceIdentifier\"\022\n\020DataChangedReplyBd\nFo" + + "rg.opendaylight.controller.protobuff.mes" + + "sages.datachange.notificationB\032DataChang" + + "eListenerMessages" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { @@ -1064,7 +2072,7 @@ public final class DataChangeListenerMessages { internal_static_org_opendaylight_controller_mdsal_DataChanged_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_org_opendaylight_controller_mdsal_DataChanged_descriptor, - new java.lang.String[] { "InstanceIdentifierPathArguments", "NormalizedNodeXml", }); + new java.lang.String[] { "OriginalSubTree", "UpdatedSubTree", "OriginalData", "UpdatedData", "CreatedData", "RemovedPaths", }); internal_static_org_opendaylight_controller_mdsal_DataChangedReply_descriptor = getDescriptor().getMessageTypes().get(1); internal_static_org_opendaylight_controller_mdsal_DataChangedReply_fieldAccessorTable = new @@ -1077,7 +2085,7 @@ public final class DataChangeListenerMessages { com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] { - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.getDescriptor(), + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.getDescriptor(), }, assigner); } 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-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/persistent/PersistentMessages.java new file mode 100644 index 0000000000..eaa90012db --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/persistent/PersistentMessages.java @@ -0,0 +1,1648 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: Persistent.proto + +package org.opendaylight.controller.protobuff.messages.persistent; + +public final class PersistentMessages { + private PersistentMessages() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + public interface ModificationOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required string type = 1; + /** + * required string type = 1; + */ + boolean hasType(); + /** + * required string type = 1; + */ + java.lang.String getType(); + /** + * required string type = 1; + */ + com.google.protobuf.ByteString + getTypeBytes(); + + // required .org.opendaylight.controller.mdsal.InstanceIdentifier path = 2; + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier path = 2; + */ + boolean hasPath(); + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier path = 2; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getPath(); + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier path = 2; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getPathOrBuilder(); + + // optional .org.opendaylight.controller.mdsal.Node data = 3; + /** + * optional .org.opendaylight.controller.mdsal.Node data = 3; + */ + boolean hasData(); + /** + * optional .org.opendaylight.controller.mdsal.Node data = 3; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getData(); + /** + * optional .org.opendaylight.controller.mdsal.Node data = 3; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getDataOrBuilder(); + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.Modification} + */ + public static final class Modification extends + com.google.protobuf.GeneratedMessage + implements ModificationOrBuilder { + // Use Modification.newBuilder() to construct. + private Modification(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private Modification(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final Modification defaultInstance; + public static Modification getDefaultInstance() { + return defaultInstance; + } + + public Modification getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Modification( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + bitField0_ |= 0x00000001; + type_ = input.readBytes(); + break; + } + case 18: { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder subBuilder = null; + if (((bitField0_ & 0x00000002) == 0x00000002)) { + subBuilder = path_.toBuilder(); + } + path_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(path_); + path_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000002; + break; + } + case 26: { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder subBuilder = null; + if (((bitField0_ & 0x00000004) == 0x00000004)) { + subBuilder = data_.toBuilder(); + } + data_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(data_); + data_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000004; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.internal_static_org_opendaylight_controller_mdsal_Modification_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.internal_static_org_opendaylight_controller_mdsal_Modification_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification.class, org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public Modification parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Modification(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // required string type = 1; + public static final int TYPE_FIELD_NUMBER = 1; + private java.lang.Object type_; + /** + * required string type = 1; + */ + public boolean hasType() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string type = 1; + */ + public java.lang.String getType() { + java.lang.Object ref = type_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + type_ = s; + } + return s; + } + } + /** + * required string type = 1; + */ + public com.google.protobuf.ByteString + getTypeBytes() { + java.lang.Object ref = type_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + type_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // required .org.opendaylight.controller.mdsal.InstanceIdentifier path = 2; + public static final int PATH_FIELD_NUMBER = 2; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier path_; + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier path = 2; + */ + public boolean hasPath() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier path = 2; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getPath() { + return path_; + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier path = 2; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getPathOrBuilder() { + return path_; + } + + // optional .org.opendaylight.controller.mdsal.Node data = 3; + public static final int DATA_FIELD_NUMBER = 3; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node data_; + /** + * optional .org.opendaylight.controller.mdsal.Node data = 3; + */ + public boolean hasData() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional .org.opendaylight.controller.mdsal.Node data = 3; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getData() { + return data_; + } + /** + * optional .org.opendaylight.controller.mdsal.Node data = 3; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getDataOrBuilder() { + return data_; + } + + private void initFields() { + type_ = ""; + path_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + data_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasType()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasPath()) { + memoizedIsInitialized = 0; + return false; + } + if (!getPath().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + if (hasData()) { + if (!getData().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getTypeBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeMessage(2, path_); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeMessage(3, data_); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getTypeBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, path_); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, data_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.Modification} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.ModificationOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.internal_static_org_opendaylight_controller_mdsal_Modification_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.internal_static_org_opendaylight_controller_mdsal_Modification_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification.class, org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification.Builder.class); + } + + // Construct using org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getPathFieldBuilder(); + getDataFieldBuilder(); + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + type_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + if (pathBuilder_ == null) { + path_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + } else { + pathBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + if (dataBuilder_ == null) { + data_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); + } else { + dataBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000004); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.internal_static_org_opendaylight_controller_mdsal_Modification_descriptor; + } + + public org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification getDefaultInstanceForType() { + return org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification.getDefaultInstance(); + } + + public org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification build() { + org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification buildPartial() { + org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification result = new org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.type_ = type_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + if (pathBuilder_ == null) { + result.path_ = path_; + } else { + result.path_ = pathBuilder_.build(); + } + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000004; + } + if (dataBuilder_ == null) { + result.data_ = data_; + } else { + result.data_ = dataBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification) { + return mergeFrom((org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification other) { + if (other == org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification.getDefaultInstance()) return this; + if (other.hasType()) { + bitField0_ |= 0x00000001; + type_ = other.type_; + onChanged(); + } + if (other.hasPath()) { + mergePath(other.getPath()); + } + if (other.hasData()) { + mergeData(other.getData()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasType()) { + + return false; + } + if (!hasPath()) { + + return false; + } + if (!getPath().isInitialized()) { + + return false; + } + if (hasData()) { + if (!getData().isInitialized()) { + + return false; + } + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required string type = 1; + private java.lang.Object type_ = ""; + /** + * required string type = 1; + */ + public boolean hasType() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string type = 1; + */ + public java.lang.String getType() { + java.lang.Object ref = type_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + type_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string type = 1; + */ + public com.google.protobuf.ByteString + getTypeBytes() { + java.lang.Object ref = type_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + type_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string type = 1; + */ + public Builder setType( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + type_ = value; + onChanged(); + return this; + } + /** + * required string type = 1; + */ + public Builder clearType() { + bitField0_ = (bitField0_ & ~0x00000001); + type_ = getDefaultInstance().getType(); + onChanged(); + return this; + } + /** + * required string type = 1; + */ + public Builder setTypeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + type_ = value; + onChanged(); + return this; + } + + // required .org.opendaylight.controller.mdsal.InstanceIdentifier path = 2; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier path_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> pathBuilder_; + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier path = 2; + */ + public boolean hasPath() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier path = 2; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getPath() { + if (pathBuilder_ == null) { + return path_; + } else { + return pathBuilder_.getMessage(); + } + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier path = 2; + */ + public Builder setPath(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier value) { + if (pathBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + path_ = value; + onChanged(); + } else { + pathBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + return this; + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier path = 2; + */ + public Builder setPath( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder builderForValue) { + if (pathBuilder_ == null) { + path_ = builderForValue.build(); + onChanged(); + } else { + pathBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + return this; + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier path = 2; + */ + public Builder mergePath(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier value) { + if (pathBuilder_ == null) { + if (((bitField0_ & 0x00000002) == 0x00000002) && + path_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance()) { + path_ = + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.newBuilder(path_).mergeFrom(value).buildPartial(); + } else { + path_ = value; + } + onChanged(); + } else { + pathBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000002; + return this; + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier path = 2; + */ + public Builder clearPath() { + if (pathBuilder_ == null) { + path_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + onChanged(); + } else { + pathBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier path = 2; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder getPathBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getPathFieldBuilder().getBuilder(); + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier path = 2; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getPathOrBuilder() { + if (pathBuilder_ != null) { + return pathBuilder_.getMessageOrBuilder(); + } else { + return path_; + } + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier path = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> + getPathFieldBuilder() { + if (pathBuilder_ == null) { + pathBuilder_ = new com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder>( + path_, + getParentForChildren(), + isClean()); + path_ = null; + } + return pathBuilder_; + } + + // optional .org.opendaylight.controller.mdsal.Node data = 3; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node data_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> dataBuilder_; + /** + * optional .org.opendaylight.controller.mdsal.Node data = 3; + */ + public boolean hasData() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional .org.opendaylight.controller.mdsal.Node data = 3; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getData() { + if (dataBuilder_ == null) { + return data_; + } else { + return dataBuilder_.getMessage(); + } + } + /** + * optional .org.opendaylight.controller.mdsal.Node data = 3; + */ + public Builder setData(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node value) { + if (dataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + data_ = value; + onChanged(); + } else { + dataBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.Node data = 3; + */ + public Builder setData( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder builderForValue) { + if (dataBuilder_ == null) { + data_ = builderForValue.build(); + onChanged(); + } else { + dataBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.Node data = 3; + */ + public Builder mergeData(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node value) { + if (dataBuilder_ == null) { + if (((bitField0_ & 0x00000004) == 0x00000004) && + data_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance()) { + data_ = + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.newBuilder(data_).mergeFrom(value).buildPartial(); + } else { + data_ = value; + } + onChanged(); + } else { + dataBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000004; + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.Node data = 3; + */ + public Builder clearData() { + if (dataBuilder_ == null) { + data_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); + onChanged(); + } else { + dataBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000004); + return this; + } + /** + * optional .org.opendaylight.controller.mdsal.Node data = 3; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder getDataBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getDataFieldBuilder().getBuilder(); + } + /** + * optional .org.opendaylight.controller.mdsal.Node data = 3; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getDataOrBuilder() { + if (dataBuilder_ != null) { + return dataBuilder_.getMessageOrBuilder(); + } else { + return data_; + } + } + /** + * optional .org.opendaylight.controller.mdsal.Node data = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> + getDataFieldBuilder() { + if (dataBuilder_ == null) { + dataBuilder_ = new com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder>( + data_, + getParentForChildren(), + isClean()); + data_ = null; + } + return dataBuilder_; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.Modification) + } + + static { + defaultInstance = new Modification(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.Modification) + } + + public interface CompositeModificationOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + java.util.List + getModificationList(); + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification getModification(int index); + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + int getModificationCount(); + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + java.util.List + getModificationOrBuilderList(); + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.ModificationOrBuilder getModificationOrBuilder( + int index); + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CompositeModification} + */ + public static final class CompositeModification extends + com.google.protobuf.GeneratedMessage + implements CompositeModificationOrBuilder { + // Use CompositeModification.newBuilder() to construct. + private CompositeModification(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private CompositeModification(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final CompositeModification defaultInstance; + public static CompositeModification getDefaultInstance() { + return defaultInstance; + } + + public CompositeModification getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private CompositeModification( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + modification_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + modification_.add(input.readMessage(org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification.PARSER, extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + modification_ = java.util.Collections.unmodifiableList(modification_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.internal_static_org_opendaylight_controller_mdsal_CompositeModification_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.internal_static_org_opendaylight_controller_mdsal_CompositeModification_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification.class, org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public CompositeModification parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new CompositeModification(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + // repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + public static final int MODIFICATION_FIELD_NUMBER = 1; + private java.util.List modification_; + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + public java.util.List getModificationList() { + return modification_; + } + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + public java.util.List + getModificationOrBuilderList() { + return modification_; + } + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + public int getModificationCount() { + return modification_.size(); + } + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + public org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification getModification(int index) { + return modification_.get(index); + } + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + public org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.ModificationOrBuilder getModificationOrBuilder( + int index) { + return modification_.get(index); + } + + private void initFields() { + modification_ = java.util.Collections.emptyList(); + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + for (int i = 0; i < getModificationCount(); i++) { + if (!getModification(i).isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + for (int i = 0; i < modification_.size(); i++) { + output.writeMessage(1, modification_.get(i)); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < modification_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, modification_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CompositeModification} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModificationOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.internal_static_org_opendaylight_controller_mdsal_CompositeModification_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.internal_static_org_opendaylight_controller_mdsal_CompositeModification_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification.class, org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification.Builder.class); + } + + // Construct using org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getModificationFieldBuilder(); + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + if (modificationBuilder_ == null) { + modification_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + modificationBuilder_.clear(); + } + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.internal_static_org_opendaylight_controller_mdsal_CompositeModification_descriptor; + } + + public org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification getDefaultInstanceForType() { + return org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification.getDefaultInstance(); + } + + public org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification build() { + org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification buildPartial() { + org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification result = new org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification(this); + int from_bitField0_ = bitField0_; + if (modificationBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + modification_ = java.util.Collections.unmodifiableList(modification_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.modification_ = modification_; + } else { + result.modification_ = modificationBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification) { + return mergeFrom((org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification other) { + if (other == org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification.getDefaultInstance()) return this; + if (modificationBuilder_ == null) { + if (!other.modification_.isEmpty()) { + if (modification_.isEmpty()) { + modification_ = other.modification_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureModificationIsMutable(); + modification_.addAll(other.modification_); + } + onChanged(); + } + } else { + if (!other.modification_.isEmpty()) { + if (modificationBuilder_.isEmpty()) { + modificationBuilder_.dispose(); + modificationBuilder_ = null; + modification_ = other.modification_; + bitField0_ = (bitField0_ & ~0x00000001); + modificationBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getModificationFieldBuilder() : null; + } else { + modificationBuilder_.addAllMessages(other.modification_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + for (int i = 0; i < getModificationCount(); i++) { + if (!getModification(i).isInitialized()) { + + return false; + } + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + private java.util.List modification_ = + java.util.Collections.emptyList(); + private void ensureModificationIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + modification_ = new java.util.ArrayList(modification_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification, org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification.Builder, org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.ModificationOrBuilder> modificationBuilder_; + + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + public java.util.List getModificationList() { + if (modificationBuilder_ == null) { + return java.util.Collections.unmodifiableList(modification_); + } else { + return modificationBuilder_.getMessageList(); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + public int getModificationCount() { + if (modificationBuilder_ == null) { + return modification_.size(); + } else { + return modificationBuilder_.getCount(); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + public org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification getModification(int index) { + if (modificationBuilder_ == null) { + return modification_.get(index); + } else { + return modificationBuilder_.getMessage(index); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + public Builder setModification( + int index, org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification value) { + if (modificationBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureModificationIsMutable(); + modification_.set(index, value); + onChanged(); + } else { + modificationBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + public Builder setModification( + int index, org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification.Builder builderForValue) { + if (modificationBuilder_ == null) { + ensureModificationIsMutable(); + modification_.set(index, builderForValue.build()); + onChanged(); + } else { + modificationBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + public Builder addModification(org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification value) { + if (modificationBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureModificationIsMutable(); + modification_.add(value); + onChanged(); + } else { + modificationBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + public Builder addModification( + int index, org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification value) { + if (modificationBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureModificationIsMutable(); + modification_.add(index, value); + onChanged(); + } else { + modificationBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + public Builder addModification( + org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification.Builder builderForValue) { + if (modificationBuilder_ == null) { + ensureModificationIsMutable(); + modification_.add(builderForValue.build()); + onChanged(); + } else { + modificationBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + public Builder addModification( + int index, org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification.Builder builderForValue) { + if (modificationBuilder_ == null) { + ensureModificationIsMutable(); + modification_.add(index, builderForValue.build()); + onChanged(); + } else { + modificationBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + public Builder addAllModification( + java.lang.Iterable values) { + if (modificationBuilder_ == null) { + ensureModificationIsMutable(); + super.addAll(values, modification_); + onChanged(); + } else { + modificationBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + public Builder clearModification() { + if (modificationBuilder_ == null) { + modification_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + modificationBuilder_.clear(); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + public Builder removeModification(int index) { + if (modificationBuilder_ == null) { + ensureModificationIsMutable(); + modification_.remove(index); + onChanged(); + } else { + modificationBuilder_.remove(index); + } + return this; + } + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + public org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification.Builder getModificationBuilder( + int index) { + return getModificationFieldBuilder().getBuilder(index); + } + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + public org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.ModificationOrBuilder getModificationOrBuilder( + int index) { + if (modificationBuilder_ == null) { + return modification_.get(index); } else { + return modificationBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + public java.util.List + getModificationOrBuilderList() { + if (modificationBuilder_ != null) { + return modificationBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(modification_); + } + } + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + public org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification.Builder addModificationBuilder() { + return getModificationFieldBuilder().addBuilder( + org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification.getDefaultInstance()); + } + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + public org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification.Builder addModificationBuilder( + int index) { + return getModificationFieldBuilder().addBuilder( + index, org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification.getDefaultInstance()); + } + /** + * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; + */ + public java.util.List + getModificationBuilderList() { + return getModificationFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification, org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification.Builder, org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.ModificationOrBuilder> + getModificationFieldBuilder() { + if (modificationBuilder_ == null) { + modificationBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification, org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification.Builder, org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.ModificationOrBuilder>( + modification_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + modification_ = null; + } + return modificationBuilder_; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.CompositeModification) + } + + static { + defaultInstance = new CompositeModification(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.CompositeModification) + } + + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_Modification_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_Modification_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_CompositeModification_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_CompositeModification_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\020Persistent.proto\022!org.opendaylight.con" + + "troller.mdsal\032\014Common.proto\032\033AppendEntri" + + "esMessages.proto\"\230\001\n\014Modification\022\014\n\004typ" + + "e\030\001 \002(\t\022C\n\004path\030\002 \002(\01325.org.opendaylight" + + ".controller.mdsal.InstanceIdentifier\0225\n\004" + + "data\030\003 \001(\0132\'.org.opendaylight.controller" + + ".mdsal.Node\"^\n\025CompositeModification\022E\n\014" + + "modification\030\001 \003(\0132/.org.opendaylight.co" + + "ntroller.mdsal.ModificationBO\n9org.opend" + + "aylight.controller.protobuff.messages.pe", + "rsistentB\022PersistentMessages" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + internal_static_org_opendaylight_controller_mdsal_Modification_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_org_opendaylight_controller_mdsal_Modification_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_Modification_descriptor, + new java.lang.String[] { "Type", "Path", "Data", }); + internal_static_org_opendaylight_controller_mdsal_CompositeModification_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_org_opendaylight_controller_mdsal_CompositeModification_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_CompositeModification_descriptor, + new java.lang.String[] { "Modification", }); + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.getDescriptor(), + org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.getDescriptor(), + }, assigner); + } + + // @@protoc_insertion_point(outer_class_scope) +} 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-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/registration/ListenerRegistrationMessages.java index a1906b8ba5..e06dd0d429 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/registration/ListenerRegistrationMessages.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/registration/ListenerRegistrationMessages.java @@ -8,28 +8,32 @@ public final class ListenerRegistrationMessages { public static void registerAllExtensions( com.google.protobuf.ExtensionRegistry registry) { } - public interface CloseOrBuilder + public interface CloseDataChangeListenerRegistrationOrBuilder extends com.google.protobuf.MessageOrBuilder { } /** - * Protobuf type {@code org.opendaylight.controller.mdsal.Close} + * Protobuf type {@code org.opendaylight.controller.mdsal.CloseDataChangeListenerRegistration} + * + *
+   ** used when a listener needs to be unregistered
+   * 
*/ - public static final class Close extends + public static final class CloseDataChangeListenerRegistration extends com.google.protobuf.GeneratedMessage - implements CloseOrBuilder { - // Use Close.newBuilder() to construct. - private Close(com.google.protobuf.GeneratedMessage.Builder builder) { + implements CloseDataChangeListenerRegistrationOrBuilder { + // Use CloseDataChangeListenerRegistration.newBuilder() to construct. + private CloseDataChangeListenerRegistration(com.google.protobuf.GeneratedMessage.Builder builder) { super(builder); this.unknownFields = builder.getUnknownFields(); } - private Close(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + private CloseDataChangeListenerRegistration(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - private static final Close defaultInstance; - public static Close getDefaultInstance() { + private static final CloseDataChangeListenerRegistration defaultInstance; + public static CloseDataChangeListenerRegistration getDefaultInstance() { return defaultInstance; } - public Close getDefaultInstanceForType() { + public CloseDataChangeListenerRegistration getDefaultInstanceForType() { return defaultInstance; } @@ -39,7 +43,7 @@ public final class ListenerRegistrationMessages { getUnknownFields() { return this.unknownFields; } - private Close( + private CloseDataChangeListenerRegistration( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { @@ -75,28 +79,28 @@ public final class ListenerRegistrationMessages { } public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_Close_descriptor; + return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_CloseDataChangeListenerRegistration_descriptor; } protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { - return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_Close_fieldAccessorTable + return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_CloseDataChangeListenerRegistration_fieldAccessorTable .ensureFieldAccessorsInitialized( - org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close.class, org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close.Builder.class); + org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration.class, org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration.Builder.class); } - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public Close parsePartialFrom( + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public CloseDataChangeListenerRegistration parsePartialFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { - return new Close(input, extensionRegistry); + return new CloseDataChangeListenerRegistration(input, extensionRegistry); } }; @java.lang.Override - public com.google.protobuf.Parser getParserForType() { + public com.google.protobuf.Parser getParserForType() { return PARSER; } @@ -135,53 +139,53 @@ public final class ListenerRegistrationMessages { return super.writeReplace(); } - public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close parseFrom( + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration parseFrom( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close parseFrom( + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration parseFrom( com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close parseFrom(byte[] data) + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close parseFrom( + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration parseFrom( byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close parseFrom(java.io.InputStream input) + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration parseFrom(java.io.InputStream input) throws java.io.IOException { return PARSER.parseFrom(input); } - public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close parseFrom( + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return PARSER.parseFrom(input, extensionRegistry); } - public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close parseDelimitedFrom(java.io.InputStream input) + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { return PARSER.parseDelimitedFrom(input); } - public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close parseDelimitedFrom( + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return PARSER.parseDelimitedFrom(input, extensionRegistry); } - public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close parseFrom( + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { return PARSER.parseFrom(input); } - public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close parseFrom( + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { @@ -190,7 +194,7 @@ public final class ListenerRegistrationMessages { public static Builder newBuilder() { return Builder.create(); } public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close prototype) { + public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); } @@ -202,24 +206,28 @@ public final class ListenerRegistrationMessages { return builder; } /** - * Protobuf type {@code org.opendaylight.controller.mdsal.Close} + * Protobuf type {@code org.opendaylight.controller.mdsal.CloseDataChangeListenerRegistration} + * + *
+     ** used when a listener needs to be unregistered
+     * 
*/ public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder - implements org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseOrBuilder { + implements org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_Close_descriptor; + return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_CloseDataChangeListenerRegistration_descriptor; } protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { - return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_Close_fieldAccessorTable + return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_CloseDataChangeListenerRegistration_fieldAccessorTable .ensureFieldAccessorsInitialized( - org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close.class, org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close.Builder.class); + org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration.class, org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration.Builder.class); } - // Construct using org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close.newBuilder() + // Construct using org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration.newBuilder() private Builder() { maybeForceBuilderInitialization(); } @@ -248,38 +256,38 @@ public final class ListenerRegistrationMessages { public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_Close_descriptor; + return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_CloseDataChangeListenerRegistration_descriptor; } - public org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close getDefaultInstanceForType() { - return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close.getDefaultInstance(); + public org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration getDefaultInstanceForType() { + return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration.getDefaultInstance(); } - public org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close build() { - org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close result = buildPartial(); + public org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration build() { + org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; } - public org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close buildPartial() { - org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close result = new org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close(this); + public org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration buildPartial() { + org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration result = new org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration(this); onBuilt(); return result; } public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close) { - return mergeFrom((org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close)other); + if (other instanceof org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration) { + return mergeFrom((org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration)other); } else { super.mergeFrom(other); return this; } } - public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close other) { - if (other == org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close.getDefaultInstance()) return this; + public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration other) { + if (other == org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration.getDefaultInstance()) return this; this.mergeUnknownFields(other.getUnknownFields()); return this; } @@ -292,11 +300,11 @@ public final class ListenerRegistrationMessages { com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close parsedMessage = null; + org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration parsedMessage = null; try { parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.Close) e.getUnfinishedMessage(); + parsedMessage = (org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistration) e.getUnfinishedMessage(); throw e; } finally { if (parsedMessage != null) { @@ -306,39 +314,43 @@ public final class ListenerRegistrationMessages { return this; } - // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.Close) + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.CloseDataChangeListenerRegistration) } static { - defaultInstance = new Close(true); + defaultInstance = new CloseDataChangeListenerRegistration(true); defaultInstance.initFields(); } - // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.Close) + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.CloseDataChangeListenerRegistration) } - public interface CloseReplyOrBuilder + public interface CloseDataChangeListenerRegistrationReplyOrBuilder extends com.google.protobuf.MessageOrBuilder { } /** - * Protobuf type {@code org.opendaylight.controller.mdsal.CloseReply} + * Protobuf type {@code org.opendaylight.controller.mdsal.CloseDataChangeListenerRegistrationReply} + * + *
+   ** reply to the CloseDataChangeListenerRegistration request
+   * 
*/ - public static final class CloseReply extends + public static final class CloseDataChangeListenerRegistrationReply extends com.google.protobuf.GeneratedMessage - implements CloseReplyOrBuilder { - // Use CloseReply.newBuilder() to construct. - private CloseReply(com.google.protobuf.GeneratedMessage.Builder builder) { + implements CloseDataChangeListenerRegistrationReplyOrBuilder { + // Use CloseDataChangeListenerRegistrationReply.newBuilder() to construct. + private CloseDataChangeListenerRegistrationReply(com.google.protobuf.GeneratedMessage.Builder builder) { super(builder); this.unknownFields = builder.getUnknownFields(); } - private CloseReply(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + private CloseDataChangeListenerRegistrationReply(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - private static final CloseReply defaultInstance; - public static CloseReply getDefaultInstance() { + private static final CloseDataChangeListenerRegistrationReply defaultInstance; + public static CloseDataChangeListenerRegistrationReply getDefaultInstance() { return defaultInstance; } - public CloseReply getDefaultInstanceForType() { + public CloseDataChangeListenerRegistrationReply getDefaultInstanceForType() { return defaultInstance; } @@ -348,7 +360,7 @@ public final class ListenerRegistrationMessages { getUnknownFields() { return this.unknownFields; } - private CloseReply( + private CloseDataChangeListenerRegistrationReply( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { @@ -384,28 +396,28 @@ public final class ListenerRegistrationMessages { } public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_CloseReply_descriptor; + return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_CloseDataChangeListenerRegistrationReply_descriptor; } protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { - return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_CloseReply_fieldAccessorTable + return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_CloseDataChangeListenerRegistrationReply_fieldAccessorTable .ensureFieldAccessorsInitialized( - org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply.class, org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply.Builder.class); + org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply.class, org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply.Builder.class); } - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public CloseReply parsePartialFrom( + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public CloseDataChangeListenerRegistrationReply parsePartialFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { - return new CloseReply(input, extensionRegistry); + return new CloseDataChangeListenerRegistrationReply(input, extensionRegistry); } }; @java.lang.Override - public com.google.protobuf.Parser getParserForType() { + public com.google.protobuf.Parser getParserForType() { return PARSER; } @@ -444,53 +456,53 @@ public final class ListenerRegistrationMessages { return super.writeReplace(); } - public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply parseFrom( + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply parseFrom( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply parseFrom( + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply parseFrom( com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply parseFrom(byte[] data) + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply parseFrom( + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply parseFrom( byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply parseFrom(java.io.InputStream input) + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply parseFrom(java.io.InputStream input) throws java.io.IOException { return PARSER.parseFrom(input); } - public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply parseFrom( + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return PARSER.parseFrom(input, extensionRegistry); } - public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply parseDelimitedFrom(java.io.InputStream input) + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { return PARSER.parseDelimitedFrom(input); } - public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply parseDelimitedFrom( + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return PARSER.parseDelimitedFrom(input, extensionRegistry); } - public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply parseFrom( + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { return PARSER.parseFrom(input); } - public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply parseFrom( + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { @@ -499,7 +511,7 @@ public final class ListenerRegistrationMessages { public static Builder newBuilder() { return Builder.create(); } public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply prototype) { + public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); } @@ -511,24 +523,28 @@ public final class ListenerRegistrationMessages { return builder; } /** - * Protobuf type {@code org.opendaylight.controller.mdsal.CloseReply} + * Protobuf type {@code org.opendaylight.controller.mdsal.CloseDataChangeListenerRegistrationReply} + * + *
+     ** reply to the CloseDataChangeListenerRegistration request
+     * 
*/ public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder - implements org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReplyOrBuilder { + implements org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReplyOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_CloseReply_descriptor; + return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_CloseDataChangeListenerRegistrationReply_descriptor; } protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { - return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_CloseReply_fieldAccessorTable + return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_CloseDataChangeListenerRegistrationReply_fieldAccessorTable .ensureFieldAccessorsInitialized( - org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply.class, org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply.Builder.class); + org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply.class, org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply.Builder.class); } - // Construct using org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply.newBuilder() + // Construct using org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply.newBuilder() private Builder() { maybeForceBuilderInitialization(); } @@ -557,38 +573,38 @@ public final class ListenerRegistrationMessages { public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_CloseReply_descriptor; + return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_CloseDataChangeListenerRegistrationReply_descriptor; } - public org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply getDefaultInstanceForType() { - return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply.getDefaultInstance(); + public org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply getDefaultInstanceForType() { + return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply.getDefaultInstance(); } - public org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply build() { - org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply result = buildPartial(); + public org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply build() { + org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; } - public org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply buildPartial() { - org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply result = new org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply(this); + public org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply buildPartial() { + org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply result = new org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply(this); onBuilt(); return result; } public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply) { - return mergeFrom((org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply)other); + if (other instanceof org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply) { + return mergeFrom((org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply)other); } else { super.mergeFrom(other); return this; } } - public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply other) { - if (other == org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply.getDefaultInstance()) return this; + public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply other) { + if (other == org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply.getDefaultInstance()) return this; this.mergeUnknownFields(other.getUnknownFields()); return this; } @@ -601,11 +617,11 @@ public final class ListenerRegistrationMessages { com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply parsedMessage = null; + org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply parsedMessage = null; try { parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseReply) e.getUnfinishedMessage(); + parsedMessage = (org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply) e.getUnfinishedMessage(); throw e; } finally { if (parsedMessage != null) { @@ -615,27 +631,1306 @@ public final class ListenerRegistrationMessages { return this; } - // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.CloseReply) + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.CloseDataChangeListenerRegistrationReply) } static { - defaultInstance = new CloseReply(true); + defaultInstance = new CloseDataChangeListenerRegistrationReply(true); defaultInstance.initFields(); } - // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.CloseReply) + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.CloseDataChangeListenerRegistrationReply) + } + + public interface RegisterChangeListenerOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + boolean hasInstanceIdentifierPath(); + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierPath(); + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierPathOrBuilder(); + + // required string dataChangeListenerActorPath = 2; + /** + * required string dataChangeListenerActorPath = 2; + */ + boolean hasDataChangeListenerActorPath(); + /** + * required string dataChangeListenerActorPath = 2; + */ + java.lang.String getDataChangeListenerActorPath(); + /** + * required string dataChangeListenerActorPath = 2; + */ + com.google.protobuf.ByteString + getDataChangeListenerActorPathBytes(); + + // required int32 dataChangeScope = 3; + /** + * required int32 dataChangeScope = 3; + */ + boolean hasDataChangeScope(); + /** + * required int32 dataChangeScope = 3; + */ + int getDataChangeScope(); + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.RegisterChangeListener} + */ + public static final class RegisterChangeListener extends + com.google.protobuf.GeneratedMessage + implements RegisterChangeListenerOrBuilder { + // Use RegisterChangeListener.newBuilder() to construct. + private RegisterChangeListener(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private RegisterChangeListener(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final RegisterChangeListener defaultInstance; + public static RegisterChangeListener getDefaultInstance() { + return defaultInstance; + } + + public RegisterChangeListener getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private RegisterChangeListener( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder subBuilder = null; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + subBuilder = instanceIdentifierPath_.toBuilder(); + } + instanceIdentifierPath_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(instanceIdentifierPath_); + instanceIdentifierPath_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000001; + break; + } + case 18: { + bitField0_ |= 0x00000002; + dataChangeListenerActorPath_ = input.readBytes(); + break; + } + case 24: { + bitField0_ |= 0x00000004; + dataChangeScope_ = input.readInt32(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_RegisterChangeListener_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_RegisterChangeListener_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener.class, org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public RegisterChangeListener parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new RegisterChangeListener(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + public static final int INSTANCEIDENTIFIERPATH_FIELD_NUMBER = 1; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier instanceIdentifierPath_; + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + public boolean hasInstanceIdentifierPath() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierPath() { + return instanceIdentifierPath_; + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierPathOrBuilder() { + return instanceIdentifierPath_; + } + + // required string dataChangeListenerActorPath = 2; + public static final int DATACHANGELISTENERACTORPATH_FIELD_NUMBER = 2; + private java.lang.Object dataChangeListenerActorPath_; + /** + * required string dataChangeListenerActorPath = 2; + */ + public boolean hasDataChangeListenerActorPath() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required string dataChangeListenerActorPath = 2; + */ + public java.lang.String getDataChangeListenerActorPath() { + java.lang.Object ref = dataChangeListenerActorPath_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + dataChangeListenerActorPath_ = s; + } + return s; + } + } + /** + * required string dataChangeListenerActorPath = 2; + */ + public com.google.protobuf.ByteString + getDataChangeListenerActorPathBytes() { + java.lang.Object ref = dataChangeListenerActorPath_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + dataChangeListenerActorPath_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // required int32 dataChangeScope = 3; + public static final int DATACHANGESCOPE_FIELD_NUMBER = 3; + private int dataChangeScope_; + /** + * required int32 dataChangeScope = 3; + */ + public boolean hasDataChangeScope() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * required int32 dataChangeScope = 3; + */ + public int getDataChangeScope() { + return dataChangeScope_; + } + + private void initFields() { + instanceIdentifierPath_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + dataChangeListenerActorPath_ = ""; + dataChangeScope_ = 0; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasInstanceIdentifierPath()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasDataChangeListenerActorPath()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasDataChangeScope()) { + memoizedIsInitialized = 0; + return false; + } + if (!getInstanceIdentifierPath().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeMessage(1, instanceIdentifierPath_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeBytes(2, getDataChangeListenerActorPathBytes()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeInt32(3, dataChangeScope_); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, instanceIdentifierPath_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, getDataChangeListenerActorPathBytes()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(3, dataChangeScope_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.RegisterChangeListener} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_RegisterChangeListener_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_RegisterChangeListener_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener.class, org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener.Builder.class); + } + + // Construct using org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getInstanceIdentifierPathFieldBuilder(); + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + if (instanceIdentifierPathBuilder_ == null) { + instanceIdentifierPath_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + } else { + instanceIdentifierPathBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + dataChangeListenerActorPath_ = ""; + bitField0_ = (bitField0_ & ~0x00000002); + dataChangeScope_ = 0; + bitField0_ = (bitField0_ & ~0x00000004); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_RegisterChangeListener_descriptor; + } + + public org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener getDefaultInstanceForType() { + return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener.getDefaultInstance(); + } + + public org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener build() { + org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener buildPartial() { + org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener result = new org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + if (instanceIdentifierPathBuilder_ == null) { + result.instanceIdentifierPath_ = instanceIdentifierPath_; + } else { + result.instanceIdentifierPath_ = instanceIdentifierPathBuilder_.build(); + } + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.dataChangeListenerActorPath_ = dataChangeListenerActorPath_; + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000004; + } + result.dataChangeScope_ = dataChangeScope_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener) { + return mergeFrom((org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener other) { + if (other == org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener.getDefaultInstance()) return this; + if (other.hasInstanceIdentifierPath()) { + mergeInstanceIdentifierPath(other.getInstanceIdentifierPath()); + } + if (other.hasDataChangeListenerActorPath()) { + bitField0_ |= 0x00000002; + dataChangeListenerActorPath_ = other.dataChangeListenerActorPath_; + onChanged(); + } + if (other.hasDataChangeScope()) { + setDataChangeScope(other.getDataChangeScope()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasInstanceIdentifierPath()) { + + return false; + } + if (!hasDataChangeListenerActorPath()) { + + return false; + } + if (!hasDataChangeScope()) { + + return false; + } + if (!getInstanceIdentifierPath().isInitialized()) { + + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListener) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier instanceIdentifierPath_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> instanceIdentifierPathBuilder_; + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + public boolean hasInstanceIdentifierPath() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierPath() { + if (instanceIdentifierPathBuilder_ == null) { + return instanceIdentifierPath_; + } else { + return instanceIdentifierPathBuilder_.getMessage(); + } + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + public Builder setInstanceIdentifierPath(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier value) { + if (instanceIdentifierPathBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + instanceIdentifierPath_ = value; + onChanged(); + } else { + instanceIdentifierPathBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + return this; + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + public Builder setInstanceIdentifierPath( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder builderForValue) { + if (instanceIdentifierPathBuilder_ == null) { + instanceIdentifierPath_ = builderForValue.build(); + onChanged(); + } else { + instanceIdentifierPathBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + return this; + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + public Builder mergeInstanceIdentifierPath(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier value) { + if (instanceIdentifierPathBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001) && + instanceIdentifierPath_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance()) { + instanceIdentifierPath_ = + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.newBuilder(instanceIdentifierPath_).mergeFrom(value).buildPartial(); + } else { + instanceIdentifierPath_ = value; + } + onChanged(); + } else { + instanceIdentifierPathBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000001; + return this; + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + public Builder clearInstanceIdentifierPath() { + if (instanceIdentifierPathBuilder_ == null) { + instanceIdentifierPath_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + onChanged(); + } else { + instanceIdentifierPathBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder getInstanceIdentifierPathBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getInstanceIdentifierPathFieldBuilder().getBuilder(); + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierPathOrBuilder() { + if (instanceIdentifierPathBuilder_ != null) { + return instanceIdentifierPathBuilder_.getMessageOrBuilder(); + } else { + return instanceIdentifierPath_; + } + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> + getInstanceIdentifierPathFieldBuilder() { + if (instanceIdentifierPathBuilder_ == null) { + instanceIdentifierPathBuilder_ = new com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder>( + instanceIdentifierPath_, + getParentForChildren(), + isClean()); + instanceIdentifierPath_ = null; + } + return instanceIdentifierPathBuilder_; + } + + // required string dataChangeListenerActorPath = 2; + private java.lang.Object dataChangeListenerActorPath_ = ""; + /** + * required string dataChangeListenerActorPath = 2; + */ + public boolean hasDataChangeListenerActorPath() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required string dataChangeListenerActorPath = 2; + */ + public java.lang.String getDataChangeListenerActorPath() { + java.lang.Object ref = dataChangeListenerActorPath_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + dataChangeListenerActorPath_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string dataChangeListenerActorPath = 2; + */ + public com.google.protobuf.ByteString + getDataChangeListenerActorPathBytes() { + java.lang.Object ref = dataChangeListenerActorPath_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + dataChangeListenerActorPath_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string dataChangeListenerActorPath = 2; + */ + public Builder setDataChangeListenerActorPath( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + dataChangeListenerActorPath_ = value; + onChanged(); + return this; + } + /** + * required string dataChangeListenerActorPath = 2; + */ + public Builder clearDataChangeListenerActorPath() { + bitField0_ = (bitField0_ & ~0x00000002); + dataChangeListenerActorPath_ = getDefaultInstance().getDataChangeListenerActorPath(); + onChanged(); + return this; + } + /** + * required string dataChangeListenerActorPath = 2; + */ + public Builder setDataChangeListenerActorPathBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + dataChangeListenerActorPath_ = value; + onChanged(); + return this; + } + + // required int32 dataChangeScope = 3; + private int dataChangeScope_ ; + /** + * required int32 dataChangeScope = 3; + */ + public boolean hasDataChangeScope() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * required int32 dataChangeScope = 3; + */ + public int getDataChangeScope() { + return dataChangeScope_; + } + /** + * required int32 dataChangeScope = 3; + */ + public Builder setDataChangeScope(int value) { + bitField0_ |= 0x00000004; + dataChangeScope_ = value; + onChanged(); + return this; + } + /** + * required int32 dataChangeScope = 3; + */ + public Builder clearDataChangeScope() { + bitField0_ = (bitField0_ & ~0x00000004); + dataChangeScope_ = 0; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.RegisterChangeListener) + } + + static { + defaultInstance = new RegisterChangeListener(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.RegisterChangeListener) + } + + public interface RegisterChangeListenerReplyOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required string listenerRegistrationPath = 1; + /** + * required string listenerRegistrationPath = 1; + */ + boolean hasListenerRegistrationPath(); + /** + * required string listenerRegistrationPath = 1; + */ + java.lang.String getListenerRegistrationPath(); + /** + * required string listenerRegistrationPath = 1; + */ + com.google.protobuf.ByteString + getListenerRegistrationPathBytes(); + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.RegisterChangeListenerReply} + * + *
+   **
+   * This is the reply for the RegisterChangeListener message
+   * It contains the listenerRegistration actor path
+   * that can be used to unregister the listener
+   * 
+ */ + public static final class RegisterChangeListenerReply extends + com.google.protobuf.GeneratedMessage + implements RegisterChangeListenerReplyOrBuilder { + // Use RegisterChangeListenerReply.newBuilder() to construct. + private RegisterChangeListenerReply(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private RegisterChangeListenerReply(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final RegisterChangeListenerReply defaultInstance; + public static RegisterChangeListenerReply getDefaultInstance() { + return defaultInstance; + } + + public RegisterChangeListenerReply getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private RegisterChangeListenerReply( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + bitField0_ |= 0x00000001; + listenerRegistrationPath_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_RegisterChangeListenerReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_RegisterChangeListenerReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply.class, org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public RegisterChangeListenerReply parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new RegisterChangeListenerReply(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // required string listenerRegistrationPath = 1; + public static final int LISTENERREGISTRATIONPATH_FIELD_NUMBER = 1; + private java.lang.Object listenerRegistrationPath_; + /** + * required string listenerRegistrationPath = 1; + */ + public boolean hasListenerRegistrationPath() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string listenerRegistrationPath = 1; + */ + public java.lang.String getListenerRegistrationPath() { + java.lang.Object ref = listenerRegistrationPath_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + listenerRegistrationPath_ = s; + } + return s; + } + } + /** + * required string listenerRegistrationPath = 1; + */ + public com.google.protobuf.ByteString + getListenerRegistrationPathBytes() { + java.lang.Object ref = listenerRegistrationPath_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + listenerRegistrationPath_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private void initFields() { + listenerRegistrationPath_ = ""; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasListenerRegistrationPath()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getListenerRegistrationPathBytes()); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getListenerRegistrationPathBytes()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.RegisterChangeListenerReply} + * + *
+     **
+     * This is the reply for the RegisterChangeListener message
+     * It contains the listenerRegistration actor path
+     * that can be used to unregister the listener
+     * 
+ */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReplyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_RegisterChangeListenerReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_RegisterChangeListenerReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply.class, org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply.Builder.class); + } + + // Construct using org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + listenerRegistrationPath_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_RegisterChangeListenerReply_descriptor; + } + + public org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply getDefaultInstanceForType() { + return org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply.getDefaultInstance(); + } + + public org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply build() { + org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply buildPartial() { + org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply result = new org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.listenerRegistrationPath_ = listenerRegistrationPath_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply) { + return mergeFrom((org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply other) { + if (other == org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply.getDefaultInstance()) return this; + if (other.hasListenerRegistrationPath()) { + bitField0_ |= 0x00000001; + listenerRegistrationPath_ = other.listenerRegistrationPath_; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasListenerRegistrationPath()) { + + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages.RegisterChangeListenerReply) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required string listenerRegistrationPath = 1; + private java.lang.Object listenerRegistrationPath_ = ""; + /** + * required string listenerRegistrationPath = 1; + */ + public boolean hasListenerRegistrationPath() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string listenerRegistrationPath = 1; + */ + public java.lang.String getListenerRegistrationPath() { + java.lang.Object ref = listenerRegistrationPath_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + listenerRegistrationPath_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string listenerRegistrationPath = 1; + */ + public com.google.protobuf.ByteString + getListenerRegistrationPathBytes() { + java.lang.Object ref = listenerRegistrationPath_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + listenerRegistrationPath_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string listenerRegistrationPath = 1; + */ + public Builder setListenerRegistrationPath( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + listenerRegistrationPath_ = value; + onChanged(); + return this; + } + /** + * required string listenerRegistrationPath = 1; + */ + public Builder clearListenerRegistrationPath() { + bitField0_ = (bitField0_ & ~0x00000001); + listenerRegistrationPath_ = getDefaultInstance().getListenerRegistrationPath(); + onChanged(); + return this; + } + /** + * required string listenerRegistrationPath = 1; + */ + public Builder setListenerRegistrationPathBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + listenerRegistrationPath_ = value; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.RegisterChangeListenerReply) + } + + static { + defaultInstance = new RegisterChangeListenerReply(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.RegisterChangeListenerReply) } private static com.google.protobuf.Descriptors.Descriptor - internal_static_org_opendaylight_controller_mdsal_Close_descriptor; + internal_static_org_opendaylight_controller_mdsal_CloseDataChangeListenerRegistration_descriptor; private static com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_org_opendaylight_controller_mdsal_Close_fieldAccessorTable; + internal_static_org_opendaylight_controller_mdsal_CloseDataChangeListenerRegistration_fieldAccessorTable; private static com.google.protobuf.Descriptors.Descriptor - internal_static_org_opendaylight_controller_mdsal_CloseReply_descriptor; + internal_static_org_opendaylight_controller_mdsal_CloseDataChangeListenerRegistrationReply_descriptor; private static com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_org_opendaylight_controller_mdsal_CloseReply_fieldAccessorTable; + internal_static_org_opendaylight_controller_mdsal_CloseDataChangeListenerRegistrationReply_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_RegisterChangeListener_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_RegisterChangeListener_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_RegisterChangeListenerReply_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_RegisterChangeListenerReply_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { @@ -646,34 +1941,55 @@ public final class ListenerRegistrationMessages { static { java.lang.String[] descriptorData = { "\n\032ListenerRegistration.proto\022!org.openda" + - "ylight.controller.mdsal\"\007\n\005Close\"\014\n\nClos" + - "eReplyB[\n;org.opendaylight.controller.pr" + - "otobuff.messages.registrationB\034ListenerR" + - "egistrationMessages" + "ylight.controller.mdsal\032\014Common.proto\"%\n" + + "#CloseDataChangeListenerRegistration\"*\n(" + + "CloseDataChangeListenerRegistrationReply" + + "\"\255\001\n\026RegisterChangeListener\022U\n\026instanceI" + + "dentifierPath\030\001 \002(\01325.org.opendaylight.c" + + "ontroller.mdsal.InstanceIdentifier\022#\n\033da" + + "taChangeListenerActorPath\030\002 \002(\t\022\027\n\017dataC" + + "hangeScope\030\003 \002(\005\"?\n\033RegisterChangeListen" + + "erReply\022 \n\030listenerRegistrationPath\030\001 \002(", + "\tB[\n;org.opendaylight.controller.protobu" + + "ff.messages.registrationB\034ListenerRegist" + + "rationMessages" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { public com.google.protobuf.ExtensionRegistry assignDescriptors( com.google.protobuf.Descriptors.FileDescriptor root) { descriptor = root; - internal_static_org_opendaylight_controller_mdsal_Close_descriptor = + internal_static_org_opendaylight_controller_mdsal_CloseDataChangeListenerRegistration_descriptor = getDescriptor().getMessageTypes().get(0); - internal_static_org_opendaylight_controller_mdsal_Close_fieldAccessorTable = new + internal_static_org_opendaylight_controller_mdsal_CloseDataChangeListenerRegistration_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_org_opendaylight_controller_mdsal_Close_descriptor, + internal_static_org_opendaylight_controller_mdsal_CloseDataChangeListenerRegistration_descriptor, new java.lang.String[] { }); - internal_static_org_opendaylight_controller_mdsal_CloseReply_descriptor = + internal_static_org_opendaylight_controller_mdsal_CloseDataChangeListenerRegistrationReply_descriptor = getDescriptor().getMessageTypes().get(1); - internal_static_org_opendaylight_controller_mdsal_CloseReply_fieldAccessorTable = new + internal_static_org_opendaylight_controller_mdsal_CloseDataChangeListenerRegistrationReply_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_org_opendaylight_controller_mdsal_CloseReply_descriptor, + internal_static_org_opendaylight_controller_mdsal_CloseDataChangeListenerRegistrationReply_descriptor, new java.lang.String[] { }); + internal_static_org_opendaylight_controller_mdsal_RegisterChangeListener_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_org_opendaylight_controller_mdsal_RegisterChangeListener_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_RegisterChangeListener_descriptor, + new java.lang.String[] { "InstanceIdentifierPath", "DataChangeListenerActorPath", "DataChangeScope", }); + internal_static_org_opendaylight_controller_mdsal_RegisterChangeListenerReply_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_org_opendaylight_controller_mdsal_RegisterChangeListenerReply_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_RegisterChangeListenerReply_descriptor, + new java.lang.String[] { "ListenerRegistrationPath", }); return null; } }; com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.getDescriptor(), }, assigner); } 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-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/shard/ShardManagerMessages.java index 055f18e4d3..7c2a47e1b0 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/shard/ShardManagerMessages.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/shard/ShardManagerMessages.java @@ -139,7 +139,7 @@ public final class ShardManagerMessages { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -155,7 +155,7 @@ public final class ShardManagerMessages { getShardNameBytes() { java.lang.Object ref = shardName_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); shardName_ = b; @@ -377,7 +377,7 @@ public final class ShardManagerMessages { public final boolean isInitialized() { if (!hasShardName()) { - + return false; } return true; @@ -431,7 +431,7 @@ public final class ShardManagerMessages { getShardNameBytes() { java.lang.Object ref = shardName_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); shardName_ = b; @@ -489,6 +489,21 @@ public final class ShardManagerMessages { public interface PrimaryFoundOrBuilder extends com.google.protobuf.MessageOrBuilder { + + // required string primaryPath = 1; + /** + * required string primaryPath = 1; + */ + boolean hasPrimaryPath(); + /** + * required string primaryPath = 1; + */ + java.lang.String getPrimaryPath(); + /** + * required string primaryPath = 1; + */ + com.google.protobuf.ByteString + getPrimaryPathBytes(); } /** * Protobuf type {@code org.opendaylight.controller.mdsal.PrimaryFound} @@ -523,6 +538,7 @@ public final class ShardManagerMessages { com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { initFields(); + int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -540,6 +556,11 @@ public final class ShardManagerMessages { } break; } + case 10: { + bitField0_ |= 0x00000001; + primaryPath_ = input.readBytes(); + break; + } } } } catch (com.google.protobuf.InvalidProtocolBufferException e) { @@ -579,13 +600,62 @@ public final class ShardManagerMessages { return PARSER; } + private int bitField0_; + // required string primaryPath = 1; + public static final int PRIMARYPATH_FIELD_NUMBER = 1; + private java.lang.Object primaryPath_; + /** + * required string primaryPath = 1; + */ + public boolean hasPrimaryPath() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string primaryPath = 1; + */ + public java.lang.String getPrimaryPath() { + java.lang.Object ref = primaryPath_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + primaryPath_ = s; + } + return s; + } + } + /** + * required string primaryPath = 1; + */ + public com.google.protobuf.ByteString + getPrimaryPathBytes() { + java.lang.Object ref = primaryPath_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + primaryPath_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + private void initFields() { + primaryPath_ = ""; } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized != -1) return isInitialized == 1; + if (!hasPrimaryPath()) { + memoizedIsInitialized = 0; + return false; + } memoizedIsInitialized = 1; return true; } @@ -593,6 +663,9 @@ public final class ShardManagerMessages { public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getPrimaryPathBytes()); + } getUnknownFields().writeTo(output); } @@ -602,6 +675,10 @@ public final class ShardManagerMessages { if (size != -1) return size; size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getPrimaryPathBytes()); + } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; @@ -718,6 +795,8 @@ public final class ShardManagerMessages { public Builder clear() { super.clear(); + primaryPath_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); return this; } @@ -744,6 +823,13 @@ public final class ShardManagerMessages { public org.opendaylight.controller.protobuff.messages.shard.ShardManagerMessages.PrimaryFound buildPartial() { org.opendaylight.controller.protobuff.messages.shard.ShardManagerMessages.PrimaryFound result = new org.opendaylight.controller.protobuff.messages.shard.ShardManagerMessages.PrimaryFound(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.primaryPath_ = primaryPath_; + result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -759,11 +845,20 @@ public final class ShardManagerMessages { public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.shard.ShardManagerMessages.PrimaryFound other) { if (other == org.opendaylight.controller.protobuff.messages.shard.ShardManagerMessages.PrimaryFound.getDefaultInstance()) return this; + if (other.hasPrimaryPath()) { + bitField0_ |= 0x00000001; + primaryPath_ = other.primaryPath_; + onChanged(); + } this.mergeUnknownFields(other.getUnknownFields()); return this; } public final boolean isInitialized() { + if (!hasPrimaryPath()) { + + return false; + } return true; } @@ -784,6 +879,81 @@ public final class ShardManagerMessages { } return this; } + private int bitField0_; + + // required string primaryPath = 1; + private java.lang.Object primaryPath_ = ""; + /** + * required string primaryPath = 1; + */ + public boolean hasPrimaryPath() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string primaryPath = 1; + */ + public java.lang.String getPrimaryPath() { + java.lang.Object ref = primaryPath_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + primaryPath_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string primaryPath = 1; + */ + public com.google.protobuf.ByteString + getPrimaryPathBytes() { + java.lang.Object ref = primaryPath_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + primaryPath_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string primaryPath = 1; + */ + public Builder setPrimaryPath( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + primaryPath_ = value; + onChanged(); + return this; + } + /** + * required string primaryPath = 1; + */ + public Builder clearPrimaryPath() { + bitField0_ = (bitField0_ & ~0x00000001); + primaryPath_ = getDefaultInstance().getPrimaryPath(); + onChanged(); + return this; + } + /** + * required string primaryPath = 1; + */ + public Builder setPrimaryPathBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + primaryPath_ = value; + onChanged(); + return this; + } // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.PrimaryFound) } @@ -798,6 +968,21 @@ public final class ShardManagerMessages { public interface PrimaryNotFoundOrBuilder extends com.google.protobuf.MessageOrBuilder { + + // required string shardName = 1; + /** + * required string shardName = 1; + */ + boolean hasShardName(); + /** + * required string shardName = 1; + */ + java.lang.String getShardName(); + /** + * required string shardName = 1; + */ + com.google.protobuf.ByteString + getShardNameBytes(); } /** * Protobuf type {@code org.opendaylight.controller.mdsal.PrimaryNotFound} @@ -832,6 +1017,7 @@ public final class ShardManagerMessages { com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { initFields(); + int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -849,6 +1035,11 @@ public final class ShardManagerMessages { } break; } + case 10: { + bitField0_ |= 0x00000001; + shardName_ = input.readBytes(); + break; + } } } } catch (com.google.protobuf.InvalidProtocolBufferException e) { @@ -888,13 +1079,62 @@ public final class ShardManagerMessages { return PARSER; } + private int bitField0_; + // required string shardName = 1; + public static final int SHARDNAME_FIELD_NUMBER = 1; + private java.lang.Object shardName_; + /** + * required string shardName = 1; + */ + public boolean hasShardName() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string shardName = 1; + */ + public java.lang.String getShardName() { + java.lang.Object ref = shardName_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + shardName_ = s; + } + return s; + } + } + /** + * required string shardName = 1; + */ + public com.google.protobuf.ByteString + getShardNameBytes() { + java.lang.Object ref = shardName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + shardName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + private void initFields() { + shardName_ = ""; } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized != -1) return isInitialized == 1; + if (!hasShardName()) { + memoizedIsInitialized = 0; + return false; + } memoizedIsInitialized = 1; return true; } @@ -902,6 +1142,9 @@ public final class ShardManagerMessages { public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getShardNameBytes()); + } getUnknownFields().writeTo(output); } @@ -911,6 +1154,10 @@ public final class ShardManagerMessages { if (size != -1) return size; size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getShardNameBytes()); + } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; @@ -1027,6 +1274,8 @@ public final class ShardManagerMessages { public Builder clear() { super.clear(); + shardName_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); return this; } @@ -1053,6 +1302,13 @@ public final class ShardManagerMessages { public org.opendaylight.controller.protobuff.messages.shard.ShardManagerMessages.PrimaryNotFound buildPartial() { org.opendaylight.controller.protobuff.messages.shard.ShardManagerMessages.PrimaryNotFound result = new org.opendaylight.controller.protobuff.messages.shard.ShardManagerMessages.PrimaryNotFound(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.shardName_ = shardName_; + result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -1068,11 +1324,20 @@ public final class ShardManagerMessages { public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.shard.ShardManagerMessages.PrimaryNotFound other) { if (other == org.opendaylight.controller.protobuff.messages.shard.ShardManagerMessages.PrimaryNotFound.getDefaultInstance()) return this; + if (other.hasShardName()) { + bitField0_ |= 0x00000001; + shardName_ = other.shardName_; + onChanged(); + } this.mergeUnknownFields(other.getUnknownFields()); return this; } public final boolean isInitialized() { + if (!hasShardName()) { + + return false; + } return true; } @@ -1093,6 +1358,81 @@ public final class ShardManagerMessages { } return this; } + private int bitField0_; + + // required string shardName = 1; + private java.lang.Object shardName_ = ""; + /** + * required string shardName = 1; + */ + public boolean hasShardName() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string shardName = 1; + */ + public java.lang.String getShardName() { + java.lang.Object ref = shardName_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + shardName_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string shardName = 1; + */ + public com.google.protobuf.ByteString + getShardNameBytes() { + java.lang.Object ref = shardName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + shardName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string shardName = 1; + */ + public Builder setShardName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + shardName_ = value; + onChanged(); + return this; + } + /** + * required string shardName = 1; + */ + public Builder clearShardName() { + bitField0_ = (bitField0_ & ~0x00000001); + shardName_ = getDefaultInstance().getShardName(); + onChanged(); + return this; + } + /** + * required string shardName = 1; + */ + public Builder setShardNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + shardName_ = value; + onChanged(); + return this; + } // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.PrimaryNotFound) } @@ -1131,8 +1471,9 @@ public final class ShardManagerMessages { java.lang.String[] descriptorData = { "\n\022ShardManager.proto\022!org.opendaylight.c" + "ontroller.mdsal\" \n\013FindPrimary\022\021\n\tshardN" + - "ame\030\001 \002(\t\"\016\n\014PrimaryFound\"\021\n\017PrimaryNotF" + - "oundBL\n4org.opendaylight.controller.prot" + + "ame\030\001 \002(\t\"#\n\014PrimaryFound\022\023\n\013primaryPath" + + "\030\001 \002(\t\"$\n\017PrimaryNotFound\022\021\n\tshardName\030\001" + + " \002(\tBL\n4org.opendaylight.controller.prot" + "obuff.messages.shardB\024ShardManagerMessag" + "es" }; @@ -1152,13 +1493,13 @@ public final class ShardManagerMessages { internal_static_org_opendaylight_controller_mdsal_PrimaryFound_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_org_opendaylight_controller_mdsal_PrimaryFound_descriptor, - new java.lang.String[] { }); + new java.lang.String[] { "PrimaryPath", }); internal_static_org_opendaylight_controller_mdsal_PrimaryNotFound_descriptor = getDescriptor().getMessageTypes().get(2); internal_static_org_opendaylight_controller_mdsal_PrimaryNotFound_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_org_opendaylight_controller_mdsal_PrimaryNotFound_descriptor, - new java.lang.String[] { }); + new java.lang.String[] { "ShardName", }); return null; } }; 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-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionChainMessages.java index 63dd5e7081..3f354ba40e 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionChainMessages.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionChainMessages.java @@ -1066,7 +1066,7 @@ public final class ShardTransactionChainMessages { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -1082,7 +1082,7 @@ public final class ShardTransactionChainMessages { getTransactionChainPathBytes() { java.lang.Object ref = transactionChainPath_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); transactionChainPath_ = b; @@ -1304,7 +1304,7 @@ public final class ShardTransactionChainMessages { public final boolean isInitialized() { if (!hasTransactionChainPath()) { - + return false; } return true; @@ -1358,7 +1358,7 @@ public final class ShardTransactionChainMessages { getTransactionChainPathBytes() { java.lang.Object ref = transactionChainPath_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); transactionChainPath_ = b; 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-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionMessages.java index cabcf859da..ee2c70423e 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionMessages.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionMessages.java @@ -628,6 +628,21 @@ public final class ShardTransactionMessages { public interface CreateTransactionOrBuilder extends com.google.protobuf.MessageOrBuilder { + + // required string transactionId = 1; + /** + * required string transactionId = 1; + */ + boolean hasTransactionId(); + /** + * required string transactionId = 1; + */ + java.lang.String getTransactionId(); + /** + * required string transactionId = 1; + */ + com.google.protobuf.ByteString + getTransactionIdBytes(); } /** * Protobuf type {@code org.opendaylight.controller.mdsal.CreateTransaction} @@ -662,6 +677,7 @@ public final class ShardTransactionMessages { com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { initFields(); + int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -679,6 +695,11 @@ public final class ShardTransactionMessages { } break; } + case 10: { + bitField0_ |= 0x00000001; + transactionId_ = input.readBytes(); + break; + } } } } catch (com.google.protobuf.InvalidProtocolBufferException e) { @@ -718,13 +739,62 @@ public final class ShardTransactionMessages { return PARSER; } + private int bitField0_; + // required string transactionId = 1; + public static final int TRANSACTIONID_FIELD_NUMBER = 1; + private java.lang.Object transactionId_; + /** + * required string transactionId = 1; + */ + public boolean hasTransactionId() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string transactionId = 1; + */ + public java.lang.String getTransactionId() { + java.lang.Object ref = transactionId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + transactionId_ = s; + } + return s; + } + } + /** + * required string transactionId = 1; + */ + public com.google.protobuf.ByteString + getTransactionIdBytes() { + java.lang.Object ref = transactionId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + transactionId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + private void initFields() { + transactionId_ = ""; } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized != -1) return isInitialized == 1; + if (!hasTransactionId()) { + memoizedIsInitialized = 0; + return false; + } memoizedIsInitialized = 1; return true; } @@ -732,6 +802,9 @@ public final class ShardTransactionMessages { public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getTransactionIdBytes()); + } getUnknownFields().writeTo(output); } @@ -741,6 +814,10 @@ public final class ShardTransactionMessages { if (size != -1) return size; size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getTransactionIdBytes()); + } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; @@ -857,6 +934,8 @@ public final class ShardTransactionMessages { public Builder clear() { super.clear(); + transactionId_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); return this; } @@ -883,6 +962,13 @@ public final class ShardTransactionMessages { public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.CreateTransaction buildPartial() { org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.CreateTransaction result = new org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.CreateTransaction(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.transactionId_ = transactionId_; + result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -898,11 +984,20 @@ public final class ShardTransactionMessages { public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.CreateTransaction other) { if (other == org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.CreateTransaction.getDefaultInstance()) return this; + if (other.hasTransactionId()) { + bitField0_ |= 0x00000001; + transactionId_ = other.transactionId_; + onChanged(); + } this.mergeUnknownFields(other.getUnknownFields()); return this; } public final boolean isInitialized() { + if (!hasTransactionId()) { + + return false; + } return true; } @@ -923,6 +1018,81 @@ public final class ShardTransactionMessages { } return this; } + private int bitField0_; + + // required string transactionId = 1; + private java.lang.Object transactionId_ = ""; + /** + * required string transactionId = 1; + */ + public boolean hasTransactionId() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string transactionId = 1; + */ + public java.lang.String getTransactionId() { + java.lang.Object ref = transactionId_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + transactionId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string transactionId = 1; + */ + public com.google.protobuf.ByteString + getTransactionIdBytes() { + java.lang.Object ref = transactionId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + transactionId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string transactionId = 1; + */ + public Builder setTransactionId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + transactionId_ = value; + onChanged(); + return this; + } + /** + * required string transactionId = 1; + */ + public Builder clearTransactionId() { + bitField0_ = (bitField0_ & ~0x00000001); + transactionId_ = getDefaultInstance().getTransactionId(); + onChanged(); + return this; + } + /** + * required string transactionId = 1; + */ + public Builder setTransactionIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + transactionId_ = value; + onChanged(); + return this; + } // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.CreateTransaction) } @@ -938,20 +1108,35 @@ public final class ShardTransactionMessages { public interface CreateTransactionReplyOrBuilder extends com.google.protobuf.MessageOrBuilder { - // required string transactionPath = 1; + // required string transactionActorPath = 1; + /** + * required string transactionActorPath = 1; + */ + boolean hasTransactionActorPath(); + /** + * required string transactionActorPath = 1; + */ + java.lang.String getTransactionActorPath(); + /** + * required string transactionActorPath = 1; + */ + com.google.protobuf.ByteString + getTransactionActorPathBytes(); + + // required string transactionId = 2; /** - * required string transactionPath = 1; + * required string transactionId = 2; */ - boolean hasTransactionPath(); + boolean hasTransactionId(); /** - * required string transactionPath = 1; + * required string transactionId = 2; */ - java.lang.String getTransactionPath(); + java.lang.String getTransactionId(); /** - * required string transactionPath = 1; + * required string transactionId = 2; */ com.google.protobuf.ByteString - getTransactionPathBytes(); + getTransactionIdBytes(); } /** * Protobuf type {@code org.opendaylight.controller.mdsal.CreateTransactionReply} @@ -1006,7 +1191,12 @@ public final class ShardTransactionMessages { } case 10: { bitField0_ |= 0x00000001; - transactionPath_ = input.readBytes(); + transactionActorPath_ = input.readBytes(); + break; + } + case 18: { + bitField0_ |= 0x00000002; + transactionId_ = input.readBytes(); break; } } @@ -1049,43 +1239,86 @@ public final class ShardTransactionMessages { } private int bitField0_; - // required string transactionPath = 1; - public static final int TRANSACTIONPATH_FIELD_NUMBER = 1; - private java.lang.Object transactionPath_; + // required string transactionActorPath = 1; + public static final int TRANSACTIONACTORPATH_FIELD_NUMBER = 1; + private java.lang.Object transactionActorPath_; /** - * required string transactionPath = 1; + * required string transactionActorPath = 1; */ - public boolean hasTransactionPath() { + public boolean hasTransactionActorPath() { return ((bitField0_ & 0x00000001) == 0x00000001); } /** - * required string transactionPath = 1; + * required string transactionActorPath = 1; + */ + public java.lang.String getTransactionActorPath() { + java.lang.Object ref = transactionActorPath_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + transactionActorPath_ = s; + } + return s; + } + } + /** + * required string transactionActorPath = 1; + */ + public com.google.protobuf.ByteString + getTransactionActorPathBytes() { + java.lang.Object ref = transactionActorPath_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + transactionActorPath_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // required string transactionId = 2; + public static final int TRANSACTIONID_FIELD_NUMBER = 2; + private java.lang.Object transactionId_; + /** + * required string transactionId = 2; + */ + public boolean hasTransactionId() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required string transactionId = 2; */ - public java.lang.String getTransactionPath() { - java.lang.Object ref = transactionPath_; + public java.lang.String getTransactionId() { + java.lang.Object ref = transactionId_; if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { - transactionPath_ = s; + transactionId_ = s; } return s; } } /** - * required string transactionPath = 1; + * required string transactionId = 2; */ public com.google.protobuf.ByteString - getTransactionPathBytes() { - java.lang.Object ref = transactionPath_; + getTransactionIdBytes() { + java.lang.Object ref = transactionId_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); - transactionPath_ = b; + transactionId_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; @@ -1093,14 +1326,19 @@ public final class ShardTransactionMessages { } private void initFields() { - transactionPath_ = ""; + transactionActorPath_ = ""; + transactionId_ = ""; } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized != -1) return isInitialized == 1; - if (!hasTransactionPath()) { + if (!hasTransactionActorPath()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasTransactionId()) { memoizedIsInitialized = 0; return false; } @@ -1112,7 +1350,10 @@ public final class ShardTransactionMessages { throws java.io.IOException { getSerializedSize(); if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeBytes(1, getTransactionPathBytes()); + output.writeBytes(1, getTransactionActorPathBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeBytes(2, getTransactionIdBytes()); } getUnknownFields().writeTo(output); } @@ -1125,7 +1366,11 @@ public final class ShardTransactionMessages { size = 0; if (((bitField0_ & 0x00000001) == 0x00000001)) { size += com.google.protobuf.CodedOutputStream - .computeBytesSize(1, getTransactionPathBytes()); + .computeBytesSize(1, getTransactionActorPathBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, getTransactionIdBytes()); } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; @@ -1243,8 +1488,10 @@ public final class ShardTransactionMessages { public Builder clear() { super.clear(); - transactionPath_ = ""; + transactionActorPath_ = ""; bitField0_ = (bitField0_ & ~0x00000001); + transactionId_ = ""; + bitField0_ = (bitField0_ & ~0x00000002); return this; } @@ -1276,7 +1523,11 @@ public final class ShardTransactionMessages { if (((from_bitField0_ & 0x00000001) == 0x00000001)) { to_bitField0_ |= 0x00000001; } - result.transactionPath_ = transactionPath_; + result.transactionActorPath_ = transactionActorPath_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.transactionId_ = transactionId_; result.bitField0_ = to_bitField0_; onBuilt(); return result; @@ -1293,9 +1544,14 @@ public final class ShardTransactionMessages { public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.CreateTransactionReply other) { if (other == org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.CreateTransactionReply.getDefaultInstance()) return this; - if (other.hasTransactionPath()) { + if (other.hasTransactionActorPath()) { bitField0_ |= 0x00000001; - transactionPath_ = other.transactionPath_; + transactionActorPath_ = other.transactionActorPath_; + onChanged(); + } + if (other.hasTransactionId()) { + bitField0_ |= 0x00000002; + transactionId_ = other.transactionId_; onChanged(); } this.mergeUnknownFields(other.getUnknownFields()); @@ -1303,8 +1559,12 @@ public final class ShardTransactionMessages { } public final boolean isInitialized() { - if (!hasTransactionPath()) { - + if (!hasTransactionActorPath()) { + + return false; + } + if (!hasTransactionId()) { + return false; } return true; @@ -1329,76 +1589,150 @@ public final class ShardTransactionMessages { } private int bitField0_; - // required string transactionPath = 1; - private java.lang.Object transactionPath_ = ""; + // required string transactionActorPath = 1; + private java.lang.Object transactionActorPath_ = ""; /** - * required string transactionPath = 1; + * required string transactionActorPath = 1; */ - public boolean hasTransactionPath() { + public boolean hasTransactionActorPath() { return ((bitField0_ & 0x00000001) == 0x00000001); } /** - * required string transactionPath = 1; + * required string transactionActorPath = 1; */ - public java.lang.String getTransactionPath() { - java.lang.Object ref = transactionPath_; + public java.lang.String getTransactionActorPath() { + java.lang.Object ref = transactionActorPath_; if (!(ref instanceof java.lang.String)) { java.lang.String s = ((com.google.protobuf.ByteString) ref) .toStringUtf8(); - transactionPath_ = s; + transactionActorPath_ = s; return s; } else { return (java.lang.String) ref; } } /** - * required string transactionPath = 1; + * required string transactionActorPath = 1; */ public com.google.protobuf.ByteString - getTransactionPathBytes() { - java.lang.Object ref = transactionPath_; + getTransactionActorPathBytes() { + java.lang.Object ref = transactionActorPath_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); - transactionPath_ = b; + transactionActorPath_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } /** - * required string transactionPath = 1; + * required string transactionActorPath = 1; */ - public Builder setTransactionPath( + public Builder setTransactionActorPath( java.lang.String value) { if (value == null) { throw new NullPointerException(); } bitField0_ |= 0x00000001; - transactionPath_ = value; + transactionActorPath_ = value; onChanged(); return this; } /** - * required string transactionPath = 1; + * required string transactionActorPath = 1; */ - public Builder clearTransactionPath() { + public Builder clearTransactionActorPath() { bitField0_ = (bitField0_ & ~0x00000001); - transactionPath_ = getDefaultInstance().getTransactionPath(); + transactionActorPath_ = getDefaultInstance().getTransactionActorPath(); onChanged(); return this; } /** - * required string transactionPath = 1; + * required string transactionActorPath = 1; */ - public Builder setTransactionPathBytes( + public Builder setTransactionActorPathBytes( com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } bitField0_ |= 0x00000001; - transactionPath_ = value; + transactionActorPath_ = value; + onChanged(); + return this; + } + + // required string transactionId = 2; + private java.lang.Object transactionId_ = ""; + /** + * required string transactionId = 2; + */ + public boolean hasTransactionId() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required string transactionId = 2; + */ + public java.lang.String getTransactionId() { + java.lang.Object ref = transactionId_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + transactionId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string transactionId = 2; + */ + public com.google.protobuf.ByteString + getTransactionIdBytes() { + java.lang.Object ref = transactionId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + transactionId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string transactionId = 2; + */ + public Builder setTransactionId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + transactionId_ = value; + onChanged(); + return this; + } + /** + * required string transactionId = 2; + */ + public Builder clearTransactionId() { + bitField0_ = (bitField0_ & ~0x00000002); + transactionId_ = getDefaultInstance().getTransactionId(); + onChanged(); + return this; + } + /** + * required string transactionId = 2; + */ + public Builder setTransactionIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + transactionId_ = value; onChanged(); return this; } @@ -1854,7 +2188,7 @@ public final class ShardTransactionMessages { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -1870,7 +2204,7 @@ public final class ShardTransactionMessages { getActorPathBytes() { java.lang.Object ref = actorPath_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); actorPath_ = b; @@ -2092,7 +2426,7 @@ public final class ShardTransactionMessages { public final boolean isInitialized() { if (!hasActorPath()) { - + return false; } return true; @@ -2146,7 +2480,7 @@ public final class ShardTransactionMessages { getActorPathBytes() { java.lang.Object ref = actorPath_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); actorPath_ = b; @@ -2205,25 +2539,19 @@ public final class ShardTransactionMessages { public interface DeleteDataOrBuilder extends com.google.protobuf.MessageOrBuilder { - // repeated string instanceIdentifierPathArguments = 1; - /** - * repeated string instanceIdentifierPathArguments = 1; - */ - java.util.List - getInstanceIdentifierPathArgumentsList(); + // required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - int getInstanceIdentifierPathArgumentsCount(); + boolean hasInstanceIdentifierPathArguments(); /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - java.lang.String getInstanceIdentifierPathArguments(int index); + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierPathArguments(); /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - com.google.protobuf.ByteString - getInstanceIdentifierPathArgumentsBytes(int index); + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierPathArgumentsOrBuilder(); } /** * Protobuf type {@code org.opendaylight.controller.mdsal.DeleteData} @@ -2277,11 +2605,16 @@ public final class ShardTransactionMessages { break; } case 10: { - if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - instanceIdentifierPathArguments_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000001; + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder subBuilder = null; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + subBuilder = instanceIdentifierPathArguments_.toBuilder(); + } + instanceIdentifierPathArguments_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(instanceIdentifierPathArguments_); + instanceIdentifierPathArguments_ = subBuilder.buildPartial(); } - instanceIdentifierPathArguments_.add(input.readBytes()); + bitField0_ |= 0x00000001; break; } } @@ -2292,9 +2625,6 @@ public final class ShardTransactionMessages { throw new com.google.protobuf.InvalidProtocolBufferException( e.getMessage()).setUnfinishedMessage(this); } finally { - if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - instanceIdentifierPathArguments_ = new com.google.protobuf.UnmodifiableLazyStringList(instanceIdentifierPathArguments_); - } this.unknownFields = unknownFields.build(); makeExtensionsImmutable(); } @@ -2326,44 +2656,45 @@ public final class ShardTransactionMessages { return PARSER; } - // repeated string instanceIdentifierPathArguments = 1; + private int bitField0_; + // required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; public static final int INSTANCEIDENTIFIERPATHARGUMENTS_FIELD_NUMBER = 1; - private com.google.protobuf.LazyStringList instanceIdentifierPathArguments_; - /** - * repeated string instanceIdentifierPathArguments = 1; - */ - public java.util.List - getInstanceIdentifierPathArgumentsList() { - return instanceIdentifierPathArguments_; - } + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier instanceIdentifierPathArguments_; /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public int getInstanceIdentifierPathArgumentsCount() { - return instanceIdentifierPathArguments_.size(); + public boolean hasInstanceIdentifierPathArguments() { + return ((bitField0_ & 0x00000001) == 0x00000001); } /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public java.lang.String getInstanceIdentifierPathArguments(int index) { - return instanceIdentifierPathArguments_.get(index); + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierPathArguments() { + return instanceIdentifierPathArguments_; } /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public com.google.protobuf.ByteString - getInstanceIdentifierPathArgumentsBytes(int index) { - return instanceIdentifierPathArguments_.getByteString(index); + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierPathArgumentsOrBuilder() { + return instanceIdentifierPathArguments_; } private void initFields() { - instanceIdentifierPathArguments_ = com.google.protobuf.LazyStringArrayList.EMPTY; + instanceIdentifierPathArguments_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized != -1) return isInitialized == 1; + if (!hasInstanceIdentifierPathArguments()) { + memoizedIsInitialized = 0; + return false; + } + if (!getInstanceIdentifierPathArguments().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } memoizedIsInitialized = 1; return true; } @@ -2371,8 +2702,8 @@ public final class ShardTransactionMessages { public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { getSerializedSize(); - for (int i = 0; i < instanceIdentifierPathArguments_.size(); i++) { - output.writeBytes(1, instanceIdentifierPathArguments_.getByteString(i)); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeMessage(1, instanceIdentifierPathArguments_); } getUnknownFields().writeTo(output); } @@ -2383,14 +2714,9 @@ public final class ShardTransactionMessages { if (size != -1) return size; size = 0; - { - int dataSize = 0; - for (int i = 0; i < instanceIdentifierPathArguments_.size(); i++) { - dataSize += com.google.protobuf.CodedOutputStream - .computeBytesSizeNoTag(instanceIdentifierPathArguments_.getByteString(i)); - } - size += dataSize; - size += 1 * getInstanceIdentifierPathArgumentsList().size(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, instanceIdentifierPathArguments_); } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; @@ -2500,6 +2826,7 @@ public final class ShardTransactionMessages { } private void maybeForceBuilderInitialization() { if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getInstanceIdentifierPathArgumentsFieldBuilder(); } } private static Builder create() { @@ -2508,7 +2835,11 @@ public final class ShardTransactionMessages { public Builder clear() { super.clear(); - instanceIdentifierPathArguments_ = com.google.protobuf.LazyStringArrayList.EMPTY; + if (instanceIdentifierPathArgumentsBuilder_ == null) { + instanceIdentifierPathArguments_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + } else { + instanceIdentifierPathArgumentsBuilder_.clear(); + } bitField0_ = (bitField0_ & ~0x00000001); return this; } @@ -2537,12 +2868,16 @@ public final class ShardTransactionMessages { public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.DeleteData buildPartial() { org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.DeleteData result = new org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.DeleteData(this); int from_bitField0_ = bitField0_; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - instanceIdentifierPathArguments_ = new com.google.protobuf.UnmodifiableLazyStringList( - instanceIdentifierPathArguments_); - bitField0_ = (bitField0_ & ~0x00000001); + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + if (instanceIdentifierPathArgumentsBuilder_ == null) { + result.instanceIdentifierPathArguments_ = instanceIdentifierPathArguments_; + } else { + result.instanceIdentifierPathArguments_ = instanceIdentifierPathArgumentsBuilder_.build(); } - result.instanceIdentifierPathArguments_ = instanceIdentifierPathArguments_; + result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -2558,21 +2893,22 @@ public final class ShardTransactionMessages { public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.DeleteData other) { if (other == org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.DeleteData.getDefaultInstance()) return this; - if (!other.instanceIdentifierPathArguments_.isEmpty()) { - if (instanceIdentifierPathArguments_.isEmpty()) { - instanceIdentifierPathArguments_ = other.instanceIdentifierPathArguments_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureInstanceIdentifierPathArgumentsIsMutable(); - instanceIdentifierPathArguments_.addAll(other.instanceIdentifierPathArguments_); - } - onChanged(); + if (other.hasInstanceIdentifierPathArguments()) { + mergeInstanceIdentifierPathArguments(other.getInstanceIdentifierPathArguments()); } this.mergeUnknownFields(other.getUnknownFields()); return this; } public final boolean isInitialized() { + if (!hasInstanceIdentifierPathArguments()) { + + return false; + } + if (!getInstanceIdentifierPathArguments().isInitialized()) { + + return false; + } return true; } @@ -2595,97 +2931,121 @@ public final class ShardTransactionMessages { } private int bitField0_; - // repeated string instanceIdentifierPathArguments = 1; - private com.google.protobuf.LazyStringList instanceIdentifierPathArguments_ = com.google.protobuf.LazyStringArrayList.EMPTY; - private void ensureInstanceIdentifierPathArgumentsIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - instanceIdentifierPathArguments_ = new com.google.protobuf.LazyStringArrayList(instanceIdentifierPathArguments_); - bitField0_ |= 0x00000001; - } - } + // required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier instanceIdentifierPathArguments_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> instanceIdentifierPathArgumentsBuilder_; /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public java.util.List - getInstanceIdentifierPathArgumentsList() { - return java.util.Collections.unmodifiableList(instanceIdentifierPathArguments_); + public boolean hasInstanceIdentifierPathArguments() { + return ((bitField0_ & 0x00000001) == 0x00000001); } /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public int getInstanceIdentifierPathArgumentsCount() { - return instanceIdentifierPathArguments_.size(); + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierPathArguments() { + if (instanceIdentifierPathArgumentsBuilder_ == null) { + return instanceIdentifierPathArguments_; + } else { + return instanceIdentifierPathArgumentsBuilder_.getMessage(); + } } /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public java.lang.String getInstanceIdentifierPathArguments(int index) { - return instanceIdentifierPathArguments_.get(index); + public Builder setInstanceIdentifierPathArguments(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier value) { + if (instanceIdentifierPathArgumentsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + instanceIdentifierPathArguments_ = value; + onChanged(); + } else { + instanceIdentifierPathArgumentsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + return this; } /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public com.google.protobuf.ByteString - getInstanceIdentifierPathArgumentsBytes(int index) { - return instanceIdentifierPathArguments_.getByteString(index); + public Builder setInstanceIdentifierPathArguments( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder builderForValue) { + if (instanceIdentifierPathArgumentsBuilder_ == null) { + instanceIdentifierPathArguments_ = builderForValue.build(); + onChanged(); + } else { + instanceIdentifierPathArgumentsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + return this; } /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public Builder setInstanceIdentifierPathArguments( - int index, java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureInstanceIdentifierPathArgumentsIsMutable(); - instanceIdentifierPathArguments_.set(index, value); - onChanged(); + public Builder mergeInstanceIdentifierPathArguments(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier value) { + if (instanceIdentifierPathArgumentsBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001) && + instanceIdentifierPathArguments_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance()) { + instanceIdentifierPathArguments_ = + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.newBuilder(instanceIdentifierPathArguments_).mergeFrom(value).buildPartial(); + } else { + instanceIdentifierPathArguments_ = value; + } + onChanged(); + } else { + instanceIdentifierPathArgumentsBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000001; return this; } /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public Builder addInstanceIdentifierPathArguments( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureInstanceIdentifierPathArgumentsIsMutable(); - instanceIdentifierPathArguments_.add(value); - onChanged(); + public Builder clearInstanceIdentifierPathArguments() { + if (instanceIdentifierPathArgumentsBuilder_ == null) { + instanceIdentifierPathArguments_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + onChanged(); + } else { + instanceIdentifierPathArgumentsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); return this; } /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public Builder addAllInstanceIdentifierPathArguments( - java.lang.Iterable values) { - ensureInstanceIdentifierPathArgumentsIsMutable(); - super.addAll(values, instanceIdentifierPathArguments_); + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder getInstanceIdentifierPathArgumentsBuilder() { + bitField0_ |= 0x00000001; onChanged(); - return this; + return getInstanceIdentifierPathArgumentsFieldBuilder().getBuilder(); } /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public Builder clearInstanceIdentifierPathArguments() { - instanceIdentifierPathArguments_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - return this; + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierPathArgumentsOrBuilder() { + if (instanceIdentifierPathArgumentsBuilder_ != null) { + return instanceIdentifierPathArgumentsBuilder_.getMessageOrBuilder(); + } else { + return instanceIdentifierPathArguments_; + } } /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public Builder addInstanceIdentifierPathArgumentsBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - ensureInstanceIdentifierPathArgumentsIsMutable(); - instanceIdentifierPathArguments_.add(value); - onChanged(); - return this; + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> + getInstanceIdentifierPathArgumentsFieldBuilder() { + if (instanceIdentifierPathArgumentsBuilder_ == null) { + instanceIdentifierPathArgumentsBuilder_ = new com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder>( + instanceIdentifierPathArguments_, + getParentForChildren(), + isClean()); + instanceIdentifierPathArguments_ = null; + } + return instanceIdentifierPathArgumentsBuilder_; } // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.DeleteData) @@ -3011,20 +3371,19 @@ public final class ShardTransactionMessages { public interface ReadDataOrBuilder extends com.google.protobuf.MessageOrBuilder { - // required string instanceIdentifierPathArguments = 1; + // required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; /** - * required string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ boolean hasInstanceIdentifierPathArguments(); /** - * required string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - java.lang.String getInstanceIdentifierPathArguments(); + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierPathArguments(); /** - * required string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - com.google.protobuf.ByteString - getInstanceIdentifierPathArgumentsBytes(); + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierPathArgumentsOrBuilder(); } /** * Protobuf type {@code org.opendaylight.controller.mdsal.ReadData} @@ -3078,8 +3437,16 @@ public final class ShardTransactionMessages { break; } case 10: { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder subBuilder = null; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + subBuilder = instanceIdentifierPathArguments_.toBuilder(); + } + instanceIdentifierPathArguments_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(instanceIdentifierPathArguments_); + instanceIdentifierPathArguments_ = subBuilder.buildPartial(); + } bitField0_ |= 0x00000001; - instanceIdentifierPathArguments_ = input.readBytes(); break; } } @@ -3122,51 +3489,30 @@ public final class ShardTransactionMessages { } private int bitField0_; - // required string instanceIdentifierPathArguments = 1; + // required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; public static final int INSTANCEIDENTIFIERPATHARGUMENTS_FIELD_NUMBER = 1; - private java.lang.Object instanceIdentifierPathArguments_; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier instanceIdentifierPathArguments_; /** - * required string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ public boolean hasInstanceIdentifierPathArguments() { return ((bitField0_ & 0x00000001) == 0x00000001); } /** - * required string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public java.lang.String getInstanceIdentifierPathArguments() { - java.lang.Object ref = instanceIdentifierPathArguments_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - instanceIdentifierPathArguments_ = s; - } - return s; - } + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierPathArguments() { + return instanceIdentifierPathArguments_; } /** - * required string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public com.google.protobuf.ByteString - getInstanceIdentifierPathArgumentsBytes() { - java.lang.Object ref = instanceIdentifierPathArguments_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - instanceIdentifierPathArguments_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierPathArgumentsOrBuilder() { + return instanceIdentifierPathArguments_; } private void initFields() { - instanceIdentifierPathArguments_ = ""; + instanceIdentifierPathArguments_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { @@ -3177,6 +3523,10 @@ public final class ShardTransactionMessages { memoizedIsInitialized = 0; return false; } + if (!getInstanceIdentifierPathArguments().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } memoizedIsInitialized = 1; return true; } @@ -3185,7 +3535,7 @@ public final class ShardTransactionMessages { throws java.io.IOException { getSerializedSize(); if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeBytes(1, getInstanceIdentifierPathArgumentsBytes()); + output.writeMessage(1, instanceIdentifierPathArguments_); } getUnknownFields().writeTo(output); } @@ -3198,7 +3548,7 @@ public final class ShardTransactionMessages { size = 0; if (((bitField0_ & 0x00000001) == 0x00000001)) { size += com.google.protobuf.CodedOutputStream - .computeBytesSize(1, getInstanceIdentifierPathArgumentsBytes()); + .computeMessageSize(1, instanceIdentifierPathArguments_); } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; @@ -3308,6 +3658,7 @@ public final class ShardTransactionMessages { } private void maybeForceBuilderInitialization() { if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getInstanceIdentifierPathArgumentsFieldBuilder(); } } private static Builder create() { @@ -3316,7 +3667,11 @@ public final class ShardTransactionMessages { public Builder clear() { super.clear(); - instanceIdentifierPathArguments_ = ""; + if (instanceIdentifierPathArgumentsBuilder_ == null) { + instanceIdentifierPathArguments_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + } else { + instanceIdentifierPathArgumentsBuilder_.clear(); + } bitField0_ = (bitField0_ & ~0x00000001); return this; } @@ -3349,7 +3704,11 @@ public final class ShardTransactionMessages { if (((from_bitField0_ & 0x00000001) == 0x00000001)) { to_bitField0_ |= 0x00000001; } - result.instanceIdentifierPathArguments_ = instanceIdentifierPathArguments_; + if (instanceIdentifierPathArgumentsBuilder_ == null) { + result.instanceIdentifierPathArguments_ = instanceIdentifierPathArguments_; + } else { + result.instanceIdentifierPathArguments_ = instanceIdentifierPathArgumentsBuilder_.build(); + } result.bitField0_ = to_bitField0_; onBuilt(); return result; @@ -3367,9 +3726,7 @@ public final class ShardTransactionMessages { public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.ReadData other) { if (other == org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.ReadData.getDefaultInstance()) return this; if (other.hasInstanceIdentifierPathArguments()) { - bitField0_ |= 0x00000001; - instanceIdentifierPathArguments_ = other.instanceIdentifierPathArguments_; - onChanged(); + mergeInstanceIdentifierPathArguments(other.getInstanceIdentifierPathArguments()); } this.mergeUnknownFields(other.getUnknownFields()); return this; @@ -3377,7 +3734,11 @@ public final class ShardTransactionMessages { public final boolean isInitialized() { if (!hasInstanceIdentifierPathArguments()) { - + + return false; + } + if (!getInstanceIdentifierPathArguments().isInitialized()) { + return false; } return true; @@ -3402,78 +3763,121 @@ public final class ShardTransactionMessages { } private int bitField0_; - // required string instanceIdentifierPathArguments = 1; - private java.lang.Object instanceIdentifierPathArguments_ = ""; + // required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier instanceIdentifierPathArguments_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> instanceIdentifierPathArgumentsBuilder_; /** - * required string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ public boolean hasInstanceIdentifierPathArguments() { return ((bitField0_ & 0x00000001) == 0x00000001); } /** - * required string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public java.lang.String getInstanceIdentifierPathArguments() { - java.lang.Object ref = instanceIdentifierPathArguments_; - if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - instanceIdentifierPathArguments_ = s; - return s; + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierPathArguments() { + if (instanceIdentifierPathArgumentsBuilder_ == null) { + return instanceIdentifierPathArguments_; } else { - return (java.lang.String) ref; + return instanceIdentifierPathArgumentsBuilder_.getMessage(); } } /** - * required string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public com.google.protobuf.ByteString - getInstanceIdentifierPathArgumentsBytes() { - java.lang.Object ref = instanceIdentifierPathArguments_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - instanceIdentifierPathArguments_ = b; - return b; + public Builder setInstanceIdentifierPathArguments(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier value) { + if (instanceIdentifierPathArgumentsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + instanceIdentifierPathArguments_ = value; + onChanged(); } else { - return (com.google.protobuf.ByteString) ref; + instanceIdentifierPathArgumentsBuilder_.setMessage(value); } + bitField0_ |= 0x00000001; + return this; } /** - * required string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ public Builder setInstanceIdentifierPathArguments( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - instanceIdentifierPathArguments_ = value; - onChanged(); + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder builderForValue) { + if (instanceIdentifierPathArgumentsBuilder_ == null) { + instanceIdentifierPathArguments_ = builderForValue.build(); + onChanged(); + } else { + instanceIdentifierPathArgumentsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + return this; + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; + */ + public Builder mergeInstanceIdentifierPathArguments(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier value) { + if (instanceIdentifierPathArgumentsBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001) && + instanceIdentifierPathArguments_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance()) { + instanceIdentifierPathArguments_ = + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.newBuilder(instanceIdentifierPathArguments_).mergeFrom(value).buildPartial(); + } else { + instanceIdentifierPathArguments_ = value; + } + onChanged(); + } else { + instanceIdentifierPathArgumentsBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000001; return this; } /** - * required string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ public Builder clearInstanceIdentifierPathArguments() { + if (instanceIdentifierPathArgumentsBuilder_ == null) { + instanceIdentifierPathArguments_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + onChanged(); + } else { + instanceIdentifierPathArgumentsBuilder_.clear(); + } bitField0_ = (bitField0_ & ~0x00000001); - instanceIdentifierPathArguments_ = getDefaultInstance().getInstanceIdentifierPathArguments(); - onChanged(); return this; } /** - * required string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public Builder setInstanceIdentifierPathArgumentsBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - instanceIdentifierPathArguments_ = value; + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder getInstanceIdentifierPathArgumentsBuilder() { + bitField0_ |= 0x00000001; onChanged(); - return this; + return getInstanceIdentifierPathArgumentsFieldBuilder().getBuilder(); + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierPathArgumentsOrBuilder() { + if (instanceIdentifierPathArgumentsBuilder_ != null) { + return instanceIdentifierPathArgumentsBuilder_.getMessageOrBuilder(); + } else { + return instanceIdentifierPathArguments_; + } + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> + getInstanceIdentifierPathArgumentsFieldBuilder() { + if (instanceIdentifierPathArgumentsBuilder_ == null) { + instanceIdentifierPathArgumentsBuilder_ = new com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder>( + instanceIdentifierPathArguments_, + getParentForChildren(), + isClean()); + instanceIdentifierPathArguments_ = null; + } + return instanceIdentifierPathArgumentsBuilder_; } // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.ReadData) @@ -3490,19 +3894,19 @@ public final class ShardTransactionMessages { public interface ReadDataReplyOrBuilder extends com.google.protobuf.MessageOrBuilder { - // required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 1; + // optional .org.opendaylight.controller.mdsal.Node normalizedNode = 1; /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 1; + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 1; */ boolean hasNormalizedNode(); /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 1; + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 1; */ - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml getNormalizedNode(); + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getNormalizedNode(); /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 1; + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 1; */ - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXmlOrBuilder getNormalizedNodeOrBuilder(); + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getNormalizedNodeOrBuilder(); } /** * Protobuf type {@code org.opendaylight.controller.mdsal.ReadDataReply} @@ -3556,11 +3960,11 @@ public final class ShardTransactionMessages { break; } case 10: { - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.Builder subBuilder = null; + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder subBuilder = null; if (((bitField0_ & 0x00000001) == 0x00000001)) { subBuilder = normalizedNode_.toBuilder(); } - normalizedNode_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.PARSER, extensionRegistry); + normalizedNode_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.PARSER, extensionRegistry); if (subBuilder != null) { subBuilder.mergeFrom(normalizedNode_); normalizedNode_ = subBuilder.buildPartial(); @@ -3608,43 +4012,41 @@ public final class ShardTransactionMessages { } private int bitField0_; - // required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 1; + // optional .org.opendaylight.controller.mdsal.Node normalizedNode = 1; public static final int NORMALIZEDNODE_FIELD_NUMBER = 1; - private org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml normalizedNode_; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node normalizedNode_; /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 1; + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 1; */ public boolean hasNormalizedNode() { return ((bitField0_ & 0x00000001) == 0x00000001); } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 1; + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 1; */ - public org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml getNormalizedNode() { + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getNormalizedNode() { return normalizedNode_; } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 1; + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 1; */ - public org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXmlOrBuilder getNormalizedNodeOrBuilder() { + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getNormalizedNodeOrBuilder() { return normalizedNode_; } private void initFields() { - normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.getDefaultInstance(); + normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized != -1) return isInitialized == 1; - if (!hasNormalizedNode()) { - memoizedIsInitialized = 0; - return false; - } - if (!getNormalizedNode().isInitialized()) { - memoizedIsInitialized = 0; - return false; + if (hasNormalizedNode()) { + if (!getNormalizedNode().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } } memoizedIsInitialized = 1; return true; @@ -3787,7 +4189,7 @@ public final class ShardTransactionMessages { public Builder clear() { super.clear(); if (normalizedNodeBuilder_ == null) { - normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.getDefaultInstance(); + normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); } else { normalizedNodeBuilder_.clear(); } @@ -3852,13 +4254,11 @@ public final class ShardTransactionMessages { } public final boolean isInitialized() { - if (!hasNormalizedNode()) { - - return false; - } - if (!getNormalizedNode().isInitialized()) { - - return false; + if (hasNormalizedNode()) { + if (!getNormalizedNode().isInitialized()) { + + return false; + } } return true; } @@ -3882,20 +4282,20 @@ public final class ShardTransactionMessages { } private int bitField0_; - // required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 1; - private org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.getDefaultInstance(); + // optional .org.opendaylight.controller.mdsal.Node normalizedNode = 1; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml, org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.Builder, org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXmlOrBuilder> normalizedNodeBuilder_; + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> normalizedNodeBuilder_; /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 1; + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 1; */ public boolean hasNormalizedNode() { return ((bitField0_ & 0x00000001) == 0x00000001); } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 1; + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 1; */ - public org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml getNormalizedNode() { + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getNormalizedNode() { if (normalizedNodeBuilder_ == null) { return normalizedNode_; } else { @@ -3903,9 +4303,9 @@ public final class ShardTransactionMessages { } } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 1; + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 1; */ - public Builder setNormalizedNode(org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml value) { + public Builder setNormalizedNode(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node value) { if (normalizedNodeBuilder_ == null) { if (value == null) { throw new NullPointerException(); @@ -3919,10 +4319,10 @@ public final class ShardTransactionMessages { return this; } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 1; + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 1; */ public Builder setNormalizedNode( - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.Builder builderForValue) { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder builderForValue) { if (normalizedNodeBuilder_ == null) { normalizedNode_ = builderForValue.build(); onChanged(); @@ -3933,14 +4333,14 @@ public final class ShardTransactionMessages { return this; } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 1; + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 1; */ - public Builder mergeNormalizedNode(org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml value) { + public Builder mergeNormalizedNode(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node value) { if (normalizedNodeBuilder_ == null) { if (((bitField0_ & 0x00000001) == 0x00000001) && - normalizedNode_ != org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.getDefaultInstance()) { + normalizedNode_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance()) { normalizedNode_ = - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.newBuilder(normalizedNode_).mergeFrom(value).buildPartial(); + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.newBuilder(normalizedNode_).mergeFrom(value).buildPartial(); } else { normalizedNode_ = value; } @@ -3952,11 +4352,11 @@ public final class ShardTransactionMessages { return this; } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 1; + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 1; */ public Builder clearNormalizedNode() { if (normalizedNodeBuilder_ == null) { - normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.getDefaultInstance(); + normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); onChanged(); } else { normalizedNodeBuilder_.clear(); @@ -3965,17 +4365,17 @@ public final class ShardTransactionMessages { return this; } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 1; + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 1; */ - public org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.Builder getNormalizedNodeBuilder() { + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder getNormalizedNodeBuilder() { bitField0_ |= 0x00000001; onChanged(); return getNormalizedNodeFieldBuilder().getBuilder(); } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 1; + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 1; */ - public org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXmlOrBuilder getNormalizedNodeOrBuilder() { + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getNormalizedNodeOrBuilder() { if (normalizedNodeBuilder_ != null) { return normalizedNodeBuilder_.getMessageOrBuilder(); } else { @@ -3983,14 +4383,14 @@ public final class ShardTransactionMessages { } } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 1; + * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 1; */ private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml, org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.Builder, org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXmlOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> getNormalizedNodeFieldBuilder() { if (normalizedNodeBuilder_ == null) { normalizedNodeBuilder_ = new com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml, org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.Builder, org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXmlOrBuilder>( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder>( normalizedNode_, getParentForChildren(), isClean()); @@ -4013,39 +4413,33 @@ public final class ShardTransactionMessages { public interface WriteDataOrBuilder extends com.google.protobuf.MessageOrBuilder { - // repeated string instanceIdentifierPathArguments = 1; - /** - * repeated string instanceIdentifierPathArguments = 1; - */ - java.util.List - getInstanceIdentifierPathArgumentsList(); + // required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - int getInstanceIdentifierPathArgumentsCount(); + boolean hasInstanceIdentifierPathArguments(); /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - java.lang.String getInstanceIdentifierPathArguments(int index); + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierPathArguments(); /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - com.google.protobuf.ByteString - getInstanceIdentifierPathArgumentsBytes(int index); + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierPathArgumentsOrBuilder(); - // required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 2; + // required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 2; + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; */ boolean hasNormalizedNode(); /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 2; + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; */ - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml getNormalizedNode(); + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getNormalizedNode(); /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 2; + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; */ - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXmlOrBuilder getNormalizedNodeOrBuilder(); + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getNormalizedNodeOrBuilder(); } /** * Protobuf type {@code org.opendaylight.controller.mdsal.WriteData} @@ -4099,24 +4493,29 @@ public final class ShardTransactionMessages { break; } case 10: { - if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - instanceIdentifierPathArguments_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000001; + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder subBuilder = null; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + subBuilder = instanceIdentifierPathArguments_.toBuilder(); } - instanceIdentifierPathArguments_.add(input.readBytes()); + instanceIdentifierPathArguments_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(instanceIdentifierPathArguments_); + instanceIdentifierPathArguments_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000001; break; } case 18: { - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.Builder subBuilder = null; - if (((bitField0_ & 0x00000001) == 0x00000001)) { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder subBuilder = null; + if (((bitField0_ & 0x00000002) == 0x00000002)) { subBuilder = normalizedNode_.toBuilder(); } - normalizedNode_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.PARSER, extensionRegistry); + normalizedNode_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.PARSER, extensionRegistry); if (subBuilder != null) { subBuilder.mergeFrom(normalizedNode_); normalizedNode_ = subBuilder.buildPartial(); } - bitField0_ |= 0x00000001; + bitField0_ |= 0x00000002; break; } } @@ -4127,9 +4526,6 @@ public final class ShardTransactionMessages { throw new com.google.protobuf.InvalidProtocolBufferException( e.getMessage()).setUnfinishedMessage(this); } finally { - if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - instanceIdentifierPathArguments_ = new com.google.protobuf.UnmodifiableLazyStringList(instanceIdentifierPathArguments_); - } this.unknownFields = unknownFields.build(); makeExtensionsImmutable(); } @@ -4162,71 +4558,71 @@ public final class ShardTransactionMessages { } private int bitField0_; - // repeated string instanceIdentifierPathArguments = 1; + // required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; public static final int INSTANCEIDENTIFIERPATHARGUMENTS_FIELD_NUMBER = 1; - private com.google.protobuf.LazyStringList instanceIdentifierPathArguments_; - /** - * repeated string instanceIdentifierPathArguments = 1; - */ - public java.util.List - getInstanceIdentifierPathArgumentsList() { - return instanceIdentifierPathArguments_; - } + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier instanceIdentifierPathArguments_; /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public int getInstanceIdentifierPathArgumentsCount() { - return instanceIdentifierPathArguments_.size(); + public boolean hasInstanceIdentifierPathArguments() { + return ((bitField0_ & 0x00000001) == 0x00000001); } /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public java.lang.String getInstanceIdentifierPathArguments(int index) { - return instanceIdentifierPathArguments_.get(index); + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierPathArguments() { + return instanceIdentifierPathArguments_; } /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public com.google.protobuf.ByteString - getInstanceIdentifierPathArgumentsBytes(int index) { - return instanceIdentifierPathArguments_.getByteString(index); + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierPathArgumentsOrBuilder() { + return instanceIdentifierPathArguments_; } - // required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 2; + // required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; public static final int NORMALIZEDNODE_FIELD_NUMBER = 2; - private org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml normalizedNode_; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node normalizedNode_; /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 2; + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; */ public boolean hasNormalizedNode() { - return ((bitField0_ & 0x00000001) == 0x00000001); + return ((bitField0_ & 0x00000002) == 0x00000002); } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 2; + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; */ - public org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml getNormalizedNode() { + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getNormalizedNode() { return normalizedNode_; } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 2; + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; */ - public org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXmlOrBuilder getNormalizedNodeOrBuilder() { + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getNormalizedNodeOrBuilder() { return normalizedNode_; } private void initFields() { - instanceIdentifierPathArguments_ = com.google.protobuf.LazyStringArrayList.EMPTY; - normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.getDefaultInstance(); + instanceIdentifierPathArguments_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized != -1) return isInitialized == 1; + if (!hasInstanceIdentifierPathArguments()) { + memoizedIsInitialized = 0; + return false; + } if (!hasNormalizedNode()) { memoizedIsInitialized = 0; return false; } + if (!getInstanceIdentifierPathArguments().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } if (!getNormalizedNode().isInitialized()) { memoizedIsInitialized = 0; return false; @@ -4238,10 +4634,10 @@ public final class ShardTransactionMessages { public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { getSerializedSize(); - for (int i = 0; i < instanceIdentifierPathArguments_.size(); i++) { - output.writeBytes(1, instanceIdentifierPathArguments_.getByteString(i)); - } if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeMessage(1, instanceIdentifierPathArguments_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { output.writeMessage(2, normalizedNode_); } getUnknownFields().writeTo(output); @@ -4253,16 +4649,11 @@ public final class ShardTransactionMessages { if (size != -1) return size; size = 0; - { - int dataSize = 0; - for (int i = 0; i < instanceIdentifierPathArguments_.size(); i++) { - dataSize += com.google.protobuf.CodedOutputStream - .computeBytesSizeNoTag(instanceIdentifierPathArguments_.getByteString(i)); - } - size += dataSize; - size += 1 * getInstanceIdentifierPathArgumentsList().size(); - } if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, instanceIdentifierPathArguments_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(2, normalizedNode_); } @@ -4374,6 +4765,7 @@ public final class ShardTransactionMessages { } private void maybeForceBuilderInitialization() { if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getInstanceIdentifierPathArgumentsFieldBuilder(); getNormalizedNodeFieldBuilder(); } } @@ -4383,10 +4775,14 @@ public final class ShardTransactionMessages { public Builder clear() { super.clear(); - instanceIdentifierPathArguments_ = com.google.protobuf.LazyStringArrayList.EMPTY; + if (instanceIdentifierPathArgumentsBuilder_ == null) { + instanceIdentifierPathArguments_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + } else { + instanceIdentifierPathArgumentsBuilder_.clear(); + } bitField0_ = (bitField0_ & ~0x00000001); if (normalizedNodeBuilder_ == null) { - normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.getDefaultInstance(); + normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); } else { normalizedNodeBuilder_.clear(); } @@ -4419,14 +4815,16 @@ public final class ShardTransactionMessages { org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteData result = new org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteData(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - instanceIdentifierPathArguments_ = new com.google.protobuf.UnmodifiableLazyStringList( - instanceIdentifierPathArguments_); - bitField0_ = (bitField0_ & ~0x00000001); + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + if (instanceIdentifierPathArgumentsBuilder_ == null) { + result.instanceIdentifierPathArguments_ = instanceIdentifierPathArguments_; + } else { + result.instanceIdentifierPathArguments_ = instanceIdentifierPathArgumentsBuilder_.build(); } - result.instanceIdentifierPathArguments_ = instanceIdentifierPathArguments_; if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000001; + to_bitField0_ |= 0x00000002; } if (normalizedNodeBuilder_ == null) { result.normalizedNode_ = normalizedNode_; @@ -4449,15 +4847,8 @@ public final class ShardTransactionMessages { public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteData other) { if (other == org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteData.getDefaultInstance()) return this; - if (!other.instanceIdentifierPathArguments_.isEmpty()) { - if (instanceIdentifierPathArguments_.isEmpty()) { - instanceIdentifierPathArguments_ = other.instanceIdentifierPathArguments_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureInstanceIdentifierPathArgumentsIsMutable(); - instanceIdentifierPathArguments_.addAll(other.instanceIdentifierPathArguments_); - } - onChanged(); + if (other.hasInstanceIdentifierPathArguments()) { + mergeInstanceIdentifierPathArguments(other.getInstanceIdentifierPathArguments()); } if (other.hasNormalizedNode()) { mergeNormalizedNode(other.getNormalizedNode()); @@ -4467,12 +4858,20 @@ public final class ShardTransactionMessages { } public final boolean isInitialized() { + if (!hasInstanceIdentifierPathArguments()) { + + return false; + } if (!hasNormalizedNode()) { - + + return false; + } + if (!getInstanceIdentifierPathArguments().isInitialized()) { + return false; } if (!getNormalizedNode().isInitialized()) { - + return false; } return true; @@ -4497,113 +4896,1177 @@ public final class ShardTransactionMessages { } private int bitField0_; - // repeated string instanceIdentifierPathArguments = 1; - private com.google.protobuf.LazyStringList instanceIdentifierPathArguments_ = com.google.protobuf.LazyStringArrayList.EMPTY; - private void ensureInstanceIdentifierPathArgumentsIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - instanceIdentifierPathArguments_ = new com.google.protobuf.LazyStringArrayList(instanceIdentifierPathArguments_); - bitField0_ |= 0x00000001; - } - } + // required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier instanceIdentifierPathArguments_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> instanceIdentifierPathArgumentsBuilder_; /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public java.util.List - getInstanceIdentifierPathArgumentsList() { - return java.util.Collections.unmodifiableList(instanceIdentifierPathArguments_); + public boolean hasInstanceIdentifierPathArguments() { + return ((bitField0_ & 0x00000001) == 0x00000001); } /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public int getInstanceIdentifierPathArgumentsCount() { - return instanceIdentifierPathArguments_.size(); + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierPathArguments() { + if (instanceIdentifierPathArgumentsBuilder_ == null) { + return instanceIdentifierPathArguments_; + } else { + return instanceIdentifierPathArgumentsBuilder_.getMessage(); + } } /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public java.lang.String getInstanceIdentifierPathArguments(int index) { - return instanceIdentifierPathArguments_.get(index); + public Builder setInstanceIdentifierPathArguments(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier value) { + if (instanceIdentifierPathArgumentsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + instanceIdentifierPathArguments_ = value; + onChanged(); + } else { + instanceIdentifierPathArgumentsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + return this; } /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public com.google.protobuf.ByteString - getInstanceIdentifierPathArgumentsBytes(int index) { - return instanceIdentifierPathArguments_.getByteString(index); - } + public Builder setInstanceIdentifierPathArguments( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder builderForValue) { + if (instanceIdentifierPathArgumentsBuilder_ == null) { + instanceIdentifierPathArguments_ = builderForValue.build(); + onChanged(); + } else { + instanceIdentifierPathArgumentsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + return this; + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; + */ + public Builder mergeInstanceIdentifierPathArguments(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier value) { + if (instanceIdentifierPathArgumentsBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001) && + instanceIdentifierPathArguments_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance()) { + instanceIdentifierPathArguments_ = + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.newBuilder(instanceIdentifierPathArguments_).mergeFrom(value).buildPartial(); + } else { + instanceIdentifierPathArguments_ = value; + } + onChanged(); + } else { + instanceIdentifierPathArgumentsBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000001; + return this; + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; + */ + public Builder clearInstanceIdentifierPathArguments() { + if (instanceIdentifierPathArgumentsBuilder_ == null) { + instanceIdentifierPathArguments_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + onChanged(); + } else { + instanceIdentifierPathArgumentsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder getInstanceIdentifierPathArgumentsBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getInstanceIdentifierPathArgumentsFieldBuilder().getBuilder(); + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierPathArgumentsOrBuilder() { + if (instanceIdentifierPathArgumentsBuilder_ != null) { + return instanceIdentifierPathArgumentsBuilder_.getMessageOrBuilder(); + } else { + return instanceIdentifierPathArguments_; + } + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> + getInstanceIdentifierPathArgumentsFieldBuilder() { + if (instanceIdentifierPathArgumentsBuilder_ == null) { + instanceIdentifierPathArgumentsBuilder_ = new com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder>( + instanceIdentifierPathArguments_, + getParentForChildren(), + isClean()); + instanceIdentifierPathArguments_ = null; + } + return instanceIdentifierPathArgumentsBuilder_; + } + + // required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> normalizedNodeBuilder_; + /** + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public boolean hasNormalizedNode() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getNormalizedNode() { + if (normalizedNodeBuilder_ == null) { + return normalizedNode_; + } else { + return normalizedNodeBuilder_.getMessage(); + } + } + /** + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public Builder setNormalizedNode(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node value) { + if (normalizedNodeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + normalizedNode_ = value; + onChanged(); + } else { + normalizedNodeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + return this; + } + /** + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public Builder setNormalizedNode( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder builderForValue) { + if (normalizedNodeBuilder_ == null) { + normalizedNode_ = builderForValue.build(); + onChanged(); + } else { + normalizedNodeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + return this; + } + /** + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public Builder mergeNormalizedNode(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node value) { + if (normalizedNodeBuilder_ == null) { + if (((bitField0_ & 0x00000002) == 0x00000002) && + normalizedNode_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance()) { + normalizedNode_ = + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.newBuilder(normalizedNode_).mergeFrom(value).buildPartial(); + } else { + normalizedNode_ = value; + } + onChanged(); + } else { + normalizedNodeBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000002; + return this; + } + /** + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public Builder clearNormalizedNode() { + if (normalizedNodeBuilder_ == null) { + normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); + onChanged(); + } else { + normalizedNodeBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + /** + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder getNormalizedNodeBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getNormalizedNodeFieldBuilder().getBuilder(); + } + /** + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getNormalizedNodeOrBuilder() { + if (normalizedNodeBuilder_ != null) { + return normalizedNodeBuilder_.getMessageOrBuilder(); + } else { + return normalizedNode_; + } + } + /** + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> + getNormalizedNodeFieldBuilder() { + if (normalizedNodeBuilder_ == null) { + normalizedNodeBuilder_ = new com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder>( + normalizedNode_, + getParentForChildren(), + isClean()); + normalizedNode_ = null; + } + return normalizedNodeBuilder_; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.WriteData) + } + + static { + defaultInstance = new WriteData(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.WriteData) + } + + public interface WriteDataReplyOrBuilder + extends com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.WriteDataReply} + */ + public static final class WriteDataReply extends + com.google.protobuf.GeneratedMessage + implements WriteDataReplyOrBuilder { + // Use WriteDataReply.newBuilder() to construct. + private WriteDataReply(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private WriteDataReply(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final WriteDataReply defaultInstance; + public static WriteDataReply getDefaultInstance() { + return defaultInstance; + } + + public WriteDataReply getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private WriteDataReply( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_WriteDataReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_WriteDataReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply.class, org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public WriteDataReply parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new WriteDataReply(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private void initFields() { + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.WriteDataReply} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReplyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_WriteDataReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_WriteDataReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply.class, org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply.Builder.class); + } + + // Construct using org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_WriteDataReply_descriptor; + } + + public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply getDefaultInstanceForType() { + return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply.getDefaultInstance(); + } + + public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply build() { + org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply buildPartial() { + org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply result = new org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply(this); + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply) { + return mergeFrom((org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply other) { + if (other == org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply.getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.WriteDataReply) + } + + static { + defaultInstance = new WriteDataReply(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.WriteDataReply) + } + + public interface MergeDataOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; + */ + boolean hasInstanceIdentifierPathArguments(); + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierPathArguments(); + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierPathArgumentsOrBuilder(); + + // required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + /** + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + boolean hasNormalizedNode(); + /** + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getNormalizedNode(); + /** + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getNormalizedNodeOrBuilder(); + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.MergeData} + */ + public static final class MergeData extends + com.google.protobuf.GeneratedMessage + implements MergeDataOrBuilder { + // Use MergeData.newBuilder() to construct. + private MergeData(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private MergeData(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final MergeData defaultInstance; + public static MergeData getDefaultInstance() { + return defaultInstance; + } + + public MergeData getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private MergeData( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder subBuilder = null; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + subBuilder = instanceIdentifierPathArguments_.toBuilder(); + } + instanceIdentifierPathArguments_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(instanceIdentifierPathArguments_); + instanceIdentifierPathArguments_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000001; + break; + } + case 18: { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder subBuilder = null; + if (((bitField0_ & 0x00000002) == 0x00000002)) { + subBuilder = normalizedNode_.toBuilder(); + } + normalizedNode_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(normalizedNode_); + normalizedNode_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000002; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_MergeData_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_MergeData_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData.class, org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public MergeData parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new MergeData(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; + public static final int INSTANCEIDENTIFIERPATHARGUMENTS_FIELD_NUMBER = 1; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier instanceIdentifierPathArguments_; + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; + */ + public boolean hasInstanceIdentifierPathArguments() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierPathArguments() { + return instanceIdentifierPathArguments_; + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierPathArgumentsOrBuilder() { + return instanceIdentifierPathArguments_; + } + + // required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + public static final int NORMALIZEDNODE_FIELD_NUMBER = 2; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node normalizedNode_; + /** + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public boolean hasNormalizedNode() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getNormalizedNode() { + return normalizedNode_; + } + /** + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getNormalizedNodeOrBuilder() { + return normalizedNode_; + } + + private void initFields() { + instanceIdentifierPathArguments_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasInstanceIdentifierPathArguments()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasNormalizedNode()) { + memoizedIsInitialized = 0; + return false; + } + if (!getInstanceIdentifierPathArguments().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + if (!getNormalizedNode().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeMessage(1, instanceIdentifierPathArguments_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeMessage(2, normalizedNode_); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, instanceIdentifierPathArguments_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, normalizedNode_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.MergeData} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_MergeData_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_MergeData_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData.class, org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData.Builder.class); + } + + // Construct using org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getInstanceIdentifierPathArgumentsFieldBuilder(); + getNormalizedNodeFieldBuilder(); + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + if (instanceIdentifierPathArgumentsBuilder_ == null) { + instanceIdentifierPathArguments_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + } else { + instanceIdentifierPathArgumentsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + if (normalizedNodeBuilder_ == null) { + normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); + } else { + normalizedNodeBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_MergeData_descriptor; + } + + public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData getDefaultInstanceForType() { + return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData.getDefaultInstance(); + } + + public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData build() { + org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData buildPartial() { + org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData result = new org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + if (instanceIdentifierPathArgumentsBuilder_ == null) { + result.instanceIdentifierPathArguments_ = instanceIdentifierPathArguments_; + } else { + result.instanceIdentifierPathArguments_ = instanceIdentifierPathArgumentsBuilder_.build(); + } + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + if (normalizedNodeBuilder_ == null) { + result.normalizedNode_ = normalizedNode_; + } else { + result.normalizedNode_ = normalizedNodeBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData) { + return mergeFrom((org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData other) { + if (other == org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData.getDefaultInstance()) return this; + if (other.hasInstanceIdentifierPathArguments()) { + mergeInstanceIdentifierPathArguments(other.getInstanceIdentifierPathArguments()); + } + if (other.hasNormalizedNode()) { + mergeNormalizedNode(other.getNormalizedNode()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasInstanceIdentifierPathArguments()) { + + return false; + } + if (!hasNormalizedNode()) { + + return false; + } + if (!getInstanceIdentifierPathArguments().isInitialized()) { + + return false; + } + if (!getNormalizedNode().isInitialized()) { + + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeData) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier instanceIdentifierPathArguments_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> instanceIdentifierPathArgumentsBuilder_; /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public Builder setInstanceIdentifierPathArguments( - int index, java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureInstanceIdentifierPathArgumentsIsMutable(); - instanceIdentifierPathArguments_.set(index, value); - onChanged(); + public boolean hasInstanceIdentifierPathArguments() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierPathArguments() { + if (instanceIdentifierPathArgumentsBuilder_ == null) { + return instanceIdentifierPathArguments_; + } else { + return instanceIdentifierPathArgumentsBuilder_.getMessage(); + } + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; + */ + public Builder setInstanceIdentifierPathArguments(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier value) { + if (instanceIdentifierPathArgumentsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + instanceIdentifierPathArguments_ = value; + onChanged(); + } else { + instanceIdentifierPathArgumentsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; return this; } /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public Builder addInstanceIdentifierPathArguments( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureInstanceIdentifierPathArgumentsIsMutable(); - instanceIdentifierPathArguments_.add(value); - onChanged(); + public Builder setInstanceIdentifierPathArguments( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder builderForValue) { + if (instanceIdentifierPathArgumentsBuilder_ == null) { + instanceIdentifierPathArguments_ = builderForValue.build(); + onChanged(); + } else { + instanceIdentifierPathArgumentsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; return this; } /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public Builder addAllInstanceIdentifierPathArguments( - java.lang.Iterable values) { - ensureInstanceIdentifierPathArgumentsIsMutable(); - super.addAll(values, instanceIdentifierPathArguments_); - onChanged(); + public Builder mergeInstanceIdentifierPathArguments(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier value) { + if (instanceIdentifierPathArgumentsBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001) && + instanceIdentifierPathArguments_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance()) { + instanceIdentifierPathArguments_ = + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.newBuilder(instanceIdentifierPathArguments_).mergeFrom(value).buildPartial(); + } else { + instanceIdentifierPathArguments_ = value; + } + onChanged(); + } else { + instanceIdentifierPathArgumentsBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000001; return this; } /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ public Builder clearInstanceIdentifierPathArguments() { - instanceIdentifierPathArguments_ = com.google.protobuf.LazyStringArrayList.EMPTY; + if (instanceIdentifierPathArgumentsBuilder_ == null) { + instanceIdentifierPathArguments_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance(); + onChanged(); + } else { + instanceIdentifierPathArgumentsBuilder_.clear(); + } bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); return this; } /** - * repeated string instanceIdentifierPathArguments = 1; + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ - public Builder addInstanceIdentifierPathArgumentsBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - ensureInstanceIdentifierPathArgumentsIsMutable(); - instanceIdentifierPathArguments_.add(value); + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder getInstanceIdentifierPathArgumentsBuilder() { + bitField0_ |= 0x00000001; onChanged(); - return this; + return getInstanceIdentifierPathArgumentsFieldBuilder().getBuilder(); + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; + */ + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierPathArgumentsOrBuilder() { + if (instanceIdentifierPathArgumentsBuilder_ != null) { + return instanceIdentifierPathArgumentsBuilder_.getMessageOrBuilder(); + } else { + return instanceIdentifierPathArguments_; + } + } + /** + * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> + getInstanceIdentifierPathArgumentsFieldBuilder() { + if (instanceIdentifierPathArgumentsBuilder_ == null) { + instanceIdentifierPathArgumentsBuilder_ = new com.google.protobuf.SingleFieldBuilder< + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder>( + instanceIdentifierPathArguments_, + getParentForChildren(), + isClean()); + instanceIdentifierPathArguments_ = null; + } + return instanceIdentifierPathArgumentsBuilder_; } - // required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 2; - private org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.getDefaultInstance(); + // required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; + private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml, org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.Builder, org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXmlOrBuilder> normalizedNodeBuilder_; + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> normalizedNodeBuilder_; /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 2; + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; */ public boolean hasNormalizedNode() { return ((bitField0_ & 0x00000002) == 0x00000002); } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 2; + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; */ - public org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml getNormalizedNode() { + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getNormalizedNode() { if (normalizedNodeBuilder_ == null) { return normalizedNode_; } else { @@ -4611,9 +6074,9 @@ public final class ShardTransactionMessages { } } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 2; + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; */ - public Builder setNormalizedNode(org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml value) { + public Builder setNormalizedNode(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node value) { if (normalizedNodeBuilder_ == null) { if (value == null) { throw new NullPointerException(); @@ -4627,10 +6090,10 @@ public final class ShardTransactionMessages { return this; } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 2; + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; */ public Builder setNormalizedNode( - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.Builder builderForValue) { + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder builderForValue) { if (normalizedNodeBuilder_ == null) { normalizedNode_ = builderForValue.build(); onChanged(); @@ -4641,14 +6104,14 @@ public final class ShardTransactionMessages { return this; } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 2; + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; */ - public Builder mergeNormalizedNode(org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml value) { + public Builder mergeNormalizedNode(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node value) { if (normalizedNodeBuilder_ == null) { if (((bitField0_ & 0x00000002) == 0x00000002) && - normalizedNode_ != org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.getDefaultInstance()) { + normalizedNode_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance()) { normalizedNode_ = - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.newBuilder(normalizedNode_).mergeFrom(value).buildPartial(); + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.newBuilder(normalizedNode_).mergeFrom(value).buildPartial(); } else { normalizedNode_ = value; } @@ -4660,11 +6123,11 @@ public final class ShardTransactionMessages { return this; } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 2; + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; */ public Builder clearNormalizedNode() { if (normalizedNodeBuilder_ == null) { - normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.getDefaultInstance(); + normalizedNode_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance(); onChanged(); } else { normalizedNodeBuilder_.clear(); @@ -4673,17 +6136,17 @@ public final class ShardTransactionMessages { return this; } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 2; + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; */ - public org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.Builder getNormalizedNodeBuilder() { + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder getNormalizedNodeBuilder() { bitField0_ |= 0x00000002; onChanged(); return getNormalizedNodeFieldBuilder().getBuilder(); } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 2; + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; */ - public org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXmlOrBuilder getNormalizedNodeOrBuilder() { + public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getNormalizedNodeOrBuilder() { if (normalizedNodeBuilder_ != null) { return normalizedNodeBuilder_.getMessageOrBuilder(); } else { @@ -4691,14 +6154,14 @@ public final class ShardTransactionMessages { } } /** - * required .org.opendaylight.controller.mdsal.NormalizedNodeXml normalizedNode = 2; + * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; */ private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml, org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.Builder, org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXmlOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> getNormalizedNodeFieldBuilder() { if (normalizedNodeBuilder_ == null) { normalizedNodeBuilder_ = new com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml, org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXml.Builder, org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.NormalizedNodeXmlOrBuilder>( + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder>( normalizedNode_, getParentForChildren(), isClean()); @@ -4707,39 +6170,39 @@ public final class ShardTransactionMessages { return normalizedNodeBuilder_; } - // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.WriteData) + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.MergeData) } static { - defaultInstance = new WriteData(true); + defaultInstance = new MergeData(true); defaultInstance.initFields(); } - // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.WriteData) + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.MergeData) } - public interface WriteDataReplyOrBuilder + public interface MergeDataReplyOrBuilder extends com.google.protobuf.MessageOrBuilder { } /** - * Protobuf type {@code org.opendaylight.controller.mdsal.WriteDataReply} + * Protobuf type {@code org.opendaylight.controller.mdsal.MergeDataReply} */ - public static final class WriteDataReply extends + public static final class MergeDataReply extends com.google.protobuf.GeneratedMessage - implements WriteDataReplyOrBuilder { - // Use WriteDataReply.newBuilder() to construct. - private WriteDataReply(com.google.protobuf.GeneratedMessage.Builder builder) { + implements MergeDataReplyOrBuilder { + // Use MergeDataReply.newBuilder() to construct. + private MergeDataReply(com.google.protobuf.GeneratedMessage.Builder builder) { super(builder); this.unknownFields = builder.getUnknownFields(); } - private WriteDataReply(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + private MergeDataReply(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - private static final WriteDataReply defaultInstance; - public static WriteDataReply getDefaultInstance() { + private static final MergeDataReply defaultInstance; + public static MergeDataReply getDefaultInstance() { return defaultInstance; } - public WriteDataReply getDefaultInstanceForType() { + public MergeDataReply getDefaultInstanceForType() { return defaultInstance; } @@ -4749,7 +6212,7 @@ public final class ShardTransactionMessages { getUnknownFields() { return this.unknownFields; } - private WriteDataReply( + private MergeDataReply( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { @@ -4785,28 +6248,28 @@ public final class ShardTransactionMessages { } public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_WriteDataReply_descriptor; + return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_MergeDataReply_descriptor; } protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { - return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_WriteDataReply_fieldAccessorTable + return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_MergeDataReply_fieldAccessorTable .ensureFieldAccessorsInitialized( - org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply.class, org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply.Builder.class); + org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply.class, org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply.Builder.class); } - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public WriteDataReply parsePartialFrom( + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public MergeDataReply parsePartialFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { - return new WriteDataReply(input, extensionRegistry); + return new MergeDataReply(input, extensionRegistry); } }; @java.lang.Override - public com.google.protobuf.Parser getParserForType() { + public com.google.protobuf.Parser getParserForType() { return PARSER; } @@ -4845,53 +6308,53 @@ public final class ShardTransactionMessages { return super.writeReplace(); } - public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply parseFrom( + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply parseFrom( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply parseFrom( + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply parseFrom( com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply parseFrom(byte[] data) + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply parseFrom( + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply parseFrom( byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply parseFrom(java.io.InputStream input) + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply parseFrom(java.io.InputStream input) throws java.io.IOException { return PARSER.parseFrom(input); } - public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply parseFrom( + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return PARSER.parseFrom(input, extensionRegistry); } - public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply parseDelimitedFrom(java.io.InputStream input) + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { return PARSER.parseDelimitedFrom(input); } - public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply parseDelimitedFrom( + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return PARSER.parseDelimitedFrom(input, extensionRegistry); } - public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply parseFrom( + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { return PARSER.parseFrom(input); } - public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply parseFrom( + public static org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { @@ -4900,7 +6363,7 @@ public final class ShardTransactionMessages { public static Builder newBuilder() { return Builder.create(); } public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply prototype) { + public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); } @@ -4912,24 +6375,24 @@ public final class ShardTransactionMessages { return builder; } /** - * Protobuf type {@code org.opendaylight.controller.mdsal.WriteDataReply} + * Protobuf type {@code org.opendaylight.controller.mdsal.MergeDataReply} */ public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder - implements org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReplyOrBuilder { + implements org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReplyOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_WriteDataReply_descriptor; + return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_MergeDataReply_descriptor; } protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { - return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_WriteDataReply_fieldAccessorTable + return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_MergeDataReply_fieldAccessorTable .ensureFieldAccessorsInitialized( - org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply.class, org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply.Builder.class); + org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply.class, org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply.Builder.class); } - // Construct using org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply.newBuilder() + // Construct using org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply.newBuilder() private Builder() { maybeForceBuilderInitialization(); } @@ -4958,38 +6421,38 @@ public final class ShardTransactionMessages { public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_WriteDataReply_descriptor; + return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_MergeDataReply_descriptor; } - public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply getDefaultInstanceForType() { - return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply.getDefaultInstance(); + public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply getDefaultInstanceForType() { + return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply.getDefaultInstance(); } - public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply build() { - org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply result = buildPartial(); + public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply build() { + org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; } - public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply buildPartial() { - org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply result = new org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply(this); + public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply buildPartial() { + org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply result = new org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply(this); onBuilt(); return result; } public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply) { - return mergeFrom((org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply)other); + if (other instanceof org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply) { + return mergeFrom((org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply)other); } else { super.mergeFrom(other); return this; } } - public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply other) { - if (other == org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply.getDefaultInstance()) return this; + public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply other) { + if (other == org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply.getDefaultInstance()) return this; this.mergeUnknownFields(other.getUnknownFields()); return this; } @@ -5002,11 +6465,11 @@ public final class ShardTransactionMessages { com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply parsedMessage = null; + org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply parsedMessage = null; try { parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.WriteDataReply) e.getUnfinishedMessage(); + parsedMessage = (org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.MergeDataReply) e.getUnfinishedMessage(); throw e; } finally { if (parsedMessage != null) { @@ -5016,15 +6479,15 @@ public final class ShardTransactionMessages { return this; } - // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.WriteDataReply) + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.MergeDataReply) } static { - defaultInstance = new WriteDataReply(true); + defaultInstance = new MergeDataReply(true); defaultInstance.initFields(); } - // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.WriteDataReply) + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.MergeDataReply) } private static com.google.protobuf.Descriptors.Descriptor @@ -5087,6 +6550,16 @@ public final class ShardTransactionMessages { private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_org_opendaylight_controller_mdsal_WriteDataReply_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_MergeData_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_MergeData_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_MergeDataReply_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_MergeDataReply_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { @@ -5097,24 +6570,33 @@ public final class ShardTransactionMessages { static { java.lang.String[] descriptorData = { "\n\026ShardTransaction.proto\022!org.opendaylig" + - "ht.controller.mdsal\032\032SimpleNormalizedNod" + - "e.proto\"\022\n\020CloseTransaction\"\027\n\025CloseTran" + - "sactionReply\"\023\n\021CreateTransaction\"1\n\026Cre" + - "ateTransactionReply\022\027\n\017transactionPath\030\001" + - " \002(\t\"\022\n\020ReadyTransaction\"*\n\025ReadyTransac" + - "tionReply\022\021\n\tactorPath\030\001 \002(\t\"5\n\nDeleteDa" + - "ta\022\'\n\037instanceIdentifierPathArguments\030\001 " + - "\003(\t\"\021\n\017DeleteDataReply\"3\n\010ReadData\022\'\n\037in" + - "stanceIdentifierPathArguments\030\001 \002(\t\"]\n\rR", - "eadDataReply\022L\n\016normalizedNode\030\001 \002(\01324.o" + - "rg.opendaylight.controller.mdsal.Normali" + - "zedNodeXml\"\202\001\n\tWriteData\022\'\n\037instanceIden" + - "tifierPathArguments\030\001 \003(\t\022L\n\016normalizedN" + - "ode\030\002 \002(\01324.org.opendaylight.controller." + - "mdsal.NormalizedNodeXml\"\020\n\016WriteDataRepl" + - "yBV\n:org.opendaylight.controller.protobu" + - "ff.messages.transactionB\030ShardTransactio" + - "nMessages" + "ht.controller.mdsal\032\014Common.proto\"\022\n\020Clo" + + "seTransaction\"\027\n\025CloseTransactionReply\"*" + + "\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" + + "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" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { @@ -5138,13 +6620,13 @@ 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[] { }); + new java.lang.String[] { "TransactionId", }); internal_static_org_opendaylight_controller_mdsal_CreateTransactionReply_descriptor = getDescriptor().getMessageTypes().get(3); internal_static_org_opendaylight_controller_mdsal_CreateTransactionReply_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_org_opendaylight_controller_mdsal_CreateTransactionReply_descriptor, - new java.lang.String[] { "TransactionPath", }); + new java.lang.String[] { "TransactionActorPath", "TransactionId", }); internal_static_org_opendaylight_controller_mdsal_ReadyTransaction_descriptor = getDescriptor().getMessageTypes().get(4); internal_static_org_opendaylight_controller_mdsal_ReadyTransaction_fieldAccessorTable = new @@ -5193,13 +6675,25 @@ public final class ShardTransactionMessages { com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_org_opendaylight_controller_mdsal_WriteDataReply_descriptor, new java.lang.String[] { }); + internal_static_org_opendaylight_controller_mdsal_MergeData_descriptor = + getDescriptor().getMessageTypes().get(12); + internal_static_org_opendaylight_controller_mdsal_MergeData_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_MergeData_descriptor, + new java.lang.String[] { "InstanceIdentifierPathArguments", "NormalizedNode", }); + internal_static_org_opendaylight_controller_mdsal_MergeDataReply_descriptor = + getDescriptor().getMessageTypes().get(13); + internal_static_org_opendaylight_controller_mdsal_MergeDataReply_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_MergeDataReply_descriptor, + new java.lang.String[] { }); return null; } }; com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] { - org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage.getDescriptor(), + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.getDescriptor(), }, assigner); } diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/Cohort.proto b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/Cohort.proto new file mode 100644 index 0000000000..dab64131e6 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/Cohort.proto @@ -0,0 +1,37 @@ +package org.opendaylight.controller.mdsal; + +option java_package = "org.opendaylight.controller.protobuff.messages.cohort3pc"; +option java_outer_classname = "ThreePhaseCommitCohortMessages"; + + +message CanCommitTransaction{ + +} + +message CanCommitTransactionReply{ + required bool canCommit = 1; + +} + +message AbortTransaction{ + +} + +message AbortTransactionReply { + +} + +message CommitTransaction{ + +} + +message CommitTransactionReply{ + +} + +message PreCommitTransaction{ + +} +message PreCommitTransactionReply{ + +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/Common.proto b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/Common.proto new file mode 100644 index 0000000000..59d78dd04d --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/Common.proto @@ -0,0 +1,52 @@ +package org.opendaylight.controller.mdsal; + +option java_package = "org.opendaylight.controller.protobuff.messages.common"; +option java_outer_classname = "NormalizedNodeMessages"; + + +message Attribute{ + required string name =1; + optional string value=2; + optional string type=3; +} + +message QName { + required string value=1; +} + +message PathArgument { + required string value=1; + optional string type=2; //NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates + optional QName nodeType=3; + repeated Attribute attributes=4; + +} + +message InstanceIdentifier { + repeated PathArgument arguments=1; +} + +message Node{ + optional string path = 1; + optional string type = 2; + repeated Attribute attributes = 3; + repeated Node child=4; + optional string value = 5; + optional string valueType = 6; + repeated string bitsValue = 7; + optional InstanceIdentifier instanceIdentifierValue = 8; +} + +message Container{ + required string parentPath =1 ; + optional Node normalizedNode=2; +} + +message NodeMapEntry{ + required InstanceIdentifier instanceIdentifierPath =1; + optional Node normalizedNode=2; +} + +message NodeMap{ +repeated NodeMapEntry mapEntries=1; +} diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/CompositeModificationPayload.proto b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/CompositeModificationPayload.proto new file mode 100644 index 0000000000..b571cd25c5 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/CompositeModificationPayload.proto @@ -0,0 +1,11 @@ +package org.opendaylight.controller.mdsal; + +import "AppendEntriesMessages.proto"; +import "Common.proto"; +import "Persistent.proto"; + +extend org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload { + optional CompositeModification modification=2; +} + + diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/DataChangeListener.proto b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/DataChangeListener.proto index f50c36f684..e4ba800730 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/DataChangeListener.proto +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/DataChangeListener.proto @@ -1,14 +1,19 @@ package org.opendaylight.controller.mdsal; -import "SimpleNormalizedNode.proto"; +import "Common.proto"; option java_package = "org.opendaylight.controller.protobuff.messages.datachange.notification"; option java_outer_classname = "DataChangeListenerMessages"; -message DataChanged{ - repeated string instanceIdentifierPathArguments =1 ; - required NormalizedNodeXml normalizedNodeXml = 2; +message DataChanged { + optional Node originalSubTree = 1; + optional Node updatedSubTree = 2; + optional NodeMap originalData =3; + optional NodeMap updatedData =4; + optional NodeMap createdData =5; + repeated InstanceIdentifier removedPaths =6; } + message DataChangedReply{ -} \ No newline at end of file +} diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ListenerRegistration.proto b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ListenerRegistration.proto index 27f3c232e7..3342a1364a 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ListenerRegistration.proto +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ListenerRegistration.proto @@ -1,13 +1,40 @@ package org.opendaylight.controller.mdsal; +import "Common.proto"; + option java_package = "org.opendaylight.controller.protobuff.messages.registration"; option java_outer_classname = "ListenerRegistrationMessages"; -message Close { +/** used when a listener needs to be unregistered*/ +message CloseDataChangeListenerRegistration { + +} +/** reply to the CloseDataChangeListenerRegistration request*/ +message CloseDataChangeListenerRegistrationReply{ } -message CloseReply{ +/** + * When registering a listener at particular level of tree + * identified by instanceIdentifierPath. + * dataChangeListenerActorPath is path to actor that will + * receive the change event + * scope is the data change scope like BASE,ONE and SUBTREE + * defined in AsyncDataBroker.DataChangeScope + */ + +message RegisterChangeListener{ +required InstanceIdentifier instanceIdentifierPath=1; +required string dataChangeListenerActorPath=2; +required int32 dataChangeScope=3; +} +/** +* This is the reply for the RegisterChangeListener message +* It contains the listenerRegistration actor path +* that can be used to unregister the listener +*/ +message RegisterChangeListenerReply{ +required string listenerRegistrationPath=1; } diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/Persistent.proto b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/Persistent.proto new file mode 100644 index 0000000000..8e834494cb --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/Persistent.proto @@ -0,0 +1,20 @@ +package org.opendaylight.controller.mdsal; + +import "Common.proto"; +import "AppendEntriesMessages.proto"; + +option java_package = "org.opendaylight.controller.protobuff.messages.persistent"; +option java_outer_classname = "PersistentMessages"; + + +message Modification { + required string type=1; + required InstanceIdentifier path=2; + optional Node data=3; +} + + +message CompositeModification { + repeated Modification modification=1; +} + diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ShardManager.proto b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ShardManager.proto index c86fde0c72..abd6fcc109 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ShardManager.proto +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ShardManager.proto @@ -8,7 +8,9 @@ message FindPrimary { } message PrimaryFound { + required string primaryPath =1; } message PrimaryNotFound { + required string shardName =1; } diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ShardTransaction.proto b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ShardTransaction.proto index 120913eb66..9684b7d72f 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ShardTransaction.proto +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ShardTransaction.proto @@ -1,5 +1,7 @@ package org.opendaylight.controller.mdsal; -import "SimpleNormalizedNode.proto"; + +import "Common.proto"; + option java_package = "org.opendaylight.controller.protobuff.messages.transaction"; option java_outer_classname = "ShardTransactionMessages"; @@ -11,11 +13,12 @@ message CloseTransactionReply{ } message CreateTransaction{ - + required string transactionId = 1; } message CreateTransactionReply{ -required string transactionPath = 1; +required string transactionActorPath = 1; +required string transactionId = 2; } @@ -28,26 +31,36 @@ required string actorPath = 1; } message DeleteData { -repeated string instanceIdentifierPathArguments = 1; +required InstanceIdentifier instanceIdentifierPathArguments = 1; } message DeleteDataReply{ } message ReadData { -required string instanceIdentifierPathArguments=1; +required InstanceIdentifier instanceIdentifierPathArguments=1; } message ReadDataReply{ - required NormalizedNodeXml normalizedNode=1; + optional Node normalizedNode=1; } message WriteData { - repeated string instanceIdentifierPathArguments = 1; -required NormalizedNodeXml normalizedNode =2; + required InstanceIdentifier instanceIdentifierPathArguments = 1; +required Node normalizedNode =2; } message WriteDataReply{ -} \ No newline at end of file +} + +message MergeData { + required InstanceIdentifier instanceIdentifierPathArguments = 1; +required Node normalizedNode =2; + +} + +message MergeDataReply{ + +} 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-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodecTest.java new file mode 100644 index 0000000000..4ccbc97f35 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodecTest.java @@ -0,0 +1,158 @@ +/* + * 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.node; + +import junit.framework.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.controller.cluster.datastore.node.utils.NodeIdentifierFactory; +import org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeGetter; +import org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeNavigator; +import org.opendaylight.controller.cluster.datastore.util.TestModel; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container; +import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node; +import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; + +import java.util.ArrayList; +import java.util.List; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; + +public class NormalizedNodeToNodeCodecTest { + + + + private SchemaContext schemaContext; + + @Before + public void setUp(){ + schemaContext = TestModel.createTestContext(); + assertNotNull("Schema context must not be null.", schemaContext); + } + + private YangInstanceIdentifier instanceIdentifierFromString(String s){ + + String[] ids = s.split("/"); + + List pathArguments = new ArrayList<>(); + for(String nodeId : ids){ + if(!"".equals(nodeId)) { + pathArguments.add(NodeIdentifierFactory.getArgument(nodeId)); + } + } + final YangInstanceIdentifier instanceIdentifier = YangInstanceIdentifier.create(pathArguments); + return instanceIdentifier; + } + + + @Test + public void testNormalizeNodeAttributesToProtoBuffNode(){ + final NormalizedNode documentOne = TestModel.createTestContainer(); + String id = "/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test" + + "/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)outer-list" + + "/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)outer-list[{(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)id=2}]" + + "/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)id"; + + NormalizedNodeGetter normalizedNodeGetter = new NormalizedNodeGetter(id); + new NormalizedNodeNavigator(normalizedNodeGetter).navigate( + YangInstanceIdentifier.builder().build().toString(), documentOne); + + // Validate the value of id can be retrieved from the normalized node + NormalizedNode output = normalizedNodeGetter.getOutput(); + assertNotNull(output); + + + NormalizedNodeToNodeCodec codec = new NormalizedNodeToNodeCodec(schemaContext); + Container container = codec.encode(instanceIdentifierFromString(id),output); + + assertNotNull(container); + assertEquals(id, container.getParentPath()+"/"+container.getNormalizedNode().getPath()) ; + + // Decode the normalized node from the ProtocolBuffer form + //first get the node representation of normalized node + final Node node = container.getNormalizedNode(); + + NormalizedNode normalizedNode = codec.decode(instanceIdentifierFromString(id),node); + + assertEquals(normalizedNode.getValue().toString(),output.getValue().toString()); + } + + @Test + public void testThatANormalizedNodeToProtoBuffNodeEncodeDecode() throws Exception { + final NormalizedNode documentOne = TestModel.createTestContainer(); + + final NormalizedNodeToNodeCodec normalizedNodeToNodeCodec = new NormalizedNodeToNodeCodec(schemaContext); + + Container container = normalizedNodeToNodeCodec.encode(YangInstanceIdentifier.builder().build(), documentOne); + + + final NormalizedNode decode = normalizedNodeToNodeCodec.decode(instanceIdentifierFromString("/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test"),container.getNormalizedNode()); + assertNotNull(decode != null); + + //let us ensure that the return decode normalized node encode returns same container + Container containerResult = normalizedNodeToNodeCodec.encode(YangInstanceIdentifier.builder().build(), decode); + + assertEquals(container.getParentPath(),containerResult.getParentPath()); + assertEquals(container.getNormalizedNode().getChildCount(),container.getNormalizedNode().getChildCount()); + + Assert.assertEquals(containerResult.getNormalizedNode().getChildCount(),container.getNormalizedNode().getChildCount()); + + //check first level children are proper + ListchildrenResult = containerResult.getNormalizedNode().getChildList(); + ListchildrenOriginal = container.getNormalizedNode().getChildList(); + + System.out.println("-------------------------------------------------"); + + System.out.println(childrenOriginal.toString()); + + System.out.println("-------------------------------------------------"); + + System.out.println(childrenResult.toString()); + + boolean bFound; + for(Node resultChild: childrenResult){ + bFound = false; + for(Node originalChild:childrenOriginal){ + if(originalChild.getPath().equals(resultChild.getPath()) + && resultChild.getType().equals(resultChild.getType())){ + bFound=true; + break; + } + } + Assert.assertTrue(bFound); + } + + } + + @Test + public void addAugmentations(){ + String stringId = "/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test" + + "/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)augmented-list" + + "/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)augmented-list[{(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)id=1}]"; + + YangInstanceIdentifier identifier = instanceIdentifierFromString(stringId); + + MapEntryNode uno = TestModel.createAugmentedListEntry(1, "Uno"); + + NormalizedNodeToNodeCodec codec = + new NormalizedNodeToNodeCodec(schemaContext); + + Container encode = codec + .encode(identifier, uno); + + System.out.println(encode.getNormalizedNode()); + + codec.decode(identifier, encode.getNormalizedNode()); + } + +} 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-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierFactoryTest.java new file mode 100644 index 0000000000..4b0bde83e0 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierFactoryTest.java @@ -0,0 +1,20 @@ +package org.opendaylight.controller.cluster.datastore.node.utils; + +import junit.framework.Assert; +import org.junit.Test; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; + +public class NodeIdentifierFactoryTest { + + @Test + public void validateAugmentationIdentifier(){ + YangInstanceIdentifier.PathArgument argument = NodeIdentifierFactory + .getArgument( + "AugmentationIdentifier{childNames=[(urn:opendaylight:flow:table:statistics?revision=2013-12-15)flow-table-statistics]}"); + + Assert.assertTrue(argument instanceof YangInstanceIdentifier.AugmentationIdentifier); + + + } + +} 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-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtilsTest.java new file mode 100644 index 0000000000..bb246fb1e4 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtilsTest.java @@ -0,0 +1,141 @@ +package org.opendaylight.controller.cluster.datastore.util; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; + +public class InstanceIdentifierUtilsTest { + + private static QName TEST_QNAME = QName.create("(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test"); + private static QName NODE_WITH_VALUE_QNAME = QName.create("(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)value"); + private static QName NODE_WITH_PREDICATES_QNAME = QName.create("(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)pred"); + private static QName NAME_QNAME = QName.create("(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)name"); + + @Test + public void testSerializationOfNodeIdentifier(){ + YangInstanceIdentifier.PathArgument p1 = + new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME); + + List arguments = new ArrayList<>(); + + arguments.add(p1); + + YangInstanceIdentifier expected = YangInstanceIdentifier.create(arguments); + + NormalizedNodeMessages.InstanceIdentifier instanceIdentifier = + InstanceIdentifierUtils.toSerializable(expected); + + YangInstanceIdentifier actual = + InstanceIdentifierUtils.fromSerializable(instanceIdentifier); + + + Assert.assertEquals(expected.getLastPathArgument(), + actual.getLastPathArgument()); + + + } + + @Test + public void testSerializationOfNodeWithValue(){ + + withValue((short) 1); + withValue((long) 2); + withValue(3); + withValue(true); + + } + + private void withValue(Object value){ + YangInstanceIdentifier.PathArgument p1 = + new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME); + + YangInstanceIdentifier.PathArgument p2 = + new YangInstanceIdentifier.NodeWithValue(NODE_WITH_VALUE_QNAME, value); + + + List arguments = new ArrayList<>(); + + arguments.add(p1); + arguments.add(p2); + + YangInstanceIdentifier expected = YangInstanceIdentifier.create(arguments); + + NormalizedNodeMessages.InstanceIdentifier instanceIdentifier = + InstanceIdentifierUtils.toSerializable(expected); + + YangInstanceIdentifier actual = + InstanceIdentifierUtils.fromSerializable(instanceIdentifier); + + + Assert.assertEquals(expected.getLastPathArgument(), + actual.getLastPathArgument()); + } + + + @Test + public void testSerializationOfNodeIdentifierWithPredicates(){ + + withPredicates((short) 1); + withPredicates((long) 2); + withPredicates(3); + withPredicates(true); + + } + + private void withPredicates(Object value){ + YangInstanceIdentifier.PathArgument p1 = + new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME); + + YangInstanceIdentifier.PathArgument p2 = + new YangInstanceIdentifier.NodeIdentifierWithPredicates(NODE_WITH_PREDICATES_QNAME, NAME_QNAME, value); + + + List arguments = new ArrayList<>(); + + arguments.add(p1); + arguments.add(p2); + + YangInstanceIdentifier expected = YangInstanceIdentifier.create(arguments); + + NormalizedNodeMessages.InstanceIdentifier instanceIdentifier = + InstanceIdentifierUtils.toSerializable(expected); + + YangInstanceIdentifier actual = + InstanceIdentifierUtils.fromSerializable(instanceIdentifier); + + + Assert.assertEquals(expected.getLastPathArgument(), + actual.getLastPathArgument()); + } + + @Test + public void testAugmentationIdentifier(){ + YangInstanceIdentifier.PathArgument p1 = + new YangInstanceIdentifier.AugmentationIdentifier(new HashSet(Arrays.asList(TEST_QNAME))); + + List arguments = new ArrayList<>(); + + arguments.add(p1); + + YangInstanceIdentifier expected = YangInstanceIdentifier.create(arguments); + + NormalizedNodeMessages.InstanceIdentifier instanceIdentifier = + InstanceIdentifierUtils.toSerializable(expected); + + YangInstanceIdentifier actual = + InstanceIdentifierUtils.fromSerializable(instanceIdentifier); + + + Assert.assertEquals(expected.getLastPathArgument(), + actual.getLastPathArgument()); + + } + +} 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-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/NormalizedNodeXmlConverterTest.java index 8d609823a7..fb28704952 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/NormalizedNodeXmlConverterTest.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/NormalizedNodeXmlConverterTest.java @@ -7,37 +7,16 @@ */ package org.opendaylight.controller.cluster.datastore.util; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.StringWriter; -import java.net.URI; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.TransformerFactoryConfigurationError; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - +import com.google.common.base.Preconditions; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; import org.custommonkey.xmlunit.Diff; import org.custommonkey.xmlunit.XMLUnit; import org.junit.Test; import org.opendaylight.controller.protobuff.messages.common.SimpleNormalizedNodeMessage; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; @@ -65,10 +44,30 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.SAXException; -import com.google.common.base.Preconditions; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.TransformerFactoryConfigurationError; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.StringWriter; +import java.net.URI; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Set; /** @@ -81,423 +80,403 @@ import com.google.common.collect.Sets; public class NormalizedNodeXmlConverterTest { - private static final Logger logger = LoggerFactory - .getLogger(NormalizedNodeXmlConverterTest.class); - public static final String NAMESPACE = - "urn:opendaylight:params:xml:ns:yang:controller:test"; - private static Date revision; - private ContainerNode expectedNode; - private ContainerSchemaNode containerNode; - private String xmlPath; - - static { - try { - revision = new SimpleDateFormat("yyyy-MM-dd").parse("2014-03-13"); - } catch (ParseException e) { - throw new RuntimeException(e); - } - } - - public static DataSchemaNode getSchemaNode(final SchemaContext context, - final String moduleName, final String childNodeName) { - for (Module module : context.getModules()) { - if (module.getName().equals(moduleName)) { - DataSchemaNode found = - findChildNode(module.getChildNodes(), childNodeName); - Preconditions.checkState(found != null, "Unable to find %s", - childNodeName); - return found; - } + private static final Logger logger = LoggerFactory + .getLogger(NormalizedNodeXmlConverterTest.class); + public static final String NAMESPACE = + "urn:opendaylight:params:xml:ns:yang:controller:test"; + private static Date revision; + private ContainerNode expectedNode; + private ContainerSchemaNode containerNode; + private String xmlPath; + + static { + try { + revision = new SimpleDateFormat("yyyy-MM-dd").parse("2014-03-13"); + } catch (ParseException e) { + throw new RuntimeException(e); + } } - throw new IllegalStateException("Unable to find child node " - + childNodeName); - } - static DataSchemaNode findChildNode(final Iterable children, final String name) { - List containers = Lists.newArrayList(); + public static DataSchemaNode getSchemaNode(final SchemaContext context, + final String moduleName, final String childNodeName) { + for (Module module : context.getModules()) { + if (module.getName().equals(moduleName)) { + DataSchemaNode found = + findChildNode(module.getChildNodes(), childNodeName); + Preconditions.checkState(found != null, "Unable to find %s", + childNodeName); + return found; + } + } + throw new IllegalStateException("Unable to find child node " + + childNodeName); + } - for (DataSchemaNode dataSchemaNode : children) { - if (dataSchemaNode.getQName().getLocalName().equals(name)) { - return dataSchemaNode; + static DataSchemaNode findChildNode(final Collection children, final String name) { + List containers = Lists.newArrayList(); + + for (DataSchemaNode dataSchemaNode : children) { + if (dataSchemaNode.getQName().getLocalName().equals(name)) { + return dataSchemaNode; + } + if (dataSchemaNode instanceof DataNodeContainer) { + containers.add((DataNodeContainer) dataSchemaNode); + } else if (dataSchemaNode instanceof ChoiceNode) { + containers.addAll(((ChoiceNode) dataSchemaNode).getCases()); + } + } + + for (DataNodeContainer container : containers) { + DataSchemaNode retVal = findChildNode(container.getChildNodes(), name); + if (retVal != null) { + return retVal; + } + } + + return null; } - if (dataSchemaNode instanceof DataNodeContainer) { - containers.add((DataNodeContainer) dataSchemaNode); - } else if (dataSchemaNode instanceof ChoiceNode) { - containers.addAll(((ChoiceNode) dataSchemaNode).getCases()); - } + + public static YangInstanceIdentifier.NodeIdentifier getNodeIdentifier( + final String localName) { + return new YangInstanceIdentifier.NodeIdentifier(QName.create( + URI.create(NAMESPACE), revision, localName)); } - for (DataNodeContainer container : containers) { - DataSchemaNode retVal = findChildNode(container.getChildNodes(), name); - if (retVal != null) { - return retVal; - } + public static YangInstanceIdentifier.AugmentationIdentifier getAugmentIdentifier( + final String... childNames) { + Set qn = Sets.newHashSet(); + + for (String childName : childNames) { + qn.add(getNodeIdentifier(childName).getNodeType()); + } + + return new YangInstanceIdentifier.AugmentationIdentifier(qn); } - return null; - } - private static InstanceIdentifier.NodeIdentifier getNodeIdentifier( - final String localName) { - return new InstanceIdentifier.NodeIdentifier(QName.create( - URI.create(NAMESPACE), revision, localName)); - } + public static ContainerNode augmentChoiceExpectedNode() { + + DataContainerNodeBuilder b = + Builders.containerBuilder(); + b.withNodeIdentifier(getNodeIdentifier("container")); + + b.withChild(Builders + .choiceBuilder() + .withNodeIdentifier(getNodeIdentifier("ch2")) + .withChild( + Builders.leafBuilder() + .withNodeIdentifier(getNodeIdentifier("c2Leaf")).withValue("2") + .build()) + .withChild( + Builders + .choiceBuilder() + .withNodeIdentifier(getNodeIdentifier("c2DeepChoice")) + .withChild( + Builders + .leafBuilder() + .withNodeIdentifier( + getNodeIdentifier("c2DeepChoiceCase1Leaf2")) + .withValue("2").build()).build()).build()); + + b.withChild(Builders + .choiceBuilder() + .withNodeIdentifier(getNodeIdentifier("ch3")) + .withChild( + Builders.leafBuilder() + .withNodeIdentifier(getNodeIdentifier("c3Leaf")).withValue("3") + .build()).build()); + + b.withChild(Builders + .augmentationBuilder() + .withNodeIdentifier(getAugmentIdentifier("augLeaf")) + .withChild( + Builders.leafBuilder() + .withNodeIdentifier(getNodeIdentifier("augLeaf")) + .withValue("augment").build()).build()); + + b.withChild(Builders + .augmentationBuilder() + .withNodeIdentifier(getAugmentIdentifier("ch")) + .withChild( + Builders + .choiceBuilder() + .withNodeIdentifier(getNodeIdentifier("ch")) + .withChild( + Builders.leafBuilder() + .withNodeIdentifier(getNodeIdentifier("c1Leaf")) + .withValue("1").build()) + .withChild( + Builders + .augmentationBuilder() + .withNodeIdentifier( + getAugmentIdentifier("c1Leaf_AnotherAugment", + "deepChoice")) + .withChild( + Builders + .leafBuilder() + .withNodeIdentifier( + getNodeIdentifier("c1Leaf_AnotherAugment")) + .withValue("1").build()) + .withChild( + Builders + .choiceBuilder() + .withNodeIdentifier( + getNodeIdentifier("deepChoice")) + .withChild( + Builders + .leafBuilder() + .withNodeIdentifier( + getNodeIdentifier("deepLeafc1")) + .withValue("1").build()).build()) + .build()).build()).build()); + + return b.build(); + } - public static InstanceIdentifier.AugmentationIdentifier getAugmentIdentifier( - final String... childNames) { - Set qn = Sets.newHashSet(); - for (String childName : childNames) { - qn.add(getNodeIdentifier(childName).getNodeType()); + + public void init(final String yangPath, final String xmlPath, final ContainerNode expectedNode) + throws Exception { + SchemaContext schema = parseTestSchema(yangPath); + this.xmlPath = xmlPath; + this.containerNode = + (ContainerSchemaNode) getSchemaNode(schema, "test", "container"); + this.expectedNode = expectedNode; } - return new InstanceIdentifier.AugmentationIdentifier(qn); - } - - - private static ContainerNode augmentChoiceExpectedNode() { - - DataContainerNodeBuilder b = - Builders.containerBuilder(); - b.withNodeIdentifier(getNodeIdentifier("container")); - - b.withChild(Builders - .choiceBuilder() - .withNodeIdentifier(getNodeIdentifier("ch2")) - .withChild( - Builders.leafBuilder() - .withNodeIdentifier(getNodeIdentifier("c2Leaf")).withValue("2") - .build()) - .withChild( - Builders - .choiceBuilder() - .withNodeIdentifier(getNodeIdentifier("c2DeepChoice")) - .withChild( - Builders - .leafBuilder() - .withNodeIdentifier( - getNodeIdentifier("c2DeepChoiceCase1Leaf2")) - .withValue("2").build()).build()).build()); - - b.withChild(Builders - .choiceBuilder() - .withNodeIdentifier(getNodeIdentifier("ch3")) - .withChild( - Builders.leafBuilder() - .withNodeIdentifier(getNodeIdentifier("c3Leaf")).withValue("3") - .build()).build()); - - b.withChild(Builders - .augmentationBuilder() - .withNodeIdentifier(getAugmentIdentifier("augLeaf")) - .withChild( - Builders.leafBuilder() - .withNodeIdentifier(getNodeIdentifier("augLeaf")) - .withValue("augment").build()).build()); - - b.withChild(Builders - .augmentationBuilder() - .withNodeIdentifier(getAugmentIdentifier("ch")) - .withChild( - Builders - .choiceBuilder() - .withNodeIdentifier(getNodeIdentifier("ch")) - .withChild( - Builders.leafBuilder() - .withNodeIdentifier(getNodeIdentifier("c1Leaf")) - .withValue("1").build()) - .withChild( - Builders - .augmentationBuilder() - .withNodeIdentifier( - getAugmentIdentifier("c1Leaf_AnotherAugment", - "deepChoice")) - .withChild( - Builders - .leafBuilder() - .withNodeIdentifier( - getNodeIdentifier("c1Leaf_AnotherAugment")) - .withValue("1").build()) - .withChild( - Builders - .choiceBuilder() - .withNodeIdentifier( - getNodeIdentifier("deepChoice")) - .withChild( - Builders - .leafBuilder() - .withNodeIdentifier( - getNodeIdentifier("deepLeafc1")) - .withValue("1").build()).build()) - .build()).build()).build()); - - return b.build(); - } - - - - public void init(final String yangPath, final String xmlPath, final ContainerNode expectedNode) - throws Exception { - SchemaContext schema = parseTestSchema(yangPath); - this.xmlPath = xmlPath; - this.containerNode = - (ContainerSchemaNode) getSchemaNode(schema, "test", "container"); - this.expectedNode = expectedNode; - } - - SchemaContext parseTestSchema(final String yangPath) throws Exception { - - YangParserImpl yangParserImpl = new YangParserImpl(); - InputStream stream = - NormalizedNodeXmlConverterTest.class.getResourceAsStream(yangPath); - ArrayList al = new ArrayList(); - al.add(stream); - Set modules = yangParserImpl.parseYangModelsFromStreams(al); - return yangParserImpl.resolveSchemaContext(modules); - - } - - - @Test - public void testConversionWithAugmentChoice() throws Exception { - init("/augment_choice.yang", "/augment_choice.xml", - augmentChoiceExpectedNode()); - Document doc = loadDocument(xmlPath); - - ContainerNode built = - DomToNormalizedNodeParserFactory - .getInstance(DomUtils.defaultValueCodecProvider()) - .getContainerNodeParser() - .parse(Collections.singletonList(doc.getDocumentElement()), - containerNode); - - if (expectedNode != null) { - junit.framework.Assert.assertEquals(expectedNode, built); + SchemaContext parseTestSchema(final String yangPath) throws Exception { + + YangParserImpl yangParserImpl = new YangParserImpl(); + InputStream stream = + NormalizedNodeXmlConverterTest.class.getResourceAsStream(yangPath); + ArrayList al = new ArrayList(); + al.add(stream); + Set modules = yangParserImpl.parseYangModelsFromStreams(al); + return yangParserImpl.resolveSchemaContext(modules); + } - logger.info("{}", built); - Iterable els = - DomFromNormalizedNodeSerializerFactory - .getInstance(XmlDocumentUtils.getDocument(), - DomUtils.defaultValueCodecProvider()) - .getContainerNodeSerializer().serialize(containerNode, built); + @Test + public void testConversionWithAugmentChoice() throws Exception { + init("/augment_choice.yang", "/augment_choice.xml", + augmentChoiceExpectedNode()); + Document doc = loadDocument(xmlPath); - Element el = els.iterator().next(); + ContainerNode built = + DomToNormalizedNodeParserFactory + .getInstance(DomUtils.defaultValueCodecProvider()) + .getContainerNodeParser() + .parse(Collections.singletonList(doc.getDocumentElement()), + containerNode); - XMLUnit.setIgnoreWhitespace(true); - XMLUnit.setIgnoreComments(true); + if (expectedNode != null) { + junit.framework.Assert.assertEquals(expectedNode, built); + } - System.out.println(toString(doc.getDocumentElement())); - System.out.println(toString(el)); + logger.info("{}", built); - new Diff( - XMLUnit.buildControlDocument(toString(doc.getDocumentElement())), - XMLUnit.buildTestDocument(toString(el))).similar(); - } + Iterable els = + DomFromNormalizedNodeSerializerFactory + .getInstance(XmlDocumentUtils.getDocument(), + DomUtils.defaultValueCodecProvider()) + .getContainerNodeSerializer().serialize(containerNode, built); - private static ContainerNode listLeafListWithAttributes() { - DataContainerNodeBuilder b = - Builders.containerBuilder(); - b.withNodeIdentifier(getNodeIdentifier("container")); + Element el = els.iterator().next(); - CollectionNodeBuilder listBuilder = - Builders.mapBuilder().withNodeIdentifier(getNodeIdentifier("list")); + XMLUnit.setIgnoreWhitespace(true); + XMLUnit.setIgnoreComments(true); - Map predicates = Maps.newHashMap(); - predicates.put(getNodeIdentifier("uint32InList").getNodeType(), 3L); + System.out.println(toString(doc.getDocumentElement())); + System.out.println(toString(el)); - DataContainerNodeBuilder list1Builder = - Builders.mapEntryBuilder().withNodeIdentifier( - new InstanceIdentifier.NodeIdentifierWithPredicates( - getNodeIdentifier("list").getNodeType(), predicates)); - NormalizedNodeBuilder> uint32InListBuilder = - Builders.leafBuilder().withNodeIdentifier( - getNodeIdentifier("uint32InList")); + new Diff( + XMLUnit.buildControlDocument(toString(doc.getDocumentElement())), + XMLUnit.buildTestDocument(toString(el))).similar(); + } - list1Builder.withChild(uint32InListBuilder.withValue(3L).build()); + private static ContainerNode listLeafListWithAttributes() { + DataContainerNodeBuilder b = + Builders.containerBuilder(); + b.withNodeIdentifier(getNodeIdentifier("container")); - listBuilder.withChild(list1Builder.build()); - b.withChild(listBuilder.build()); + CollectionNodeBuilder listBuilder = + Builders.mapBuilder().withNodeIdentifier(getNodeIdentifier("list")); - NormalizedNodeBuilder> booleanBuilder = - Builders.leafBuilder().withNodeIdentifier(getNodeIdentifier("boolean")); - booleanBuilder.withValue(false); - b.withChild(booleanBuilder.build()); + Map predicates = Maps.newHashMap(); + predicates.put(getNodeIdentifier("uint32InList").getNodeType(), 3L); - ListNodeBuilder> leafListBuilder = - Builders.leafSetBuilder().withNodeIdentifier( - getNodeIdentifier("leafList")); + DataContainerNodeBuilder list1Builder = + Builders.mapEntryBuilder().withNodeIdentifier( + new YangInstanceIdentifier.NodeIdentifierWithPredicates( + getNodeIdentifier("list").getNodeType(), predicates)); + NormalizedNodeBuilder> uint32InListBuilder = + Builders.leafBuilder().withNodeIdentifier( + getNodeIdentifier("uint32InList")); - NormalizedNodeBuilder> leafList1Builder = - Builders.leafSetEntryBuilder().withNodeIdentifier( - new InstanceIdentifier.NodeWithValue(getNodeIdentifier("leafList") - .getNodeType(), "a")); + list1Builder.withChild(uint32InListBuilder.withValue(3L).build()); - leafList1Builder.withValue("a"); + listBuilder.withChild(list1Builder.build()); + b.withChild(listBuilder.build()); - leafListBuilder.withChild(leafList1Builder.build()); - b.withChild(leafListBuilder.build()); + NormalizedNodeBuilder> booleanBuilder = + Builders.leafBuilder().withNodeIdentifier(getNodeIdentifier("boolean")); + booleanBuilder.withValue(false); + b.withChild(booleanBuilder.build()); - return b.build(); - } + ListNodeBuilder> leafListBuilder = + Builders.leafSetBuilder().withNodeIdentifier( + getNodeIdentifier("leafList")); + NormalizedNodeBuilder> leafList1Builder = + Builders.leafSetEntryBuilder().withNodeIdentifier( + new YangInstanceIdentifier.NodeWithValue(getNodeIdentifier("leafList") + .getNodeType(), "a")); - @Test - public void testConversionWithAttributes() throws Exception { - init("/test.yang", "/simple_xml_with_attributes.xml", - listLeafListWithAttributes()); - Document doc = loadDocument(xmlPath); + leafList1Builder.withValue("a"); - ContainerNode built = - DomToNormalizedNodeParserFactory - .getInstance(DomUtils.defaultValueCodecProvider()) - .getContainerNodeParser() - .parse(Collections.singletonList(doc.getDocumentElement()), - containerNode); + leafListBuilder.withChild(leafList1Builder.build()); + b.withChild(leafListBuilder.build()); - if (expectedNode != null) { - junit.framework.Assert.assertEquals(expectedNode, built); + return b.build(); } - logger.info("{}", built); - Iterable els = - DomFromNormalizedNodeSerializerFactory - .getInstance(XmlDocumentUtils.getDocument(), - DomUtils.defaultValueCodecProvider()) - .getContainerNodeSerializer().serialize(containerNode, built); + @Test + public void testConversionWithAttributes() throws Exception { + init("/test.yang", "/simple_xml_with_attributes.xml", + listLeafListWithAttributes()); + Document doc = loadDocument(xmlPath); + + ContainerNode built = + DomToNormalizedNodeParserFactory + .getInstance(DomUtils.defaultValueCodecProvider()) + .getContainerNodeParser() + .parse(Collections.singletonList(doc.getDocumentElement()), + containerNode); - Element el = els.iterator().next(); + if (expectedNode != null) { + junit.framework.Assert.assertEquals(expectedNode, built); + } - XMLUnit.setIgnoreWhitespace(true); - XMLUnit.setIgnoreComments(true); + logger.info("{}", built); - System.out.println(toString(doc.getDocumentElement())); - System.out.println(toString(el)); + Iterable els = + DomFromNormalizedNodeSerializerFactory + .getInstance(XmlDocumentUtils.getDocument(), + DomUtils.defaultValueCodecProvider()) + .getContainerNodeSerializer().serialize(containerNode, built); - new Diff( - XMLUnit.buildControlDocument(toString(doc.getDocumentElement())), - XMLUnit.buildTestDocument(toString(el))).similar(); - } + Element el = els.iterator().next(); + XMLUnit.setIgnoreWhitespace(true); + XMLUnit.setIgnoreComments(true); - private Document loadDocument(final String xmlPath) throws Exception { - InputStream resourceAsStream = - NormalizedNodeXmlConverterTest.class.getResourceAsStream(xmlPath); + System.out.println(toString(doc.getDocumentElement())); + System.out.println(toString(el)); - Document currentConfigElement = readXmlToDocument(resourceAsStream); - Preconditions.checkNotNull(currentConfigElement); - return currentConfigElement; - } + new Diff( + XMLUnit.buildControlDocument(toString(doc.getDocumentElement())), + XMLUnit.buildTestDocument(toString(el))).similar(); + } - private static final DocumentBuilderFactory BUILDERFACTORY; - static { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setNamespaceAware(true); - factory.setCoalescing(true); - factory.setIgnoringElementContentWhitespace(true); - factory.setIgnoringComments(true); - BUILDERFACTORY = factory; - } + private Document loadDocument(final String xmlPath) throws Exception { + InputStream resourceAsStream = + NormalizedNodeXmlConverterTest.class.getResourceAsStream(xmlPath); - private Document readXmlToDocument(final InputStream xmlContent) - throws IOException, SAXException { - DocumentBuilder dBuilder; - try { - dBuilder = BUILDERFACTORY.newDocumentBuilder(); - } catch (ParserConfigurationException e) { - throw new RuntimeException("Failed to parse XML document", e); + Document currentConfigElement = readXmlToDocument(resourceAsStream); + Preconditions.checkNotNull(currentConfigElement); + return currentConfigElement; } - Document doc = dBuilder.parse(xmlContent); - - doc.getDocumentElement().normalize(); - return doc; - } - - public static String toString(final Element xml) { - try { - Transformer transformer = - TransformerFactory.newInstance().newTransformer(); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - - StreamResult result = new StreamResult(new StringWriter()); - DOMSource source = new DOMSource(xml); - transformer.transform(source, result); - - return result.getWriter().toString(); - } catch (IllegalArgumentException | TransformerFactoryConfigurationError - | TransformerException e) { - throw new RuntimeException("Unable to serialize xml element " + xml, e); + + private static final DocumentBuilderFactory BUILDERFACTORY; + + static { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(true); + factory.setCoalescing(true); + factory.setIgnoringElementContentWhitespace(true); + factory.setIgnoringComments(true); + BUILDERFACTORY = factory; + } + + private Document readXmlToDocument(final InputStream xmlContent) + throws IOException, SAXException { + DocumentBuilder dBuilder; + try { + dBuilder = BUILDERFACTORY.newDocumentBuilder(); + } catch (ParserConfigurationException e) { + throw new RuntimeException("Failed to parse XML document", e); + } + Document doc = dBuilder.parse(xmlContent); + + doc.getDocumentElement().normalize(); + return doc; + } + + public static String toString(final Element xml) { + try { + Transformer transformer = + TransformerFactory.newInstance().newTransformer(); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + + StreamResult result = new StreamResult(new StringWriter()); + DOMSource source = new DOMSource(xml); + transformer.transform(source, result); + + return result.getWriter().toString(); + } catch (IllegalArgumentException | TransformerFactoryConfigurationError + | TransformerException e) { + throw new RuntimeException("Unable to serialize xml element " + xml, e); + } + } + + @Test + public void testConversionToNormalizedXml() throws Exception { + SimpleNormalizedNodeMessage.NormalizedNodeXml nnXml = + EncoderDecoderUtil.encode(parseTestSchema("/augment_choice.yang"), + augmentChoiceExpectedNode()); + Document expectedDoc = loadDocument("/augment_choice.xml"); + Document convertedDoc = + EncoderDecoderUtil.factory.newDocumentBuilder().parse( + new ByteArrayInputStream(nnXml.getXmlString().getBytes("utf-8"))); + System.out.println(toString(convertedDoc.getDocumentElement())); + XMLUnit.setIgnoreWhitespace(true); + XMLUnit.setIgnoreComments(true); + new Diff(XMLUnit.buildControlDocument(toString(expectedDoc + .getDocumentElement())), + XMLUnit.buildTestDocument(toString(convertedDoc + .getDocumentElement()))).similar(); + System.out.println(toString(expectedDoc.getDocumentElement())); + + } + + + @Test + public void testConversionFromXmlToNormalizedNode() throws Exception { + SimpleNormalizedNodeMessage.NormalizedNodeXml nnXml = + EncoderDecoderUtil.encode(parseTestSchema("/test.yang"), + listLeafListWithAttributes()); + Document expectedDoc = loadDocument("/simple_xml_with_attributes.xml"); + Document convertedDoc = + EncoderDecoderUtil.factory.newDocumentBuilder().parse( + new ByteArrayInputStream(nnXml.getXmlString().getBytes("utf-8"))); + System.out.println(toString(convertedDoc.getDocumentElement())); + XMLUnit.setIgnoreWhitespace(true); + XMLUnit.setIgnoreComments(true); + new Diff(XMLUnit.buildControlDocument(toString(expectedDoc + .getDocumentElement())), + XMLUnit.buildTestDocument(toString(convertedDoc + .getDocumentElement()))).similar(); + System.out.println(toString(expectedDoc.getDocumentElement())); + + // now we will try to convert xml back to normalize node. + ContainerNode cn = + (ContainerNode) EncoderDecoderUtil.decode( + parseTestSchema("/test.yang"), nnXml); + junit.framework.Assert.assertEquals(listLeafListWithAttributes(), cn); + } - } - @Test - public void testConversionToNormalizedXml() throws Exception { - SimpleNormalizedNodeMessage.NormalizedNodeXml nnXml = - EncoderDecoderUtil.encode(parseTestSchema("/augment_choice.yang"), - augmentChoiceExpectedNode()); - Document expectedDoc = loadDocument("/augment_choice.xml"); - Document convertedDoc = - EncoderDecoderUtil.factory.newDocumentBuilder().parse( - new ByteArrayInputStream(nnXml.getXmlString().getBytes("utf-8"))); - System.out.println(toString(convertedDoc.getDocumentElement())); - XMLUnit.setIgnoreWhitespace(true); - XMLUnit.setIgnoreComments(true); - new Diff(XMLUnit.buildControlDocument(toString(expectedDoc - .getDocumentElement())), - XMLUnit.buildTestDocument(toString(convertedDoc - .getDocumentElement()))).similar(); - System.out.println(toString(expectedDoc.getDocumentElement())); - - } - - - @Test - public void testConversionFromXmlToNormalizedNode() throws Exception { - SimpleNormalizedNodeMessage.NormalizedNodeXml nnXml = - EncoderDecoderUtil.encode(parseTestSchema("/test.yang"), - listLeafListWithAttributes()); - Document expectedDoc = loadDocument("/simple_xml_with_attributes.xml"); - Document convertedDoc = - EncoderDecoderUtil.factory.newDocumentBuilder().parse( - new ByteArrayInputStream(nnXml.getXmlString().getBytes("utf-8"))); - System.out.println(toString(convertedDoc.getDocumentElement())); - XMLUnit.setIgnoreWhitespace(true); - XMLUnit.setIgnoreComments(true); - new Diff(XMLUnit.buildControlDocument(toString(expectedDoc - .getDocumentElement())), - XMLUnit.buildTestDocument(toString(convertedDoc - .getDocumentElement()))).similar(); - System.out.println(toString(expectedDoc.getDocumentElement())); - - // now we will try to convert xml back to normalize node. - ContainerNode cn = - (ContainerNode) EncoderDecoderUtil.decode( - parseTestSchema("/test.yang"), nnXml); - junit.framework.Assert.assertEquals(listLeafListWithAttributes(), cn); - - } - - @Test - public void testInMemoryTestModelProtoBuffEncoding() throws Exception { - - SimpleNormalizedNodeMessage.NormalizedNodeXml nnXml = - EncoderDecoderUtil.encode(parseTestSchema("/odl-datastore-test.yang"), - TestModel.createFamily()); - - Document convertedDoc = - EncoderDecoderUtil.factory.newDocumentBuilder().parse( - new ByteArrayInputStream(nnXml.getXmlString().getBytes("utf-8"))); - System.out.println(toString(convertedDoc.getDocumentElement())); - - // now we will try to convert xml back to normalize node. - ContainerNode cn = - (ContainerNode) EncoderDecoderUtil.decode( - parseTestSchema("/odl-datastore-test.yang"), nnXml); - junit.framework.Assert.assertEquals(TestModel.createFamily(), cn); - - - } } 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-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java index 81878ba616..bef4057aa2 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java @@ -1,7 +1,7 @@ package org.opendaylight.controller.cluster.datastore.util; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; @@ -17,6 +17,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContaine import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl; @@ -33,340 +34,453 @@ import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.ma 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 AUG_QNAME = QName.create( - "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:aug", - "2014-03-13", "name"); - - public static final QName DESC_QNAME = QName.create(TEST_QNAME, "desc"); - 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"); - public static final QName ID_QNAME = QName.create(TEST_QNAME, "id"); - public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name"); - public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value"); - private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang"; - private static final String DATASTORE_AUG_YANG = - "/odl-datastore-augmentation.yang"; - private static final String DATASTORE_TEST_NOTIFICATION_YANG = - "/odl-datastore-test-notification.yang"; - - - public static final InstanceIdentifier TEST_PATH = InstanceIdentifier - .of(TEST_QNAME); - public static final InstanceIdentifier DESC_PATH = InstanceIdentifier - .builder(TEST_PATH).node(DESC_QNAME).build(); - public static final InstanceIdentifier OUTER_LIST_PATH = InstanceIdentifier - .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"); - - private static final Integer ONE_ID = 1; - private static final Integer TWO_ID = 2; - private static final String TWO_ONE_NAME = "one"; - private static final String TWO_TWO_NAME = "two"; - private static final String DESC = "Hello there"; - - // Family specific constants - public static final QName FAMILY_QNAME = - QName - .create( - "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:notification-test", - "2014-04-15", "family"); - public static final QName CHILDREN_QNAME = QName.create(FAMILY_QNAME, - "children"); - public static final QName GRAND_CHILDREN_QNAME = QName.create(FAMILY_QNAME, - "grand-children"); - public static final QName CHILD_NUMBER_QNAME = QName.create(FAMILY_QNAME, - "child-number"); - public static final QName CHILD_NAME_QNAME = QName.create(FAMILY_QNAME, - "child-name"); - public static final QName GRAND_CHILD_NUMBER_QNAME = QName.create( - FAMILY_QNAME, "grand-child-number"); - public static final QName GRAND_CHILD_NAME_QNAME = QName.create(FAMILY_QNAME, - "grand-child-name"); - - public static final InstanceIdentifier FAMILY_PATH = InstanceIdentifier - .of(FAMILY_QNAME); - public static final InstanceIdentifier FAMILY_DESC_PATH = InstanceIdentifier - .builder(FAMILY_PATH).node(DESC_QNAME).build(); - public static final InstanceIdentifier CHILDREN_PATH = InstanceIdentifier - .builder(FAMILY_PATH).node(CHILDREN_QNAME).build(); - - private static final Integer FIRST_CHILD_ID = 1; - private static final Integer SECOND_CHILD_ID = 2; - - private static final String FIRST_CHILD_NAME = "first child"; - private static final String SECOND_CHILD_NAME = "second child"; - - private static final Integer FIRST_GRAND_CHILD_ID = 1; - private static final Integer SECOND_GRAND_CHILD_ID = 2; - - private static final String FIRST_GRAND_CHILD_NAME = "first grand child"; - private static final String SECOND_GRAND_CHILD_NAME = "second grand child"; - - // first child - private static final InstanceIdentifier CHILDREN_1_PATH = InstanceIdentifier - .builder(CHILDREN_PATH) - .nodeWithKey(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID) // - .build(); - private static final InstanceIdentifier CHILDREN_1_NAME_PATH = - InstanceIdentifier.builder(CHILDREN_PATH) - .nodeWithKey(CHILDREN_QNAME, CHILD_NAME_QNAME, FIRST_CHILD_NAME) // - .build(); - - private static final InstanceIdentifier CHILDREN_2_PATH = InstanceIdentifier - .builder(CHILDREN_PATH) - .nodeWithKey(CHILDREN_QNAME, CHILD_NUMBER_QNAME, SECOND_CHILD_ID) // - .build(); - private static final InstanceIdentifier CHILDREN_2_NAME_PATH = - InstanceIdentifier.builder(CHILDREN_PATH) - .nodeWithKey(CHILDREN_QNAME, CHILD_NAME_QNAME, SECOND_CHILD_NAME) // - .build(); - - - private static final InstanceIdentifier GRAND_CHILD_1_PATH = - InstanceIdentifier.builder(CHILDREN_1_PATH) - .node(GRAND_CHILDREN_QNAME) - // - .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, - FIRST_GRAND_CHILD_ID) // - .build(); - - private static final InstanceIdentifier GRAND_CHILD_1_NAME_PATH = - InstanceIdentifier.builder(CHILDREN_1_PATH) - .node(GRAND_CHILDREN_QNAME) - // - .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NAME_QNAME, - FIRST_GRAND_CHILD_NAME) // - .build(); - - private static final InstanceIdentifier GRAND_CHILD_2_PATH = - InstanceIdentifier.builder(CHILDREN_2_PATH) - .node(GRAND_CHILDREN_QNAME) - // - .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, - SECOND_GRAND_CHILD_ID) // - .build(); - - private static final InstanceIdentifier GRAND_CHILD_2_NAME_PATH = - InstanceIdentifier.builder(CHILDREN_2_PATH) - .node(GRAND_CHILDREN_QNAME) - // - .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NAME_QNAME, - SECOND_GRAND_CHILD_NAME) // - .build(); - - private static final InstanceIdentifier DESC_PATH_ID = InstanceIdentifier - .builder(DESC_PATH).build(); - private static final InstanceIdentifier OUTER_LIST_1_PATH = - InstanceIdentifier.builder(OUTER_LIST_PATH) - .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, ONE_ID) // - .build(); - - private static final InstanceIdentifier OUTER_LIST_2_PATH = - InstanceIdentifier.builder(OUTER_LIST_PATH) - .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, TWO_ID) // - .build(); - - private static final InstanceIdentifier TWO_TWO_PATH = InstanceIdentifier - .builder(OUTER_LIST_2_PATH).node(INNER_LIST_QNAME) // - .nodeWithKey(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME) // - .build(); - - private static final InstanceIdentifier TWO_TWO_VALUE_PATH = - InstanceIdentifier.builder(TWO_TWO_PATH).node(VALUE_QNAME) // - .build(); - - private static final MapEntryNode BAR_NODE = mapEntryBuilder( - OUTER_LIST_QNAME, ID_QNAME, TWO_ID) // - .withChild(mapNodeBuilder(INNER_LIST_QNAME) // - .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_ONE_NAME)) // - .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME)) // - .build()) // - .build(); - - public static final InputStream getDatastoreTestInputStream() { - return getInputStream(DATASTORE_TEST_YANG); - } - - public static final InputStream getDatastoreAugInputStream() { - return getInputStream(DATASTORE_AUG_YANG); - } - - public static final InputStream getDatastoreTestNotificationInputStream() { - return getInputStream(DATASTORE_TEST_NOTIFICATION_YANG); - } - - private static InputStream getInputStream(final String resourceName) { - return TestModel.class.getResourceAsStream(resourceName); - } - - public static SchemaContext createTestContext() { - List inputStreams = new ArrayList<>(); - inputStreams.add(getDatastoreTestInputStream()); - inputStreams.add(getDatastoreAugInputStream()); - inputStreams.add(getDatastoreTestNotificationInputStream()); - - YangParserImpl parser = new YangParserImpl(); - Set modules = parser.parseYangModelsFromStreams(inputStreams); - return parser.resolveSchemaContext(modules); - } - - /** - * Returns a test document - * - *
-   * test
-   *     outer-list
-   *          id 1
-   *     outer-list
-   *          id 2
-   *          inner-list
-   *                  name "one"
-   *          inner-list
-   *                  name "two"
-   *
-   * 
- * - * @return - */ - public static NormalizedNode createDocumentOne( - SchemaContext schemaContext) { - return ImmutableContainerNodeBuilder - .create() - .withNodeIdentifier( - new InstanceIdentifier.NodeIdentifier(schemaContext.getQName())) - .withChild(createTestContainer()).build(); - - } - - public static ContainerNode createTestContainer() { - - - final LeafSetEntryNode nike = - ImmutableLeafSetEntryNodeBuilder - .create() - .withNodeIdentifier( - new InstanceIdentifier.NodeWithValue(QName.create(TEST_QNAME, - "shoe"), "nike")).withValue("nike").build(); - final LeafSetEntryNode puma = - ImmutableLeafSetEntryNodeBuilder - .create() - .withNodeIdentifier( - new InstanceIdentifier.NodeWithValue(QName.create(TEST_QNAME, - "shoe"), "puma")).withValue("puma").build(); - final LeafSetNode shoes = - ImmutableLeafSetNodeBuilder - .create() - .withNodeIdentifier( - new InstanceIdentifier.NodeIdentifier(QName.create(TEST_QNAME, - "shoe"))).withChild(nike).withChild(puma).build(); + 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 AUG_NAME_QNAME = QName.create( + "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:aug", + "2014-03-13", "name"); + + public static final QName AUG_CONT_QNAME = QName.create( + "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:aug", + "2014-03-13", "cont"); + + + public static final QName DESC_QNAME = QName.create(TEST_QNAME, "desc"); + public static final QName POINTER_QNAME = + QName.create(TEST_QNAME, "pointer"); + public static final QName SOME_REF_QNAME = + QName.create(TEST_QNAME, "some-ref"); + public static final QName MYIDENTITY_QNAME = + QName.create(TEST_QNAME, "myidentity"); + public static final QName SWITCH_FEATURES_QNAME = + QName.create(TEST_QNAME, "switch-features"); + + public static final QName AUGMENTED_LIST_QNAME = + QName.create(TEST_QNAME, "augmented-list"); + + 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"); + public static final QName ID_QNAME = QName.create(TEST_QNAME, "id"); + public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name"); + public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value"); + private static final String DATASTORE_TEST_YANG = + "/odl-datastore-test.yang"; + private static final String DATASTORE_AUG_YANG = + "/odl-datastore-augmentation.yang"; + private static final String DATASTORE_TEST_NOTIFICATION_YANG = + "/odl-datastore-test-notification.yang"; + + + public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier + .of(TEST_QNAME); + public static final YangInstanceIdentifier DESC_PATH = YangInstanceIdentifier + .builder(TEST_PATH).node(DESC_QNAME).build(); + 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"); + + private static final Integer ONE_ID = 1; + private static final Integer TWO_ID = 2; + private static final String TWO_ONE_NAME = "one"; + private static final String TWO_TWO_NAME = "two"; + private static final String DESC = "Hello there"; + + // Family specific constants + public static final QName FAMILY_QNAME = + QName + .create( + "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:notification-test", + "2014-04-17", "family"); + public static final QName CHILDREN_QNAME = QName.create(FAMILY_QNAME, + "children"); + public static final QName GRAND_CHILDREN_QNAME = QName.create(FAMILY_QNAME, + "grand-children"); + public static final QName CHILD_NUMBER_QNAME = QName.create(FAMILY_QNAME, + "child-number"); + public static final QName CHILD_NAME_QNAME = QName.create(FAMILY_QNAME, + "child-name"); + public static final QName GRAND_CHILD_NUMBER_QNAME = QName.create( + FAMILY_QNAME, "grand-child-number"); + public static final QName GRAND_CHILD_NAME_QNAME = + QName.create(FAMILY_QNAME, + "grand-child-name"); + + public static final YangInstanceIdentifier FAMILY_PATH = YangInstanceIdentifier + .of(FAMILY_QNAME); + public static final YangInstanceIdentifier FAMILY_DESC_PATH = YangInstanceIdentifier + .builder(FAMILY_PATH).node(DESC_QNAME).build(); + public static final YangInstanceIdentifier CHILDREN_PATH = YangInstanceIdentifier + .builder(FAMILY_PATH).node(CHILDREN_QNAME).build(); + + private static final Integer FIRST_CHILD_ID = 1; + private static final Integer SECOND_CHILD_ID = 2; + + private static final String FIRST_CHILD_NAME = "first child"; + private static final String SECOND_CHILD_NAME = "second child"; + + private static final Integer FIRST_GRAND_CHILD_ID = 1; + private static final Integer SECOND_GRAND_CHILD_ID = 2; + + private static final String FIRST_GRAND_CHILD_NAME = "first grand child"; + private static final String SECOND_GRAND_CHILD_NAME = "second grand child"; + + // first child + private static final YangInstanceIdentifier CHILDREN_1_PATH = YangInstanceIdentifier + .builder(CHILDREN_PATH) + .nodeWithKey(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID) // + .build(); + private static final YangInstanceIdentifier CHILDREN_1_NAME_PATH = + YangInstanceIdentifier.builder(CHILDREN_PATH) + .nodeWithKey(CHILDREN_QNAME, CHILD_NAME_QNAME, FIRST_CHILD_NAME) // + .build(); + + private static final YangInstanceIdentifier CHILDREN_2_PATH = YangInstanceIdentifier + .builder(CHILDREN_PATH) + .nodeWithKey(CHILDREN_QNAME, CHILD_NUMBER_QNAME, SECOND_CHILD_ID) // + .build(); + private static final YangInstanceIdentifier CHILDREN_2_NAME_PATH = + YangInstanceIdentifier.builder(CHILDREN_PATH) + .nodeWithKey(CHILDREN_QNAME, CHILD_NAME_QNAME, SECOND_CHILD_NAME) // + .build(); - final LeafSetEntryNode five = - ImmutableLeafSetEntryNodeBuilder + private static final YangInstanceIdentifier GRAND_CHILD_1_PATH = + YangInstanceIdentifier.builder(CHILDREN_1_PATH) + .node(GRAND_CHILDREN_QNAME) + // + .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, + FIRST_GRAND_CHILD_ID) // + .build(); + + private static final YangInstanceIdentifier GRAND_CHILD_1_NAME_PATH = + YangInstanceIdentifier.builder(CHILDREN_1_PATH) + .node(GRAND_CHILDREN_QNAME) + // + .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NAME_QNAME, + FIRST_GRAND_CHILD_NAME) // + .build(); + + private static final YangInstanceIdentifier GRAND_CHILD_2_PATH = + YangInstanceIdentifier.builder(CHILDREN_2_PATH) + .node(GRAND_CHILDREN_QNAME) + // + .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, + SECOND_GRAND_CHILD_ID) // + .build(); + + private static final YangInstanceIdentifier GRAND_CHILD_2_NAME_PATH = + YangInstanceIdentifier.builder(CHILDREN_2_PATH) + .node(GRAND_CHILDREN_QNAME) + // + .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NAME_QNAME, + SECOND_GRAND_CHILD_NAME) // + .build(); + + private static final YangInstanceIdentifier DESC_PATH_ID = YangInstanceIdentifier + .builder(DESC_PATH).build(); + private static final YangInstanceIdentifier OUTER_LIST_1_PATH = + YangInstanceIdentifier.builder(OUTER_LIST_PATH) + .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, ONE_ID) // + .build(); + + private static final YangInstanceIdentifier OUTER_LIST_2_PATH = + YangInstanceIdentifier.builder(OUTER_LIST_PATH) + .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, TWO_ID) // + .build(); + + private static final YangInstanceIdentifier TWO_TWO_PATH = YangInstanceIdentifier + .builder(OUTER_LIST_2_PATH).node(INNER_LIST_QNAME) // + .nodeWithKey(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME) // + .build(); + + private static final YangInstanceIdentifier TWO_TWO_VALUE_PATH = + YangInstanceIdentifier.builder(TWO_TWO_PATH).node(VALUE_QNAME) // + .build(); + + private static final MapEntryNode BAR_NODE = mapEntryBuilder( + OUTER_LIST_QNAME, ID_QNAME, TWO_ID) // + .withChild(mapNodeBuilder(INNER_LIST_QNAME) // + .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_ONE_NAME)) // + .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME)) // + .build()) // + .build(); + + public static final InputStream getDatastoreTestInputStream() { + return getInputStream(DATASTORE_TEST_YANG); + } + + public static final InputStream getDatastoreAugInputStream() { + return getInputStream(DATASTORE_AUG_YANG); + } + + public static final InputStream getDatastoreTestNotificationInputStream() { + return getInputStream(DATASTORE_TEST_NOTIFICATION_YANG); + } + + private static InputStream getInputStream(final String resourceName) { + return TestModel.class.getResourceAsStream(resourceName); + } + + public static SchemaContext createTestContext() { + List inputStreams = new ArrayList<>(); + inputStreams.add(getDatastoreTestInputStream()); + inputStreams.add(getDatastoreAugInputStream()); + inputStreams.add(getDatastoreTestNotificationInputStream()); + + YangParserImpl parser = new YangParserImpl(); + Set modules = parser.parseYangModelsFromStreams(inputStreams); + return parser.resolveSchemaContext(modules); + } + + /** + * Returns a test document + *

+ *

+     * test
+     *     outer-list
+     *          id 1
+     *     outer-list
+     *          id 2
+     *          inner-list
+     *                  name "one"
+     *          inner-list
+     *                  name "two"
+     *
+     * 
+ * + * @return + */ + public static NormalizedNode createDocumentOne( + SchemaContext schemaContext) { + return ImmutableContainerNodeBuilder .create() .withNodeIdentifier( - (new InstanceIdentifier.NodeWithValue(QName.create(TEST_QNAME, - "number"), 5))).withValue(5).build(); - final LeafSetEntryNode fifteen = - ImmutableLeafSetEntryNodeBuilder + new YangInstanceIdentifier.NodeIdentifier(schemaContext.getQName())) + .withChild(createTestContainer()).build(); + + } + + public static ContainerNode createTestContainer() { + + + // Create a list of shoes + // This is to test leaf list entry + final LeafSetEntryNode nike = + ImmutableLeafSetEntryNodeBuilder + .create() + .withNodeIdentifier( + new YangInstanceIdentifier.NodeWithValue( + QName.create(TEST_QNAME, + "shoe"), "nike") + ).withValue("nike").build(); + + final LeafSetEntryNode puma = + ImmutableLeafSetEntryNodeBuilder + .create() + .withNodeIdentifier( + new YangInstanceIdentifier.NodeWithValue( + QName.create(TEST_QNAME, + "shoe"), "puma") + ).withValue("puma").build(); + + final LeafSetNode shoes = + ImmutableLeafSetNodeBuilder + .create() + .withNodeIdentifier( + new YangInstanceIdentifier.NodeIdentifier( + QName.create(TEST_QNAME, + "shoe")) + ).withChild(nike).withChild(puma).build(); + + + // Test a leaf-list where each entry contains an identity + final LeafSetEntryNode cap1 = + ImmutableLeafSetEntryNodeBuilder + .create() + .withNodeIdentifier( + new YangInstanceIdentifier.NodeWithValue( + QName.create(TEST_QNAME, + "capability"), DESC_QNAME) + ).withValue(DESC_QNAME).build(); + + final LeafSetNode capabilities = + ImmutableLeafSetNodeBuilder + .create() + .withNodeIdentifier( + new YangInstanceIdentifier.NodeIdentifier( + QName.create(TEST_QNAME, + "capability")) + ).withChild(cap1).build(); + + ContainerNode switchFeatures = ImmutableContainerNodeBuilder .create() - .withNodeIdentifier( - (new InstanceIdentifier.NodeWithValue(QName.create(TEST_QNAME, - "number"), 15))).withValue(15).build(); - final LeafSetNode numbers = - ImmutableLeafSetNodeBuilder + .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier( + SWITCH_FEATURES_QNAME)) + .withChild(capabilities) + .build(); + + // Create a leaf list with numbers + final LeafSetEntryNode five = + ImmutableLeafSetEntryNodeBuilder + .create() + .withNodeIdentifier( + (new YangInstanceIdentifier.NodeWithValue( + QName.create(TEST_QNAME, + "number"), 5)) + ).withValue(5).build(); + final LeafSetEntryNode fifteen = + ImmutableLeafSetEntryNodeBuilder + .create() + .withNodeIdentifier( + (new YangInstanceIdentifier.NodeWithValue( + QName.create(TEST_QNAME, + "number"), 15)) + ).withValue(15).build(); + final LeafSetNode numbers = + ImmutableLeafSetNodeBuilder + .create() + .withNodeIdentifier( + new YangInstanceIdentifier.NodeIdentifier( + QName.create(TEST_QNAME, + "number")) + ).withChild(five).withChild(fifteen).build(); + + + // Create augmentations + MapEntryNode mapEntry = createAugmentedListEntry(1, "First Test"); + + + // Create the document + return ImmutableContainerNodeBuilder .create() .withNodeIdentifier( - new InstanceIdentifier.NodeIdentifier(QName.create(TEST_QNAME, - "number"))).withChild(five).withChild(fifteen).build(); - - - Set childAugmentations = new HashSet<>(); - childAugmentations.add(AUG_QNAME); - final InstanceIdentifier.AugmentationIdentifier augmentationIdentifier = - new InstanceIdentifier.AugmentationIdentifier(null, childAugmentations); - final AugmentationNode augmentationNode = - Builders.augmentationBuilder() - .withNodeIdentifier(augmentationIdentifier) - .withChild(ImmutableNodes.leafNode(AUG_QNAME, "First Test")) + new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME)) + .withChild(ImmutableNodes.leafNode(DESC_QNAME, DESC)) + .withChild(ImmutableNodes.leafNode(POINTER_QNAME, "pointer")) + .withChild(ImmutableNodes.leafNode(SOME_REF_QNAME, + YangInstanceIdentifier.builder().build())) + .withChild(ImmutableNodes.leafNode(MYIDENTITY_QNAME, DESC_QNAME)) + + //.withChild(augmentationNode) + .withChild(shoes) + .withChild(numbers) + .withChild(switchFeatures) + .withChild(mapNodeBuilder(AUGMENTED_LIST_QNAME).withChild(mapEntry).build()) + .withChild( + mapNodeBuilder(OUTER_LIST_QNAME) + .withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID)) + .withChild(BAR_NODE).build() + ).build(); + + } + + public static MapEntryNode createAugmentedListEntry(int id, String name) { + + Set childAugmentations = new HashSet<>(); + childAugmentations.add(AUG_CONT_QNAME); + + ContainerNode augCont = ImmutableContainerNodeBuilder + .create() + .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(AUG_CONT_QNAME)) + .withChild(ImmutableNodes.leafNode(AUG_NAME_QNAME, name)) .build(); - return ImmutableContainerNodeBuilder - .create() - .withNodeIdentifier(new InstanceIdentifier.NodeIdentifier(TEST_QNAME)) - .withChild(ImmutableNodes.leafNode(DESC_QNAME, DESC)) - .withChild(augmentationNode) - .withChild(shoes) - .withChild(numbers) - .withChild( - mapNodeBuilder(OUTER_LIST_QNAME) - .withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID)) - .withChild(BAR_NODE).build()).build(); - - } - - - public static ContainerNode createFamily() { - final DataContainerNodeAttrBuilder familyContainerBuilder = - ImmutableContainerNodeBuilder.create().withNodeIdentifier( - new InstanceIdentifier.NodeIdentifier(FAMILY_QNAME)); - - final CollectionNodeBuilder childrenBuilder = - mapNodeBuilder(CHILDREN_QNAME); - - final DataContainerNodeBuilder firstChildBuilder = - mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID); - final DataContainerNodeBuilder secondChildBuilder = - mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, SECOND_CHILD_ID); - - final DataContainerNodeBuilder firstGrandChildBuilder = - mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, - FIRST_GRAND_CHILD_ID); - final DataContainerNodeBuilder secondGrandChildBuilder = - mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, - SECOND_GRAND_CHILD_ID); - - firstGrandChildBuilder - .withChild( - ImmutableNodes.leafNode(GRAND_CHILD_NUMBER_QNAME, - FIRST_GRAND_CHILD_ID)).withChild( - ImmutableNodes.leafNode(GRAND_CHILD_NAME_QNAME, - FIRST_GRAND_CHILD_NAME)); - - secondGrandChildBuilder.withChild( - ImmutableNodes - .leafNode(GRAND_CHILD_NUMBER_QNAME, SECOND_GRAND_CHILD_ID)) - .withChild( - ImmutableNodes.leafNode(GRAND_CHILD_NAME_QNAME, - SECOND_GRAND_CHILD_NAME)); - firstChildBuilder - .withChild(ImmutableNodes.leafNode(CHILD_NUMBER_QNAME, FIRST_CHILD_ID)) - .withChild(ImmutableNodes.leafNode(CHILD_NAME_QNAME, FIRST_CHILD_NAME)) - .withChild( - mapNodeBuilder(GRAND_CHILDREN_QNAME).withChild( - firstGrandChildBuilder.build()).build()); + final YangInstanceIdentifier.AugmentationIdentifier augmentationIdentifier = + new YangInstanceIdentifier.AugmentationIdentifier(childAugmentations); - secondChildBuilder - .withChild(ImmutableNodes.leafNode(CHILD_NUMBER_QNAME, SECOND_CHILD_ID)) - .withChild(ImmutableNodes.leafNode(CHILD_NAME_QNAME, SECOND_CHILD_NAME)) - .withChild( - mapNodeBuilder(GRAND_CHILDREN_QNAME).withChild( - firstGrandChildBuilder.build()).build()); + final AugmentationNode augmentationNode = + Builders.augmentationBuilder() + .withNodeIdentifier(augmentationIdentifier) + .withChild(augCont) + .build(); - childrenBuilder.withChild(firstChildBuilder.build()); - childrenBuilder.withChild(secondChildBuilder.build()); - - return familyContainerBuilder.withChild(childrenBuilder.build()).build(); - } + return ImmutableMapEntryNodeBuilder.create() + .withNodeIdentifier( + new YangInstanceIdentifier.NodeIdentifierWithPredicates( + AUGMENTED_LIST_QNAME, ID_QNAME, id)) + .withChild(ImmutableNodes.leafNode(ID_QNAME, id)) + .withChild(augmentationNode).build(); + } + + + public static ContainerNode createFamily() { + final DataContainerNodeAttrBuilder + familyContainerBuilder = + ImmutableContainerNodeBuilder.create().withNodeIdentifier( + new YangInstanceIdentifier.NodeIdentifier(FAMILY_QNAME)); + + final CollectionNodeBuilder childrenBuilder = + mapNodeBuilder(CHILDREN_QNAME); + + final DataContainerNodeBuilder + firstChildBuilder = + mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID); + final DataContainerNodeBuilder + secondChildBuilder = + mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, + SECOND_CHILD_ID); + + final DataContainerNodeBuilder + firstGrandChildBuilder = + mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, + FIRST_GRAND_CHILD_ID); + final DataContainerNodeBuilder + secondGrandChildBuilder = + mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, + SECOND_GRAND_CHILD_ID); + + firstGrandChildBuilder + .withChild( + ImmutableNodes.leafNode(GRAND_CHILD_NUMBER_QNAME, + FIRST_GRAND_CHILD_ID) + ).withChild( + ImmutableNodes.leafNode(GRAND_CHILD_NAME_QNAME, + FIRST_GRAND_CHILD_NAME) + ); + + secondGrandChildBuilder.withChild( + ImmutableNodes + .leafNode(GRAND_CHILD_NUMBER_QNAME, SECOND_GRAND_CHILD_ID) + ) + .withChild( + ImmutableNodes.leafNode(GRAND_CHILD_NAME_QNAME, + SECOND_GRAND_CHILD_NAME) + ); + + firstChildBuilder + .withChild( + ImmutableNodes.leafNode(CHILD_NUMBER_QNAME, FIRST_CHILD_ID)) + .withChild( + ImmutableNodes.leafNode(CHILD_NAME_QNAME, FIRST_CHILD_NAME)) + .withChild( + mapNodeBuilder(GRAND_CHILDREN_QNAME).withChild( + firstGrandChildBuilder.build()).build() + ); + + + secondChildBuilder + .withChild( + ImmutableNodes.leafNode(CHILD_NUMBER_QNAME, SECOND_CHILD_ID)) + .withChild( + ImmutableNodes.leafNode(CHILD_NAME_QNAME, SECOND_CHILD_NAME)) + .withChild( + mapNodeBuilder(GRAND_CHILDREN_QNAME).withChild( + firstGrandChildBuilder.build()).build() + ); + + childrenBuilder.withChild(firstChildBuilder.build()); + childrenBuilder.withChild(secondChildBuilder.build()); + + return familyContainerBuilder.withChild(childrenBuilder.build()) + .build(); + } } 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-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionMessagesTest.java new file mode 100644 index 0000000000..2b1ee5630c --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionMessagesTest.java @@ -0,0 +1,10 @@ +package org.opendaylight.controller.protobuff.messages.transaction; + +/** + * @author: syedbahm + * Date: 7/7/14 + */ +public class ShardTransactionMessagesTest { + + +} diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/application.conf b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/application.conf new file mode 100644 index 0000000000..e69de29bb2 diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/odl-datastore-augmentation.yang b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/odl-datastore-augmentation.yang new file mode 100644 index 0000000000..c305572951 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/odl-datastore-augmentation.yang @@ -0,0 +1,21 @@ +module odl-datastore-augmentation { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:aug"; + prefix "store-aug"; + + import odl-datastore-test {prefix test;revision-date "2014-03-13";} + + revision "2014-03-13" { + description "Initial revision."; + } + + + augment "/test:test/test:augmented-list" { + container cont { + leaf name { + type string; + } + } + } + +} diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/odl-datastore-test-notification.yang b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/odl-datastore-test-notification.yang new file mode 100644 index 0000000000..25cc53ab93 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/odl-datastore-test-notification.yang @@ -0,0 +1,33 @@ +module odl-datastore-test-notification { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:notification-test"; + prefix "notification-test-using-family-model"; + + revision "2014-04-17" { + description "Family structure created on "; + } + + container family { + leaf desc { + type string; + } + list children { + key child-number; + leaf child-number { + type uint16; + } + leaf child-name { + type string; + } + list grand-children { + key grand-child-number; + leaf grand-child-number { + type uint16; + } + leaf grand-child-name { + type string; + } + } + } + } +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/odl-datastore-test.yang b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/odl-datastore-test.yang index 32ec2777ce..e4eca7b717 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/odl-datastore-test.yang +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/odl-datastore-test.yang @@ -1,33 +1,91 @@ module odl-datastore-test { yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:notification-test"; - prefix "notification-test-using-family-model"; + namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test"; + prefix "store-test"; - revision "2014-04-15" { - description "Family structure created on "; + revision "2014-03-13" { + description "Initial revision."; } - container family { + identity feature-capability { + } + + container test { leaf desc { type string; } - list children { - key child-number; - leaf child-number { + list outer-list { + key id; + leaf id { type uint16; } - leaf child-name { - type string; - } - list grand-children { - key grand-child-number; - leaf grand-child-number { - type uint16; + choice outer-choice { + case one { + leaf one { + type string; + } + } + case two-three { + leaf two { + type string; + } + leaf three { + type string; + } + } + } + list inner-list { + key name; + leaf name { + type string; } - leaf grand-child-name { + leaf value { type string; } } } + + leaf-list shoe { + type string; + } + + leaf-list number { + type uint8; + } + + leaf pointer { + type leafref { + path "/network-topology/topology/node/termination-point/tp-id"; + } + } + + leaf some-ref { + type instance-identifier; + } + + leaf myidentity { + type identityref { + base feature-capability; + } + } + + container switch-features { + leaf-list capability { + type identityref { + base feature-capability; + } + + } + } + + list augmented-list { + key id; + + leaf id { + type uint8; + } + } + + } -} \ No newline at end of file +} diff --git a/opendaylight/md-sal/sal-remoterpc-connector/pom.xml b/opendaylight/md-sal/sal-remoterpc-connector/pom.xml index 6ee301d827..ce3bfe9a4c 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/pom.xml +++ b/opendaylight/md-sal/sal-remoterpc-connector/pom.xml @@ -55,22 +55,37 @@ org.opendaylight.controller netconf-util - + + org.opendaylight.controller + sal-core-spi + + + org.opendaylight.controller + sal-common-impl + org.opendaylight.yangtools yang-data-api + + + org.opendaylight.yangtools + yang-model-api + + org.opendaylight.yangtools yang-data-impl + org.opendaylight.yangtools yang-common + @@ -107,6 +122,17 @@ ${slf4j.version} test + + org.opendaylight.yangtools + yang-parser-impl + test + + + com.google.collections + google-collections + 1.0 + test + diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/config/yang/config/remote_rpc_connector/RemoteRPCBrokerModule.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/config/yang/config/remote_rpc_connector/RemoteRPCBrokerModule.java index 8315bbeeb3..9824889b80 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/config/yang/config/remote_rpc_connector/RemoteRPCBrokerModule.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/config/yang/config/remote_rpc_connector/RemoteRPCBrokerModule.java @@ -2,10 +2,8 @@ package org.opendaylight.controller.config.yang.config.remote_rpc_connector; import org.opendaylight.controller.remote.rpc.RemoteRpcProviderFactory; import org.opendaylight.controller.sal.core.api.Broker; -import org.osgi.framework.BundleContext; public class RemoteRPCBrokerModule extends org.opendaylight.controller.config.yang.config.remote_rpc_connector.AbstractRemoteRPCBrokerModule { - private BundleContext bundleContext; public RemoteRPCBrokerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { super(identifier, dependencyResolver); } @@ -22,10 +20,6 @@ public class RemoteRPCBrokerModule extends org.opendaylight.controller.config.ya @Override public java.lang.AutoCloseable createInstance() { Broker broker = getDomBrokerDependency(); - return RemoteRpcProviderFactory.createInstance(broker, bundleContext); - } - - public void setBundleContext(final BundleContext bundleContext) { - this.bundleContext = bundleContext; + return RemoteRpcProviderFactory.createInstance(broker); } } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/config/yang/config/remote_rpc_connector/RemoteRPCBrokerModuleFactory.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/config/yang/config/remote_rpc_connector/RemoteRPCBrokerModuleFactory.java index e1ba46ae15..330845b14f 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/config/yang/config/remote_rpc_connector/RemoteRPCBrokerModuleFactory.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/config/yang/config/remote_rpc_connector/RemoteRPCBrokerModuleFactory.java @@ -9,27 +9,7 @@ */ package org.opendaylight.controller.config.yang.config.remote_rpc_connector; -import org.opendaylight.controller.config.api.DependencyResolver; -import org.opendaylight.controller.config.api.DynamicMBeanWithInstance; -import org.opendaylight.controller.config.spi.Module; -import org.osgi.framework.BundleContext; public class RemoteRPCBrokerModuleFactory extends org.opendaylight.controller.config.yang.config.remote_rpc_connector.AbstractRemoteRPCBrokerModuleFactory { - @Override - public Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) { - RemoteRPCBrokerModule module = (RemoteRPCBrokerModule)super.createModule(instanceName,dependencyResolver,bundleContext); - module.setBundleContext(bundleContext); - return module; - } - - @Override - public Module createModule(String instanceName, DependencyResolver dependencyResolver, - DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception { - RemoteRPCBrokerModule module = (RemoteRPCBrokerModule)super.createModule(instanceName, dependencyResolver, - old, bundleContext); - module.setBundleContext(bundleContext); - return module; - } - } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcImplementation.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcImplementation.java index 43aa5b7e85..d384144f4f 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcImplementation.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcImplementation.java @@ -7,21 +7,19 @@ import org.opendaylight.controller.remote.rpc.messages.ErrorResponse; import org.opendaylight.controller.remote.rpc.messages.InvokeRoutedRpc; import org.opendaylight.controller.remote.rpc.messages.InvokeRpc; import org.opendaylight.controller.remote.rpc.messages.RpcResponse; -import org.opendaylight.controller.sal.common.util.RpcErrors; -import org.opendaylight.controller.sal.common.util.Rpcs; +import org.opendaylight.controller.remote.rpc.utils.ActorUtil; +import org.opendaylight.controller.remote.rpc.utils.XmlUtils; import org.opendaylight.controller.sal.core.api.RoutedRpcDefaultImplementation; import org.opendaylight.controller.sal.core.api.RpcImplementation; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.Set; @@ -37,7 +35,7 @@ public class RemoteRpcImplementation implements RpcImplementation, } @Override - public ListenableFuture> invokeRpc(QName rpc, InstanceIdentifier identifier, CompositeNode input) { + public ListenableFuture> invokeRpc(QName rpc, YangInstanceIdentifier identifier, CompositeNode input) { InvokeRoutedRpc rpcMsg = new InvokeRoutedRpc(rpc, identifier, input); return executeMsg(rpcMsg); @@ -56,22 +54,33 @@ public class RemoteRpcImplementation implements RpcImplementation, } private ListenableFuture> executeMsg(Object rpcMsg) { - CompositeNode result = null; - Collection errors = errors = new ArrayList<>(); + ListenableFuture> listenableFuture = null; + try { Object response = ActorUtil.executeLocalOperation(rpcBroker, rpcMsg, ActorUtil.ASK_DURATION, ActorUtil.AWAIT_DURATION); if(response instanceof RpcResponse) { + RpcResponse rpcResponse = (RpcResponse) response; - result = XmlUtils.xmlToCompositeNode(rpcResponse.getResultCompositeNode()); + CompositeNode result = XmlUtils.xmlToCompositeNode(rpcResponse.getResultCompositeNode()); + listenableFuture = Futures.immediateFuture(RpcResultBuilder.success(result).build()); + } else if(response instanceof ErrorResponse) { + ErrorResponse errorResponse = (ErrorResponse) response; Exception e = errorResponse.getException(); - errors.add(RpcErrors.getRpcError(null, null, null, null, e.getMessage(), null, e.getCause())); + final RpcResultBuilder failed = RpcResultBuilder.failed(); + failed.withError(null, null, e.getMessage(), null, null, e.getCause()); + listenableFuture = Futures.immediateFuture(failed.build()); + } } catch (Exception e) { LOG.error("Error occurred while invoking RPC actor {}", e.toString()); - errors.add(RpcErrors.getRpcError(null, null, null, null, e.getMessage(), null, e.getCause())); + + final RpcResultBuilder failed = RpcResultBuilder.failed(); + failed.withError(null, null, e.getMessage(), null, null, e.getCause()); + listenableFuture = Futures.immediateFuture(failed.build()); } - return Futures.immediateFuture(Rpcs.getRpcResult(true, result, errors)); + + return listenableFuture; } } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProvider.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProvider.java index 1bb7ea4514..3df572d7c2 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProvider.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProvider.java @@ -11,37 +11,35 @@ package org.opendaylight.controller.remote.rpc; import akka.actor.ActorRef; import akka.actor.ActorSystem; +import org.opendaylight.controller.remote.rpc.messages.UpdateSchemaContext; import org.opendaylight.controller.remote.rpc.registry.ClusterWrapper; import org.opendaylight.controller.remote.rpc.registry.ClusterWrapperImpl; -import org.opendaylight.controller.remote.rpc.registry.RpcRegistry; import org.opendaylight.controller.sal.core.api.Broker; import org.opendaylight.controller.sal.core.api.Provider; import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry; import org.opendaylight.controller.sal.core.api.model.SchemaService; -import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Collection; -import java.util.Set; /** * This is the base class which initialize all the actors, listeners and * default RPc implementation so remote invocation of rpcs. */ -public class RemoteRpcProvider implements AutoCloseable, Provider{ +public class RemoteRpcProvider implements AutoCloseable, Provider, SchemaContextListener { private static final Logger LOG = LoggerFactory.getLogger(RemoteRpcProvider.class); private final ActorSystem actorSystem; - private ActorRef rpcBroker; - private ActorRef rpcRegistry; private final RpcProvisionRegistry rpcProvisionRegistry; private Broker.ProviderSession brokerSession; - private RpcListener rpcListener; - private RoutedRpcListener routeChangeListener; - private RemoteRpcImplementation rpcImplementation; + private SchemaContext schemaContext; + private ActorRef rpcManager; + + public RemoteRpcProvider(ActorSystem actorSystem, RpcProvisionRegistry rpcProvisionRegistry) { this.actorSystem = actorSystem; this.rpcProvisionRegistry = rpcProvisionRegistry; @@ -50,8 +48,6 @@ public class RemoteRpcProvider implements AutoCloseable, Provider{ @Override public void close() throws Exception { this.actorSystem.shutdown(); - unregisterSupportedRpcs(); - unregisterSupportedRoutedRpcs(); } @Override @@ -66,64 +62,22 @@ public class RemoteRpcProvider implements AutoCloseable, Provider{ } private void start() { - LOG.debug("Starting all rpc listeners."); + LOG.info("Starting all rpc listeners and actors."); // Create actor to handle and sync routing table in cluster ClusterWrapper clusterWrapper = new ClusterWrapperImpl(actorSystem); - rpcRegistry = actorSystem.actorOf(RpcRegistry.props(clusterWrapper), "rpc-registry"); - - // Create actor to invoke and execute rpc SchemaService schemaService = brokerSession.getService(SchemaService.class); - SchemaContext schemaContext = schemaService.getGlobalContext(); - rpcBroker = actorSystem.actorOf(RpcBroker.props(brokerSession, rpcRegistry, schemaContext), "rpc-broker"); - String rpcBrokerPath = clusterWrapper.getAddress().toString() + "/user/rpc-broker"; - rpcListener = new RpcListener(rpcRegistry, rpcBrokerPath); - routeChangeListener = new RoutedRpcListener(rpcRegistry, rpcBrokerPath); - rpcImplementation = new RemoteRpcImplementation(rpcBroker, schemaContext); - brokerSession.addRpcRegistrationListener(rpcListener); - rpcProvisionRegistry.registerRouteChangeListener(routeChangeListener); - rpcProvisionRegistry.setRoutedRpcDefaultDelegate(rpcImplementation); - announceSupportedRpcs(); - announceSupportedRoutedRpcs(); + schemaContext = schemaService.getGlobalContext(); - } + rpcManager = actorSystem.actorOf(RpcManager.props(clusterWrapper, schemaContext, brokerSession, rpcProvisionRegistry), "rpc"); - /** - * Add all the locally registered RPCs in the clustered routing table - */ - private void announceSupportedRpcs(){ - LOG.debug("Adding all supported rpcs to routing table"); - Set currentlySupported = brokerSession.getSupportedRpcs(); - for (QName rpc : currentlySupported) { - rpcListener.onRpcImplementationAdded(rpc); - } + LOG.debug("Rpc actors are created."); } - /** - * Add all the locally registered Routed RPCs in the clustered routing table - */ - private void announceSupportedRoutedRpcs(){ - - //TODO: announce all routed RPCs as well - } - - /** - * Un-Register all the supported RPCs from clustered routing table - */ - private void unregisterSupportedRpcs(){ - LOG.debug("removing all supported rpcs to routing table"); - Set currentlySupported = brokerSession.getSupportedRpcs(); - for (QName rpc : currentlySupported) { - rpcListener.onRpcImplementationRemoved(rpc); - } - } - - /** - * Un-Register all the locally supported Routed RPCs from clustered routing table - */ - private void unregisterSupportedRoutedRpcs(){ - - //TODO: remove all routed RPCs as well + @Override + public void onGlobalContextUpdated(SchemaContext schemaContext) { + this.schemaContext = schemaContext; + rpcManager.tell(new UpdateSchemaContext(schemaContext), null); } } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderFactory.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderFactory.java index 61dc8183df..4c40ca1777 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderFactory.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderFactory.java @@ -11,13 +11,12 @@ package org.opendaylight.controller.remote.rpc; import org.opendaylight.controller.sal.core.api.Broker; import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry; -import org.osgi.framework.BundleContext; public class RemoteRpcProviderFactory { - public static RemoteRpcProvider createInstance(final Broker broker, final BundleContext bundleContext){ + public static RemoteRpcProvider createInstance(final Broker broker){ RemoteRpcProvider rpcProvider = new RemoteRpcProvider(ActorSystemFactory.getInstance(), (RpcProvisionRegistry) broker); - broker.registerProvider(rpcProvider, bundleContext); + broker.registerProvider(rpcProvider); return rpcProvider; } } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RouteIdentifierImpl.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RouteIdentifierImpl.java index ea72238fbc..85d21381b6 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RouteIdentifierImpl.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RouteIdentifierImpl.java @@ -7,20 +7,23 @@ */ package org.opendaylight.controller.remote.rpc; +import com.google.common.base.Preconditions; import org.opendaylight.controller.sal.connector.api.RpcRouter; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; + import java.io.Serializable; -public class RouteIdentifierImpl implements RpcRouter.RouteIdentifier,Serializable { +public class RouteIdentifierImpl implements RpcRouter.RouteIdentifier,Serializable { private static final long serialVersionUID = 1L; - private QName context; - private QName type; - private InstanceIdentifier route; + private final QName context; + private final QName type; + private final YangInstanceIdentifier route; - public RouteIdentifierImpl(QName context, QName type, InstanceIdentifier route) { + public RouteIdentifierImpl(final QName context, final QName type, final YangInstanceIdentifier route) { + Preconditions.checkNotNull(type, "Rpc type should not be null"); this.context = context; this.type = type; this.route = route; @@ -37,7 +40,7 @@ public class RouteIdentifierImpl implements RpcRouter.RouteIdentifier{ +public class RoutedRpcListener implements RouteChangeListener{ private static final Logger LOG = LoggerFactory.getLogger(RoutedRpcListener.class); private final ActorRef rpcRegistry; private final String actorPath; public RoutedRpcListener(ActorRef rpcRegistry, String actorPath) { + Preconditions.checkNotNull(rpcRegistry, "rpc registry actor should not be null"); + Preconditions.checkNotNull(actorPath, "actor path of rpc broker on current node should not be null"); + this.rpcRegistry = rpcRegistry; this.actorPath = actorPath; } @Override - public void onRouteChange(RouteChange routeChange) { - Map> announcements = routeChange.getAnnouncements(); + public void onRouteChange(RouteChange routeChange) { + Map> announcements = routeChange.getAnnouncements(); announce(getRouteIdentifiers(announcements)); - Map> removals = routeChange.getRemovals(); + Map> removals = routeChange.getRemovals(); remove(getRouteIdentifiers(removals)); } @@ -78,12 +83,12 @@ public class RoutedRpcListener implements RouteChangeListener> getRouteIdentifiers(Map> changes) { + private Set> getRouteIdentifiers(Map> changes) { RouteIdentifierImpl routeId = null; Set> routeIdSet = new HashSet<>(); for (RpcRoutingContext context : changes.keySet()){ - for (InstanceIdentifier instanceId : changes.get(context)){ + for (YangInstanceIdentifier instanceId : changes.get(context)){ routeId = new RouteIdentifierImpl(null, context.getRpc(), instanceId); routeIdSet.add(routeId); } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcBroker.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcBroker.java index 3354fc3da2..26e8e960e3 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcBroker.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcBroker.java @@ -20,6 +20,8 @@ import org.opendaylight.controller.remote.rpc.messages.GetRpcReply; import org.opendaylight.controller.remote.rpc.messages.InvokeRoutedRpc; import org.opendaylight.controller.remote.rpc.messages.InvokeRpc; import org.opendaylight.controller.remote.rpc.messages.RpcResponse; +import org.opendaylight.controller.remote.rpc.utils.ActorUtil; +import org.opendaylight.controller.remote.rpc.utils.XmlUtils; import org.opendaylight.controller.sal.core.api.Broker; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.data.api.CompositeNode; @@ -38,7 +40,7 @@ public class RpcBroker extends AbstractUntypedActor { private static final Logger LOG = LoggerFactory.getLogger(RpcBroker.class); private final Broker.ProviderSession brokerSession; private final ActorRef rpcRegistry; - private final SchemaContext schemaContext; + private SchemaContext schemaContext; private RpcBroker(Broker.ProviderSession brokerSession, ActorRef rpcRegistry, SchemaContext schemaContext){ this.brokerSession = brokerSession; @@ -72,7 +74,7 @@ public class RpcBroker extends AbstractUntypedActor { try { RouteIdentifierImpl routeId = new RouteIdentifierImpl(null, msg.getRpc(), msg.getIdentifier()); GetRoutedRpc routedRpcMsg = new GetRoutedRpc(routeId); - GetRoutedRpcReply rpcReply = (GetRoutedRpcReply)ActorUtil.executeLocalOperation(rpcRegistry, routedRpcMsg, ActorUtil.LOCAL_ASK_DURATION, ActorUtil.LOCAL_AWAIT_DURATION); + GetRoutedRpcReply rpcReply = (GetRoutedRpcReply) ActorUtil.executeLocalOperation(rpcRegistry, routedRpcMsg, ActorUtil.LOCAL_ASK_DURATION, ActorUtil.LOCAL_AWAIT_DURATION); String remoteActorPath = rpcReply.getRoutePath(); if(remoteActorPath == null) { @@ -105,11 +107,12 @@ public class RpcBroker extends AbstractUntypedActor { String remoteActorPath = rpcReply.getRoutePath(); if(remoteActorPath == null) { - LOG.debug("No remote actor found for rpc execution."); + LOG.debug("No remote actor found for rpc {{}}.", msg.getRpc()); getSender().tell(new ErrorResponse( - new IllegalStateException("No remote actor found for rpc execution.")), self()); + new IllegalStateException("No remote actor found for rpc execution of : " + msg.getRpc())), self()); } else { + ExecuteRpc executeMsg = new ExecuteRpc(XmlUtils.inputCompositeNodeToXml(msg.getInput(), schemaContext), msg.getRpc()); Object operationRes = ActorUtil.executeRemoteOperation(this.context().actorSelection(remoteActorPath), executeMsg, ActorUtil.REMOTE_ASK_DURATION, ActorUtil.REMOTE_AWAIT_DURATION); @@ -127,7 +130,6 @@ public class RpcBroker extends AbstractUntypedActor { try { Future> rpc = brokerSession.rpc(msg.getRpc(), XmlUtils.inputXmlToCompositeNode(msg.getRpc(), msg.getInputCompositeNode(), schemaContext)); RpcResult rpcResult = rpc != null ? rpc.get():null; - CompositeNode result = rpcResult != null ? rpcResult.getResult() : null; getSender().tell(new RpcResponse(XmlUtils.outputCompositeNodeToXml(result, schemaContext)), self()); } catch (Exception e) { diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcListener.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcListener.java index ae760fadc4..f614990669 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcListener.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcListener.java @@ -12,6 +12,7 @@ package org.opendaylight.controller.remote.rpc; import akka.actor.ActorRef; import org.opendaylight.controller.remote.rpc.messages.AddRpc; import org.opendaylight.controller.remote.rpc.messages.RemoveRpc; +import org.opendaylight.controller.remote.rpc.utils.ActorUtil; import org.opendaylight.controller.sal.core.api.RpcRegistrationListener; import org.opendaylight.yangtools.yang.common.QName; import org.slf4j.Logger; diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcManager.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcManager.java new file mode 100644 index 0000000000..4925a17c13 --- /dev/null +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcManager.java @@ -0,0 +1,128 @@ +/* + * 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.remote.rpc; + + +import akka.actor.ActorRef; +import akka.actor.OneForOneStrategy; +import akka.actor.Props; +import akka.actor.SupervisorStrategy; +import akka.japi.Creator; +import akka.japi.Function; +import org.opendaylight.controller.remote.rpc.messages.UpdateSchemaContext; +import org.opendaylight.controller.remote.rpc.registry.ClusterWrapper; +import org.opendaylight.controller.remote.rpc.registry.RpcRegistry; +import org.opendaylight.controller.sal.core.api.Broker; +import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import scala.concurrent.duration.Duration; +import java.util.Set; + +/** + * This class acts as a supervisor, creates all the actors, resumes them, if an exception is thrown. + * + * It also starts the rpc listeners + */ + +public class RpcManager extends AbstractUntypedActor { + + private static final Logger LOG = LoggerFactory.getLogger(RpcManager.class); + + private SchemaContext schemaContext; + private final ClusterWrapper clusterWrapper; + private ActorRef rpcBroker; + private ActorRef rpcRegistry; + private final Broker.ProviderSession brokerSession; + private RpcListener rpcListener; + private RoutedRpcListener routeChangeListener; + private RemoteRpcImplementation rpcImplementation; + private final RpcProvisionRegistry rpcProvisionRegistry; + + private RpcManager(ClusterWrapper clusterWrapper, SchemaContext schemaContext, + Broker.ProviderSession brokerSession, RpcProvisionRegistry rpcProvisionRegistry) { + this.clusterWrapper = clusterWrapper; + this.schemaContext = schemaContext; + this.brokerSession = brokerSession; + this.rpcProvisionRegistry = rpcProvisionRegistry; + + createRpcActors(); + startListeners(); + } + + + public static Props props(final ClusterWrapper clusterWrapper, final SchemaContext schemaContext, + final Broker.ProviderSession brokerSession, final RpcProvisionRegistry rpcProvisionRegistry) { + return Props.create(new Creator() { + @Override + public RpcManager create() throws Exception { + return new RpcManager(clusterWrapper, schemaContext, brokerSession, rpcProvisionRegistry); + } + }); + } + + private void createRpcActors() { + LOG.debug("Create rpc registry and broker actors"); + + rpcRegistry = getContext().actorOf(RpcRegistry.props(clusterWrapper), "rpc-registry"); + rpcBroker = getContext().actorOf(RpcBroker.props(brokerSession, rpcRegistry, schemaContext), "rpc-broker"); + } + + private void startListeners() { + LOG.debug("Registers rpc listeners"); + + String rpcBrokerPath = clusterWrapper.getAddress().toString() + "/user/rpc/rpc-broker"; + rpcListener = new RpcListener(rpcRegistry, rpcBrokerPath); + routeChangeListener = new RoutedRpcListener(rpcRegistry, rpcBrokerPath); + rpcImplementation = new RemoteRpcImplementation(rpcBroker, schemaContext); + + brokerSession.addRpcRegistrationListener(rpcListener); + rpcProvisionRegistry.registerRouteChangeListener(routeChangeListener); + rpcProvisionRegistry.setRoutedRpcDefaultDelegate(rpcImplementation); + announceSupportedRpcs(); + } + + /** + * Add all the locally registered RPCs in the clustered routing table + */ + private void announceSupportedRpcs(){ + LOG.debug("Adding all supported rpcs to routing table"); + Set currentlySupported = brokerSession.getSupportedRpcs(); + for (QName rpc : currentlySupported) { + rpcListener.onRpcImplementationAdded(rpc); + } + } + + + @Override + protected void handleReceive(Object message) throws Exception { + if(message instanceof UpdateSchemaContext) { + updateSchemaContext((UpdateSchemaContext) message); + } + + } + + private void updateSchemaContext(UpdateSchemaContext message) { + this.schemaContext = message.getSchemaContext(); + } + + @Override + public SupervisorStrategy supervisorStrategy() { + return new OneForOneStrategy(10, Duration.create("1 minute"), + new Function() { + @Override + public SupervisorStrategy.Directive apply(Throwable t) { + return SupervisorStrategy.resume(); + } + } + ); + } +} diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/XmlUtils.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/XmlUtils.java deleted file mode 100644 index 5fb2bb8772..0000000000 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/XmlUtils.java +++ /dev/null @@ -1,145 +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.remote.rpc; - -import com.google.common.base.Optional; -import org.opendaylight.yangtools.yang.common.QName; -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.impl.XmlTreeBuilder; -import org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlDocumentUtils; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.controller.netconf.util.xml.XmlUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.dom.Document; -import org.xml.sax.SAXException; - -import javax.activation.UnsupportedDataTypeException; -import javax.xml.stream.XMLStreamException; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.StringWriter; -import java.util.Set; - -public class XmlUtils { - - private static final Logger LOG = LoggerFactory.getLogger(XmlUtils.class); - - public static String inputCompositeNodeToXml(CompositeNode cNode, SchemaContext schemaContext){ - if (cNode == null) return new String(); - - //Document domTree = NodeUtils.buildShadowDomTree(cNode); - Document domTree = null; - try { - Set rpcs = schemaContext.getOperations(); - for(RpcDefinition rpc : rpcs) { - if(rpc.getQName().equals(cNode.getNodeType())){ - domTree = XmlDocumentUtils.toDocument(cNode, rpc.getInput(), XmlDocumentUtils.defaultValueCodecProvider()); - break; - } - } - - } catch (UnsupportedDataTypeException e) { - LOG.error("Error during translation of CompositeNode to Document", e); - } - return domTransformer(domTree); - } - - public static String outputCompositeNodeToXml(CompositeNode cNode, SchemaContext schemaContext){ - if (cNode == null) return new String(); - - //Document domTree = NodeUtils.buildShadowDomTree(cNode); - Document domTree = null; - try { - Set rpcs = schemaContext.getOperations(); - for(RpcDefinition rpc : rpcs) { - if(rpc.getQName().equals(cNode.getNodeType())){ - domTree = XmlDocumentUtils.toDocument(cNode, rpc.getInput(), XmlDocumentUtils.defaultValueCodecProvider()); - break; - } - } - - } catch (UnsupportedDataTypeException e) { - LOG.error("Error during translation of CompositeNode to Document", e); - } - return domTransformer(domTree); - } - - private static String domTransformer(Document domTree) { - StringWriter writer = new StringWriter(); - try { - TransformerFactory tf = TransformerFactory.newInstance(); - Transformer transformer = tf.newTransformer(); - transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); - transformer.transform(new DOMSource(domTree), new StreamResult(writer)); - } catch (TransformerException e) { - - LOG.error("Error during translation of Document to OutputStream", e); - } - LOG.debug("compositeNodeToXml " + writer.toString()); - - return writer.toString(); - } - - public static CompositeNode xmlToCompositeNode(String xml){ - if (xml==null || xml.length()==0) return null; - - Node dataTree; - try { - dataTree = XmlTreeBuilder.buildDataTree(new ByteArrayInputStream(xml.getBytes())); - } catch (XMLStreamException e) { - LOG.error("Error during building data tree from XML", e); - return null; - } - if (dataTree == null) { - LOG.error("data tree is null"); - return null; - } - if (dataTree instanceof SimpleNode) { - LOG.error("RPC XML was resolved as SimpleNode"); - return null; - } - return (CompositeNode) dataTree; - } - - public static CompositeNode inputXmlToCompositeNode(QName rpc, String xml, SchemaContext schemaContext){ - if (xml==null || xml.length()==0) return null; - - Node dataTree = null; - try { - - Document doc = XmlUtil.readXmlToDocument(xml); - LOG.debug("xmlToCompositeNode Document is " + xml ); - Set rpcs = schemaContext.getOperations(); - for(RpcDefinition rpcDef : rpcs) { - if(rpcDef.getQName().equals(rpc)){ - dataTree = XmlDocumentUtils.toDomNode(doc.getDocumentElement(), Optional.of(rpcDef.getInput()), Optional.of(XmlDocumentUtils.defaultValueCodecProvider())); - break; - } - } - } catch (SAXException e) { - LOG.error("Error during building data tree from XML", e); - } catch (IOException e) { - LOG.error("Error during building data tree from XML", e); - } - - LOG.debug("xmlToCompositeNode " + dataTree.toString()); - return (CompositeNode) dataTree; - } -} diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/AddRoutedRpc.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/AddRoutedRpc.java index 25773bb8a6..fd1af2b33c 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/AddRoutedRpc.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/AddRoutedRpc.java @@ -8,6 +8,7 @@ package org.opendaylight.controller.remote.rpc.messages; +import com.google.common.base.Preconditions; import org.opendaylight.controller.sal.connector.api.RpcRouter; import java.io.Serializable; @@ -15,10 +16,13 @@ import java.util.Set; public class AddRoutedRpc implements Serializable { - Set> announcements; - String actorPath; + private final Set> announcements; + private final String actorPath; + + public AddRoutedRpc(final Set> announcements, final String actorPath) { + Preconditions.checkNotNull(announcements, "Route identifier should not be null"); + Preconditions.checkNotNull(actorPath, "Actor path should not be null"); - public AddRoutedRpc(Set> announcements, String actorPath) { this.announcements = announcements; this.actorPath = actorPath; } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/AddRpc.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/AddRpc.java index eac973137e..7eaa8f0618 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/AddRpc.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/AddRpc.java @@ -8,16 +8,20 @@ package org.opendaylight.controller.remote.rpc.messages; +import com.google.common.base.Preconditions; import org.opendaylight.controller.remote.rpc.RouteIdentifierImpl; import java.io.Serializable; public class AddRpc implements Serializable { - RouteIdentifierImpl routeId; - String actorPath; + private final RouteIdentifierImpl routeId; + private final String actorPath; + + public AddRpc(final RouteIdentifierImpl routeId, final String actorPath) { + Preconditions.checkNotNull(routeId, "Route identifier should not be null"); + Preconditions.checkNotNull(actorPath, "Actor path should not be null"); - public AddRpc(RouteIdentifierImpl routeId, String actorPath) { this.routeId = routeId; this.actorPath = actorPath; } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/ErrorResponse.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/ErrorResponse.java index ef3f528112..2c26243fe9 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/ErrorResponse.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/ErrorResponse.java @@ -7,13 +7,16 @@ */ package org.opendaylight.controller.remote.rpc.messages; +import com.google.common.base.Preconditions; + import java.io.Serializable; public class ErrorResponse implements Serializable { - Exception exception; + private final Exception exception; - public ErrorResponse(Exception e) { + public ErrorResponse(final Exception e) { + Preconditions.checkNotNull(e, "Exception should be present for error message"); this.exception = e; } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/ExecuteRpc.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/ExecuteRpc.java index 030d81ac7e..522dd44f5b 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/ExecuteRpc.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/ExecuteRpc.java @@ -8,16 +8,20 @@ package org.opendaylight.controller.remote.rpc.messages; +import com.google.common.base.Preconditions; import org.opendaylight.yangtools.yang.common.QName; import java.io.Serializable; public class ExecuteRpc implements Serializable { - private String inputCompositeNode; - private QName rpc; + private final String inputCompositeNode; + private final QName rpc; + + public ExecuteRpc(final String inputCompositeNode, final QName rpc) { + Preconditions.checkNotNull(inputCompositeNode, "Composite Node input string should be present"); + Preconditions.checkNotNull(rpc, "rpc Qname should not be null"); - public ExecuteRpc(String inputCompositeNode, QName rpc) { this.inputCompositeNode = inputCompositeNode; this.rpc = rpc; } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/GetRoutedRpc.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/GetRoutedRpc.java index b1fa410e8d..e8d2262182 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/GetRoutedRpc.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/GetRoutedRpc.java @@ -9,15 +9,17 @@ package org.opendaylight.controller.remote.rpc.messages; +import com.google.common.base.Preconditions; import org.opendaylight.controller.remote.rpc.RouteIdentifierImpl; import java.io.Serializable; public class GetRoutedRpc implements Serializable { - RouteIdentifierImpl routeId; + private final RouteIdentifierImpl routeId; - public GetRoutedRpc(RouteIdentifierImpl routeId) { + public GetRoutedRpc(final RouteIdentifierImpl routeId) { + Preconditions.checkNotNull(routeId, "route id should not be null"); this.routeId = routeId; } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/GetRoutedRpcReply.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/GetRoutedRpcReply.java index 0e1563340b..d426662192 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/GetRoutedRpcReply.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/GetRoutedRpcReply.java @@ -12,9 +12,9 @@ import java.io.Serializable; public class GetRoutedRpcReply implements Serializable { - private String routePath; + private final String routePath; - public GetRoutedRpcReply(String routePath) { + public GetRoutedRpcReply(final String routePath) { this.routePath = routePath; } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/GetRpc.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/GetRpc.java index c55627961a..c1d4240dca 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/GetRpc.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/GetRpc.java @@ -7,15 +7,17 @@ */ package org.opendaylight.controller.remote.rpc.messages; +import com.google.common.base.Preconditions; import org.opendaylight.controller.remote.rpc.RouteIdentifierImpl; import java.io.Serializable; public class GetRpc implements Serializable { - RouteIdentifierImpl routeId; + private final RouteIdentifierImpl routeId; - public GetRpc(RouteIdentifierImpl routeId) { + public GetRpc(final RouteIdentifierImpl routeId) { + Preconditions.checkNotNull(routeId, "Route Id should not be null"); this.routeId = routeId; } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/GetRpcReply.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/GetRpcReply.java index 3309b989c5..aaf089d16f 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/GetRpcReply.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/GetRpcReply.java @@ -12,9 +12,9 @@ import java.io.Serializable; public class GetRpcReply implements Serializable { - private String routePath; + private final String routePath; - public GetRpcReply(String routePath) { + public GetRpcReply(final String routePath) { this.routePath = routePath; } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/InvokeRoutedRpc.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/InvokeRoutedRpc.java index 00ef980bb1..fd73144e1d 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/InvokeRoutedRpc.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/InvokeRoutedRpc.java @@ -7,26 +7,26 @@ */ package org.opendaylight.controller.remote.rpc.messages; +import com.google.common.base.Preconditions; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import java.io.Serializable; public class InvokeRoutedRpc implements Serializable { - private QName rpc; - private InstanceIdentifier identifier; - private CompositeNode input; + private final QName rpc; + private final YangInstanceIdentifier identifier; + private final CompositeNode input; - public InvokeRoutedRpc(QName rpc, InstanceIdentifier identifier, CompositeNode input) { - this.rpc = rpc; - this.identifier = identifier; - this.input = input; - } + public InvokeRoutedRpc(final QName rpc, final YangInstanceIdentifier identifier, final CompositeNode input) { + Preconditions.checkNotNull(rpc, "rpc qname should not be null"); + Preconditions.checkNotNull(identifier, "instance identifier of routed rpc should not be null"); + Preconditions.checkNotNull(input, "rpc input should not be null"); - public InvokeRoutedRpc(QName rpc, CompositeNode input) { this.rpc = rpc; + this.identifier = identifier; this.input = input; } @@ -34,7 +34,7 @@ public class InvokeRoutedRpc implements Serializable { return rpc; } - public InstanceIdentifier getIdentifier() { + public YangInstanceIdentifier getIdentifier() { return identifier; } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/InvokeRpc.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/InvokeRpc.java index 1f4eab0971..94b7fe4024 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/InvokeRpc.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/InvokeRpc.java @@ -7,6 +7,7 @@ */ package org.opendaylight.controller.remote.rpc.messages; +import com.google.common.base.Preconditions; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.CompositeNode; @@ -14,10 +15,13 @@ import java.io.Serializable; public class InvokeRpc implements Serializable { - private QName rpc; - private CompositeNode input; + private final QName rpc; + private final CompositeNode input; + + public InvokeRpc(final QName rpc, final CompositeNode input) { + Preconditions.checkNotNull(rpc, "rpc qname should not be null"); + Preconditions.checkNotNull(input, "rpc input should not be null"); - public InvokeRpc(QName rpc, CompositeNode input) { this.rpc = rpc; this.input = input; } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/RemoveRoutedRpc.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/RemoveRoutedRpc.java index a3aa9d12fa..b560b8c8c0 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/RemoveRoutedRpc.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/RemoveRoutedRpc.java @@ -8,6 +8,7 @@ package org.opendaylight.controller.remote.rpc.messages; +import com.google.common.base.Preconditions; import org.opendaylight.controller.sal.connector.api.RpcRouter; import java.io.Serializable; @@ -15,10 +16,13 @@ import java.util.Set; public class RemoveRoutedRpc implements Serializable { - Set> announcements; - String actorPath; + private final Set> announcements; + private final String actorPath; + + public RemoveRoutedRpc(final Set> announcements, final String actorPath) { + Preconditions.checkNotNull(announcements, "Route identifier should not be null"); + Preconditions.checkNotNull(actorPath, "Actor path should not be null"); - public RemoveRoutedRpc(Set> announcements, String actorPath) { this.announcements = announcements; this.actorPath = actorPath; } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/RemoveRpc.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/RemoveRpc.java index 0bfd78aaae..289334fccc 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/RemoveRpc.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/RemoveRpc.java @@ -8,15 +8,18 @@ package org.opendaylight.controller.remote.rpc.messages; +import com.google.common.base.Preconditions; import org.opendaylight.controller.remote.rpc.RouteIdentifierImpl; import java.io.Serializable; public class RemoveRpc implements Serializable { - RouteIdentifierImpl routeId; + private final RouteIdentifierImpl routeId; + + public RemoveRpc(final RouteIdentifierImpl routeId) { + Preconditions.checkNotNull(routeId, "Route Id should not be null"); - public RemoveRpc(RouteIdentifierImpl routeId) { this.routeId = routeId; } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/RoutingTableData.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/RoutingTableData.java index 132fdba054..c57a258426 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/RoutingTableData.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/RoutingTableData.java @@ -15,11 +15,11 @@ import java.util.LinkedHashSet; import java.util.Map; public class RoutingTableData implements Serializable { - private Map, String> rpcMap; - private Map, LinkedHashSet> routedRpcMap; + private final Map, String> rpcMap; + private final Map, LinkedHashSet> routedRpcMap; - public RoutingTableData(Map, String> rpcMap, - Map, LinkedHashSet> routedRpcMap) { + public RoutingTableData(final Map, String> rpcMap, + final Map, LinkedHashSet> routedRpcMap) { this.rpcMap = rpcMap; this.routedRpcMap = routedRpcMap; } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/RpcResponse.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/RpcResponse.java index cbfecb1918..17766f15b9 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/RpcResponse.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/RpcResponse.java @@ -12,9 +12,9 @@ package org.opendaylight.controller.remote.rpc.messages; import java.io.Serializable; public class RpcResponse implements Serializable { - private String resultCompositeNode; + private final String resultCompositeNode; - public RpcResponse(String resultCompositeNode) { + public RpcResponse(final String resultCompositeNode) { this.resultCompositeNode = resultCompositeNode; } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/UpdateSchemaContext.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/UpdateSchemaContext.java new file mode 100644 index 0000000000..83fc7723b3 --- /dev/null +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/UpdateSchemaContext.java @@ -0,0 +1,24 @@ +/* + * 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.remote.rpc.messages; + +import org.opendaylight.yangtools.yang.model.api.SchemaContext; + +public class UpdateSchemaContext { + + private final SchemaContext schemaContext; + + public UpdateSchemaContext(final SchemaContext schemaContext) { + this.schemaContext = schemaContext; + } + + public SchemaContext getSchemaContext() { + return schemaContext; + } +} diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/ActorUtil.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/utils/ActorUtil.java similarity index 97% rename from opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/ActorUtil.java rename to opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/utils/ActorUtil.java index 13324f996e..8f60eabf5f 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/ActorUtil.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/utils/ActorUtil.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html * */ -package org.opendaylight.controller.remote.rpc; +package org.opendaylight.controller.remote.rpc.utils; import akka.actor.ActorRef; import akka.actor.ActorSelection; diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/utils/InstanceIdentifierForXmlCodec.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/utils/InstanceIdentifierForXmlCodec.java new file mode 100644 index 0000000000..92a7fbae79 --- /dev/null +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/utils/InstanceIdentifierForXmlCodec.java @@ -0,0 +1,219 @@ +/* + * 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.remote.rpc.utils; + +import com.google.common.base.Preconditions; +import com.google.common.base.Splitter; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.model.api.Module; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.w3c.dom.Element; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public final class InstanceIdentifierForXmlCodec { + private static final Pattern PREDICATE_PATTERN = Pattern.compile("\\[(.*?)\\]"); + private static final Splitter SLASH_SPLITTER = Splitter.on('/'); + private static final Splitter COLON_SPLITTER = Splitter.on(':'); + private static final Splitter AT_SPLITTER = Splitter.on('@'); + private static final Logger logger = LoggerFactory.getLogger(InstanceIdentifierForXmlCodec.class); + + private InstanceIdentifierForXmlCodec() { + throw new UnsupportedOperationException("Utility class"); + } + + public static YangInstanceIdentifier deserialize(final Element element, final SchemaContext schemaContext) { + Preconditions.checkNotNull(element, "Value of element for deserialization can't be null"); + Preconditions.checkNotNull(schemaContext, + "Schema context for deserialization of instance identifier type can't be null"); + + final String valueTrimmed = element.getTextContent().trim(); + logger.debug("Instance identifier derserialize: splitting the text {} with Slash to find path arguments", valueTrimmed); + final Iterator xPathParts = SLASH_SPLITTER.split(valueTrimmed).iterator(); + + // must be at least "/pr:node" + if (!xPathParts.hasNext() || !xPathParts.next().isEmpty() || !xPathParts.hasNext()) { + logger.debug("Instance identifier derserialize: No path argument found for element."); + return null; + } + + List result = new ArrayList<>(); + while (xPathParts.hasNext()) { + String xPathPartTrimmed = xPathParts.next().trim(); + + PathArgument pathArgument = toPathArgument(xPathPartTrimmed, element, schemaContext); + if (pathArgument != null) { + result.add(pathArgument); + } + } + return YangInstanceIdentifier.create(result); + } + + public static Element serialize(final YangInstanceIdentifier id, final Element element) { + Preconditions.checkNotNull(id, "Variable should contain instance of instance identifier and can't be null"); + Preconditions.checkNotNull(element, "DOM element can't be null"); + + final RandomPrefix prefixes = new RandomPrefix(); + final String str = XmlUtils.encodeIdentifier(prefixes, id); + + for (Entry e: prefixes.getPrefixes()) { + element.setAttribute("xmlns:" + e.getValue(), e.getKey().toString()); + } + element.setTextContent(str); + return element; + } + + private static String getIdAndPrefixAsStr(final String pathPart) { + int predicateStartIndex = pathPart.indexOf('['); + return predicateStartIndex == -1 ? pathPart : pathPart.substring(0, predicateStartIndex); + } + + private static PathArgument toPathArgument(final String xPathArgument, final Element element, final SchemaContext schemaContext) { + final QName mainQName = toIdentity(xPathArgument, element, schemaContext); + + // predicates + final Matcher matcher = PREDICATE_PATTERN.matcher(xPathArgument); + final Map predicates = new HashMap<>(); + QName currentQName = mainQName; + + while (matcher.find()) { + final String predicateStr = matcher.group(1).trim(); + final int indexOfEqualityMark = predicateStr.indexOf('='); + if (indexOfEqualityMark != -1) { + final Object predicateValue = toPredicateValue(predicateStr.substring(indexOfEqualityMark + 1)); + if (predicateValue == null) { + return null; + } + + if (predicateStr.charAt(0) != '.') { + // target is not a leaf-list + currentQName = toIdentity(predicateStr.substring(0, indexOfEqualityMark), element, schemaContext); + if (currentQName == null) { + return null; + } + } + logger.debug("Instance identifier derserialize: finding predicates of node {}", predicateValue); + predicates.put(currentQName, predicateValue); + } + } + + if (predicates.isEmpty()) { + return new YangInstanceIdentifier.NodeIdentifier(mainQName); + } else { + return new YangInstanceIdentifier.NodeIdentifierWithPredicates(mainQName, predicates); + } + + } + + public static QName toIdentity(final String xPathArgument, final Element element, final SchemaContext schemaContext) { + final String xPathPartTrimmed = getIdAndPrefixAsStr(xPathArgument).trim(); + final Iterator it = COLON_SPLITTER.split(xPathPartTrimmed).iterator(); + + // Empty string + if (!it.hasNext()) { + return null; + } + + final String prefix = it.next().trim(); + if (prefix.isEmpty()) { + return null; + } + + // it is not "prefix:value" + if (!it.hasNext()) { + return null; + } + + final String identifier = it.next().trim(); + if (identifier.isEmpty()) { + return null; + } + + URI namespace = null; + String namespaceStr = null; + try { + namespaceStr = element.getAttribute("xmlns:"+prefix); + namespace = new URI(namespaceStr); + } catch (URISyntaxException e) { + throw new IllegalArgumentException("It wasn't possible to convert " + namespaceStr + " to URI object."); + } catch (NullPointerException e) { + throw new IllegalArgumentException("I wasn't possible to get namespace for prefix " + prefix); + } + + Module module = schemaContext.findModuleByNamespaceAndRevision(namespace, null); + return QName.create(module.getQNameModule(), identifier); + } + + private static String trimIfEndIs(final String str, final char end) { + final int l = str.length() - 1; + if (str.charAt(l) != end) { + return null; + } + + return str.substring(1, l); + } + + private static Object toPredicateValue(final String predicatedValue) { + logger.debug("Instance identifier derserialize: converting the predicate vstring to object {}", predicatedValue); + final String predicatedValueTrimmed = predicatedValue.trim(); + if (predicatedValue.isEmpty()) { + return null; + } + String updatedValue = null; + switch (predicatedValueTrimmed.charAt(0)) { + case '"': + updatedValue = trimIfEndIs(predicatedValueTrimmed, '"'); + break; + case '\'': + updatedValue = trimIfEndIs(predicatedValueTrimmed, '\''); + break; + default: + updatedValue = predicatedValueTrimmed; + } + Iterator it = AT_SPLITTER.split(updatedValue).iterator(); + // Empty string + if (!it.hasNext()) { + return null; + } + + final String value = it.next().trim(); + if (value.isEmpty()) { + return null; + } + + if (!it.hasNext()) { + return value; + } + + final String type = it.next().trim(); + if (type.isEmpty()) { + return value; + } + Object predicateObject = null; + try { + logger.debug("Instance identifier derserialize: converting the predicate value {{}}to correct object type {{}}", value, type); + predicateObject = Class.forName(type).getConstructor(String.class).newInstance(value); + } catch (Exception e) { + logger.error("Could not convert to valid type of value", e); + } + return predicateObject; + } +} diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/utils/RandomPrefix.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/utils/RandomPrefix.java new file mode 100644 index 0000000000..55cc8192a8 --- /dev/null +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/utils/RandomPrefix.java @@ -0,0 +1,50 @@ +/* + * 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.remote.rpc.utils; + +import org.opendaylight.yangtools.yang.common.QName; + +import java.net.URI; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.ThreadLocalRandom; + +/** + * Picked from Yang tools because it was not public class + */ + +final class RandomPrefix { + final Map prefixes = new HashMap<>(); + + Iterable> getPrefixes() { + return prefixes.entrySet(); + } + + String encodeQName(final QName qname) { + String prefix = prefixes.get(qname.getNamespace()); + if (prefix == null) { + prefix = qname.getPrefix(); + if (prefix == null || prefix.isEmpty() || prefixes.containsValue(prefix)) { + final ThreadLocalRandom random = ThreadLocalRandom.current(); + do { + final StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 4; i++) { + sb.append((char)('a' + random.nextInt(25))); + } + + prefix = sb.toString(); + } while (prefixes.containsValue(prefix)); + } + + prefixes.put(qname.getNamespace(), prefix); + } + + return prefix + ':' + qname.getLocalName(); + } +} diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/utils/XmlDocumentUtils.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/utils/XmlDocumentUtils.java new file mode 100644 index 0000000000..127aa0732b --- /dev/null +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/utils/XmlDocumentUtils.java @@ -0,0 +1,311 @@ +/* + * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.remote.rpc.utils; + +import com.google.common.base.Function; +import com.google.common.base.Objects; +import com.google.common.base.Optional; +import com.google.common.base.Preconditions; +import com.google.common.base.Strings; +import com.google.common.collect.ImmutableList; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.CompositeNode; +import org.opendaylight.yangtools.yang.data.api.ModifyAction; +import org.opendaylight.yangtools.yang.data.api.Node; +import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode; +import org.opendaylight.yangtools.yang.data.impl.SimpleNodeTOImpl; +import org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec; +import org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlCodecProvider; +import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode; +import org.opendaylight.yangtools.yang.model.api.ChoiceNode; +import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; +import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; +import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; +import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; +import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; +import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.SchemaNode; +import org.opendaylight.yangtools.yang.model.api.TypeDefinition; +import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.w3c.dom.Attr; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +import javax.activation.UnsupportedDataTypeException; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; +import javax.xml.transform.dom.DOMResult; +import java.net.URI; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import static com.google.common.base.Preconditions.checkState; + +public class XmlDocumentUtils { + private static class ElementWithSchemaContext { + Element element; + SchemaContext schemaContext; + + ElementWithSchemaContext(final Element element,final SchemaContext schemaContext) { + this.schemaContext = schemaContext; + this.element = element; + } + + Element getElement() { + return element; + } + + SchemaContext getSchemaContext() { + return schemaContext; + } + } + + public static final QName OPERATION_ATTRIBUTE_QNAME = QName.create(URI.create("urn:ietf:params:xml:ns:netconf:base:1.0"), null, "operation"); + private static final Logger logger = LoggerFactory.getLogger(XmlDocumentUtils.class); + private static final XMLOutputFactory FACTORY = XMLOutputFactory.newFactory(); + + /** + * Converts Data DOM structure to XML Document for specified XML Codec Provider and corresponding + * Data Node Container schema. The CompositeNode data parameter enters as root of Data DOM tree and will + * be transformed to root in XML Document. Each element of Data DOM tree is compared against specified Data + * Node Container Schema and transformed accordingly. + * + * @param data Data DOM root element + * @param schema Data Node Container Schema + * @param codecProvider XML Codec Provider + * @return new instance of XML Document + * @throws javax.activation.UnsupportedDataTypeException + */ + public static Document toDocument(final CompositeNode data, final DataNodeContainer schema, final XmlCodecProvider codecProvider) + throws UnsupportedDataTypeException { + Preconditions.checkNotNull(data); + Preconditions.checkNotNull(schema); + + if (!(schema instanceof ContainerSchemaNode || schema instanceof ListSchemaNode)) { + throw new UnsupportedDataTypeException("Schema can be ContainerSchemaNode or ListSchemaNode. Other types are not supported yet."); + } + + final DOMResult result = new DOMResult(getDocument()); + try { + final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(result); + XmlStreamUtils.create(codecProvider).writeDocument(writer, data, (SchemaNode)schema); + writer.close(); + return (Document)result.getNode(); + } catch (XMLStreamException e) { + logger.error("Failed to serialize data {}", data, e); + return null; + } + } + + public static Document getDocument() { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + Document doc = null; + try { + DocumentBuilder bob = dbf.newDocumentBuilder(); + doc = bob.newDocument(); + } catch (ParserConfigurationException e) { + throw new RuntimeException(e); + } + return doc; + } + + + public static QName qNameFromElement(final Element xmlElement) { + String namespace = xmlElement.getNamespaceURI(); + String localName = xmlElement.getLocalName(); + return QName.create(namespace != null ? URI.create(namespace) : null, null, localName); + } + + private static Node toNodeWithSchema(final Element xmlElement, final DataSchemaNode schema, final XmlCodecProvider codecProvider,final SchemaContext schemaCtx) { + checkQName(xmlElement, schema.getQName()); + if (schema instanceof DataNodeContainer) { + return toCompositeNodeWithSchema(xmlElement, schema.getQName(), (DataNodeContainer) schema, schemaCtx); + } else if (schema instanceof LeafSchemaNode) { + return toSimpleNodeWithType(xmlElement, (LeafSchemaNode) schema, codecProvider,schemaCtx); + } else if (schema instanceof LeafListSchemaNode) { + return toSimpleNodeWithType(xmlElement, (LeafListSchemaNode) schema, codecProvider,schemaCtx); + } + return null; + } + + + + private static Node toSimpleNodeWithType(final Element xmlElement, final LeafSchemaNode schema, + final XmlCodecProvider codecProvider,final SchemaContext schemaCtx) { + TypeDefinitionAwareCodec> codec = codecProvider.codecFor(schema.getType()); + String text = xmlElement.getTextContent(); + Object value = null; + if (codec != null) { + logger.debug("toSimpleNodeWithType: found codec, deserializing text {}", text); + value = codec.deserialize(text); + } + + final TypeDefinition baseType = XmlUtils.resolveBaseTypeFrom(schema.getType()); + if (baseType instanceof org.opendaylight.yangtools.yang.model.util.InstanceIdentifier) { + logger.debug("toSimpleNodeWithType: base type of node is instance identifier, deserializing element", xmlElement); + value = InstanceIdentifierForXmlCodec.deserialize(xmlElement,schemaCtx); + + } else if(baseType instanceof IdentityrefTypeDefinition){ + logger.debug("toSimpleNodeWithType: base type of node is IdentityrefTypeDefinition, deserializing element", xmlElement); + value = InstanceIdentifierForXmlCodec.toIdentity(xmlElement.getTextContent(), xmlElement, schemaCtx); + + } + + if (value == null) { + logger.debug("toSimpleNodeWithType: no type found for element, returning just the text string value of element {}", xmlElement); + value = xmlElement.getTextContent(); + } + + Optional modifyAction = getModifyOperationFromAttributes(xmlElement); + return new SimpleNodeTOImpl<>(schema.getQName(), null, value, modifyAction.orNull()); + } + + private static Node toSimpleNodeWithType(final Element xmlElement, final LeafListSchemaNode schema, + final XmlCodecProvider codecProvider,final SchemaContext schemaCtx) { + TypeDefinitionAwareCodec> codec = codecProvider.codecFor(schema.getType()); + String text = xmlElement.getTextContent(); + Object value = null; + if (codec != null) { + logger.debug("toSimpleNodeWithType: found codec, deserializing text {}", text); + value = codec.deserialize(text); + } + + if (schema.getType() instanceof org.opendaylight.yangtools.yang.model.util.InstanceIdentifier) { + logger.debug("toSimpleNodeWithType: base type of node is instance identifier, deserializing element", xmlElement); + value = InstanceIdentifierForXmlCodec.deserialize(xmlElement,schemaCtx); + } + + if (value == null) { + logger.debug("toSimpleNodeWithType: no type found for element, returning just the text string value of element {}", xmlElement); + value = xmlElement.getTextContent(); + } + + Optional modifyAction = getModifyOperationFromAttributes(xmlElement); + return new SimpleNodeTOImpl<>(schema.getQName(), null, value, modifyAction.orNull()); + } + + private static Node toCompositeNodeWithSchema(final Element xmlElement, final QName qName, final DataNodeContainer schema, + final SchemaContext schemaCtx) { + List> values = toDomNodes(xmlElement, Optional.fromNullable(schema.getChildNodes()),schemaCtx); + Optional modifyAction = getModifyOperationFromAttributes(xmlElement); + return ImmutableCompositeNode.create(qName, values, modifyAction.orNull()); + } + + private static Optional getModifyOperationFromAttributes(final Element xmlElement) { + Attr attributeNodeNS = xmlElement.getAttributeNodeNS(OPERATION_ATTRIBUTE_QNAME.getNamespace().toString(), OPERATION_ATTRIBUTE_QNAME.getLocalName()); + if(attributeNodeNS == null) { + return Optional.absent(); + } + + ModifyAction action = ModifyAction.fromXmlValue(attributeNodeNS.getValue()); + Preconditions.checkArgument(action.isOnElementPermitted(), "Unexpected operation %s on %s", action, xmlElement); + + return Optional.of(action); + } + + private static void checkQName(final Element xmlElement, final QName qName) { + checkState(Objects.equal(xmlElement.getNamespaceURI(), qName.getNamespace().toString())); + checkState(qName.getLocalName().equals(xmlElement.getLocalName())); + } + + public static final Optional findFirstSchema(final QName qname, final Collection dataSchemaNode) { + if (dataSchemaNode != null && !dataSchemaNode.isEmpty() && qname != null) { + for (DataSchemaNode dsn : dataSchemaNode) { + if (qname.isEqualWithoutRevision(dsn.getQName())) { + return Optional. of(dsn); + } else if (dsn instanceof ChoiceNode) { + for (ChoiceCaseNode choiceCase : ((ChoiceNode) dsn).getCases()) { + Optional foundDsn = findFirstSchema(qname, choiceCase.getChildNodes()); + if (foundDsn != null && foundDsn.isPresent()) { + return foundDsn; + } + } + } + } + } + return Optional.absent(); + } + + private static Node toDomNode(Element element) { + QName qname = qNameFromElement(element); + + ImmutableList.Builder> values = ImmutableList.> builder(); + NodeList nodes = element.getChildNodes(); + boolean isSimpleObject = true; + String value = null; + for (int i = 0; i < nodes.getLength(); i++) { + org.w3c.dom.Node child = nodes.item(i); + if (child instanceof Element) { + isSimpleObject = false; + values.add(toDomNode((Element) child)); + } + if (isSimpleObject && child instanceof org.w3c.dom.Text) { + value = element.getTextContent(); + if (!Strings.isNullOrEmpty(value)) { + isSimpleObject = true; + } + } + } + if (isSimpleObject) { + return new SimpleNodeTOImpl<>(qname, null, value); + } + return ImmutableCompositeNode.create(qname, values.build()); + } + + public static List> toDomNodes(final Element element, final Optional> context,SchemaContext schemaCtx) { + return forEachChild(element.getChildNodes(),schemaCtx, new Function>>() { + + @Override + public Optional> apply(ElementWithSchemaContext input) { + if (context.isPresent()) { + QName partialQName = qNameFromElement(input.getElement()); + Optional schemaNode = XmlDocumentUtils.findFirstSchema(partialQName, context.get()); + if (schemaNode.isPresent()) { + return Optional.> fromNullable(// + toNodeWithSchema(input.getElement(), schemaNode.get(), XmlDocumentUtils.defaultValueCodecProvider(),input.getSchemaContext())); + } + } + return Optional.> fromNullable(toDomNode(input.getElement())); + } + + }); + + } + + private static final List forEachChild(final NodeList nodes, final SchemaContext schemaContext, final Function> forBody) { + final int l = nodes.getLength(); + if (l == 0) { + return ImmutableList.of(); + } + + final List list = new ArrayList<>(l); + for (int i = 0; i < l; i++) { + org.w3c.dom.Node child = nodes.item(i); + if (child instanceof Element) { + Optional result = forBody.apply(new ElementWithSchemaContext((Element) child,schemaContext)); + if (result.isPresent()) { + list.add(result.get()); + } + } + } + return ImmutableList.copyOf(list); + } + + public static final XmlCodecProvider defaultValueCodecProvider() { + return XmlUtils.DEFAULT_XML_CODEC_PROVIDER; + } +} diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/utils/XmlStreamUtils.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/utils/XmlStreamUtils.java new file mode 100644 index 0000000000..e4576c445b --- /dev/null +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/utils/XmlStreamUtils.java @@ -0,0 +1,249 @@ +/* + * 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.remote.rpc.utils; + +import com.google.common.annotations.Beta; +import com.google.common.base.Preconditions; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.AttributesContainer; +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.impl.codec.TypeDefinitionAwareCodec; +import org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlCodecProvider; +import org.opendaylight.yangtools.yang.data.impl.schema.SchemaUtils; +import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; +import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; +import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; +import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; +import org.opendaylight.yangtools.yang.model.api.SchemaNode; +import org.opendaylight.yangtools.yang.model.api.TypeDefinition; +import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition; +import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; +import java.net.URI; +import java.util.Map.Entry; + +/** + * Utility class for bridging JAXP Stream and YANG Data APIs. Note that the definition of this class + * by no means final and subject to change as more functionality is centralized here. + */ +@Beta +public class XmlStreamUtils { + private static final Logger LOG = LoggerFactory.getLogger(XmlStreamUtils.class); + private final XmlCodecProvider codecProvider; + + protected XmlStreamUtils(final XmlCodecProvider codecProvider) { + this.codecProvider = Preconditions.checkNotNull(codecProvider); + } + + /** + * Create a new instance encapsulating a particular codec provider. + * + * @param codecProvider XML codec provider + * @return A new instance + */ + public static XmlStreamUtils create(final XmlCodecProvider codecProvider) { + return new XmlStreamUtils(codecProvider); + } + + /** + * Check if a particular data element can be emitted as an empty element, bypassing value encoding. This + * functionality is optional, as valid XML stream is produced even if start/end element is produced unconditionally. + * + * @param data Data node + * @return True if the data node will result in empty element body. + */ + public static boolean isEmptyElement(final Node data) { + if (data == null) { + return true; + } + + if (data instanceof CompositeNode) { + return ((CompositeNode) data).getValue().isEmpty(); + } + if (data instanceof SimpleNode) { + return data.getValue() == null; + } + + // Safe default + return false; + } + + /** + * Write an InstanceIdentifier into the output stream. Calling corresponding {@link javax.xml.stream.XMLStreamWriter#writeStartElement(String)} + * and {@link javax.xml.stream.XMLStreamWriter#writeEndElement()} is the responsibility of the caller. + * + * @param writer XML Stream writer + * @param id InstanceIdentifier + * @throws javax.xml.stream.XMLStreamException + */ + public static void write(final @Nonnull XMLStreamWriter writer, final @Nonnull YangInstanceIdentifier id) throws XMLStreamException { + Preconditions.checkNotNull(writer, "Writer may not be null"); + Preconditions.checkNotNull(id, "Variable should contain instance of instance identifier and can't be null"); + LOG.debug("Writing Instance identifier with Random prefix"); + final RandomPrefix prefixes = new RandomPrefix(); + final String str = XmlUtils.encodeIdentifier(prefixes, id); + + for (Entry e: prefixes.getPrefixes()) { + writer.writeNamespace(e.getValue(), e.getKey().toString()); + } + LOG.debug("Instance identifier with Random prefix is now {}", str); + writer.writeCharacters(str); + } + + /** + * Write a full XML document corresponding to a CompositeNode into an XML stream writer. + * + * @param writer XML Stream writer + * @param data data node + * @param schema corresponding schema node, may be null + * @throws javax.xml.stream.XMLStreamException if an encoding problem occurs + */ + public void writeDocument(final @Nonnull XMLStreamWriter writer, final @Nonnull CompositeNode data, final @Nullable SchemaNode schema) throws XMLStreamException { + // final Boolean repairing = (Boolean) writer.getProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES); + // Preconditions.checkArgument(repairing == true, "XML Stream Writer has to be repairing namespaces"); + + writer.writeStartDocument(); + writeElement(writer, data, schema); + writer.writeEndDocument(); + writer.flush(); + } + + + /** + * Write an element into a XML stream writer. This includes the element start/end tags and + * the value of the element. + * + * @param writer XML Stream writer + * @param data data node + * @param schema Schema node + * @throws javax.xml.stream.XMLStreamException if an encoding problem occurs + */ + public void writeElement(final XMLStreamWriter writer, final @Nonnull Node data, final SchemaNode schema) throws XMLStreamException { + final QName qname = data.getNodeType(); + final String pfx = qname.getPrefix() != null ? qname.getPrefix() : ""; + final String ns = qname.getNamespace() != null ? qname.getNamespace().toString() : ""; + + if (isEmptyElement(data)) { + writer.writeEmptyElement(pfx, qname.getLocalName(), ns); + return; + } + + writer.writeStartElement(pfx, qname.getLocalName(), ns); + if (data instanceof AttributesContainer && ((AttributesContainer) data).getAttributes() != null) { + for (Entry attribute : ((AttributesContainer) data).getAttributes().entrySet()) { + writer.writeAttribute(attribute.getKey().getNamespace().toString(), attribute.getKey().getLocalName(), attribute.getValue()); + } + } + + if (data instanceof SimpleNode) { + LOG.debug("writeElement : node is of type SimpleNode"); + // Simple node + if (schema instanceof LeafListSchemaNode) { + writeValue(writer, ((LeafListSchemaNode) schema).getType(), data.getValue()); + } else if (schema instanceof LeafSchemaNode) { + writeValue(writer, ((LeafSchemaNode) schema).getType(), data.getValue()); + } else { + Object value = data.getValue(); + if (value != null) { + writer.writeCharacters(String.valueOf(value)); + } + } + } else { + LOG.debug("writeElement : node is of type CompositeNode"); + // CompositeNode + for (Node child : ((CompositeNode) data).getValue()) { + DataSchemaNode childSchema = null; + if (schema instanceof DataNodeContainer) { + childSchema = SchemaUtils.findFirstSchema(child.getNodeType(), ((DataNodeContainer) schema).getChildNodes()).orNull(); + if (childSchema == null) { + LOG.debug("Probably the data node \"{}\" does not conform to schema", child == null ? "" : child.getNodeType().getLocalName()); + } + } + + writeElement(writer, child, childSchema); + } + } + + writer.writeEndElement(); + } + + /** + * Write a value into a XML stream writer. This method assumes the start and end of element is + * emitted by the caller. + * + * @param writer XML Stream writer + * @param type type definitions + * @param value object value + * @throws javax.xml.stream.XMLStreamException if an encoding problem occurs + */ + public void writeValue(final @Nonnull XMLStreamWriter writer, final @Nonnull TypeDefinition type, final Object value) throws XMLStreamException { + if (value == null) { + LOG.debug("Value of {}:{} is null, not encoding it", type.getQName().getNamespace(), type.getQName().getLocalName()); + return; + } + + final TypeDefinition baseType = XmlUtils.resolveBaseTypeFrom(type); + if (baseType instanceof IdentityrefTypeDefinition) { + write(writer, (IdentityrefTypeDefinition) baseType, value); + } else if (baseType instanceof InstanceIdentifierTypeDefinition) { + write(writer, (InstanceIdentifierTypeDefinition) baseType, value); + } else { + final TypeDefinitionAwareCodec codec = codecProvider.codecFor(baseType); + String text; + if (codec != null) { + try { + text = codec.serialize(value); + } catch (ClassCastException e) { + LOG.error("Provided node value {} did not have type {} required by mapping. Using stream instead.", value, baseType, e); + text = String.valueOf(value); + } + } else { + LOG.error("Failed to find codec for {}, falling back to using stream", baseType); + text = String.valueOf(value); + } + writer.writeCharacters(text); + } + } + + private static void write(final @Nonnull XMLStreamWriter writer, final @Nonnull IdentityrefTypeDefinition type, final @Nonnull Object value) throws XMLStreamException { + if (value instanceof QName) { + final QName qname = (QName) value; + final String prefix; + if (qname.getPrefix() != null && !qname.getPrefix().isEmpty()) { + prefix = qname.getPrefix(); + } else { + prefix = "x"; + } + + writer.writeNamespace(prefix, qname.getNamespace().toString()); + writer.writeCharacters(prefix + ':' + qname.getLocalName()); + } else { + LOG.debug("Value of {}:{} is not a QName but {}", type.getQName().getNamespace(), type.getQName().getLocalName(), value.getClass()); + writer.writeCharacters(String.valueOf(value)); + } + } + + private static void write(final @Nonnull XMLStreamWriter writer, final @Nonnull InstanceIdentifierTypeDefinition type, final @Nonnull Object value) throws XMLStreamException { + if (value instanceof YangInstanceIdentifier) { + LOG.debug("Writing InstanceIdentifier object {}", value); + write(writer, (YangInstanceIdentifier)value); + } else { + LOG.debug("Value of {}:{} is not an InstanceIdentifier but {}", type.getQName().getNamespace(), type.getQName().getLocalName(), value.getClass()); + writer.writeCharacters(String.valueOf(value)); + } + } +} diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/utils/XmlUtils.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/utils/XmlUtils.java new file mode 100644 index 0000000000..e07401a3e0 --- /dev/null +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/utils/XmlUtils.java @@ -0,0 +1,281 @@ +/* + * 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.remote.rpc.utils; + +import com.google.common.base.Optional; +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.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.YangInstanceIdentifier.NodeIdentifierWithPredicates; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode; +import org.opendaylight.yangtools.yang.data.impl.XmlTreeBuilder; +import org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec; +import org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlCodecProvider; +import org.opendaylight.yangtools.yang.data.impl.util.CompositeNodeBuilder; +import org.opendaylight.yangtools.yang.model.api.RpcDefinition; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.TypeDefinition; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +import javax.activation.UnsupportedDataTypeException; +import javax.annotation.Nonnull; +import javax.xml.stream.XMLStreamException; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.StringWriter; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * Common XML-related utility methods, which are not specific to a particular + * JAXP API. + */ +public class XmlUtils { + + public static final XmlCodecProvider DEFAULT_XML_CODEC_PROVIDER = new XmlCodecProvider() { + @Override + public TypeDefinitionAwareCodec> codecFor(final TypeDefinition baseType) { + return TypeDefinitionAwareCodec.from(baseType); + } + }; + + private XmlUtils() { + } + + private static final String BLANK = ""; + private static final Logger LOG = LoggerFactory.getLogger(XmlUtils.class); + + /** + * Converts the composite node to xml using rpc input schema node + * @param cNode + * @param schemaContext + * @return xml String + */ + public static String inputCompositeNodeToXml(CompositeNode cNode, SchemaContext schemaContext){ + LOG.debug("Converting input composite node to xml {}", cNode); + if (cNode == null) return BLANK; + + if(schemaContext == null) return BLANK; + + Document domTree = null; + try { + Set rpcs = schemaContext.getOperations(); + for(RpcDefinition rpc : rpcs) { + if(rpc.getQName().equals(cNode.getNodeType())){ + LOG.debug("Found the rpc definition from schema context matching with input composite node {}", rpc.getQName()); + + CompositeNode inputContainer = cNode.getFirstCompositeByName(QName.create(cNode.getNodeType(), "input")); + domTree = XmlDocumentUtils.toDocument(inputContainer, rpc.getInput(), XmlDocumentUtils.defaultValueCodecProvider()); + + LOG.debug("input composite node to document conversion complete, document is {}", domTree); + break; + } + } + + } catch (UnsupportedDataTypeException e) { + LOG.error("Error during translation of CompositeNode to Document", e); + } + return domTransformer(domTree); + } + + /** + * Converts the composite node to xml String using rpc output schema node + * @param cNode + * @param schemaContext + * @return xml string + */ + public static String outputCompositeNodeToXml(CompositeNode cNode, SchemaContext schemaContext){ + LOG.debug("Converting output composite node to xml {}", cNode); + if (cNode == null) return BLANK; + + if(schemaContext == null) return BLANK; + + Document domTree = null; + try { + Set rpcs = schemaContext.getOperations(); + for(RpcDefinition rpc : rpcs) { + if(rpc.getQName().equals(cNode.getNodeType())){ + LOG.debug("Found the rpc definition from schema context matching with output composite node {}", rpc.getQName()); + + CompositeNode outputContainer = cNode.getFirstCompositeByName(QName.create(cNode.getNodeType(), "output")); + domTree = XmlDocumentUtils.toDocument(outputContainer, rpc.getOutput(), XmlDocumentUtils.defaultValueCodecProvider()); + + LOG.debug("output composite node to document conversion complete, document is {}", domTree); + break; + } + } + + } catch (UnsupportedDataTypeException e) { + LOG.error("Error during translation of CompositeNode to Document", e); + } + return domTransformer(domTree); + } + + private static String domTransformer(Document domTree) { + StringWriter writer = new StringWriter(); + try { + TransformerFactory tf = TransformerFactory.newInstance(); + Transformer transformer = tf.newTransformer(); + transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); + transformer.transform(new DOMSource(domTree), new StreamResult(writer)); + } catch (TransformerException e) { + + LOG.error("Error during translation of Document to OutputStream", e); + } + LOG.debug("Document to string conversion complete, xml string is {} ", writer.toString()); + + return writer.toString(); + } + + public static CompositeNode xmlToCompositeNode(String xml){ + if (xml==null || xml.length()==0) return null; + + Node dataTree; + try { + dataTree = XmlTreeBuilder.buildDataTree(new ByteArrayInputStream(xml.getBytes())); + } catch (XMLStreamException e) { + LOG.error("Error during building data tree from XML", e); + return null; + } + if (dataTree == null) { + LOG.error("data tree is null"); + return null; + } + if (dataTree instanceof SimpleNode) { + LOG.error("RPC XML was resolved as SimpleNode"); + return null; + } + return (CompositeNode) dataTree; + } + + /** + * Converts the xml to composite node using rpc input schema node + * @param rpc + * @param xml + * @param schemaContext + * @return CompositeNode object based on the input, if any of the input parameter is null, a null object is returned + */ + public static CompositeNode inputXmlToCompositeNode(QName rpc, String xml, SchemaContext schemaContext){ + LOG.debug("Converting input xml to composite node {}", xml); + if (xml==null || xml.length()==0) return null; + + if(rpc == null) return null; + + if(schemaContext == null) return null; + + CompositeNode compositeNode = null; + try { + + Document doc = XmlUtil.readXmlToDocument(xml); + Set rpcs = schemaContext.getOperations(); + for(RpcDefinition rpcDef : rpcs) { + if(rpcDef.getQName().equals(rpc)){ + LOG.debug("found the rpc definition from schema context matching rpc {}", rpc); + + if(rpcDef.getInput() == null) { + LOG.warn("found rpc definition's input is null"); + return null; + } + + QName input = rpcDef.getInput().getQName(); + NodeList nodeList = doc.getElementsByTagNameNS(input.getNamespace().toString(), "input"); + if(nodeList == null || nodeList.getLength() < 1) { + LOG.warn("xml does not have input entry. {}", xml); + return null; + } + Element xmlData = (Element)nodeList.item(0); + + List> dataNodes = XmlDocumentUtils.toDomNodes(xmlData, + Optional.of(rpcDef.getInput().getChildNodes()), schemaContext); + + LOG.debug("Converted xml input to list of nodes {}", dataNodes); + + final CompositeNodeBuilder it = ImmutableCompositeNode.builder(); + it.setQName(input); + it.add(ImmutableCompositeNode.create(input, dataNodes)); + compositeNode = it.toInstance(); + break; + } + } + } catch (SAXException e) { + LOG.error("Error during building data tree from XML", e); + } catch (IOException e) { + LOG.error("Error during building data tree from XML", e); + } + + LOG.debug("Xml to composite node conversion complete {} ", compositeNode); + return compositeNode; + } + + public static TypeDefinition resolveBaseTypeFrom(final @Nonnull TypeDefinition type) { + TypeDefinition superType = type; + while (superType.getBaseType() != null) { + superType = superType.getBaseType(); + } + return superType; + } + + /** + * This code is picked from yangtools and modified to add type of instance identifier + * output of instance identifier something like below for a flow ref composite node of type instance identifier, + * which has path arguments with predicates, whose value is of type java.lang.short + * + * /jdlk:nodes/jdlk:node[jdlk:id='openflow:205558455098190@java.lang.String'] + * /bgkj:table[bgkj:id='3@java.lang.Short'] + * /bgkj:flow[bgkj:id='156@java.lang.String'] + * + * + */ + + public static String encodeIdentifier(final RandomPrefix prefixes, final YangInstanceIdentifier id) { + StringBuilder textContent = new StringBuilder(); + for (PathArgument pathArgument : id.getPathArguments()) { + textContent.append('/'); + textContent.append(prefixes.encodeQName(pathArgument.getNodeType())); + if (pathArgument instanceof NodeIdentifierWithPredicates) { + Map predicates = ((NodeIdentifierWithPredicates) pathArgument).getKeyValues(); + + for (QName keyValue : predicates.keySet()) { + Object value = predicates.get(keyValue); + String type = value.getClass().getName(); + String predicateValue = String.valueOf(value); + textContent.append('['); + textContent.append(prefixes.encodeQName(keyValue)); + textContent.append("='"); + textContent.append(predicateValue); + textContent.append("@"); + textContent.append(type); + textContent.append("']"); + } + } else if (pathArgument instanceof NodeWithValue) { + textContent.append("[.='"); + textContent.append(((NodeWithValue) pathArgument).getValue()); + textContent.append("']"); + } + } + + return textContent.toString(); + } +} 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 9585e9ffb6..6088dd0e0e 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 @@ -7,7 +7,7 @@ odl-cluster{ remote { log-remote-lifecycle-events = off netty.tcp { - hostname = "192.168.141.142" + hostname = "192.168.141.141" port = 2551 } } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RpcBrokerTest.java b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RpcBrokerTest.java index 595d8331eb..392c1e637d 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RpcBrokerTest.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RpcBrokerTest.java @@ -35,6 +35,7 @@ import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.data.api.CompositeNode; import org.opendaylight.yangtools.yang.data.api.ModifyAction; import org.opendaylight.yangtools.yang.data.api.Node; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode; import org.opendaylight.yangtools.yang.model.api.SchemaContext; @@ -72,15 +73,16 @@ public class RpcBrokerTest { Broker.ProviderSession brokerSession = Mockito.mock(Broker.ProviderSession.class); SchemaContext schemaContext = mock(SchemaContext.class); ActorRef rpcBroker = system.actorOf(RpcBroker.props(brokerSession, rpcRegistry, schemaContext)); - QName rpc = new QName(new URI("actor1"), "actor1"); - InvokeRpc invokeMsg = new InvokeRpc(rpc, null); + QName rpc = new QName(new URI("noactor1"), "noactor1"); + CompositeNode input = new ImmutableCompositeNode(QName.create("ns", "2013-12-09", "no child"), new ArrayList>(), ModifyAction.REPLACE); + InvokeRpc invokeMsg = new InvokeRpc(rpc, input); rpcBroker.tell(invokeMsg, getRef()); Boolean getMsg = new ExpectMsg("ErrorResponse") { protected Boolean match(Object in) { if (in instanceof ErrorResponse) { ErrorResponse reply = (ErrorResponse)in; - return "No remote actor found for rpc execution.".equals(reply.getException().getMessage()); + return reply.getException().getMessage().contains("No remote actor found for rpc execution of :"); } else { throw noMatch(); } @@ -144,7 +146,8 @@ public class RpcBrokerTest { SchemaContext schemaContext = mock(SchemaContext.class); ActorRef rpcBroker = system.actorOf(RpcBroker.props(brokerSession, rpcRegistry, schemaContext)); QName rpc = new QName(new URI("actor1"), "actor1"); - InvokeRoutedRpc invokeMsg = new InvokeRoutedRpc(rpc, null); + CompositeNode input = new ImmutableCompositeNode(QName.create("ns", "2013-12-09", "child1"), new ArrayList>(), ModifyAction.REPLACE); + InvokeRoutedRpc invokeMsg = new InvokeRoutedRpc(rpc, YangInstanceIdentifier.create(new YangInstanceIdentifier.NodeIdentifier(rpc)), input); rpcBroker.tell(invokeMsg, getRef()); Boolean getMsg = new ExpectMsg("ErrorResponse") { @@ -176,7 +179,8 @@ public class RpcBrokerTest { ActorRef rpcBrokerRemote = system.actorOf(RpcBroker.props(brokerSession, rpcRegistry, schemaContext), "actor2"); // Add Routed RPC in table QName rpc = new QName(new URI("actor2"), "actor2"); - RouteIdentifierImpl routeId = new RouteIdentifierImpl(null, rpc, null); + YangInstanceIdentifier identifier = YangInstanceIdentifier.create(new YangInstanceIdentifier.NodeIdentifier(rpc)); + RouteIdentifierImpl routeId = new RouteIdentifierImpl(null, rpc, identifier); final String route = rpcBrokerRemote.path().toString(); Set> routeIds = new HashSet<>(); routeIds.add(routeId); @@ -192,7 +196,7 @@ public class RpcBrokerTest { RpcResult result = Rpcs.getRpcResult(true, invokeRpcResult, errors); Future> rpcResult = Futures.immediateFuture(result); when(brokerSession.rpc(rpc, input)).thenReturn(rpcResult); - InvokeRoutedRpc invokeMsg = new InvokeRoutedRpc(rpc, input); + InvokeRoutedRpc invokeMsg = new InvokeRoutedRpc(rpc, identifier, input); rpcBroker.tell(invokeMsg, getRef()); //verify response msg diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/RoutingTableTest.java b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/RoutingTableTest.java index a57402a793..129a5a56e8 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/RoutingTableTest.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/RoutingTableTest.java @@ -39,7 +39,8 @@ public class RoutingTableTest { @Test public void addGlobalRouteNullRouteTest() { try { - RouteIdentifierImpl routeId = new RouteIdentifierImpl(null, null, null); + QName type = new QName(new URI("actor1"), "actor1"); + RouteIdentifierImpl routeId = new RouteIdentifierImpl(null, type, null); routingTable.addGlobalRoute(routeId, null); Assert.fail("Null pointer exception was not thrown."); @@ -109,7 +110,8 @@ public class RoutingTableTest { @Test public void addRoutedRpcNullRouteTest() { try { - RouteIdentifierImpl routeId = new RouteIdentifierImpl(null, null, null); + QName type = new QName(new URI("actor1"), "actor1"); + RouteIdentifierImpl routeId = new RouteIdentifierImpl(null, type, null); routingTable.addRoutedRpc(routeId, null); diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/utils/XmlUtilsTest.java b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/utils/XmlUtilsTest.java new file mode 100644 index 0000000000..a408e1d55a --- /dev/null +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/utils/XmlUtilsTest.java @@ -0,0 +1,133 @@ +/* + * 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.remote.rpc.utils; + + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import com.google.common.io.ByteSource; +import junit.framework.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.CompositeNode; +import org.opendaylight.yangtools.yang.data.api.ModifyAction; +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.impl.ImmutableCompositeNode; +import org.opendaylight.yangtools.yang.model.api.Module; +import org.opendaylight.yangtools.yang.model.api.RpcDefinition; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl; + +import javax.xml.parsers.DocumentBuilderFactory; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + + +public class XmlUtilsTest { + + private static final DocumentBuilderFactory BUILDERFACTORY; + + static { + final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(true); + factory.setCoalescing(true); + factory.setIgnoringElementContentWhitespace(true); + factory.setIgnoringComments(true); + BUILDERFACTORY = factory; + } + + private SchemaContext schema; + private RpcDefinition testRpc; + + public static final String XML_CONTENT = "" + + "flowid" + + "/ltha:node/ltha:node1[ltha:id='3@java.lang.Short']" + + ""; + + @Before + public void setUp() throws Exception { + final ByteSource byteSource = new ByteSource() { + @Override + public InputStream openStream() throws IOException { + return XmlUtilsTest.this.getClass().getResourceAsStream("rpcTest.yang"); + } + }; + schema = new YangParserImpl().parseSources(Lists.newArrayList(byteSource)); + final Module rpcTestModule = schema.getModules().iterator().next(); + testRpc = rpcTestModule.getRpcs().iterator().next(); + } + + @Test + public void testNullInputXmlToComposite() { + CompositeNode node = XmlUtils.inputXmlToCompositeNode(testRpc.getQName(), null, schema); + Assert.assertNull(node); + } + + @Test + public void testNullRpcXmlToComposite() { + CompositeNode node = XmlUtils.inputXmlToCompositeNode(null, XML_CONTENT, schema); + Assert.assertNull(node); + } + + @Test + public void testInputXmlToCompositeNode() { + CompositeNode node = XmlUtils.inputXmlToCompositeNode(testRpc.getQName(), XML_CONTENT, schema); + ImmutableList input = (ImmutableList)node.getValue().get(0).getValue(); + SimpleNode firstNode = input.get(0); + + Assert.assertEquals("id", firstNode.getNodeType().getLocalName()); + Assert.assertEquals("flowid", firstNode.getValue()); + + SimpleNode secondNode = input.get(1); + Assert.assertEquals("flow", secondNode.getNodeType().getLocalName()); + + YangInstanceIdentifier instance = (YangInstanceIdentifier) secondNode.getValue(); + Iterable iterable = instance.getPathArguments(); + Iterator it = iterable.iterator(); + YangInstanceIdentifier.NodeIdentifier firstPath = (YangInstanceIdentifier.NodeIdentifier) it.next(); + Assert.assertEquals("node", firstPath.getNodeType().getLocalName()); + YangInstanceIdentifier.NodeIdentifierWithPredicates secondPath = (YangInstanceIdentifier.NodeIdentifierWithPredicates)it.next(); + Short value = (Short)secondPath.getKeyValues().values().iterator().next(); + Short expected = 3; + Assert.assertEquals(expected, value); + } + + @Test + public void testInputCompositeNodeToXML() { + CompositeNode input = XmlUtils.inputXmlToCompositeNode(testRpc.getQName(), XML_CONTENT, schema); + List> childNodes = new ArrayList(); + childNodes.add(input); + QName rpcQName = schema.getOperations().iterator().next().getQName(); + CompositeNode node = new ImmutableCompositeNode(rpcQName, input.getValue(), ModifyAction.REPLACE); + String xml = XmlUtils.inputCompositeNodeToXml(node, schema); + Assert.assertNotNull(xml); + Assert.assertTrue(xml.contains("3@java.lang.Short")); + } + + @Test + public void testNullCompositeNodeToXml(){ + String xml = XmlUtils.inputCompositeNodeToXml(null, schema); + Assert.assertTrue(xml.isEmpty()); + } + + @Test + public void testNullSchemaCompositeNodeToXml(){ + String xml = XmlUtils.inputCompositeNodeToXml(new ImmutableCompositeNode(QName.create("ns", "2013-12-09", "child1"), new ArrayList>(), ModifyAction.REPLACE), null); + Assert.assertTrue(xml.isEmpty()); + } + + +} diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/test/resources/org/opendaylight/controller/remote/rpc/utils/rpcTest.yang b/opendaylight/md-sal/sal-remoterpc-connector/src/test/resources/org/opendaylight/controller/remote/rpc/utils/rpcTest.yang new file mode 100644 index 0000000000..5fc564fec3 --- /dev/null +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/test/resources/org/opendaylight/controller/remote/rpc/utils/rpcTest.yang @@ -0,0 +1,32 @@ +/* + * 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 + */ +module rpc-test { + yang-version 1; + namespace "urn:opendaylight:controller:rpc:test"; + prefix "rpct"; + + revision 2014-07-29 { + description "rpc test"; + } + + typedef flow-ref { + type instance-identifier; + } + + rpc add-flow { + input { + leaf id { + type string; + } + + leaf flow { + type flow-ref; + } + } + } +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector-config/pom.xml b/opendaylight/md-sal/sal-rest-connector-config/pom.xml new file mode 100644 index 0000000000..6d050cf425 --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector-config/pom.xml @@ -0,0 +1,20 @@ + + + + + 4.0.0 + + org.opendaylight.controller + sal-parent + 1.1-SNAPSHOT + + sal-rest-connector-config + Configuration files for sal-rest-connector + jar + diff --git a/opendaylight/md-sal/sal-rest-connector-config/src/main/resources/initial/10-rest-connector.xml b/opendaylight/md-sal/sal-rest-connector-config/src/main/resources/initial/10-rest-connector.xml new file mode 100644 index 0000000000..2fdc8c7d1e --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector-config/src/main/resources/initial/10-rest-connector.xml @@ -0,0 +1,38 @@ + + + + + + + + + rest:rest-connector-impl + rest-connector-default-impl + 8181 + + dom:dom-broker-osgi-registry + dom-broker + + + + + + + rest:rest-connector + + rest-connector-default + + /modules/module[type='rest-connector-impl'][name='rest-connector-default-impl'] + + + + + + + diff --git a/opendaylight/md-sal/sal-rest-connector/pom.xml b/opendaylight/md-sal/sal-rest-connector/pom.xml index b760263967..09fb5b3677 100644 --- a/opendaylight/md-sal/sal-rest-connector/pom.xml +++ b/opendaylight/md-sal/sal-rest-connector/pom.xml @@ -18,6 +18,14 @@ ${project.groupId} sal-core-api + + ${project.groupId} + sal-binding-config + + + ${project.groupId} + config-api + com.google.code.gson gson @@ -58,6 +66,10 @@ org.opendaylight.yangtools.model ietf-yang-types-20130715 + + org.opendaylight.yangtools.model + ietf-inet-types + org.slf4j slf4j-api @@ -89,6 +101,10 @@ mockito-all test + + org.opendaylight.controller + sal-core-spi + @@ -102,14 +118,43 @@ MD SAL Restconf Connector org.opendaylight.controller.sal.rest.*, org.opendaylight.controller.sal.restconf.rpc.*, - org.opendaylight.controller.sal.restconf.impl, + org.opendaylight.controller.sal.restconf.impl, + org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.rest.connector.rev140724.*, + *, com.sun.jersey.spi.container.servlet - org.opendaylight.controller.sal.rest.impl.RestconfProvider /restconf + + org.opendaylight.yangtools + yang-maven-plugin + + + config + + generate-sources + + + + + org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + ${jmxGeneratorPath} + + urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang + + + + org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl + ${salGeneratorPath} + + + true + + + + diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/rest/connector/RestConnectorModule.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/rest/connector/RestConnectorModule.java new file mode 100644 index 0000000000..582c657868 --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/rest/connector/RestConnectorModule.java @@ -0,0 +1,30 @@ +package org.opendaylight.controller.config.yang.md.sal.rest.connector; + +import org.opendaylight.controller.sal.rest.impl.RestconfProviderImpl; + +public class RestConnectorModule extends org.opendaylight.controller.config.yang.md.sal.rest.connector.AbstractRestConnectorModule { + + public RestConnectorModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public RestConnectorModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.md.sal.rest.connector.RestConnectorModule oldModule, java.lang.AutoCloseable oldInstance) { + super(identifier, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void customValidation() { + // add custom validation form module attributes here. + } + + @Override + public java.lang.AutoCloseable createInstance() { + // Create an instance of our provider + RestconfProviderImpl instance = new RestconfProviderImpl(); + // Set its port + instance.setWebsocketPort(getWebsocketPort()); + // Register it with the Broker + getDomBrokerDependency().registerProvider(instance); + return instance; + } +} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/rest/connector/RestConnectorModuleFactory.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/rest/connector/RestConnectorModuleFactory.java new file mode 100644 index 0000000000..957b08f6ae --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/rest/connector/RestConnectorModuleFactory.java @@ -0,0 +1,15 @@ +/* +* Generated file +* +* Generated from: yang module name: opendaylight-rest-connector yang module local name: rest-connector-impl +* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator +* Generated at: Fri Jul 25 04:33:31 CDT 2014 +* +* Do not modify this file unless it is present under src/main directory +*/ +package org.opendaylight.controller.config.yang.md.sal.rest.connector; + + +public class RestConnectorModuleFactory extends org.opendaylight.controller.config.yang.md.sal.rest.connector.AbstractRestConnectorModuleFactory { + +} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/RestConnector.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/RestConnector.java new file mode 100644 index 0000000000..fe45a0202d --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/RestConnector.java @@ -0,0 +1,9 @@ +package org.opendaylight.controller.sal.rest.api; + +/* + * This is a simple dummy interface to allow us to create instances of RestconfProvider + * via the config subsystem. + */ +public interface RestConnector { + +} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonMapper.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonMapper.java index cd2d91559b..34aa829b6f 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonMapper.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonMapper.java @@ -27,7 +27,7 @@ import org.opendaylight.controller.sal.restconf.impl.IdentityValuesDTO.Predicate import org.opendaylight.controller.sal.restconf.impl.RestCodec; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.Node; import org.opendaylight.yangtools.yang.data.api.SimpleNode; import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode; @@ -263,12 +263,12 @@ class JsonMapper { writeStringRepresentation(writer, node, baseType, QName.class); } } else if (baseType instanceof InstanceIdentifierTypeDefinition) { - if (node.getValue() instanceof InstanceIdentifier) { + if (node.getValue() instanceof YangInstanceIdentifier) { IdentityValuesDTO valueDTO = (IdentityValuesDTO) RestCodec.from(baseType, mountPoint).serialize( node.getValue()); writeIdentityValuesDTOToJson(writer, valueDTO); } else { - writeStringRepresentation(writer, node, baseType, InstanceIdentifier.class); + writeStringRepresentation(writer, node, baseType, YangInstanceIdentifier.class); } } else if (baseType instanceof DecimalTypeDefinition || baseType instanceof IntegerTypeDefinition || baseType instanceof UnsignedIntegerTypeDefinition) { diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfProvider.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfProviderImpl.java similarity index 54% rename from opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfProvider.java rename to opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfProviderImpl.java index 1f1d0eb831..adb176a65d 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfProvider.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfProviderImpl.java @@ -9,30 +9,30 @@ package org.opendaylight.controller.sal.rest.impl; import java.util.Collection; import java.util.Collections; -import org.opendaylight.controller.sal.core.api.Broker; + import org.opendaylight.controller.sal.core.api.Broker.ProviderSession; import org.opendaylight.controller.sal.core.api.Provider; import org.opendaylight.controller.sal.core.api.data.DataBrokerService; import org.opendaylight.controller.sal.core.api.model.SchemaService; import org.opendaylight.controller.sal.core.api.mount.MountService; +import org.opendaylight.controller.sal.rest.api.RestConnector; import org.opendaylight.controller.sal.restconf.impl.BrokerFacade; import org.opendaylight.controller.sal.restconf.impl.ControllerContext; import org.opendaylight.controller.sal.streams.websockets.WebSocketServer; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener; -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.util.tracker.ServiceTracker; -import org.osgi.util.tracker.ServiceTrackerCustomizer; -public class RestconfProvider implements BundleActivator, Provider, ServiceTrackerCustomizer { +public class RestconfProviderImpl implements Provider, AutoCloseable, RestConnector { public final static String NOT_INITALIZED_MSG = "Restconf is not initialized yet. Please try again later"; private ListenerRegistration listenerRegistration; - private ServiceTracker brokerServiceTrancker; - private BundleContext bundleContext; + private PortNumber port; + public void setWebsocketPort(PortNumber port) { + this.port = port; + } + private Thread webSocketServerThread; @Override @@ -46,32 +46,10 @@ public class RestconfProvider implements BundleActivator, Provider, ServiceTrack listenerRegistration = schemaService.registerSchemaServiceListener(ControllerContext.getInstance()); ControllerContext.getInstance().setSchemas(schemaService.getGlobalContext()); ControllerContext.getInstance().setMountService(session.getService(MountService.class)); - } - @Override - public void start(BundleContext context) throws Exception { - String websocketPortStr = context.getProperty(WebSocketServer.WEBSOCKET_SERVER_CONFIG_PROPERTY); - int websocketPort = (websocketPortStr != null && !"".equals(websocketPortStr)) ? Integer - .parseInt(websocketPortStr) : WebSocketServer.DEFAULT_PORT; - bundleContext = context; - webSocketServerThread = new Thread(WebSocketServer.createInstance(websocketPort)); - webSocketServerThread.setName("Web socket server"); + webSocketServerThread = new Thread(WebSocketServer.createInstance(port.getValue().intValue())); + webSocketServerThread.setName("Web socket server on port " + port); webSocketServerThread.start(); - brokerServiceTrancker = new ServiceTracker<>(context, Broker.class, this); - brokerServiceTrancker.open(); - } - - @Override - public void stop(BundleContext context) { - if (listenerRegistration != null) { - try { - listenerRegistration.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - webSocketServerThread.interrupt(); - brokerServiceTrancker.close(); } @Override @@ -80,22 +58,10 @@ public class RestconfProvider implements BundleActivator, Provider, ServiceTrack } @Override - public Broker addingService(ServiceReference reference) { - Broker broker = bundleContext.getService(reference); - broker.registerProvider(this, bundleContext); - return broker; - } - - @Override - public void modifiedService(ServiceReference reference, Broker service) { - // NOOP - } - - @Override - public void removedService(ServiceReference reference, Broker service) { - bundleContext.ungetService(reference); - BrokerFacade.getInstance().setContext(null); - BrokerFacade.getInstance().setDataService(null); - ControllerContext.getInstance().setSchemas(null); + public void close() { + if (listenerRegistration != null) { + listenerRegistration.close(); + } + webSocketServerThread.interrupt(); } } diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.java index ead1740ffd..861aaac3d8 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.java @@ -28,11 +28,11 @@ import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class BrokerFacade implements DataReader { +public class BrokerFacade implements DataReader { private final static Logger LOG = LoggerFactory.getLogger(BrokerFacade.class); private final static BrokerFacade INSTANCE = new BrokerFacade(); @@ -62,7 +62,7 @@ public class BrokerFacade implements DataReader> commitConfigurationDataPut(final InstanceIdentifier path, + public Future> commitConfigurationDataPut(final YangInstanceIdentifier path, final CompositeNode payload) { this.checkPreconditions(); @@ -114,7 +114,7 @@ public class BrokerFacade implements DataReader> commitConfigurationDataPutBehindMountPoint( - final MountInstance mountPoint, final InstanceIdentifier path, final CompositeNode payload) { + final MountInstance mountPoint, final YangInstanceIdentifier path, final CompositeNode payload) { this.checkPreconditions(); final DataModificationTransaction transaction = mountPoint.beginTransaction(); @@ -123,7 +123,7 @@ public class BrokerFacade implements DataReader> commitConfigurationDataPost(final InstanceIdentifier path, + public Future> commitConfigurationDataPost(final YangInstanceIdentifier path, final CompositeNode payload) { this.checkPreconditions(); @@ -143,7 +143,7 @@ public class BrokerFacade implements DataReader> commitConfigurationDataPostBehindMountPoint( - final MountInstance mountPoint, final InstanceIdentifier path, final CompositeNode payload) { + final MountInstance mountPoint, final YangInstanceIdentifier path, final CompositeNode payload) { this.checkPreconditions(); final DataModificationTransaction transaction = mountPoint.beginTransaction(); @@ -161,18 +161,18 @@ public class BrokerFacade implements DataReader> commitConfigurationDataDelete(final InstanceIdentifier path) { + public Future> commitConfigurationDataDelete(final YangInstanceIdentifier path) { this.checkPreconditions(); return deleteDataAtTarget(path, dataService.beginTransaction()); } public Future> commitConfigurationDataDeleteBehindMountPoint( - final MountInstance mountPoint, final InstanceIdentifier path) { + final MountInstance mountPoint, final YangInstanceIdentifier path) { this.checkPreconditions(); return deleteDataAtTarget(path, mountPoint.beginTransaction()); } - private Future> deleteDataAtTarget(final InstanceIdentifier path, + private Future> deleteDataAtTarget(final YangInstanceIdentifier path, final DataModificationTransaction transaction) { LOG.info("Delete Configuration via Restconf: {}", path); CompositeNode redDataAtPath = transaction.readConfigurationData(path); @@ -191,7 +191,7 @@ public class BrokerFacade implements DataReader registration = dataService.registerDataChangeListener(path, listener); 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 0a67c84d8b..dad7a2cda2 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 @@ -9,13 +9,11 @@ package org.opendaylight.controller.sal.restconf.impl; import com.google.common.base.Function; import com.google.common.base.Objects; -import com.google.common.base.Optional; 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.FluentIterable; import com.google.common.collect.HashBiMap; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; @@ -28,7 +26,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -45,11 +42,11 @@ import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorTag; import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorType; import org.opendaylight.yangtools.concepts.Codec; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.InstanceIdentifierBuilder; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +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.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode; import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode; import org.opendaylight.yangtools.yang.model.api.ChoiceNode; @@ -145,7 +142,7 @@ public class ControllerContext implements SchemaContextListener { ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); } - InstanceIdentifierBuilder builder = InstanceIdentifier.builder(); + InstanceIdentifierBuilder builder = YangInstanceIdentifier.builder(); Module latestModule = this.getLatestModule(globalSchema, startModule); InstanceIdWithSchemaNode iiWithSchemaNode = this.collectPathArguments(builder, pathArgs, latestModule, null, toMountPointIdentifier); @@ -250,7 +247,7 @@ public class ControllerContext implements SchemaContextListener { module.getRevision()); } - public DataNodeContainer getDataNodeContainerFor(final InstanceIdentifier path) { + public DataNodeContainer getDataNodeContainerFor(final YangInstanceIdentifier path) { this.checkPreconditions(); final Iterable elements = path.getPathArguments(); @@ -262,7 +259,7 @@ public class ControllerContext implements SchemaContextListener { for (final PathArgument element : elements) { QName _nodeType = element.getNodeType(); final DataSchemaNode potentialNode = ControllerContext.childByQName(node, _nodeType); - if (potentialNode == null || !this.isListOrContainer(potentialNode)) { + if (potentialNode == null || !ControllerContext.isListOrContainer(potentialNode)) { return null; } node = (DataNodeContainer) potentialNode; @@ -271,7 +268,7 @@ public class ControllerContext implements SchemaContextListener { return node; } - public String toFullRestconfIdentifier(final InstanceIdentifier path) { + public String toFullRestconfIdentifier(final YangInstanceIdentifier path) { this.checkPreconditions(); final Iterable elements = path.getPathArguments(); @@ -284,7 +281,7 @@ public class ControllerContext implements SchemaContextListener { for (final PathArgument element : elements) { QName _nodeType = element.getNodeType(); final DataSchemaNode potentialNode = ControllerContext.childByQName(node, _nodeType); - if (!this.isListOrContainer(potentialNode)) { + if (!ControllerContext.isListOrContainer(potentialNode)) { return null; } node = ((DataNodeContainer) potentialNode); @@ -559,7 +556,7 @@ public class ControllerContext implements SchemaContextListener { ErrorType.APPLICATION, ErrorTag.OPERATION_NOT_SUPPORTED); } - final InstanceIdentifier partialPath = builder.toInstance(); + final YangInstanceIdentifier partialPath = builder.toInstance(); final MountInstance mount = mountService.getMountPoint(partialPath); if (mount == null) { LOG.debug("Instance identifier to missing mount point: {}", partialPath); @@ -574,12 +571,12 @@ public class ControllerContext implements SchemaContextListener { } if (returnJustMountPoint) { - InstanceIdentifier instance = InstanceIdentifier.builder().toInstance(); + YangInstanceIdentifier instance = YangInstanceIdentifier.builder().toInstance(); return new InstanceIdWithSchemaNode(instance, mountPointSchema, mount); } if (strings.size() == 1) { - InstanceIdentifier instance = InstanceIdentifier.builder().toInstance(); + YangInstanceIdentifier instance = YangInstanceIdentifier.builder().toInstance(); return new InstanceIdWithSchemaNode(instance, mountPointSchema, mount); } @@ -598,7 +595,7 @@ public class ControllerContext implements SchemaContextListener { } List subList = strings.subList(1, strings.size()); - return this.collectPathArguments(InstanceIdentifier.builder(), subList, moduleBehindMountPoint, mount, + return this.collectPathArguments(YangInstanceIdentifier.builder(), subList, moduleBehindMountPoint, mount, returnJustMountPoint); } @@ -650,7 +647,7 @@ public class ControllerContext implements SchemaContextListener { targetNode = potentialSchemaNodes.iterator().next(); } - if (!this.isListOrContainer(targetNode)) { + if (!ControllerContext.isListOrContainer(targetNode)) { throw new RestconfDocumentedException("URI has bad format. Node \"" + head + "\" must be Container or List yang type.", ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); } @@ -824,34 +821,8 @@ public class ControllerContext implements SchemaContextListener { private QName toQName(final String name) { final String module = toModuleName(name); final String node = toNodeName(name); - Set modules = globalSchema.getModules(); - - final Comparator comparator = new Comparator() { - @Override - public int compare(final Module o1, final Module o2) { - return o1.getRevision().compareTo(o2.getRevision()); - } - }; - - List sorted = new ArrayList(modules); - Collections. sort(new ArrayList(modules), comparator); - - final Function transform = new Function() { - @Override - public QName apply(final Module m) { - return QName.create(m.getNamespace(), m.getRevision(), m.getName()); - } - }; - - final Predicate findFirst = new Predicate() { - @Override - public boolean apply(final QName qn) { - return Objects.equal(module, qn.getLocalName()); - } - }; - - Optional namespace = FluentIterable.from(sorted).transform(transform).firstMatch(findFirst); - return namespace.isPresent() ? QName.create(namespace.get(), node) : null; + final Module m = globalSchema.findModuleByName(module, null); + return m == null ? null : QName.create(m.getQNameModule(), node); } private static boolean isListOrContainer(final DataSchemaNode node) { diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/InstanceIdWithSchemaNode.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/InstanceIdWithSchemaNode.java index 08e0ce1f24..12c1ba66ec 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/InstanceIdWithSchemaNode.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/InstanceIdWithSchemaNode.java @@ -8,23 +8,23 @@ package org.opendaylight.controller.sal.restconf.impl; import org.opendaylight.controller.sal.core.api.mount.MountInstance; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; public class InstanceIdWithSchemaNode { - private final InstanceIdentifier instanceIdentifier; + private final YangInstanceIdentifier instanceIdentifier; private final DataSchemaNode schemaNode; private final MountInstance mountPoint; - public InstanceIdWithSchemaNode(InstanceIdentifier instanceIdentifier, DataSchemaNode schemaNode, + public InstanceIdWithSchemaNode(YangInstanceIdentifier instanceIdentifier, DataSchemaNode schemaNode, MountInstance mountPoint) { this.instanceIdentifier = instanceIdentifier; this.schemaNode = schemaNode; this.mountPoint = mountPoint; } - public InstanceIdentifier getInstanceIdentifier() { + public YangInstanceIdentifier getInstanceIdentifier() { return instanceIdentifier; } 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 611fb49090..ff90dd8439 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 @@ -18,11 +18,11 @@ import org.opendaylight.controller.sal.restconf.impl.IdentityValuesDTO.IdentityV import org.opendaylight.controller.sal.restconf.impl.IdentityValuesDTO.Predicate; import org.opendaylight.yangtools.concepts.Codec; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeWithValue; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +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.NodeIdentifierWithPredicates; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.api.codec.IdentityrefCodec; import org.opendaylight.yangtools.yang.data.api.codec.InstanceIdentifierCodec; import org.opendaylight.yangtools.yang.data.api.codec.LeafrefCodec; @@ -207,7 +207,7 @@ public class RestCodec { } @Override - public IdentityValuesDTO serialize(final InstanceIdentifier data) { + public IdentityValuesDTO serialize(final YangInstanceIdentifier data) { IdentityValuesDTO identityValuesDTO = new IdentityValuesDTO(); for (PathArgument pathArgument : data.getPathArguments()) { IdentityValue identityValue = qNameToIdentityValue(pathArgument.getNodeType()); @@ -227,7 +227,7 @@ public class RestCodec { } @Override - public InstanceIdentifier deserialize(final IdentityValuesDTO data) { + public YangInstanceIdentifier deserialize(final IdentityValuesDTO data) { List result = new ArrayList(); IdentityValue valueWithNamespace = data.getValuesWithNamespaces().get(0); Module module = getModuleByNamespace(valueWithNamespace.getNamespace(), mountPoint); @@ -298,7 +298,7 @@ public class RestCodec { } } - return result.isEmpty() ? null : InstanceIdentifier.create(result); + return result.isEmpty() ? null : YangInstanceIdentifier.create(result); } private List keyValuesToPredicateList(final Map keyValues) { 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 4e807b4e23..4c005c6ae5 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 @@ -50,10 +50,10 @@ import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.InstanceIdentifierBuilder; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +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.MutableCompositeNode; import org.opendaylight.yangtools.yang.data.api.Node; import org.opendaylight.yangtools.yang.data.api.SimpleNode; @@ -427,12 +427,12 @@ public class RestconfImpl implements RestconfService { rpc.getQName(), "path")); final Object pathValue = pathNode == null ? null : pathNode.getValue(); - if (!(pathValue instanceof InstanceIdentifier)) { + if (!(pathValue instanceof YangInstanceIdentifier)) { throw new RestconfDocumentedException("Instance identifier was not normalized correctly.", ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED); } - final InstanceIdentifier pathIdentifier = ((InstanceIdentifier) pathValue); + final YangInstanceIdentifier pathIdentifier = ((YangInstanceIdentifier) pathValue); String streamName = null; if (!Iterables.isEmpty(pathIdentifier.getPathArguments())) { String fullRestconfIdentifier = this.controllerContext.toFullRestconfIdentifier(pathIdentifier); @@ -943,17 +943,17 @@ public class RestconfImpl implements RestconfService { private InstanceIdWithSchemaNode addLastIdentifierFromData(final InstanceIdWithSchemaNode identifierWithSchemaNode, final CompositeNode data, final DataSchemaNode schemaOfData) { - InstanceIdentifier instanceIdentifier = null; + YangInstanceIdentifier instanceIdentifier = null; if (identifierWithSchemaNode != null) { instanceIdentifier = identifierWithSchemaNode.getInstanceIdentifier(); } - final InstanceIdentifier iiOriginal = instanceIdentifier; + final YangInstanceIdentifier iiOriginal = instanceIdentifier; InstanceIdentifierBuilder iiBuilder = null; if (iiOriginal == null) { - iiBuilder = InstanceIdentifier.builder(); + iiBuilder = YangInstanceIdentifier.builder(); } else { - iiBuilder = InstanceIdentifier.builder(iiOriginal); + iiBuilder = YangInstanceIdentifier.builder(iiOriginal); } if ((schemaOfData instanceof ListSchemaNode)) { @@ -963,7 +963,7 @@ public class RestconfImpl implements RestconfService { iiBuilder.node(schemaOfData.getQName()); } - InstanceIdentifier instance = iiBuilder.toInstance(); + YangInstanceIdentifier instance = iiBuilder.toInstance(); MountInstance mountPoint = null; if (identifierWithSchemaNode != null) { mountPoint = identifierWithSchemaNode.getMountPoint(); diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/ListenerAdapter.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/ListenerAdapter.java index e526ec13be..2b7b0246e3 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/ListenerAdapter.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/ListenerAdapter.java @@ -45,10 +45,10 @@ import org.opendaylight.controller.sal.restconf.impl.ControllerContext; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeWithValue; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -69,7 +69,7 @@ public class ListenerAdapter implements DataChangeListener { private final XmlMapper xmlMapper = new XmlMapper(); private final SimpleDateFormat rfc3339 = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ssZ"); - private final InstanceIdentifier path; + private final YangInstanceIdentifier path; private ListenerRegistration registration; private final String streamName; private Set subscribers = new ConcurrentSet<>(); @@ -84,7 +84,7 @@ public class ListenerAdapter implements DataChangeListener { * @param streamName * The name of the stream. */ - ListenerAdapter(final InstanceIdentifier path, final String streamName) { + ListenerAdapter(final YangInstanceIdentifier path, final String streamName) { Preconditions.checkNotNull(path); Preconditions.checkArgument(streamName != null && !streamName.isEmpty()); this.path = path; @@ -95,7 +95,7 @@ public class ListenerAdapter implements DataChangeListener { } @Override - public void onDataChanged(final DataChangeEvent change) { + public void onDataChanged(final DataChangeEvent change) { if (!change.getCreatedConfigurationData().isEmpty() || !change.getCreatedOperationalData().isEmpty() || !change.getUpdatedConfigurationData().isEmpty() || !change.getUpdatedOperationalData().isEmpty() || !change.getRemovedConfigurationData().isEmpty() || !change.getRemovedOperationalData().isEmpty()) { @@ -216,7 +216,7 @@ public class ListenerAdapter implements DataChangeListener { * DataChangeEvent * @return Data in printable form. */ - private String prepareXmlFrom(final DataChangeEvent change) { + private String prepareXmlFrom(final DataChangeEvent change) { Document doc = createDocument(); Element notificationElement = doc.createElementNS("urn:ietf:params:xml:ns:netconf:notification:1.0", "notification"); @@ -287,7 +287,7 @@ public class ListenerAdapter implements DataChangeListener { */ private void addValuesToDataChangedNotificationEventElement(final Document doc, final Element dataChangedNotificationEventElement, - final DataChangeEvent change) { + final DataChangeEvent change) { addValuesFromDataToElement(doc, change.getCreatedConfigurationData(), dataChangedNotificationEventElement, Store.CONFIG, Operation.CREATED); addValuesFromDataToElement(doc, change.getCreatedOperationalData(), dataChangedNotificationEventElement, @@ -312,7 +312,7 @@ public class ListenerAdapter implements DataChangeListener { * @param doc * {@link Document} * @param data - * Set of {@link InstanceIdentifier}. + * Set of {@link YangInstanceIdentifier}. * @param element * {@link Element} * @param store @@ -320,12 +320,12 @@ public class ListenerAdapter implements DataChangeListener { * @param operation * {@link Operation} */ - private void addValuesFromDataToElement(final Document doc, final Set data, + private void addValuesFromDataToElement(final Document doc, final Set data, final Element element, final Store store, final Operation operation) { if (data == null || data.isEmpty()) { return; } - for (InstanceIdentifier path : data) { + for (YangInstanceIdentifier path : data) { Node node = createDataChangeEventElement(doc, path, null, store, operation); element.appendChild(node); } @@ -337,7 +337,7 @@ public class ListenerAdapter implements DataChangeListener { * @param doc * {@link Document} * @param data - * Map of {@link InstanceIdentifier} and {@link CompositeNode}. + * Map of {@link YangInstanceIdentifier} and {@link CompositeNode}. * @param element * {@link Element} * @param store @@ -345,12 +345,12 @@ public class ListenerAdapter implements DataChangeListener { * @param operation * {@link Operation} */ - private void addValuesFromDataToElement(final Document doc, final Map data, + private void addValuesFromDataToElement(final Document doc, final Map data, final Element element, final Store store, final Operation operation) { if (data == null || data.isEmpty()) { return; } - for (Entry entry : data.entrySet()) { + for (Entry entry : data.entrySet()) { Node node = createDataChangeEventElement(doc, entry.getKey(), entry.getValue(), store, operation); element.appendChild(node); } @@ -371,7 +371,7 @@ public class ListenerAdapter implements DataChangeListener { * {@link Operation} * @return {@link Node} node represented by changed event element. */ - private Node createDataChangeEventElement(final Document doc, final InstanceIdentifier path, + private Node createDataChangeEventElement(final Document doc, final YangInstanceIdentifier path, final CompositeNode data, final Store store, final Operation operation) { Element dataChangeEventElement = doc.createElement("data-change-event"); @@ -407,7 +407,7 @@ public class ListenerAdapter implements DataChangeListener { * {@link CompositeNode} * @return Data in XML format. */ - private Node translateToXml(final InstanceIdentifier path, final CompositeNode data) { + private Node translateToXml(final YangInstanceIdentifier path, final CompositeNode data) { DataNodeContainer schemaNode = ControllerContext.getInstance().getDataNodeContainerFor(path); if (schemaNode == null) { LOG.info( @@ -432,10 +432,10 @@ public class ListenerAdapter implements DataChangeListener { * @param element * {@link Element} */ - private void addPathAsValueToElement(final InstanceIdentifier path, final Element element) { + private void addPathAsValueToElement(final YangInstanceIdentifier path, final Element element) { // Map< key = namespace, value = prefix> Map prefixes = new HashMap<>(); - InstanceIdentifier instanceIdentifier = path; + YangInstanceIdentifier instanceIdentifier = path; StringBuilder textContent = new StringBuilder(); // FIXME: BUG-1281: this is duplicated code from yangtools (BUG-1275) @@ -520,7 +520,7 @@ public class ListenerAdapter implements DataChangeListener { * * @return Path pointed to data in data store. */ - public InstanceIdentifier getPath() { + public YangInstanceIdentifier getPath() { return path; } diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/Notificator.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/Notificator.java index 166c473b9c..cf1bcd6a30 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/Notificator.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/Notificator.java @@ -12,7 +12,7 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; /** * {@link Notificator} is responsible to create, remove and find {@link ListenerAdapter} listener. @@ -20,7 +20,7 @@ import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; public class Notificator { private static Map listenersByStreamName = new ConcurrentHashMap<>(); - private static Map listenersByInstanceIdentifier = new ConcurrentHashMap<>(); + private static Map listenersByInstanceIdentifier = new ConcurrentHashMap<>(); private static final Lock lock = new ReentrantLock(); private Notificator() { @@ -45,37 +45,37 @@ public class Notificator { } /** - * Gets {@link ListenerAdapter} listener specified by {@link InstanceIdentifier} path. + * Gets {@link ListenerAdapter} listener specified by {@link YangInstanceIdentifier} path. * * @param path * Path to data in data repository. * @return ListenerAdapter */ - public static ListenerAdapter getListenerFor(InstanceIdentifier path) { + public static ListenerAdapter getListenerFor(YangInstanceIdentifier path) { return listenersByInstanceIdentifier.get(path); } /** - * Checks if the listener specified by {@link InstanceIdentifier} path exist. + * Checks if the listener specified by {@link YangInstanceIdentifier} path exist. * * @param path * Path to data in data repository. * @return True if the listener exist, false otherwise. */ - public static boolean existListenerFor(InstanceIdentifier path) { + public static boolean existListenerFor(YangInstanceIdentifier path) { return listenersByInstanceIdentifier.containsKey(path); } /** - * Creates new {@link ListenerAdapter} listener from {@link InstanceIdentifier} path and stream name. + * Creates new {@link ListenerAdapter} listener from {@link YangInstanceIdentifier} path and stream name. * * @param path * Path to data in data repository. * @param streamName * The name of the stream. - * @return New {@link ListenerAdapter} listener from {@link InstanceIdentifier} path and stream name. + * @return New {@link ListenerAdapter} listener from {@link YangInstanceIdentifier} path and stream name. */ - public static ListenerAdapter createListener(InstanceIdentifier path, String streamName) { + public static ListenerAdapter createListener(YangInstanceIdentifier path, String streamName) { ListenerAdapter listener = new ListenerAdapter(path, streamName); try { lock.lock(); @@ -88,12 +88,12 @@ public class Notificator { } /** - * Looks for listener determined by {@link InstanceIdentifier} path and removes it. + * Looks for listener determined by {@link YangInstanceIdentifier} path and removes it. * * @param path * InstanceIdentifier */ - public static void removeListener(InstanceIdentifier path) { + public static void removeListener(YangInstanceIdentifier path) { ListenerAdapter listener = listenersByInstanceIdentifier.get(path); deleteListener(listener); } diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/yang/opendaylight-rest-connector.yang b/opendaylight/md-sal/sal-rest-connector/src/main/yang/opendaylight-rest-connector.yang new file mode 100644 index 0000000000..a8fc8ff4d5 --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/main/yang/opendaylight-rest-connector.yang @@ -0,0 +1,47 @@ +module opendaylight-rest-connector { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:rest:connector"; + prefix "md-sal-rest-connector"; + + import config { prefix config; revision-date 2013-04-05; } + import opendaylight-md-sal-dom {prefix dom; revision-date 2013-10-28;} + import opendaylight-md-sal-binding {prefix sal; revision-date 2013-10-28;} + import ietf-inet-types {prefix inet; revision-date 2010-09-24;} + + description + "Service definition for Rest Connector"; + + revision "2014-07-24" { + description + "Initial revision"; + } + + identity rest-connector { + base "config:service-type"; + config:java-class "org.opendaylight.controller.sal.rest.api.RestConnector"; + } + + identity rest-connector-impl { + base config:module-type; + config:provided-service rest-connector; + config:java-name-prefix RestConnector; + } + + augment "/config:modules/config:module/config:configuration" { + case rest-connector-impl { + when "/config:modules/config:module/config:type = 'rest-connector-impl'"; + leaf websocket-port { + mandatory true; + type inet:port-number; + } + container dom-broker { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity dom:dom-broker-osgi-registry; + } + } + } + } + } +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/input/to/cnsn/test/RestPutListDataTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/input/to/cnsn/test/RestPutListDataTest.java index f4281c037c..4210944de7 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/input/to/cnsn/test/RestPutListDataTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/input/to/cnsn/test/RestPutListDataTest.java @@ -34,7 +34,7 @@ import org.opendaylight.controller.sal.restconf.impl.test.DummyRpcResult; import org.opendaylight.controller.sal.restconf.impl.test.TestUtils; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode; import org.opendaylight.yangtools.yang.data.impl.util.CompositeNodeBuilder; import org.opendaylight.yangtools.yang.model.api.SchemaContext; @@ -65,7 +65,7 @@ public class RestPutListDataTest { Builder futureBuilder = new DummyFuture.Builder(); futureBuilder.rpcResult(new DummyRpcResult.Builder().result(TransactionStatus.COMMITED) .build()); - when(brokerFacade.commitConfigurationDataPut(any(InstanceIdentifier.class), any(CompositeNode.class))) + when(brokerFacade.commitConfigurationDataPut(any(YangInstanceIdentifier.class), any(CompositeNode.class))) .thenReturn(futureBuilder.build()); } diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java index 656427352a..73f828c646 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java @@ -43,7 +43,7 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration; 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.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode; /** @@ -72,7 +72,7 @@ public class BrokerFacadeTest { QName qname = QName.create("node"); - InstanceIdentifier instanceID = InstanceIdentifier.builder().node(qname).toInstance(); + YangInstanceIdentifier instanceID = YangInstanceIdentifier.builder().node(qname).toInstance(); @Before public void setUp() throws Exception { @@ -188,7 +188,7 @@ public class BrokerFacadeTest { public void testCommitConfigurationDataPost() { Future> expFuture = Futures.immediateFuture(null); - Map nodeMap = new ImmutableMap.Builder() + Map nodeMap = new ImmutableMap.Builder() .put(instanceID, dataNode).build(); when(dataBroker.beginTransaction()).thenReturn(mockTransaction); @@ -224,7 +224,7 @@ public class BrokerFacadeTest { public void testCommitConfigurationDataPostBehindMountPoint() { Future> expFuture = Futures.immediateFuture(null); - Map nodeMap = new ImmutableMap.Builder() + Map nodeMap = new ImmutableMap.Builder() .put(instanceID, dataNode).build(); when(mockMountInstance.beginTransaction()).thenReturn(mockTransaction); @@ -262,7 +262,7 @@ public class BrokerFacadeTest { Future> expFuture = Futures.immediateFuture(null); when(dataBroker.beginTransaction()).thenReturn(mockTransaction); - when(mockTransaction.readConfigurationData(any(InstanceIdentifier.class))).thenReturn( + when(mockTransaction.readConfigurationData(any(YangInstanceIdentifier.class))).thenReturn( ImmutableCompositeNode.builder().toInstance()); mockTransaction.removeConfigurationData(instanceID); when(mockTransaction.commit()).thenReturn(expFuture); @@ -282,7 +282,7 @@ public class BrokerFacadeTest { Future> expFuture = Futures.immediateFuture(null); when(mockMountInstance.beginTransaction()).thenReturn(mockTransaction); - when(mockTransaction.readConfigurationData(any(InstanceIdentifier.class))).thenReturn( + when(mockTransaction.readConfigurationData(any(YangInstanceIdentifier.class))).thenReturn( ImmutableCompositeNode.builder().toInstance()); mockTransaction.removeConfigurationData(instanceID); when(mockTransaction.commit()).thenReturn(expFuture); diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/CnSnToXmlAndJsonInstanceIdentifierTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/CnSnToXmlAndJsonInstanceIdentifierTest.java index 47171bf247..79e51681ca 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/CnSnToXmlAndJsonInstanceIdentifierTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/CnSnToXmlAndJsonInstanceIdentifierTest.java @@ -32,11 +32,11 @@ import org.opendaylight.controller.sal.rest.impl.StructuredDataToJsonProvider; import org.opendaylight.controller.sal.rest.impl.StructuredDataToXmlProvider; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeWithValue; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +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.NodeIdentifierWithPredicates; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.api.SimpleNode; import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode; import org.opendaylight.yangtools.yang.data.impl.NodeFactory; @@ -189,7 +189,7 @@ public class CnSnToXmlAndJsonInstanceIdentifierTest extends YangAndXmlAndDataSch } - private CompositeNode prepareCnSn(final InstanceIdentifier instanceIdentifier) throws URISyntaxException { + private CompositeNode prepareCnSn(final YangInstanceIdentifier instanceIdentifier) throws URISyntaxException { CompositeNodeBuilder cont = ImmutableCompositeNode.builder(); cont.setQName(QName.create("instance:identifier:module", "2014-01-17", "cont")); @@ -207,7 +207,7 @@ public class CnSnToXmlAndJsonInstanceIdentifierTest extends YangAndXmlAndDataSch return cont.toInstance(); } - private InstanceIdentifier createInstanceIdentifier() throws URISyntaxException { + private YangInstanceIdentifier createInstanceIdentifier() throws URISyntaxException { List pathArguments = new ArrayList<>(); pathArguments.add(new NodeIdentifier(new QName(new URI("instance:identifier:module"), "cont"))); pathArguments.add(new NodeIdentifier(new QName(new URI("instance:identifier:module"), "cont1"))); @@ -221,16 +221,16 @@ public class CnSnToXmlAndJsonInstanceIdentifierTest extends YangAndXmlAndDataSch pathArguments.add(new NodeIdentifier(new QName(new URI("augment:augment:module"), "lf112"))); - return InstanceIdentifier.create(pathArguments); + return YangInstanceIdentifier.create(pathArguments); } - private InstanceIdentifier createInstanceIdentifierWithLeafList() throws URISyntaxException { + private YangInstanceIdentifier createInstanceIdentifierWithLeafList() throws URISyntaxException { List pathArguments = new ArrayList<>(); pathArguments.add(new NodeIdentifier(new QName(new URI("instance:identifier:module"), "cont"))); pathArguments.add(new NodeIdentifier(new QName(new URI("instance:identifier:module"), "cont1"))); pathArguments.add(new NodeWithValue(new QName(new URI("augment:module:leaf:list"), "lflst11"), "lflst11_1")); - return InstanceIdentifier.create(pathArguments); + return YangInstanceIdentifier.create(pathArguments); } } diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java index 2adf9b5530..9aab841546 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java @@ -93,7 +93,7 @@ public class InvokeRpcMethodTest { * string - first argument). */ @Test - public void invokeRpcMtethodTest() { + public void invokeRpcMethodTest() { ControllerContext contContext = controllerContext; try { contContext.findModuleNameByNamespace(new URI("invoke:rpc:module")); diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestDeleteOperationTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestDeleteOperationTest.java index d1d2a5babf..66ced81817 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestDeleteOperationTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestDeleteOperationTest.java @@ -31,7 +31,7 @@ import org.opendaylight.controller.sal.restconf.impl.BrokerFacade; import org.opendaylight.controller.sal.restconf.impl.ControllerContext; import org.opendaylight.controller.sal.restconf.impl.RestconfImpl; import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; @@ -71,12 +71,12 @@ public class RestDeleteOperationTest extends JerseyTest { public void deleteConfigStatusCodes() throws UnsupportedEncodingException { String uri = "/config/test-interface:interfaces"; Future> dummyFuture = createFuture(TransactionStatus.COMMITED); - when(brokerFacade.commitConfigurationDataDelete(any(InstanceIdentifier.class))).thenReturn(dummyFuture); + when(brokerFacade.commitConfigurationDataDelete(any(YangInstanceIdentifier.class))).thenReturn(dummyFuture); Response response = target(uri).request(MediaType.APPLICATION_XML).delete(); assertEquals(200, response.getStatus()); dummyFuture = createFuture(TransactionStatus.FAILED); - when(brokerFacade.commitConfigurationDataDelete(any(InstanceIdentifier.class))).thenReturn(dummyFuture); + when(brokerFacade.commitConfigurationDataDelete(any(YangInstanceIdentifier.class))).thenReturn(dummyFuture); response = target(uri).request(MediaType.APPLICATION_XML).delete(); assertEquals(500, response.getStatus()); } 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 ff4678d36f..ac660e32bc 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 @@ -62,8 +62,8 @@ import org.opendaylight.controller.sal.restconf.impl.RestconfImpl; import org.opendaylight.controller.sal.restconf.impl.SimpleNodeWrapper; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.api.Node; import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode; import org.opendaylight.yangtools.yang.data.impl.util.CompositeNodeBuilder; @@ -164,11 +164,11 @@ public class RestGetOperationTest extends JerseyTest { public void getDataWithUrlMountPoint() throws UnsupportedEncodingException, URISyntaxException { when( brokerFacade.readConfigurationDataBehindMountPoint(any(MountInstance.class), - any(InstanceIdentifier.class))).thenReturn(prepareCnDataForMountPointTest()); + any(YangInstanceIdentifier.class))).thenReturn(prepareCnDataForMountPointTest()); MountInstance mountInstance = mock(MountInstance.class); when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule); MountService mockMountService = mock(MountService.class); - when(mockMountService.getMountPoint(any(InstanceIdentifier.class))).thenReturn(mountInstance); + when(mockMountService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(mountInstance); ControllerContext.getInstance().setMountService(mockMountService); @@ -185,7 +185,7 @@ public class RestGetOperationTest extends JerseyTest { * Slashes in URI behind mount point. lst1 element with key GigabitEthernet0%2F0%2F0%2F0 (GigabitEthernet0/0/0/0) is * requested via GET HTTP operation. It is tested whether %2F character is replaced with simple / in * InstanceIdentifier parameter in method - * {@link BrokerFacade#readConfigurationDataBehindMountPoint(MountInstance, InstanceIdentifier)} which is called in + * {@link BrokerFacade#readConfigurationDataBehindMountPoint(MountInstance, YangInstanceIdentifier)} which is called in * method {@link RestconfImpl#readConfigurationData} * * @@ -194,14 +194,14 @@ public class RestGetOperationTest extends JerseyTest { @Test public void getDataWithSlashesBehindMountPoint() throws UnsupportedEncodingException, URISyntaxException, ParseException { - InstanceIdentifier awaitedInstanceIdentifier = prepareInstanceIdentifierForList(); + YangInstanceIdentifier awaitedInstanceIdentifier = prepareInstanceIdentifierForList(); when( brokerFacade.readConfigurationDataBehindMountPoint(any(MountInstance.class), eq(awaitedInstanceIdentifier))).thenReturn(prepareCnDataForMountPointTest()); MountInstance mountInstance = mock(MountInstance.class); when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule); MountService mockMountService = mock(MountService.class); - when(mockMountService.getMountPoint(any(InstanceIdentifier.class))).thenReturn(mountInstance); + when(mockMountService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(mountInstance); ControllerContext.getInstance().setMountService(mockMountService); @@ -209,7 +209,7 @@ public class RestGetOperationTest extends JerseyTest { assertEquals(200, get(uri, MediaType.APPLICATION_XML)); } - private InstanceIdentifier prepareInstanceIdentifierForList() throws URISyntaxException, ParseException { + private YangInstanceIdentifier prepareInstanceIdentifierForList() throws URISyntaxException, ParseException { List parameters = new ArrayList<>(); Date revision = new SimpleDateFormat("yyyy-MM-dd").parse("2014-01-09"); @@ -218,21 +218,21 @@ public class RestGetOperationTest extends JerseyTest { QName qNameList = QName.create(uri, revision, "lst1"); QName qNameKeyList = QName.create(uri, revision, "lf11"); - parameters.add(new InstanceIdentifier.NodeIdentifier(qNameCont)); - parameters.add(new InstanceIdentifier.NodeIdentifierWithPredicates(qNameList, qNameKeyList, + parameters.add(new YangInstanceIdentifier.NodeIdentifier(qNameCont)); + parameters.add(new YangInstanceIdentifier.NodeIdentifierWithPredicates(qNameList, qNameKeyList, "GigabitEthernet0/0/0/0")); - return InstanceIdentifier.create(parameters); + return YangInstanceIdentifier.create(parameters); } @Test public void getDataMountPointIntoHighestElement() throws UnsupportedEncodingException, URISyntaxException { when( brokerFacade.readConfigurationDataBehindMountPoint(any(MountInstance.class), - any(InstanceIdentifier.class))).thenReturn(prepareCnDataForMountPointTest()); + any(YangInstanceIdentifier.class))).thenReturn(prepareCnDataForMountPointTest()); MountInstance mountInstance = mock(MountInstance.class); when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule); MountService mockMountService = mock(MountService.class); - when(mockMountService.getMountPoint(any(InstanceIdentifier.class))).thenReturn(mountInstance); + when(mockMountService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(mountInstance); ControllerContext.getInstance().setMountService(mockMountService); @@ -364,7 +364,7 @@ public class RestGetOperationTest extends JerseyTest { MountInstance mountInstance = mock(MountInstance.class); when(mountInstance.getSchemaContext()).thenReturn(schemaContextBehindMountPoint); MountService mockMountService = mock(MountService.class); - when(mockMountService.getMountPoint(any(InstanceIdentifier.class))).thenReturn(mountInstance); + when(mockMountService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(mountInstance); controllerContext.setMountService(mockMountService); @@ -453,7 +453,7 @@ public class RestGetOperationTest extends JerseyTest { MountInstance mountInstance = mock(MountInstance.class); when(mountInstance.getSchemaContext()).thenReturn(schemaContextBehindMountPoint); MountService mockMountService = mock(MountService.class); - when(mockMountService.getMountPoint(any(InstanceIdentifier.class))).thenReturn(mountInstance); + when(mockMountService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(mountInstance); controllerContext.setMountService(mockMountService); @@ -487,7 +487,7 @@ public class RestGetOperationTest extends JerseyTest { MountInstance mountInstance = mock(MountInstance.class); when(mountInstance.getSchemaContext()).thenReturn(schemaContextBehindMountPoint); MountService mockMountService = mock(MountService.class); - when(mockMountService.getMountPoint(any(InstanceIdentifier.class))).thenReturn(mountInstance); + when(mockMountService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(mountInstance); controllerContext.setMountService(mockMountService); @@ -644,11 +644,11 @@ public class RestGetOperationTest extends JerseyTest { } private void mockReadOperationalDataMethod() { - when(brokerFacade.readOperationalData(any(InstanceIdentifier.class))).thenReturn(answerFromGet); + when(brokerFacade.readOperationalData(any(YangInstanceIdentifier.class))).thenReturn(answerFromGet); } private void mockReadConfigurationDataMethod() { - when(brokerFacade.readConfigurationData(any(InstanceIdentifier.class))).thenReturn(answerFromGet); + when(brokerFacade.readConfigurationData(any(YangInstanceIdentifier.class))).thenReturn(answerFromGet); } private static CompositeNode prepareCompositeNodeWithIetfInterfacesInterfacesData() { @@ -726,7 +726,7 @@ public class RestGetOperationTest extends JerseyTest { toSimpleNodeData(toNestedQName("depth3-leaf2"), "depth3-leaf2-value")), toSimpleNodeData(toNestedQName("depth2-leaf1"), "depth2-leaf1-value"))); - when(brokerFacade.readConfigurationData(any(InstanceIdentifier.class))).thenReturn(depth1Cont); + when(brokerFacade.readConfigurationData(any(YangInstanceIdentifier.class))).thenReturn(depth1Cont); // Test config with depth 1 @@ -852,7 +852,7 @@ public class RestGetOperationTest extends JerseyTest { toSimpleNodeData(toNestedQName("depth4-leaf1"), "depth4-leaf1-value")), toSimpleNodeData(toNestedQName("depth3-leaf1"), "depth3-leaf1-value"))); - when(brokerFacade.readOperationalData(any(InstanceIdentifier.class))).thenReturn(depth2Cont1); + when(brokerFacade.readOperationalData(any(YangInstanceIdentifier.class))).thenReturn(depth2Cont1); response = target("/operational/nested-module:depth1-cont/depth2-cont1").queryParam("depth", "3") .request("application/xml").get(); diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java index af9dd28359..979b58b78a 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java @@ -55,7 +55,7 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; @@ -174,12 +174,12 @@ public class RestPostOperationTest extends JerseyTest { rpcResult).build(); when( brokerFacade.commitConfigurationDataPostBehindMountPoint(any(MountInstance.class), - any(InstanceIdentifier.class), any(CompositeNode.class))).thenReturn(dummyFuture); + any(YangInstanceIdentifier.class), any(CompositeNode.class))).thenReturn(dummyFuture); MountInstance mountInstance = mock(MountInstance.class); when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule); MountService mockMountService = mock(MountService.class); - when(mockMountService.getMountPoint(any(InstanceIdentifier.class))).thenReturn(mountInstance); + when(mockMountService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(mountInstance); ControllerContext.getInstance().setMountService(mockMountService); @@ -217,7 +217,7 @@ public class RestPostOperationTest extends JerseyTest { dummyFuture = new DummyFuture.Builder().build(); } - when(brokerFacade.commitConfigurationDataPost(any(InstanceIdentifier.class), any(CompositeNode.class))) + when(brokerFacade.commitConfigurationDataPost(any(YangInstanceIdentifier.class), any(CompositeNode.class))) .thenReturn(dummyFuture); } @@ -229,10 +229,10 @@ public class RestPostOperationTest extends JerseyTest { Future> dummyFuture = new DummyFuture.Builder().rpcResult( rpcResult).build(); - when(brokerFacade.commitConfigurationDataPost(any(InstanceIdentifier.class), any(CompositeNode.class))) + when(brokerFacade.commitConfigurationDataPost(any(YangInstanceIdentifier.class), any(CompositeNode.class))) .thenReturn(dummyFuture); - ArgumentCaptor instanceIdCaptor = ArgumentCaptor.forClass(InstanceIdentifier.class); + ArgumentCaptor instanceIdCaptor = ArgumentCaptor.forClass(YangInstanceIdentifier.class); ArgumentCaptor compNodeCaptor = ArgumentCaptor.forClass(CompositeNode.class); String URI_1 = "/config"; @@ -253,7 +253,7 @@ public class RestPostOperationTest extends JerseyTest { public void createConfigurationDataNullTest() throws UnsupportedEncodingException { initMocking(); - when(brokerFacade.commitConfigurationDataPost(any(InstanceIdentifier.class), any(CompositeNode.class))) + when(brokerFacade.commitConfigurationDataPost(any(YangInstanceIdentifier.class), any(CompositeNode.class))) .thenReturn(null); String URI_1 = "/config"; diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutOperationTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutOperationTest.java index 44b5f491d6..5d837f42bd 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutOperationTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutOperationTest.java @@ -39,7 +39,7 @@ import org.opendaylight.controller.sal.restconf.impl.ControllerContext; import org.opendaylight.controller.sal.restconf.impl.RestconfImpl; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.SchemaContext; public class RestPutOperationTest extends JerseyTest { @@ -123,12 +123,12 @@ public class RestPutOperationTest extends JerseyTest { rpcResult).build(); when( brokerFacade.commitConfigurationDataPutBehindMountPoint(any(MountInstance.class), - any(InstanceIdentifier.class), any(CompositeNode.class))).thenReturn(dummyFuture); + any(YangInstanceIdentifier.class), any(CompositeNode.class))).thenReturn(dummyFuture); MountInstance mountInstance = mock(MountInstance.class); when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule); MountService mockMountService = mock(MountService.class); - when(mockMountService.getMountPoint(any(InstanceIdentifier.class))).thenReturn(mountInstance); + when(mockMountService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(mountInstance); ControllerContext.getInstance().setMountService(mockMountService); @@ -147,12 +147,12 @@ public class RestPutOperationTest extends JerseyTest { rpcResult).build(); when( brokerFacade.commitConfigurationDataPutBehindMountPoint(any(MountInstance.class), - any(InstanceIdentifier.class), any(CompositeNode.class))).thenReturn(dummyFuture); + any(YangInstanceIdentifier.class), any(CompositeNode.class))).thenReturn(dummyFuture); MountInstance mountInstance = mock(MountInstance.class); when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule); MountService mockMountService = mock(MountService.class); - when(mockMountService.getMountPoint(any(InstanceIdentifier.class))).thenReturn(mountInstance); + when(mockMountService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(mountInstance); ControllerContext.getInstance().setMountService(mockMountService); @@ -169,7 +169,7 @@ public class RestPutOperationTest extends JerseyTest { .build(); Future> dummyFuture = new DummyFuture.Builder().rpcResult( rpcResult).build(); - when(brokerFacade.commitConfigurationDataPut(any(InstanceIdentifier.class), any(CompositeNode.class))) + when(brokerFacade.commitConfigurationDataPut(any(YangInstanceIdentifier.class), any(CompositeNode.class))) .thenReturn(dummyFuture); } diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfImplTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfImplTest.java index 3794815c89..236712b454 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfImplTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfImplTest.java @@ -24,7 +24,7 @@ import org.opendaylight.controller.sal.restconf.impl.BrokerFacade; import org.opendaylight.controller.sal.restconf.impl.ControllerContext; import org.opendaylight.controller.sal.restconf.impl.RestconfImpl; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; @@ -58,7 +58,7 @@ public class RestconfImplTest { CompositeNode loadedCompositeNode = TestUtils.readInputToCnSn("/parts/ietf-interfaces_interfaces.xml", XmlToCompositeNodeProvider.INSTANCE); BrokerFacade brokerFacade = mock(BrokerFacade.class); - when(brokerFacade.readOperationalData(any(InstanceIdentifier.class))).thenReturn(loadedCompositeNode); + when(brokerFacade.readOperationalData(any(YangInstanceIdentifier.class))).thenReturn(loadedCompositeNode); assertEquals(loadedCompositeNode, brokerFacade.readOperationalData(null)); } 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 ed1529540d..67d98f6b55 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 @@ -51,7 +51,7 @@ import org.opendaylight.controller.sal.restconf.impl.RestconfImpl; import org.opendaylight.controller.sal.restconf.impl.StructuredData; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; @@ -229,7 +229,7 @@ public final class TestUtils { controllerContext.setSchemas(TestUtils.loadSchemaContext(modules)); - when(mockedBrokerFacade.commitConfigurationDataPut(any(InstanceIdentifier.class), any(CompositeNode.class))) + when(mockedBrokerFacade.commitConfigurationDataPut(any(YangInstanceIdentifier.class), any(CompositeNode.class))) .thenReturn( new DummyFuture.Builder().rpcResult( new DummyRpcResult.Builder().result(TransactionStatus.COMMITED) diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URITest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URITest.java index 18703040ee..655aba267f 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URITest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URITest.java @@ -28,7 +28,7 @@ import org.opendaylight.controller.sal.restconf.impl.ControllerContext; import org.opendaylight.controller.sal.restconf.impl.InstanceIdWithSchemaNode; import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException; import org.opendaylight.controller.sal.restconf.impl.RestconfImpl; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; @@ -168,6 +168,6 @@ public class URITest { } else { when(mountInstance.getSchemaContext()).thenReturn(null); } - when(mountService.getMountPoint(any(InstanceIdentifier.class))).thenReturn(mountInstance); + when(mountService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(mountInstance); } } diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/XmlAndJsonToCnSnInstanceIdentifierTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/XmlAndJsonToCnSnInstanceIdentifierTest.java index 0799fdcff8..f4e869f99f 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/XmlAndJsonToCnSnInstanceIdentifierTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/XmlAndJsonToCnSnInstanceIdentifierTest.java @@ -22,10 +22,10 @@ import org.opendaylight.controller.sal.rest.impl.JsonToCompositeNodeProvider; import org.opendaylight.controller.sal.rest.impl.XmlToCompositeNodeProvider; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeWithValue; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.api.SimpleNode; public class XmlAndJsonToCnSnInstanceIdentifierTest extends YangAndXmlAndDataSchemaLoader { @@ -70,9 +70,9 @@ public class XmlAndJsonToCnSnInstanceIdentifierTest extends YangAndXmlAndDataSch private void verifyLeafListPredicate(CompositeNode cnSn) throws URISyntaxException { SimpleNode lf11 = getSnWithInstanceIdentifierWhenLeafList(cnSn); Object value = lf11.getValue(); - assertTrue(value instanceof InstanceIdentifier); + assertTrue(value instanceof YangInstanceIdentifier); - InstanceIdentifier instanceIdentifier = (InstanceIdentifier) value; + YangInstanceIdentifier instanceIdentifier = (YangInstanceIdentifier) value; List pathArguments = instanceIdentifier.getPath(); assertEquals(3, pathArguments.size()); String revisionDate = "2014-01-17"; @@ -91,9 +91,9 @@ public class XmlAndJsonToCnSnInstanceIdentifierTest extends YangAndXmlAndDataSch private void verifyListPredicate(CompositeNode cnSn) throws URISyntaxException { SimpleNode lf111 = getSnWithInstanceIdentifierWhenList(cnSn); Object value = lf111.getValue(); - assertTrue(value instanceof InstanceIdentifier); + assertTrue(value instanceof YangInstanceIdentifier); - InstanceIdentifier instanceIdentifier = (InstanceIdentifier) value; + YangInstanceIdentifier instanceIdentifier = (YangInstanceIdentifier) value; List pathArguments = instanceIdentifier.getPath(); assertEquals(4, pathArguments.size()); String revisionDate = "2014-01-17"; diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/mountpoints/MountPointSwagger.java b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/mountpoints/MountPointSwagger.java index 20e0fa56a7..29ada12c6f 100644 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/mountpoints/MountPointSwagger.java +++ b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/mountpoints/MountPointSwagger.java @@ -31,9 +31,9 @@ import org.opendaylight.controller.sal.rest.doc.swagger.Operation; import org.opendaylight.controller.sal.rest.doc.swagger.Resource; import org.opendaylight.controller.sal.rest.doc.swagger.ResourceList; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; @@ -43,14 +43,14 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount private static final String DATASTORES_LABEL = "Datastores"; private MountProvisionService mountService; - private final Map instanceIdToLongId = new TreeMap<>( - new Comparator() { + private final Map instanceIdToLongId = new TreeMap<>( + new Comparator() { @Override - public int compare(final InstanceIdentifier o1, final InstanceIdentifier o2) { + public int compare(final YangInstanceIdentifier o1, final YangInstanceIdentifier o2) { return o1.toString().compareToIgnoreCase(o2.toString()); } }); - private final Map longIdToInstanceId = new HashMap<>(); + private final Map longIdToInstanceId = new HashMap<>(); private final Object lock = new Object(); private final AtomicLong idKey = new AtomicLong(0); @@ -62,7 +62,7 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount Map urlToId = new HashMap<>(); synchronized (lock) { SchemaContext context = globalSchema.getGlobalContext(); - for (Entry entry : instanceIdToLongId.entrySet()) { + for (Entry entry : instanceIdToLongId.entrySet()) { String modName = findModuleName(entry.getKey(), context); urlToId.put(generateUrlPrefixFromInstanceID(entry.getKey(), modName), entry.getValue()); @@ -75,7 +75,7 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount this.globalSchema = globalSchema; } - private String findModuleName(final InstanceIdentifier id, final SchemaContext context) { + private String findModuleName(final YangInstanceIdentifier id, final SchemaContext context) { PathArgument rootQName = id.getPathArguments().iterator().next(); for (Module mod : context.getModules()) { if (mod.getDataChildByName(rootQName.getNodeType()) != null) { @@ -85,7 +85,7 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount return null; } - private String generateUrlPrefixFromInstanceID(final InstanceIdentifier key, final String moduleName) { + private String generateUrlPrefixFromInstanceID(final YangInstanceIdentifier key, final String moduleName) { StringBuilder builder = new StringBuilder(); if (moduleName != null) { builder.append(moduleName); @@ -101,7 +101,7 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount builder.append('/'); } builder.append(name); - if (arg instanceof InstanceIdentifier.NodeIdentifierWithPredicates) { + if (arg instanceof YangInstanceIdentifier.NodeIdentifierWithPredicates) { NodeIdentifierWithPredicates nodeId = (NodeIdentifierWithPredicates) arg; for (Entry entry : nodeId.getKeyValues().entrySet()) { builder.append('/').append(entry.getValue()); @@ -112,13 +112,13 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount return builder.append('/').toString(); } - private String getYangMountUrl(final InstanceIdentifier key) { + private String getYangMountUrl(final YangInstanceIdentifier key) { String modName = findModuleName(key, globalSchema.getGlobalContext()); return generateUrlPrefixFromInstanceID(key, modName) + "yang-ext:mount/"; } public ResourceList getResourceList(final UriInfo uriInfo, final Long id) { - InstanceIdentifier iid = getInstanceId(id); + YangInstanceIdentifier iid = getInstanceId(id); if (iid == null) { return null; // indicating not found. } @@ -138,15 +138,15 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount return list; } - private InstanceIdentifier getInstanceId(final Long id) { - InstanceIdentifier instanceId; + private YangInstanceIdentifier getInstanceId(final Long id) { + YangInstanceIdentifier instanceId; synchronized (lock) { instanceId = longIdToInstanceId.get(id); } return instanceId; } - private SchemaContext getSchemaContext(final InstanceIdentifier id) { + private SchemaContext getSchemaContext(final YangInstanceIdentifier id) { if (id == null) { return null; @@ -165,7 +165,7 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount } public ApiDeclaration getMountPointApi(final UriInfo uriInfo, final Long id, final String module, final String revision) { - InstanceIdentifier iid = getInstanceId(id); + YangInstanceIdentifier iid = getInstanceId(id); SchemaContext context = getSchemaContext(iid); String urlPrefix = getYangMountUrl(iid); if (context == null) { @@ -211,7 +211,7 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount } @Override - public void onMountPointCreated(final InstanceIdentifier path) { + public void onMountPointCreated(final YangInstanceIdentifier path) { synchronized (lock) { Long idLong = idKey.incrementAndGet(); instanceIdToLongId.put(path, idLong); @@ -220,7 +220,7 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount } @Override - public void onMountPointRemoved(final InstanceIdentifier path) { + public void onMountPointRemoved(final YangInstanceIdentifier path) { synchronized (lock) { Long id = instanceIdToLongId.remove(path); longIdToInstanceId.remove(id); diff --git a/opendaylight/md-sal/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/MountPointSwaggerTest.java b/opendaylight/md-sal/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/MountPointSwaggerTest.java index a2e29398a3..bba8ed9ca6 100644 --- a/opendaylight/md-sal/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/MountPointSwaggerTest.java +++ b/opendaylight/md-sal/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/MountPointSwaggerTest.java @@ -32,13 +32,13 @@ import org.opendaylight.controller.sal.rest.doc.swagger.Operation; import org.opendaylight.controller.sal.rest.doc.swagger.Resource; import org.opendaylight.controller.sal.rest.doc.swagger.ResourceList; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.SchemaContext; public class MountPointSwaggerTest { private static final String HTTP_URL = "http://localhost/path"; - private static final InstanceIdentifier instanceId = InstanceIdentifier.builder() + private static final YangInstanceIdentifier instanceId = YangInstanceIdentifier.builder() .node(QName.create("nodes")) .nodeWithKey(QName.create("node"), QName.create("id"), "123").build(); private static final String INSTANCE_URL = "nodes/node/123/"; diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/FlowStatsTracker.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/FlowStatsTracker.java index add46bd162..edf7388a76 100644 --- a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/FlowStatsTracker.java +++ b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/FlowStatsTracker.java @@ -64,31 +64,15 @@ final class FlowStatsTracker extends AbstractListeningStatsTracker flowRef = getNodeIdentifierBuilder().augmentation(FlowCapableNode.class) .child(Table.class, new TableKey(tableId)) .child(Flow.class,newFlowKey).toInstance(); - flowBuilder.setKey(newFlowKey); - flowBuilder.addAugmentation(FlowStatisticsData.class, flowStatisticsData.build()); + flow.setKey(newFlowKey); + flow.addAugmentation(FlowStatisticsData.class, flowStatisticsData.build()); logger.debug("Flow {} is not present in config data store, augmenting statistics as an unaccounted flow", - flowBuilder.build()); + flow.build()); // Update entry with timestamp of latest response flow.setKey(newFlowKey); FlowStatsEntry flowStatsEntry = new FlowStatsEntry(tableId,flow.build()); - trans.putOperationalData(flowRef, flowBuilder.build()); + trans.putOperationalData(flowRef, flow.build()); return flowStatsEntry; } diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/toxml/SimpleIdentityRefAttributeWritingStrategy.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/toxml/SimpleIdentityRefAttributeWritingStrategy.java index a2b8e0bfdf..104bf4df94 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/toxml/SimpleIdentityRefAttributeWritingStrategy.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/toxml/SimpleIdentityRefAttributeWritingStrategy.java @@ -45,6 +45,6 @@ public class SimpleIdentityRefAttributeWritingStrategy extends SimpleAttributeWr QName qName = QName.create(value); String identityValue = qName.getLocalName(); String identityNamespace = qName.getNamespace().toString(); - return XmlUtil.createTextElementWithNamespacedContent(doc, key, PREFIX, identityNamespace, identityValue); + return XmlUtil.createTextElementWithNamespacedContent(doc, key, PREFIX, identityNamespace, identityValue, namespace); } } diff --git a/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/reader/impl/LeafListEntryReader.java b/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/reader/impl/LeafListEntryReader.java index 4ba3478365..a05a169c99 100644 --- a/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/reader/impl/LeafListEntryReader.java +++ b/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/reader/impl/LeafListEntryReader.java @@ -1,3 +1,4 @@ + /* * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. * @@ -9,7 +10,6 @@ package org.opendaylight.controller.netconf.cli.reader.impl; import com.google.common.base.Optional; import com.google.common.collect.Lists; -import java.util.List; import jline.console.completer.Completer; import org.opendaylight.controller.netconf.cli.io.BaseConsoleContext; import org.opendaylight.controller.netconf.cli.io.ConsoleContext; @@ -19,6 +19,8 @@ import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.TypeDefinition; +import java.util.List; + class LeafListEntryReader extends BasicDataHolderReader implements GenericListEntryReader { diff --git a/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/writer/impl/ChoiceNodeCliSerializer.java b/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/writer/impl/ChoiceNodeCliSerializer.java index 62845ad129..1ca902f739 100644 --- a/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/writer/impl/ChoiceNodeCliSerializer.java +++ b/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/writer/impl/ChoiceNodeCliSerializer.java @@ -11,7 +11,7 @@ import com.google.common.base.Preconditions; import java.util.Collections; import org.opendaylight.controller.netconf.cli.writer.OutFormatter; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; import org.opendaylight.yangtools.yang.data.impl.schema.transform.base.serializer.ChoiceNodeBaseSerializer; import org.opendaylight.yangtools.yang.data.impl.schema.transform.base.serializer.NodeSerializerDispatcher; @@ -68,4 +68,4 @@ final class ChoiceNodeCliSerializer extends ChoiceNodeBaseSerializer { protected NodeSerializerDispatcher getNodeDispatcher() { return dispatcher; } -} \ No newline at end of file +} diff --git a/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/writer/impl/CliOutputFromNormalizedNodeSerializerFactory.java b/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/writer/impl/CliOutputFromNormalizedNodeSerializerFactory.java index cab07afe6c..a62af7651e 100644 --- a/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/writer/impl/CliOutputFromNormalizedNodeSerializerFactory.java +++ b/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/writer/impl/CliOutputFromNormalizedNodeSerializerFactory.java @@ -8,6 +8,7 @@ package org.opendaylight.controller.netconf.cli.writer.impl; import org.opendaylight.controller.netconf.cli.writer.OutFormatter; +import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode; import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode; import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; @@ -20,6 +21,7 @@ import org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlCodecProvider; import org.opendaylight.yangtools.yang.data.impl.schema.transform.FromNormalizedNodeSerializer; import org.opendaylight.yangtools.yang.data.impl.schema.transform.FromNormalizedNodeSerializerFactory; import org.opendaylight.yangtools.yang.data.impl.schema.transform.base.serializer.NodeSerializerDispatcher; +import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode; import org.opendaylight.yangtools.yang.model.api.AugmentationSchema; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; @@ -100,4 +102,9 @@ public final class CliOutputFromNormalizedNodeSerializerFactory implements FromN return mapNodeSerializer; } + @Override + public FromNormalizedNodeSerializer getAnyXmlNodeSerializer() { + throw new UnsupportedOperationException(); + } + } \ No newline at end of file diff --git a/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/writer/impl/NodeCliSerializerDispatcher.java b/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/writer/impl/NodeCliSerializerDispatcher.java index 08abd47f25..566829d178 100644 --- a/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/writer/impl/NodeCliSerializerDispatcher.java +++ b/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/writer/impl/NodeCliSerializerDispatcher.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.netconf.cli.writer.impl; import com.google.common.base.Preconditions; import com.google.common.collect.Iterables; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode; import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; @@ -35,7 +35,7 @@ public class NodeCliSerializerDispatcher implements NodeSerializerDispatcher dispatchChildElement(final Object childSchema, - final DataContainerChild dataContainerChild) { + final DataContainerChild dataContainerChild) { if (dataContainerChild instanceof ContainerNode) { return onContainerNode(childSchema, dataContainerChild); } else if (dataContainerChild instanceof LeafNode) { @@ -55,14 +55,14 @@ public class NodeCliSerializerDispatcher implements NodeSerializerDispatcher onAugmentationSchema(final Object childSchema, - final DataContainerChild dataContainerChild) { + final DataContainerChild dataContainerChild) { checkSchemaCompatibility(childSchema, AugmentationSchema.class, dataContainerChild); return factory.getAugmentationNodeSerializer().serialize((AugmentationSchema) childSchema, (AugmentationNode) dataContainerChild); } private Iterable onChoiceNode(final Object childSchema, - final DataContainerChild dataContainerChild) { + final DataContainerChild dataContainerChild) { checkSchemaCompatibility(childSchema, org.opendaylight.yangtools.yang.model.api.ChoiceNode.class, dataContainerChild); return factory.getChoiceNodeSerializer().serialize( @@ -70,20 +70,20 @@ public class NodeCliSerializerDispatcher implements NodeSerializerDispatcher onListNode(final Object childSchema, - final DataContainerChild dataContainerChild) { + final DataContainerChild dataContainerChild) { checkSchemaCompatibility(childSchema, ListSchemaNode.class, dataContainerChild); return factory.getMapNodeSerializer().serialize((ListSchemaNode) childSchema, (MapNode) dataContainerChild); } private Iterable onLeafListNode(final Object childSchema, - final DataContainerChild dataContainerChild) { + final DataContainerChild dataContainerChild) { checkSchemaCompatibility(childSchema, LeafListSchemaNode.class, dataContainerChild); return factory.getLeafSetNodeSerializer().serialize((LeafListSchemaNode) childSchema, (LeafSetNode) dataContainerChild); } private Iterable onLeafNode(final Object childSchema, - final DataContainerChild dataContainerChild) { + final DataContainerChild dataContainerChild) { checkSchemaCompatibility(childSchema, LeafSchemaNode.class, dataContainerChild); final Iterable elements = factory.getLeafNodeSerializer().serialize((LeafSchemaNode) childSchema, (LeafNode) dataContainerChild); @@ -92,7 +92,7 @@ public class NodeCliSerializerDispatcher implements NodeSerializerDispatcher elements, - final DataContainerChild dataContainerChild) { + final DataContainerChild dataContainerChild) { final int size = Iterables.size(elements); Preconditions.checkArgument(size == 1, "Unexpected count of elements for entry serialized from: %s, should be 1, was: %s", dataContainerChild, @@ -100,7 +100,7 @@ public class NodeCliSerializerDispatcher implements NodeSerializerDispatcher onContainerNode(final Object childSchema, - final DataContainerChild dataContainerChild) { + final DataContainerChild dataContainerChild) { checkSchemaCompatibility(childSchema, ContainerSchemaNode.class, dataContainerChild); final Iterable elements = factory.getContainerNodeSerializer().serialize( @@ -110,9 +110,9 @@ public class NodeCliSerializerDispatcher implements NodeSerializerDispatcher containerSchemaNodeClass, - final DataContainerChild dataContainerChild) { + final DataContainerChild dataContainerChild) { Preconditions.checkArgument(containerSchemaNodeClass.isAssignableFrom(childSchema.getClass()), "Incompatible schema: %s with node: %s, expected: %s", childSchema, dataContainerChild, containerSchemaNodeClass); } -} \ No newline at end of file +} 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 eef9a39a27..c101db9ef8 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 @@ -13,7 +13,7 @@ import java.util.List; import org.opendaylight.controller.netconf.cli.io.ConsoleIO; import org.opendaylight.controller.netconf.cli.writer.OutFormatter; import org.opendaylight.controller.netconf.cli.writer.WriteException; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; 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; @@ -91,4 +91,4 @@ public class NormalizedNodeWriter extends AbstractWriter { return null; } -} \ No newline at end of file +} diff --git a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlElement.java b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlElement.java index 8780925eb1..4e3a66b7ec 100644 --- a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlElement.java +++ b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlElement.java @@ -224,11 +224,17 @@ public final class XmlElement { }); } + /** + * + * @param tagName tag name without prefix + * @return + */ public List getChildElements(final String tagName) { return getChildElementsInternal(new ElementFilteringStrategy() { @Override public boolean accept(Element e) { - return e.getTagName().equals(tagName); + // localName returns pure localName without prefix + return e.getLocalName().equals(tagName); } }); } diff --git a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlUtil.java b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlUtil.java index 01b1c8d564..9e227ee05d 100644 --- a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlUtil.java +++ b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlUtil.java @@ -124,8 +124,14 @@ public final class XmlUtil { public static Element createTextElementWithNamespacedContent(Document document, String qName, String prefix, String namespace, String contentWithoutPrefix) { + return createTextElementWithNamespacedContent(document, qName, prefix, namespace, contentWithoutPrefix, Optional.absent()); + } + + public static Element createTextElementWithNamespacedContent(Document document, String qName, String prefix, + String namespace, String contentWithoutPrefix, Optional namespaceURI) { + String content = createPrefixedValue(XmlNetconfConstants.PREFIX, contentWithoutPrefix); - Element element = createTextElement(document, qName, content, Optional.absent()); + Element element = createTextElement(document, qName, content, namespaceURI); String prefixedNamespaceAttr = createPrefixedValue(XMLNS_ATTRIBUTE_KEY, prefix); element.setAttributeNS(XMLNS_URI, prefixedNamespaceAttr, namespace); return element; diff --git a/opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronSubnet.java b/opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronSubnet.java index 840029006b..1f10b39513 100644 --- a/opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronSubnet.java +++ b/opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronSubnet.java @@ -75,7 +75,7 @@ public class NeutronSubnet extends ConfigurationObject implements Serializable, */ List myPorts; - boolean gatewayIPAssigned; + Boolean gatewayIPAssigned; public NeutronSubnet() { myPorts = new ArrayList(); @@ -299,7 +299,7 @@ public class NeutronSubnet extends ConfigurationObject implements Serializable, try { SubnetUtils util = new SubnetUtils(cidr); SubnetInfo info = util.getInfo(); - if (gatewayIP == null) { + if (gatewayIP == null || ("").equals(gatewayIP)) { gatewayIP = info.getLowAddress(); } if (allocationPools.size() < 1) { @@ -460,6 +460,10 @@ public class NeutronSubnet extends ConfigurationObject implements Serializable, gatewayIPAssigned = false; } + public Boolean getGatewayIPAllocated() { + return gatewayIPAssigned; + } + @Override public String toString() { return "NeutronSubnet [subnetUUID=" + subnetUUID + ", networkUUID=" + networkUUID + ", name=" + name diff --git a/opendaylight/northbound/commons/pom.xml b/opendaylight/northbound/commons/pom.xml index a2d2dac112..cbc1f0c328 100644 --- a/opendaylight/northbound/commons/pom.xml +++ b/opendaylight/northbound/commons/pom.xml @@ -91,7 +91,6 @@ javax.ws.rs.core, javax.xml.bind, javax.xml.bind.annotation, - org.objectweb.asm, org.opendaylight.controller.sal.utils, org.opendaylight.controller.sal.core, org.opendaylight.controller.sal.authorization, diff --git a/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronRoutersNorthbound.java b/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronRoutersNorthbound.java index 17b2fcfcf9..806e853b36 100644 --- a/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronRoutersNorthbound.java +++ b/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronRoutersNorthbound.java @@ -422,7 +422,9 @@ public class NeutronRoutersNorthbound { if (instances != null) { for (Object instance : instances) { INeutronRouterAware service = (INeutronRouterAware) instance; - service.canAttachInterface(target, input); + int status = service.canAttachInterface(target, input); + if (status < 200 || status > 299) + return Response.status(status).build(); } } @@ -498,7 +500,9 @@ public class NeutronRoutersNorthbound { if (instances != null) { for (Object instance : instances) { INeutronRouterAware service = (INeutronRouterAware) instance; - service.canDetachInterface(target, input); + int status = service.canDetachInterface(target, input); + if (status < 200 || status > 299) + return Response.status(status).build(); } } diff --git a/pom.xml b/pom.xml index 242ab8eb89..8bebd2aa61 100644 --- a/pom.xml +++ b/pom.xml @@ -126,10 +126,6 @@ opendaylight/commons/filter-valve - features/base - features/controller - features/adsal - features/extras opendaylight/dummy-console opendaylight/karaf-branding opendaylight/distribution/opendaylight-karaf