Merge "Fix a typo in javadoc"
authorTony Tkacik <ttkacik@cisco.com>
Fri, 7 Nov 2014 10:29:10 +0000 (10:29 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 7 Nov 2014 10:29:10 +0000 (10:29 +0000)
93 files changed:
opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/IdentityAttributeRefTest.java
opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/JmxAttributeValidationExceptionTest.java
opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/ModuleIdentifierTest.java
opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/ValidationExceptionTest.java
opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/jmx/CommitStatusTest.java
opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/jmx/ObjectNameUtilTest.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/InterfacesHelper.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/OsgiRegistrationUtil.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/osgi/BlankTransactionServiceTrackerTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/osgi/BundleContextBackedModuleFactoriesResolverTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/osgi/ModuleFactoryBundleTrackerTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/osgi/RefreshingSCPModuleInfoRegistryTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/util/InterfacesHelperTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/util/OsgiRegistrationUtilTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/scheduledthreadpool/TestingScheduledThreadPoolModuleFactory.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/scheduledthreadpool/test/TwoInterfacesExportTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/threadpool/TestingFixedThreadPoolModuleFactory.java
opendaylight/config/config-util/src/test/java/org/opendaylight/controller/config/util/AttributeEntryTest.java
opendaylight/config/config-util/src/test/java/org/opendaylight/controller/config/util/ConfigRegistryClientsTest.java
opendaylight/config/logback-config/src/main/java/org/opendaylight/controller/config/yang/logback/config/ContextSetterImpl.java
opendaylight/config/logback-config/src/main/java/org/opendaylight/controller/config/yang/logback/config/LogbackModuleFactory.java
opendaylight/karaf-branding/pom.xml
opendaylight/md-sal/benchmark-data-store/pom.xml
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/AbstractRuntimeCodeGenerator.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueSerializer.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueType.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/common/NormalizedNodeMessages.java
opendaylight/md-sal/sal-clustering-commons/src/main/resources/Common.proto
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/NormalizedNodeSerializerTest.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueTypeTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java
opendaylight/md-sal/sal-clustering-commons/src/test/resources/odl-datastore-test.yang
opendaylight/md-sal/sal-distributed-datastore/pom.xml
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ConfigurationImpl.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CanCommitTransactionReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseDataChangeListenerRegistration.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseDataChangeListenerRegistrationReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransactionChain.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransactionChainReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransactionReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransactionReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataChangedReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataExists.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataExistsReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DeleteData.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DeleteDataReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/MergeDataReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PreCommitTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PreCommitTransactionReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryFound.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryNotFound.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadData.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterChangeListenerReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/WriteDataReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MergeModification.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/WriteModification.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactory.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ConfigurationImplTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFailureTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/DefaultShardStrategyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactoryTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockConfiguration.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockDataChangeListener.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/TestUtils.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CarsModel.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/PeopleModel.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/SampleModelsTest.java
opendaylight/md-sal/sal-dom-xsql-config/pom.xml
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/NetconfMessageTransformUtil.java
opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfToRpcRequestTest.java
opendaylight/netconf/config-netconf-connector/pom.xml
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/runtimerpc/RuntimeRpcElementResolved.java
opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/runtimerpc/RuntimeRpcElementResolvedTest.java [new file with mode: 0644]
opendaylight/netconf/netconf-monitoring/src/test/java/org/opendaylight/controller/netconf/monitoring/GetTest.java
opendaylight/netconf/netconf-monitoring/src/test/java/org/opendaylight/controller/netconf/monitoring/osgi/NetconfMonitoringActivatorTest.java
opendaylight/netconf/netconf-monitoring/src/test/java/org/opendaylight/controller/netconf/monitoring/osgi/NetconfMonitoringServiceTrackerTest.java
opendaylight/netconf/netconf-netty-util/src/test/java/org/opendaylight/controller/netconf/nettyutil/handler/ChunkedFramingMechanismEncoderTest.java
opendaylight/netconf/netconf-netty-util/src/test/java/org/opendaylight/controller/netconf/nettyutil/handler/NetconfEXIHandlersTest.java
opendaylight/netconf/netconf-netty-util/src/test/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerTest.java
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/mapping/AbstractNetconfOperation.java
opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/NetconfUtilTest.java
opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/messages/NetconfHelloMessageTest.java
opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/messages/NetconfMessageHeaderTest.java
opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/osgi/NetconfConfigUtilTest.java

index 6e8ece343f7ca6b0b0bdd126cb5b013fddc5d342..91e1f14849c03364f57f67b28eee5ff2d6017f8c 100644 (file)
@@ -1,17 +1,13 @@
 package org.opendaylight.controller.config.api;
 
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
 import org.junit.Assert;
 import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
 
-import javax.management.*;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.*;
-
 public class IdentityAttributeRefTest {
 
     IdentityAttributeRef attr = new IdentityAttributeRef("attr");
index f6e7dfb505ed486fb80cb8a5bc7f6799536abed0..9ff74052579f14f70be71d9df771d61fccd06eb4 100644 (file)
@@ -1,23 +1,18 @@
 package org.opendaylight.controller.config.api;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import com.google.common.collect.Lists;
 import java.nio.file.AccessDeniedException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
-
-import com.google.common.collect.Lists;
 import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
-import org.junit.Before;
 import org.junit.Test;
 
-import javax.management.Query;
-
-import static org.junit.Assert.*;
-
 public class JmxAttributeValidationExceptionTest {
 
-    private JmxAttribute jmxAttribute = new JmxAttribute("attr1");
+    private final JmxAttribute jmxAttribute = new JmxAttribute("attr1");
 
     @Test
     public void testJmxAttributeValidationExceptionElement() throws Exception {
@@ -28,7 +23,7 @@ public class JmxAttributeValidationExceptionTest {
 
     @Test
     public void testJmxAttributeValidationExceptionList() throws Exception {
-        List attributeNames = new ArrayList<JmxAttribute>();
+        List<JmxAttribute> attributeNames = new ArrayList<>();
         attributeNames.add(new JmxAttribute("att1"));
         attributeNames.add(new JmxAttribute("att2"));
         attributeNames.add(new JmxAttribute("att3"));
@@ -38,7 +33,7 @@ public class JmxAttributeValidationExceptionTest {
 
     @Test
     public void testJmxAttributeValidationExceptionList2() throws Exception {
-        List attributeNames = new ArrayList<JmxAttribute>();
+        List<JmxAttribute> attributeNames = new ArrayList<>();
         attributeNames.add(new JmxAttribute("att1"));
         attributeNames.add(new JmxAttribute("att2"));
         attributeNames.add(new JmxAttribute("att3"));
@@ -84,7 +79,7 @@ public class JmxAttributeValidationExceptionTest {
         JmxAttributeValidationException.checkCondition(false, "message", jmxAttribute);
     }
 
-    private void assertJmxEx(JmxAttributeValidationException e, String message, JmxAttribute... attrNames) {
+    private void assertJmxEx(final JmxAttributeValidationException e, final String message, final JmxAttribute... attrNames) {
         assertEquals(message, e.getMessage());
         assertEquals(Lists.newArrayList(attrNames), e.getAttributeNames());
     }
index c0e584a0986009499b8dc6601c0f529318b95ee3..2771b407f46725461088d99e9e1a1d1c8dd7a82e 100644 (file)
@@ -1,11 +1,8 @@
 package org.opendaylight.controller.config.api;
 
-import junit.framework.Assert;
-import org.junit.Test;
-
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotEquals;
+import org.junit.Test;
 
 public class ModuleIdentifierTest {
     String fact = new String("factory");
index 30712c966dfdb1c5b61109f043ce552039b1d084..8b4f2fe25875149bae70d0d80157961549939c80 100644 (file)
@@ -1,23 +1,20 @@
 package org.opendaylight.controller.config.api;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertTrue;
-import static junit.framework.Assert.fail;
-import static org.junit.Assert.assertNotEquals;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
-import static org.junit.matchers.JUnitMatchers.containsString;
-
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 import com.google.common.collect.Lists;
 import java.util.Map;
-
 import org.junit.Assert;
 import org.junit.Test;
 
 public class ValidationExceptionTest {
 
-    private String instance = "instance";
+    private final String instance = "instance";
     private final ModuleIdentifier mi = new ModuleIdentifier("module", instance);
-    private String instance2 = "instance2";
+    private final String instance2 = "instance2";
     private final ModuleIdentifier mi2 = new ModuleIdentifier("module", instance2);
     private final String message = "ex message";
     private final Exception e = new IllegalStateException(message);
index 36ebc9de9358b34473b9dc6feadda7cca35ff972..cb8271a581781ae94ac90ac577255128e6db4f1a 100644 (file)
@@ -1,17 +1,16 @@
 package org.opendaylight.controller.config.api.jmx;
 
+import java.util.ArrayList;
+import java.util.List;
+import javax.management.ObjectName;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
-import javax.management.ObjectName;
-import java.util.ArrayList;
-import java.util.List;
-
 public class CommitStatusTest {
-    List newInst = new ArrayList<ObjectName>();
-    List reusedInst = new ArrayList<ObjectName>();
-    List recreatedInst = new ArrayList<ObjectName>();
+    List<ObjectName> newInst = new ArrayList<>();
+    List<ObjectName> reusedInst = new ArrayList<>();
+    List<ObjectName> recreatedInst = new ArrayList<>();
 
     @Before
     public void setUp() throws Exception {
@@ -43,9 +42,9 @@ public class CommitStatusTest {
 
     @Test
     public void testNotEqual() throws Exception {
-        List newInst2 = new ArrayList<ObjectName>();
-        List reusedInst2 = new ArrayList<ObjectName>();
-        List recreatedInst2 = new ArrayList<ObjectName>();
+        List<ObjectName> newInst2 = new ArrayList<>();
+        List<ObjectName> reusedInst2 = new ArrayList<>();
+        List<ObjectName> recreatedInst2 = new ArrayList<>();
 
         newInst2.add(new ObjectName("first: key1 = value1"));
         reusedInst2.add(new ObjectName("second: key = val"));
index 02c1c4b9815ff55843e1abb74e99b0b529d48349..e69ff921ccc4975994d8c542a738d84f33f96c34 100644 (file)
@@ -7,18 +7,15 @@
  */
 package org.opendaylight.controller.config.api.jmx;
 
-import static junit.framework.Assert.fail;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
-
+import static org.junit.Assert.fail;
 import com.google.common.base.Throwables;
 import com.google.common.collect.Maps;
-
 import java.util.HashMap;
 import java.util.Map;
 import javax.management.ObjectName;
-import junit.framework.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.config.api.ModuleIdentifier;
@@ -84,7 +81,7 @@ public class ObjectNameUtilTest {
         assertPattern(on, pattern);
     }
 
-    private void assertPattern(ObjectName test, ObjectName pattern) {
+    private void assertPattern(final ObjectName test, final ObjectName pattern) {
         assertTrue(pattern.isPattern());
         assertTrue(pattern.apply(test));
     }
@@ -150,11 +147,11 @@ public class ObjectNameUtilTest {
         }, IllegalArgumentException.class);
     }
 
-    private void assertFailure(Runnable test, Class<? extends Exception> ex) {
+    private void assertFailure(final Runnable test, final Class<? extends Exception> ex) {
         try {
             test.run();
         } catch(Exception e) {
-            Assert.assertTrue("Failed with wrong exception: " + Throwables.getStackTraceAsString(e),
+            assertTrue("Failed with wrong exception: " + Throwables.getStackTraceAsString(e),
                     e.getClass().isAssignableFrom(ex));
             return;
         }
index 4d94c6d2655650ece2f9bcb1a26a3e0b872a7d60..5cb1513d9cfa037448d24937e30dfe0ac9bc5a95 100644 (file)
@@ -7,17 +7,16 @@
  */
 package org.opendaylight.controller.config.manager.impl.util;
 
-import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
-import org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation;
-import org.opendaylight.controller.config.spi.Module;
-import org.opendaylight.controller.config.spi.ModuleFactory;
-
-import javax.management.JMX;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
+import javax.management.JMX;
+import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
+import org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation;
+import org.opendaylight.controller.config.spi.Module;
+import org.opendaylight.controller.config.spi.ModuleFactory;
 
 public class InterfacesHelper {
 
@@ -40,7 +39,7 @@ public class InterfacesHelper {
 
     }
 
-    private static Set<Class<?>> getAllSuperInterfaces(Set<Class<?>> ifcs) {
+    private static Set<Class<?>> getAllSuperInterfaces(final Set<? extends Class<?>> ifcs) {
         Set<Class<?>> interfaces = new HashSet<>(ifcs); // create copy to modify
         // each interface can extend other interfaces
         Set<Class<?>> result = new HashSet<>();
@@ -61,7 +60,7 @@ public class InterfacesHelper {
      * Get interfaces that this class is derived from that are JMX interfaces.
      */
     public static Set<Class<?>> getMXInterfaces(
-            Class<? extends Module> configBeanClass) {
+            final Class<? extends Module> configBeanClass) {
         Set<Class<?>> allInterfaces = getAllInterfaces(configBeanClass);
         Set<Class<?>> result = new HashSet<>();
         for (Class<?> clazz : allInterfaces) {
@@ -78,7 +77,7 @@ public class InterfacesHelper {
      * annotation.
      */
     public static Set<Class<?>> getServiceInterfaces(
-            Class<? extends Module> configBeanClass) {
+            final Class<? extends Module> configBeanClass) {
         Set<Class<?>> allInterfaces = getAllInterfaces(configBeanClass);
         Set<Class<?>> result = new HashSet<>();
         for (Class<?> clazz : allInterfaces) {
@@ -93,7 +92,7 @@ public class InterfacesHelper {
         return result;
     }
 
-    public static Set<Class<? extends AbstractServiceInterface>> getAllAbstractServiceClasses(Class<? extends Module> configBeanClass) {
+    public static Set<Class<? extends AbstractServiceInterface>> getAllAbstractServiceClasses(final Class<? extends Module> configBeanClass) {
 
         Set<Class<? extends AbstractServiceInterface>> foundGeneratedSIClasses = new HashSet<>();
         for (Class<?> clazz : getAllInterfaces(configBeanClass)) {
@@ -111,7 +110,7 @@ public class InterfacesHelper {
      * {@link org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation#osgiRegistrationType()}
      */
     public static Set<Class<?>> getOsgiRegistrationTypes(
-            Class<? extends Module> configBeanClass) {
+            final Class<? extends Module> configBeanClass) {
         Set<Class<?>> serviceInterfaces = getServiceInterfaces(configBeanClass);
         Set<Class<?>> result = new HashSet<>();
         for (Class<?> clazz : serviceInterfaces) {
@@ -122,7 +121,7 @@ public class InterfacesHelper {
         return result;
     }
 
-    public static Set<String> getQNames(Set<ServiceInterfaceAnnotation> siAnnotations) {
+    public static Set<String> getQNames(final Set<ServiceInterfaceAnnotation> siAnnotations) {
         Set<String> qNames = new HashSet<>();
         for (ServiceInterfaceAnnotation sia: siAnnotations) {
             qNames.add(sia.value());
@@ -130,12 +129,12 @@ public class InterfacesHelper {
         return Collections.unmodifiableSet(qNames);
     }
 
-    public static Set<ServiceInterfaceAnnotation> getServiceInterfaceAnnotations(ModuleFactory factory) {
+    public static Set<ServiceInterfaceAnnotation> getServiceInterfaceAnnotations(final ModuleFactory factory) {
         Set<Class<? extends AbstractServiceInterface>> implementedServiceIntefaces = Collections.unmodifiableSet(factory.getImplementedServiceIntefaces());
         return getServiceInterfaceAnnotations(implementedServiceIntefaces);
     }
 
-    private static Set<ServiceInterfaceAnnotation> getServiceInterfaceAnnotations(Set<Class<? extends AbstractServiceInterface>> implementedServiceIntefaces) {
+    private static Set<ServiceInterfaceAnnotation> getServiceInterfaceAnnotations(final Set<Class<? extends AbstractServiceInterface>> implementedServiceIntefaces) {
         Set<Class<? extends AbstractServiceInterface>> inspected = getAllAbstractServiceInterfaceClasses(implementedServiceIntefaces);
         Set<ServiceInterfaceAnnotation> result = new HashSet<>();
         // SIs can form hierarchies, inspect superclass until it does not extend AbstractSI
@@ -149,9 +148,9 @@ public class InterfacesHelper {
     }
 
     static Set<Class<? extends AbstractServiceInterface>> getAllAbstractServiceInterfaceClasses(
-            Set<Class<? extends AbstractServiceInterface>> directlyImplementedAbstractSIs) {
+            final Set<Class<? extends AbstractServiceInterface>> directlyImplementedAbstractSIs) {
 
-        Set<Class<?>> allInterfaces = getAllSuperInterfaces((Set) directlyImplementedAbstractSIs);
+        Set<Class<?>> allInterfaces = getAllSuperInterfaces(directlyImplementedAbstractSIs);
         Set<Class<? extends AbstractServiceInterface>> result = new HashSet<>();
         for(Class<?> ifc: allInterfaces){
             if (AbstractServiceInterface.class.isAssignableFrom(ifc) &&
index f839452dcadb8e1295e8a1669154ea51699af5f5..4f792e72b10ccb826acb99c3d4117b071bdeef84 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.controller.config.manager.impl.util;
 
 import static com.google.common.base.Preconditions.checkNotNull;
-
 import java.util.ArrayList;
 import java.util.List;
 import java.util.ListIterator;
@@ -27,7 +26,7 @@ public class OsgiRegistrationUtil {
     }
 
     @SafeVarargs
-    public static <T> AutoCloseable registerService(BundleContext bundleContext, T service, Class<? super T> ... interfaces) {
+    public static <T> AutoCloseable registerService(final BundleContext bundleContext, final T service, final Class<? super T> ... interfaces) {
         checkNotNull(service);
         checkNotNull(interfaces);
         List<AutoCloseable> autoCloseableList = new ArrayList<>();
@@ -48,7 +47,7 @@ public class OsgiRegistrationUtil {
         };
     }
 
-    public static AutoCloseable wrap(final BundleTracker bundleTracker) {
+    public static AutoCloseable wrap(final BundleTracker<?> bundleTracker) {
         checkNotNull(bundleTracker);
         return new AutoCloseable() {
             @Override
index 471c98a6769fdde5dffe3f9ddccd454ae9317bfa..8ceee0caf5596b798371436f0f81fc9c2294febc 100644 (file)
@@ -1,14 +1,13 @@
 package org.opendaylight.controller.config.manager.impl.osgi;
 
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertSame;
-import static junit.framework.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.fail;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
-
 import java.util.Collections;
 import javax.management.ObjectName;
 import org.junit.Before;
index dc3deddddc79dfa664232e5f540c74116844a181..44e6e9ab778fc89b063e176a13cdcfdd2ab71103 100644 (file)
@@ -1,13 +1,12 @@
 package org.opendaylight.controller.config.manager.impl.osgi;
 
-import static junit.framework.Assert.fail;
+import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
-import static org.junit.matchers.JUnitMatchers.containsString;
+import static org.junit.Assert.fail;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
-
 import com.google.common.collect.Lists;
 import java.util.Map;
 import org.junit.Before;
@@ -24,8 +23,8 @@ public class BundleContextBackedModuleFactoriesResolverTest {
     @Mock
     private BundleContext bundleContext;
     private BundleContextBackedModuleFactoriesResolver resolver;
-    private ServiceReference s1;
-    private ServiceReference s2;
+    private ServiceReference<?> s1;
+    private ServiceReference<?> s2;
     private ModuleFactory f1;
     private ModuleFactory f2;
 
@@ -42,15 +41,15 @@ public class BundleContextBackedModuleFactoriesResolverTest {
         resolver = new BundleContextBackedModuleFactoriesResolver(bundleContext);
     }
 
-    private ModuleFactory getMockFactory(String name) {
+    private ModuleFactory getMockFactory(final String name) {
         ModuleFactory mock = mock(ModuleFactory.class);
         doReturn(name).when(mock).toString();
         doReturn(name).when(mock).getImplementationName();
         return mock;
     }
 
-    private ServiceReference getServiceRef() {
-        ServiceReference mock = mock(ServiceReference.class);
+    private ServiceReference<?> getServiceRef() {
+        ServiceReference<?> mock = mock(ServiceReference.class);
         doReturn("serviceRef").when(mock).toString();
         final Bundle bundle = mock(Bundle.class);
         doReturn(bundleContext).when(bundle).getBundleContext();
index 5b83412083c359b09c80b5c2caac7d78fec0a16f..25d770e6c9577b11d24651515fc3f432b87eae59 100644 (file)
@@ -1,8 +1,8 @@
 package org.opendaylight.controller.config.manager.impl.osgi;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.fail;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyObject;
 import static org.mockito.Matchers.anyString;
@@ -11,10 +11,8 @@ import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyZeroInteractions;
-
 import java.util.Dictionary;
 import java.util.Set;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
@@ -44,7 +42,7 @@ public class ModuleFactoryBundleTrackerTest {
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-        doAnswer(new Answer() {
+        doAnswer(new Answer<Object>() {
             @Override
             public Object answer(final InvocationOnMock invocation) throws Throwable {
                 return getClass().getClassLoader().loadClass((String) invocation.getArguments()[0]);
@@ -141,7 +139,7 @@ public class ModuleFactoryBundleTrackerTest {
     }
 
     static class WrongConstructorTestingFactory extends TestingFactory {
-        WrongConstructorTestingFactory(String randomParam) {
+        WrongConstructorTestingFactory(final String randomParam) {
         }
     }
 
index 79391d4343a7d1a6dafa413c5fd18b1e93d8103e..9edb64ac6b8c83b594d85daad5cb3f2d48e6edd7 100644 (file)
@@ -1,5 +1,9 @@
 package org.opendaylight.controller.config.manager.impl.osgi;
 
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import java.util.Dictionary;
 import org.junit.Test;
 import org.mockito.Mockito;
 import org.opendaylight.controller.config.manager.impl.osgi.mapping.RefreshingSCPModuleInfoRegistry;
@@ -10,12 +14,6 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
 
-import java.util.*;
-
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-
 public class RefreshingSCPModuleInfoRegistryTest {
     @Test
     public void testConstructor() throws Exception {
@@ -24,8 +22,7 @@ public class RefreshingSCPModuleInfoRegistryTest {
         doReturn("string").when(prov).toString();
 
         BundleContext ctxt = mock(BundleContext.class);
-        Dictionary dict = new Hashtable();
-        ServiceRegistration servReg = mock(ServiceRegistration.class);
+        ServiceRegistration<?> servReg = mock(ServiceRegistration.class);
         doReturn(servReg).when(ctxt).registerService(Mockito.any(Class.class), Mockito.any(SchemaContextProvider.class), Mockito.any(Dictionary.class));
         doReturn(servReg).when(ctxt).registerService(Mockito.anyString(), Mockito.any(Object.class), Mockito.any(Dictionary.class));
         RefreshingSCPModuleInfoRegistry scpreg = new RefreshingSCPModuleInfoRegistry(reg, prov, ctxt);
index 220bef03bc95eab1efbbe54122e7b42cb657927e..4be40a64f5a775e008e13ce592d9d7fdefb3eacb 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.controller.config.manager.impl.util;
 
 import static org.junit.Assert.assertEquals;
-
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Sets;
 import java.util.Collections;
 import java.util.HashSet;
@@ -92,7 +92,7 @@ public class InterfacesHelperTest {
         input.add(clazz);
         Set<Class<? extends AbstractServiceInterface>> result = InterfacesHelper.getAllAbstractServiceInterfaceClasses(input);
 
-        Set<Class<?>> expected = Sets.newHashSet((Class<?>) TestingScheduledThreadPoolServiceInterface.class,
+        Set<Class<?>> expected = ImmutableSet.of((Class<?>) TestingScheduledThreadPoolServiceInterface.class,
                 TestingThreadPoolServiceInterface.class
                 );
         assertEquals(expected, result);
index fb59e3d51554d1f69d3bdc215478daf14a2d88e2..f1efc4787dfc3320fc1017c88f6819caf9f2ad5d 100644 (file)
@@ -4,7 +4,6 @@ import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
-
 import org.junit.Test;
 import org.mockito.InOrder;
 import org.mockito.Mockito;
@@ -37,7 +36,7 @@ public class OsgiRegistrationUtilTest {
         OsgiRegistrationUtil.wrap(serviceReg).close();
         verify(serviceReg).unregister();
 
-        final BundleTracker tracker = mock(BundleTracker.class);
+        final BundleTracker<?> tracker = mock(BundleTracker.class);
         doNothing().when(tracker).close();
         OsgiRegistrationUtil.wrap(tracker).close();
         verify(tracker).close();
@@ -49,7 +48,7 @@ public class OsgiRegistrationUtilTest {
     }
 
     private ServiceRegistration<?> mockServiceRegistration() {
-        ServiceRegistration mock = mock(ServiceRegistration.class);
+        ServiceRegistration<?> mock = mock(ServiceRegistration.class);
         doNothing().when(mock).unregister();
         return mock;
     }
index e5306a4fa60272e23adac53af8f83f5454876b86..d34e73ec4723d8d1fa151b0dfe8f161ec6716b33 100644 (file)
@@ -7,7 +7,9 @@
  */
 package org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool;
 
-import com.google.common.collect.Sets;
+import com.google.common.collect.ImmutableSet;
+import java.util.HashSet;
+import java.util.Set;
 import org.opendaylight.controller.config.api.DependencyResolver;
 import org.opendaylight.controller.config.api.DependencyResolverFactory;
 import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
@@ -19,20 +21,16 @@ import org.opendaylight.controller.config.spi.Module;
 import org.opendaylight.controller.config.spi.ModuleFactory;
 import org.osgi.framework.BundleContext;
 
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
 public class TestingScheduledThreadPoolModuleFactory implements ModuleFactory {
     public static final String NAME = "scheduled";
 
-    private static Set<Class<? extends AbstractServiceInterface>> ifc = Collections.unmodifiableSet(Sets.newHashSet(
+    private static Set<Class<? extends AbstractServiceInterface>> ifc = ImmutableSet.of(
             (Class<? extends AbstractServiceInterface>) TestingScheduledThreadPoolServiceInterface.class,
-                    TestingThreadPoolServiceInterface.class));
+                    TestingThreadPoolServiceInterface.class);
 
     @Override
     public boolean isModuleImplementingServiceInterface(
-            Class<? extends AbstractServiceInterface> serviceInterface) {
+            final Class<? extends AbstractServiceInterface> serviceInterface) {
         return ifc.contains(serviceInterface);
     }
 
@@ -42,15 +40,15 @@ public class TestingScheduledThreadPoolModuleFactory implements ModuleFactory {
     }
 
     @Override
-    public Module createModule(String instanceName,
-            DependencyResolver dependencyResolver, BundleContext bundleContext) {
+    public Module createModule(final String instanceName,
+            final DependencyResolver dependencyResolver, final BundleContext bundleContext) {
         return new TestingScheduledThreadPoolModule(new ModuleIdentifier(NAME,
                 instanceName), null, null);
     }
 
     @Override
-    public Module createModule(String instanceName,
-            DependencyResolver dependencyResolver, DynamicMBeanWithInstance old, BundleContext bundleContext)
+    public Module createModule(final String instanceName,
+            final DependencyResolver dependencyResolver, final DynamicMBeanWithInstance old, final BundleContext bundleContext)
             throws Exception {
         TestingScheduledThreadPoolImpl oldInstance;
         try {
@@ -68,7 +66,7 @@ public class TestingScheduledThreadPoolModuleFactory implements ModuleFactory {
     }
 
     @Override
-    public Set<Module> getDefaultModules(DependencyResolverFactory dependencyResolverFactory, BundleContext bundleContext) {
+    public Set<Module> getDefaultModules(final DependencyResolverFactory dependencyResolverFactory, final BundleContext bundleContext) {
         return new HashSet<Module>();
     }
 
index ca038f1f1caac171f77c7a3538172c70c7069ed9..9c8b575fe59a799ca13bd10dd3558a2270fa8596 100644 (file)
@@ -7,38 +7,35 @@
  */
 package org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.test;
 
+import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 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 javax.annotation.Nullable;
 import javax.management.DynamicMBean;
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.InstanceNotFoundException;
 import javax.management.ObjectName;
-
 import org.junit.Test;
 import org.opendaylight.controller.config.api.ValidationException;
 import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
 import org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean;
 import org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPModuleFactory;
 import org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.TestingScheduledThreadPoolImpl;
-import org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool
-        .TestingScheduledThreadPoolModuleFactory;
+import org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.TestingScheduledThreadPoolModuleFactory;
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
 
 public class TwoInterfacesExportTest extends AbstractScheduledTest {
 
-    private void assertExists(String moduleName, String instanceName)
+    private void assertExists(final String moduleName, final String instanceName)
             throws Exception {
         assertExists(null, moduleName, instanceName);
     }
 
-    private void assertExists(@Nullable ConfigTransactionJMXClient transaction,
-            String moduleName, String instanceName)
+    private void assertExists(@Nullable final ConfigTransactionJMXClient transaction,
+            final String moduleName, final String instanceName)
             throws InstanceNotFoundException {
         if (transaction != null) {
             transaction.lookupConfigBean(moduleName, instanceName);
@@ -56,13 +53,13 @@ public class TwoInterfacesExportTest extends AbstractScheduledTest {
         }
     }
 
-    private void assertNotExists(String moduleName, String instanceName) {
+    private void assertNotExists(final String moduleName, final String instanceName) {
         assertNotExists(null, moduleName, instanceName);
     }
 
     private void assertNotExists(
-            @Nullable ConfigTransactionJMXClient transaction,
-            String moduleName, String instanceName) {
+            @Nullable final ConfigTransactionJMXClient transaction,
+            final String moduleName, final String instanceName) {
 
         if (transaction != null) {
             try {
index bec28685576aba673422c32222acafc6aca34a23..d385a7db5a2d007bb6d4320f31d7247a4ecde1c1 100644 (file)
@@ -7,7 +7,9 @@
  */
 package org.opendaylight.controller.config.manager.testingservices.threadpool;
 
-import com.google.common.collect.Sets;
+import com.google.common.collect.ImmutableSet;
+import java.util.HashSet;
+import java.util.Set;
 import org.opendaylight.controller.config.api.DependencyResolver;
 import org.opendaylight.controller.config.api.DependencyResolverFactory;
 import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
@@ -19,16 +21,12 @@ import org.opendaylight.controller.config.spi.Module;
 import org.opendaylight.controller.config.spi.ModuleFactory;
 import org.osgi.framework.BundleContext;
 
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
 public class TestingFixedThreadPoolModuleFactory extends AbstractTestingFixedThreadPoolModuleFactory implements ModuleFactory {
     public static final String NAME = "fixed";
 
-    private static Set<Class<? extends AbstractServiceInterface>> ifc = Collections.unmodifiableSet(Sets.newHashSet(
+    private static final Set<Class<? extends AbstractServiceInterface>> ifc = ImmutableSet.of(
             (Class<? extends AbstractServiceInterface>) ModifiableThreadPoolServiceInterface.class,
-            TestingThreadPoolServiceInterface.class));
+            TestingThreadPoolServiceInterface.class);
 
     @Override
     public String getImplementationName() {
@@ -36,15 +34,15 @@ public class TestingFixedThreadPoolModuleFactory extends AbstractTestingFixedThr
     }
 
     @Override
-    public TestingFixedThreadPoolModule createModule(String instanceName,
-            DependencyResolver dependencyResolver, BundleContext bundleContext) {
+    public TestingFixedThreadPoolModule createModule(final String instanceName,
+            final DependencyResolver dependencyResolver, final BundleContext bundleContext) {
         return new TestingFixedThreadPoolModule(new ModuleIdentifier(NAME,
                 instanceName), null, null);
     }
 
     @Override
-    public Module createModule(String instanceName,
-            DependencyResolver dependencyResolver, DynamicMBeanWithInstance old, BundleContext bundleContext)
+    public Module createModule(final String instanceName,
+            final DependencyResolver dependencyResolver, final DynamicMBeanWithInstance old, final BundleContext bundleContext)
             throws Exception {
         int threadCount = (Integer) old.getAttribute("ThreadCount");
         // is the instance compatible?
@@ -65,12 +63,12 @@ public class TestingFixedThreadPoolModuleFactory extends AbstractTestingFixedThr
 
     @Override
     public boolean isModuleImplementingServiceInterface(
-            Class<? extends AbstractServiceInterface> serviceInterface) {
+            final Class<? extends AbstractServiceInterface> serviceInterface) {
         return ifc.contains(serviceInterface);
     }
 
     @Override
-    public Set<Module> getDefaultModules(DependencyResolverFactory dependencyResolverFactory, BundleContext bundleContext) {
+    public Set<Module> getDefaultModules(final DependencyResolverFactory dependencyResolverFactory, final BundleContext bundleContext) {
         return new HashSet<Module>();
     }
 
index b2afd3542ec6f208b433ec366def686fb475c0fe..200fa8854db4965fa60c759c8e15d199a9f75264 100644 (file)
@@ -2,8 +2,6 @@ package org.opendaylight.controller.config.util;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
-
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
index 0524f0019a1414aa3282f515005b3e10df38aebd..fc1c3f8afe30c9ed8965a085611745bf5306d44f 100644 (file)
@@ -7,29 +7,25 @@
  */
 package org.opendaylight.controller.config.util;
 
+import static org.hamcrest.CoreMatchers.hasItem;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertThat;
-import static org.junit.matchers.JUnitMatchers.hasItem;
-
+import com.google.common.collect.Sets;
 import java.lang.management.ManagementFactory;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
-
 import javax.management.InstanceNotFoundException;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
-
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.config.api.ConfigRegistry;
 
-import com.google.common.collect.Sets;
-
 public class ConfigRegistryClientsTest {
 
     private TestingConfigRegistry testingRegistry;
@@ -145,7 +141,7 @@ public class ConfigRegistryClientsTest {
         assertEquals(Sets.newHashSet(TestingConfigRegistry.run2, TestingConfigRegistry.run1, TestingConfigRegistry.run3), jmxLookup);
     }
 
-    private Set<ObjectName> lookupRuntimeBeans(ConfigRegistryClient client)
+    private Set<ObjectName> lookupRuntimeBeans(final ConfigRegistryClient client)
             throws Exception {
         Set<ObjectName> beans = client.lookupRuntimeBeans();
         for (ObjectName on : beans) {
@@ -178,7 +174,7 @@ public class ConfigRegistryClientsTest {
     }
 
     private Set<ObjectName> clientLookupRuntimeBeansWithModuleAndInstance(
-            ConfigRegistryClient client, String moduleName, String instanceName) {
+            final ConfigRegistryClient client, final String moduleName, final String instanceName) {
         Set<ObjectName> beans = client.lookupRuntimeBeans(moduleName, instanceName);
         if (beans.size() > 0) {
             assertEquals("RuntimeBean",
@@ -220,7 +216,7 @@ public class ConfigRegistryClientsTest {
         assertThat(clientLookupServiceInterfaceNames(testingRegistryON), hasItem(TestingConfigRegistry.serviceQName2));
     }
 
-    private Set<String> clientLookupServiceInterfaceNames(ObjectName client) throws InstanceNotFoundException{
+    private Set<String> clientLookupServiceInterfaceNames(final ObjectName client) throws InstanceNotFoundException{
         return jmxRegistryClient.lookupServiceInterfaceNames(client);
     }
 
index ff7da5df483556a9eb2a7bdb2e4e89a03bbff0df..087648cae7e2b6e80980caee648b124bcaae1179 100644 (file)
@@ -7,16 +7,6 @@
  */
 package org.opendaylight.controller.config.yang.logback.config;
 
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.slf4j.LoggerFactory;
-
 import ch.qos.logback.classic.Level;
 import ch.qos.logback.classic.LoggerContext;
 import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
@@ -26,10 +16,17 @@ import ch.qos.logback.core.Appender;
 import ch.qos.logback.core.rolling.FixedWindowRollingPolicy;
 import ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy;
 import ch.qos.logback.core.rolling.TimeBasedRollingPolicy;
-
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Sets;
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.slf4j.LoggerFactory;
 
 /**
  * Implementation of {@link ContextSetter}. Resets running logback
@@ -40,12 +37,13 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
     private final LogbackStatusListener statusListener;
     private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ContextSetterImpl.class);
 
-    public ContextSetterImpl(LogbackRuntimeRegistrator rootRuntimeBeanRegistratorWrapper) {
+    public ContextSetterImpl(final LogbackRuntimeRegistrator rootRuntimeBeanRegistratorWrapper) {
         statusListener = new LogbackStatusListener(rootRuntimeBeanRegistratorWrapper);
         statusListener.register();
     }
 
-    public void updateContext(LogbackModule module) {
+    @Override
+    public void updateContext(final LogbackModule module) {
         LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
 
         List<ch.qos.logback.classic.Logger> loggersBefore = context.getLoggerList();
@@ -53,12 +51,12 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
         createLoggers(context, module, Sets.newHashSet(loggersBefore));
     }
 
-    private Map<String, Appender<ILoggingEvent>> createConsoleAppenders(LoggerContext context, LogbackModule module) {
+    private Map<String, Appender<ILoggingEvent>> createConsoleAppenders(final LoggerContext context, final LogbackModule module) {
         Map<String, Appender<ILoggingEvent>> appendersMap = new HashMap<>();
         for (ConsoleAppenderTO appender : module.getConsoleAppenderTO()) {
             Preconditions.checkState(appendersMap.containsKey(appender.getName()) == false,
                     "Duplicate appender name %s", appender.getName());
-            ch.qos.logback.core.ConsoleAppender app = new ch.qos.logback.core.ConsoleAppender();
+            ch.qos.logback.core.ConsoleAppender<ILoggingEvent> app = new ch.qos.logback.core.ConsoleAppender<>();
             app.setContext(context);
             PatternLayoutEncoder encoder = new PatternLayoutEncoder();
             encoder.setContext(context);
@@ -77,8 +75,8 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
         return appendersMap;
     }
 
-    private void createLoggers(LoggerContext context, LogbackModule module,
-            Set<ch.qos.logback.classic.Logger> loggersBefore) {
+    private void createLoggers(final LoggerContext context, final LogbackModule module,
+            final Set<ch.qos.logback.classic.Logger> loggersBefore) {
 
         Map<String, Appender<ILoggingEvent>> appendersMap = getAppenders(module, context);
 
@@ -97,8 +95,8 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
         }
     }
 
-    private void addNewAppenders(Map<String, Appender<ILoggingEvent>> appendersMap, LoggerTO logger,
-            ch.qos.logback.classic.Logger logbackLogger, Optional<Set<Appender<ILoggingEvent>>> appendersBefore) {
+    private void addNewAppenders(final Map<String, Appender<ILoggingEvent>> appendersMap, final LoggerTO logger,
+            final ch.qos.logback.classic.Logger logbackLogger, final Optional<Set<Appender<ILoggingEvent>>> appendersBefore) {
         if (logger.getAppenders() != null) {
             for (String appenderName : logger.getAppenders()) {
                 if (appendersMap.containsKey(appenderName)) {
@@ -112,8 +110,8 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
         }
     }
 
-    private void removeBeforeAppenders(Set<ch.qos.logback.classic.Logger> loggersBefore, LoggerTO logger,
-            ch.qos.logback.classic.Logger logbackLogger, Optional<Set<Appender<ILoggingEvent>>> appendersBefore) {
+    private void removeBeforeAppenders(final Set<ch.qos.logback.classic.Logger> loggersBefore, final LoggerTO logger,
+            final ch.qos.logback.classic.Logger logbackLogger, final Optional<Set<Appender<ILoggingEvent>>> appendersBefore) {
         if (appendersBefore.isPresent()) {
             for (Appender<ILoggingEvent> appenderBefore : appendersBefore.get()) {
                 logbackLogger.detachAppender(appenderBefore);
@@ -125,8 +123,8 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
         }
     }
 
-    private Optional<Set<Appender<ILoggingEvent>>> getAppendersBefore(Set<ch.qos.logback.classic.Logger> loggersBefore,
-            ch.qos.logback.classic.Logger logbackLogger) {
+    private Optional<Set<Appender<ILoggingEvent>>> getAppendersBefore(final Set<ch.qos.logback.classic.Logger> loggersBefore,
+            final ch.qos.logback.classic.Logger logbackLogger) {
         if (loggersBefore.contains(logbackLogger)) {
             Iterator<Appender<ILoggingEvent>> appenderIt = logbackLogger.iteratorForAppenders();
             Set<Appender<ILoggingEvent>> appendersBefore = Sets.newHashSet();
@@ -140,7 +138,7 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
 
     }
 
-    private Map<String, Appender<ILoggingEvent>> getAppenders(LogbackModule module, LoggerContext context) {
+    private Map<String, Appender<ILoggingEvent>> getAppenders(final LogbackModule module, final LoggerContext context) {
         Map<String, Appender<ILoggingEvent>> appendersMap = new HashMap<>();
         addAllAppenders(appendersMap, createRollingAppenders(context, module));
         addAllAppenders(appendersMap, createFileAppenders(context, module));
@@ -149,8 +147,8 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
         return appendersMap;
     }
 
-    private void addAllAppenders(Map<String, Appender<ILoggingEvent>> allAppenders,
-            Map<String, Appender<ILoggingEvent>> appendersToAdd) {
+    private void addAllAppenders(final Map<String, Appender<ILoggingEvent>> allAppenders,
+            final Map<String, Appender<ILoggingEvent>> appendersToAdd) {
         for (String appenderName : appendersToAdd.keySet()) {
             Preconditions.checkState(allAppenders.containsKey(appenderName) == false, "Duplicate appender name %s",
                     appenderName);
@@ -158,12 +156,12 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
         }
     }
 
-    private Map<String, Appender<ILoggingEvent>> createFileAppenders(LoggerContext context, LogbackModule module) {
+    private Map<String, Appender<ILoggingEvent>> createFileAppenders(final LoggerContext context, final LogbackModule module) {
         Map<String, Appender<ILoggingEvent>> appendersMap = new HashMap<>();
         for (FileAppenderTO appender : module.getFileAppenderTO()) {
             Preconditions.checkState(appendersMap.containsKey(appender.getName()) == false,
                     "Duplicate appender name %s", appender.getName());
-            ch.qos.logback.core.FileAppender app = new ch.qos.logback.core.FileAppender<>();
+            ch.qos.logback.core.FileAppender<ILoggingEvent> app = new ch.qos.logback.core.FileAppender<>();
             app.setAppend(appender.getAppend());
             app.setContext(context);
             PatternLayoutEncoder encoder = new PatternLayoutEncoder();
@@ -180,12 +178,12 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
         return appendersMap;
     }
 
-    private Map<String, Appender<ILoggingEvent>> createRollingAppenders(LoggerContext context, LogbackModule module) {
+    private Map<String, Appender<ILoggingEvent>> createRollingAppenders(final LoggerContext context, final LogbackModule module) {
         Map<String, Appender<ILoggingEvent>> appendersMap = new HashMap<>();
         for (RollingFileAppenderTO appender : module.getRollingFileAppenderTO()) {
             Preconditions.checkState(appendersMap.containsKey(appender.getName()) == false,
                     "Duplicate appender name %s", appender.getName());
-            ch.qos.logback.core.rolling.RollingFileAppender app = new ch.qos.logback.core.rolling.RollingFileAppender<>();
+            ch.qos.logback.core.rolling.RollingFileAppender<ILoggingEvent> app = new ch.qos.logback.core.rolling.RollingFileAppender<>();
             app.setAppend(appender.getAppend());
             app.setContext(context);
             PatternLayoutEncoder encoder = new PatternLayoutEncoder();
@@ -204,7 +202,7 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
                 policy.start();
                 app.setRollingPolicy(policy);
             } else if (appender.getRollingPolicyType().equals("TimeBasedRollingPolicy")) {
-                TimeBasedRollingPolicy policy = new TimeBasedRollingPolicy();
+                TimeBasedRollingPolicy<ILoggingEvent> policy = new TimeBasedRollingPolicy<>();
                 policy.setContext(context);
                 policy.setMaxHistory(appender.getMaxHistory());
                 if (appender.getCleanHistoryOnStart() != null) {
@@ -215,7 +213,7 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
                 policy.start();
                 app.setRollingPolicy(policy);
             }
-            SizeBasedTriggeringPolicy triggeringPolicy = new SizeBasedTriggeringPolicy();
+            SizeBasedTriggeringPolicy<ILoggingEvent> triggeringPolicy = new SizeBasedTriggeringPolicy<>();
             triggeringPolicy.setContext(context);
             triggeringPolicy.setMaxFileSize(appender.getMaxFileSize());
             triggeringPolicy.start();
index b5d0d1b4de0466e1d1c09d55e92644abf6bb4dd7..bd19d5eecdc6e0e087e947b3eb3324e6a574ff9e 100644 (file)
  */
 package org.opendaylight.controller.config.yang.logback.config;
 
+import ch.qos.logback.classic.Logger;
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.classic.spi.LoggerComparator;
+import ch.qos.logback.core.Appender;
+import ch.qos.logback.core.rolling.FixedWindowRollingPolicy;
+import ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy;
+import ch.qos.logback.core.rolling.TimeBasedRollingPolicy;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -24,7 +36,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
-
 import org.apache.commons.lang3.StringUtils;
 import org.opendaylight.controller.config.api.DependencyResolver;
 import org.opendaylight.controller.config.api.DependencyResolverFactory;
@@ -32,20 +43,6 @@ import org.opendaylight.controller.config.api.ModuleIdentifier;
 import org.osgi.framework.BundleContext;
 import org.slf4j.LoggerFactory;
 
-import ch.qos.logback.classic.Logger;
-import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
-import ch.qos.logback.classic.spi.ILoggingEvent;
-import ch.qos.logback.classic.spi.LoggerComparator;
-import ch.qos.logback.core.Appender;
-import ch.qos.logback.core.rolling.FixedWindowRollingPolicy;
-import ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy;
-import ch.qos.logback.core.rolling.TimeBasedRollingPolicy;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-
 /**
 *
 */
@@ -59,8 +56,8 @@ public class LogbackModuleFactory extends
     private Map<String, FileAppenderTO> fileDTOs;
 
     @Override
-    public LogbackModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
-            BundleContext bundleContext) {
+    public LogbackModule instantiateModule(final String instanceName, final DependencyResolver dependencyResolver,
+            final BundleContext bundleContext) {
         Preconditions.checkArgument(instanceName.equals(INSTANCE_NAME),
                 "There should be just one instance of logback, named " + INSTANCE_NAME);
         prepareDTOs();
@@ -74,8 +71,8 @@ public class LogbackModuleFactory extends
     }
 
     @Override
-    public LogbackModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
-            LogbackModule oldModule, AutoCloseable oldInstance, BundleContext bundleContext) {
+    public LogbackModule instantiateModule(final String instanceName, final DependencyResolver dependencyResolver,
+            final LogbackModule oldModule, final AutoCloseable oldInstance, final BundleContext bundleContext) {
         Preconditions.checkArgument(instanceName.equals(INSTANCE_NAME),
                 "There should be just one instance of logback, named " + INSTANCE_NAME);
         prepareDTOs();
@@ -97,7 +94,7 @@ public class LogbackModuleFactory extends
         prepareAppendersDTOs(context);
     }
 
-    private void prepareAppendersDTOs(LoggerContext context) {
+    private void prepareAppendersDTOs(final LoggerContext context) {
         this.rollingDTOs = new HashMap<>();
         this.consoleDTOs = new HashMap<>();
         this.fileDTOs = new HashMap<>();
@@ -131,7 +128,7 @@ public class LogbackModuleFactory extends
                         app.setFileNamePattern(rollingPolicy.getFileNamePattern());
                         app.setRollingPolicyType("FixedWindowRollingPolicy");
                     } else if (rollingApp.getRollingPolicy() instanceof TimeBasedRollingPolicy<?>) {
-                        TimeBasedRollingPolicy rollingPolicy = (TimeBasedRollingPolicy) rollingApp.getRollingPolicy();
+                        TimeBasedRollingPolicy<ILoggingEvent> rollingPolicy = (TimeBasedRollingPolicy<ILoggingEvent>) rollingApp.getRollingPolicy();
                         app.setRollingPolicyType("TimeBasedRollingPolicy");
                         app.setFileNamePattern(rollingPolicy.getFileNamePattern());
                         app.setMaxHistory(rollingPolicy.getMaxHistory());
@@ -166,7 +163,7 @@ public class LogbackModuleFactory extends
         }
     }
 
-    private Map<String, LoggerTO> prepareLoggersDTOs(LoggerContext context) {
+    private Map<String, LoggerTO> prepareLoggersDTOs(final LoggerContext context) {
         Map<String, LoggerTO> DTOs = new HashMap<>();
         List<String> appenders = new ArrayList<>();
         List<org.slf4j.Logger> loggersToBeAdd = removeUnusableLoggers(context.getLoggerList(),
@@ -192,7 +189,7 @@ public class LogbackModuleFactory extends
         return DTOs;
     }
 
-    private List<org.slf4j.Logger> removeUnusableLoggers(List<Logger> loggerList, Logger rootLogger) {
+    private List<org.slf4j.Logger> removeUnusableLoggers(final List<Logger> loggerList, final Logger rootLogger) {
         Collections.sort(loggerList, new LoggerComparator());
         Map<String, org.slf4j.Logger> loggersToReturn = new HashMap<>();
 
@@ -234,8 +231,8 @@ public class LogbackModuleFactory extends
     }
 
     @Override
-    public Set<LogbackModule> getDefaultModules(DependencyResolverFactory dependencyResolverFactory,
-            BundleContext bundleContext) {
+    public Set<LogbackModule> getDefaultModules(final DependencyResolverFactory dependencyResolverFactory,
+            final BundleContext bundleContext) {
         DependencyResolver resolver = dependencyResolverFactory.createDependencyResolver(new ModuleIdentifier(
                 getImplementationName(), INSTANCE_NAME));
         LogbackModule defaultLogback = instantiateModule(INSTANCE_NAME, resolver, bundleContext);
index dfdc3b76cbfd7ba3453e46e675534c5debaf72c6..7b2bd864f22171ee29e33c4ec641827962f5b269 100644 (file)
@@ -8,7 +8,6 @@
     <version>0.2.0-SNAPSHOT</version>
     <relativePath>../..</relativePath>
   </parent>
-  <groupId>org.opendaylight.controller</groupId>
   <artifactId>karaf.branding</artifactId>
   <version>1.1.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
index 7d47add017802bd1e077cd97b8178e16d2757784..b196c3180fc5c7429a338b66543d4307d0b51826 100644 (file)
@@ -16,7 +16,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
   </parent>
   <modelVersion>4.0.0</modelVersion>
 
-  <groupId>org.opendaylight.controller</groupId>
   <artifactId>benchmark-data-store</artifactId>
 
   <dependencies>
index 1fa54be2005b06d0be70226ac4abd30625f8a8bb..eba5b8756b88cfaa936e3aa20828706a29abaf5d 100644 (file)
@@ -8,17 +8,11 @@
 package org.opendaylight.controller.sal.binding.codegen.impl;
 
 import com.google.common.base.Supplier;
-
-import java.util.Map;
-import java.util.WeakHashMap;
-
+import com.google.common.collect.Iterables;
 import javassist.ClassPool;
 import javassist.CtClass;
 import javassist.CtMethod;
 import javassist.NotFoundException;
-
-import javax.annotation.concurrent.GuardedBy;
-
 import org.eclipse.xtext.xbase.lib.Extension;
 import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter;
 import org.opendaylight.controller.sal.binding.codegen.RpcIsNotRoutedException;
@@ -31,6 +25,10 @@ import org.opendaylight.yangtools.yang.binding.RpcService;
 import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext;
 import org.opendaylight.yangtools.yang.binding.util.ClassLoaderUtils;
 
+import javax.annotation.concurrent.GuardedBy;
+import java.util.Map;
+import java.util.WeakHashMap;
+
 abstract class AbstractRuntimeCodeGenerator implements org.opendaylight.controller.sal.binding.codegen.RuntimeCodeGenerator, NotificationInvokerFactory {
     @GuardedBy("this")
     private final Map<Class<? extends NotificationListener>, RuntimeGeneratedInvokerPrototype> invokerClasses = new WeakHashMap<>();
@@ -174,6 +172,10 @@ abstract class AbstractRuntimeCodeGenerator implements org.opendaylight.controll
             }
         });
 
+        if (Iterables.isEmpty(metadata.getContexts())) {
+            throw new RpcIsNotRoutedException("Service doesn't have routing context associated.");
+        }
+
         synchronized (utils) {
             final T instance = ClassLoaderUtils.withClassLoader(serviceType.getClassLoader(), routerSupplier(serviceType, metadata));
             return new RpcRouterCodegenInstance<T>(name, serviceType, instance, metadata.getContexts());
index 6a843f57c7718fb76911e90649b7194e3b6db0bb..aac45e18b5d7c420eeae0f6d47b62fdee6cb3078 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.controller.cluster.datastore.node.utils.serialization;
 
+import com.google.protobuf.ByteString;
 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;
@@ -28,16 +29,18 @@ public class ValueSerializer {
                 InstanceIdentifierUtils.toSerializable((YangInstanceIdentifier) value, context));
         } else if(value instanceof Set) {
             Set set = (Set) value;
-            if(!set.isEmpty()){
-                for(Object o : set){
-                    if(o instanceof String){
+            if (!set.isEmpty()) {
+                for (Object o : set) {
+                    if (o instanceof String) {
                         builder.addBitsValue(o.toString());
                     } else {
                         throw new IllegalArgumentException("Expected value type to be Bits but was : " +
-                            value.toString());
+                                value.toString());
                     }
                 }
             }
+        } else if(value instanceof byte[]){
+            builder.setBytesValue(ByteString.copyFrom((byte[]) value));
         } else {
             builder.setValue(value.toString());
         }
@@ -57,6 +60,8 @@ public class ValueSerializer {
                     node.getInstanceIdentifierValue(), context);
         } else if(node.getIntValueType() == ValueType.BITS_TYPE.ordinal()){
             return new HashSet(node.getBitsValueList());
+        } else if(node.getIntValueType() == ValueType.BINARY_TYPE.ordinal()){
+            return node.getBytesValue().toByteArray();
         }
         return deSerializeBasicTypes(node.getIntValueType(), node.getValue());
     }
index 49db8967a685914924eb4e90d5914ecdbc1b43a8..6c884734e298a54dea541fe4973404365db41573 100644 (file)
@@ -29,7 +29,8 @@ public enum ValueType {
     YANG_IDENTIFIER_TYPE,
     STRING_TYPE,
     BIG_INTEGER_TYPE,
-    BIG_DECIMAL_TYPE;
+    BIG_DECIMAL_TYPE,
+    BINARY_TYPE;
 
     private static Map<Class, ValueType> types = new HashMap<>();
 
@@ -45,6 +46,7 @@ public enum ValueType {
         types.put(Short.class,SHORT_TYPE);
         types.put(BigInteger.class, BIG_INTEGER_TYPE);
         types.put(BigDecimal.class, BIG_DECIMAL_TYPE);
+        types.put(byte[].class, BINARY_TYPE);
     }
 
     public static final ValueType getSerializableType(Object node){
index e7f2c361aeb0615c52ff44002ee1b35451396b46..8285009d359fd56ff6d6ed797d3473e7440b7d60 100644 (file)
@@ -5410,6 +5410,16 @@ public final class NormalizedNodeMessages {
      */
     com.google.protobuf.ByteString
         getCodeBytes(int index);
+
+    // optional bytes bytesValue = 13;
+    /**
+     * <code>optional bytes bytesValue = 13;</code>
+     */
+    boolean hasBytesValue();
+    /**
+     * <code>optional bytes bytesValue = 13;</code>
+     */
+    com.google.protobuf.ByteString getBytesValue();
   }
   /**
    * Protobuf type {@code org.opendaylight.controller.mdsal.Node}
@@ -5550,6 +5560,11 @@ public final class NormalizedNodeMessages {
               code_.add(input.readBytes());
               break;
             }
+            case 106: {
+              bitField0_ |= 0x00000100;
+              bytesValue_ = input.readBytes();
+              break;
+            }
           }
         }
       } catch (com.google.protobuf.InvalidProtocolBufferException e) {
@@ -6070,6 +6085,22 @@ public final class NormalizedNodeMessages {
       return code_.getByteString(index);
     }
 
+    // optional bytes bytesValue = 13;
+    public static final int BYTESVALUE_FIELD_NUMBER = 13;
+    private com.google.protobuf.ByteString bytesValue_;
+    /**
+     * <code>optional bytes bytesValue = 13;</code>
+     */
+    public boolean hasBytesValue() {
+      return ((bitField0_ & 0x00000100) == 0x00000100);
+    }
+    /**
+     * <code>optional bytes bytesValue = 13;</code>
+     */
+    public com.google.protobuf.ByteString getBytesValue() {
+      return bytesValue_;
+    }
+
     private void initFields() {
       path_ = "";
       type_ = "";
@@ -6083,6 +6114,7 @@ public final class NormalizedNodeMessages {
       instanceIdentifierValue_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance();
       bitsValue_ = com.google.protobuf.LazyStringArrayList.EMPTY;
       code_ = com.google.protobuf.LazyStringArrayList.EMPTY;
+      bytesValue_ = com.google.protobuf.ByteString.EMPTY;
     }
     private byte memoizedIsInitialized = -1;
     public final boolean isInitialized() {
@@ -6156,6 +6188,9 @@ public final class NormalizedNodeMessages {
       for (int i = 0; i < code_.size(); i++) {
         output.writeBytes(12, code_.getByteString(i));
       }
+      if (((bitField0_ & 0x00000100) == 0x00000100)) {
+        output.writeBytes(13, bytesValue_);
+      }
       getUnknownFields().writeTo(output);
     }
 
@@ -6223,6 +6258,10 @@ public final class NormalizedNodeMessages {
         size += dataSize;
         size += 1 * getCodeList().size();
       }
+      if (((bitField0_ & 0x00000100) == 0x00000100)) {
+        size += com.google.protobuf.CodedOutputStream
+          .computeBytesSize(13, bytesValue_);
+      }
       size += getUnknownFields().getSerializedSize();
       memoizedSerializedSize = size;
       return size;
@@ -6383,6 +6422,8 @@ public final class NormalizedNodeMessages {
         bitField0_ = (bitField0_ & ~0x00000400);
         code_ = com.google.protobuf.LazyStringArrayList.EMPTY;
         bitField0_ = (bitField0_ & ~0x00000800);
+        bytesValue_ = com.google.protobuf.ByteString.EMPTY;
+        bitField0_ = (bitField0_ & ~0x00001000);
         return this;
       }
 
@@ -6481,6 +6522,10 @@ public final class NormalizedNodeMessages {
           bitField0_ = (bitField0_ & ~0x00000800);
         }
         result.code_ = code_;
+        if (((from_bitField0_ & 0x00001000) == 0x00001000)) {
+          to_bitField0_ |= 0x00000100;
+        }
+        result.bytesValue_ = bytesValue_;
         result.bitField0_ = to_bitField0_;
         onBuilt();
         return result;
@@ -6601,6 +6646,9 @@ public final class NormalizedNodeMessages {
           }
           onChanged();
         }
+        if (other.hasBytesValue()) {
+          setBytesValue(other.getBytesValue());
+        }
         this.mergeUnknownFields(other.getUnknownFields());
         return this;
       }
@@ -8110,6 +8158,42 @@ public final class NormalizedNodeMessages {
         return this;
       }
 
+      // optional bytes bytesValue = 13;
+      private com.google.protobuf.ByteString bytesValue_ = com.google.protobuf.ByteString.EMPTY;
+      /**
+       * <code>optional bytes bytesValue = 13;</code>
+       */
+      public boolean hasBytesValue() {
+        return ((bitField0_ & 0x00001000) == 0x00001000);
+      }
+      /**
+       * <code>optional bytes bytesValue = 13;</code>
+       */
+      public com.google.protobuf.ByteString getBytesValue() {
+        return bytesValue_;
+      }
+      /**
+       * <code>optional bytes bytesValue = 13;</code>
+       */
+      public Builder setBytesValue(com.google.protobuf.ByteString value) {
+        if (value == null) {
+    throw new NullPointerException();
+  }
+  bitField0_ |= 0x00001000;
+        bytesValue_ = value;
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>optional bytes bytesValue = 13;</code>
+       */
+      public Builder clearBytesValue() {
+        bitField0_ = (bitField0_ & ~0x00001000);
+        bytesValue_ = getDefaultInstance().getBytesValue();
+        onChanged();
+        return this;
+      }
+
       // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.Node)
     }
 
@@ -10287,7 +10371,7 @@ public final class NormalizedNodeMessages {
       "ntroller.mdsal.Attribute\022\017\n\007intType\030\006 \001(" +
       "\005\"f\n\022InstanceIdentifier\022B\n\targuments\030\001 \003" +
       "(\0132/.org.opendaylight.controller.mdsal.P" +
-      "athArgument\022\014\n\004code\030\002 \003(\t\"\245\003\n\004Node\022\014\n\004pa" +
+      "athArgument\022\014\n\004code\030\002 \003(\t\"\271\003\n\004Node\022\014\n\004pa" +
       "th\030\001 \001(\t\022\014\n\004type\030\002 \001(\t\022E\n\014pathArgument\030\003" +
       " \001(\0132/.org.opendaylight.controller.mdsal" +
       ".PathArgument\022\017\n\007intType\030\004 \001(\005\022@\n\nattrib",
@@ -10298,17 +10382,18 @@ public final class NormalizedNodeMessages {
       "pe\030\t \001(\005\022V\n\027instanceIdentifierValue\030\n \001(" +
       "\01325.org.opendaylight.controller.mdsal.In" +
       "stanceIdentifier\022\021\n\tbitsValue\030\013 \003(\t\022\014\n\004c" +
-      "ode\030\014 \003(\t\"`\n\tContainer\022\022\n\nparentPath\030\001 \002" +
-      "(\t\022?\n\016normalizedNode\030\002 \001(\0132\'.org.openday" +
-      "light.controller.mdsal.Node\"\246\001\n\014NodeMapE",
-      "ntry\022U\n\026instanceIdentifierPath\030\001 \002(\01325.o" +
-      "rg.opendaylight.controller.mdsal.Instanc" +
-      "eIdentifier\022?\n\016normalizedNode\030\002 \001(\0132\'.or" +
-      "g.opendaylight.controller.mdsal.Node\"N\n\007" +
-      "NodeMap\022C\n\nmapEntries\030\001 \003(\0132/.org.openda" +
-      "ylight.controller.mdsal.NodeMapEntryBO\n5" +
-      "org.opendaylight.controller.protobuff.me" +
-      "ssages.commonB\026NormalizedNodeMessages"
+      "ode\030\014 \003(\t\022\022\n\nbytesValue\030\r \001(\014\"`\n\tContain" +
+      "er\022\022\n\nparentPath\030\001 \002(\t\022?\n\016normalizedNode" +
+      "\030\002 \001(\0132\'.org.opendaylight.controller.mds",
+      "al.Node\"\246\001\n\014NodeMapEntry\022U\n\026instanceIden" +
+      "tifierPath\030\001 \002(\01325.org.opendaylight.cont" +
+      "roller.mdsal.InstanceIdentifier\022?\n\016norma" +
+      "lizedNode\030\002 \001(\0132\'.org.opendaylight.contr" +
+      "oller.mdsal.Node\"N\n\007NodeMap\022C\n\nmapEntrie" +
+      "s\030\001 \003(\0132/.org.opendaylight.controller.md" +
+      "sal.NodeMapEntryBO\n5org.opendaylight.con" +
+      "troller.protobuff.messages.commonB\026Norma" +
+      "lizedNodeMessages"
     };
     com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
       new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
@@ -10350,7 +10435,7 @@ public final class NormalizedNodeMessages {
           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", "PathArgument", "IntType", "Attributes", "Child", "Value", "ValueType", "IntValueType", "InstanceIdentifierValue", "BitsValue", "Code", });
+              new java.lang.String[] { "Path", "Type", "PathArgument", "IntType", "Attributes", "Child", "Value", "ValueType", "IntValueType", "InstanceIdentifierValue", "BitsValue", "Code", "BytesValue", });
           internal_static_org_opendaylight_controller_mdsal_Container_descriptor =
             getDescriptor().getMessageTypes().get(6);
           internal_static_org_opendaylight_controller_mdsal_Container_fieldAccessorTable = new
index 356bfbf684295a0392198dd0b02d92fcf12b4d25..842a9725d166452a229625c36c51ee73c31d73d8 100644 (file)
@@ -63,6 +63,8 @@ message Node{
   repeated string bitsValue = 11; // intValueType = Bits
 
   repeated string code = 12; // A list of string codes which can be used for any repeated strings in the NormalizedNode
+
+  optional bytes bytesValue = 13;
 }
 
 message Container{
index cdb2e69e831eb67cab28311919f9d30e0698d7ec..bcc0fd85d0f343f7b1e9ec02ed6c4a6aec1f4027 100644 (file)
@@ -1,15 +1,20 @@
 package org.opendaylight.controller.cluster.datastore.node.utils.serialization;
 
+import com.google.common.base.Optional;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.opendaylight.controller.cluster.datastore.util.TestModel;
 import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
 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.DataContainerChild;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 public class NormalizedNodeSerializerTest {
 
@@ -49,6 +54,37 @@ public class NormalizedNodeSerializerTest {
         // created by serializing the original node and deSerializing it back.
         assertEquals(expectedNode, actualNode);
 
+        byte[] binaryData = new byte[5];
+        for(byte i=0;i<5;i++){
+            binaryData[i] = i;
+        }
+
+        ContainerNode node1 = TestModel.createBaseTestContainerBuilder()
+                .withChild(ImmutableNodes.leafNode(TestModel.SOME_BINARY_DATE_QNAME, binaryData))
+                .build();
+
+        NormalizedNodeMessages.Node serializedNode1 = NormalizedNodeSerializer
+                .serialize(node1);
+
+        ContainerNode node2 =
+                (ContainerNode) NormalizedNodeSerializer.deSerialize(serializedNode1);
+
+
+        // FIXME: This will not work due to BUG 2326. Once that is fixed we can uncomment this assertion
+        // assertEquals(node1, node2);
+
+        Optional<DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> child = node2.getChild(new YangInstanceIdentifier.NodeIdentifier(TestModel.SOME_BINARY_DATE_QNAME));
+
+        Object value = child.get().getValue();
+
+        assertTrue("value should be of type byte[]", value instanceof byte[]);
+
+        byte[] bytesValue = (byte[]) value;
+
+        for(byte i=0;i<5;i++){
+            assertEquals(i, bytesValue[i]);
+        }
+
     }
 
     @Test(expected = NullPointerException.class)
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueTypeTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueTypeTest.java
new file mode 100644 (file)
index 0000000..8fe0633
--- /dev/null
@@ -0,0 +1,18 @@
+package org.opendaylight.controller.cluster.datastore.node.utils.serialization;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class ValueTypeTest {
+
+    @Test
+    public void testGetSerializableType(){
+        byte[] b = new byte[10];
+        b[0] = 1;
+        b[2] = 2;
+
+        ValueType serializableType = ValueType.getSerializableType(b);
+        assertEquals(ValueType.BINARY_TYPE, serializableType);
+    }
+}
\ No newline at end of file
index cda4b06e2926cf42bb8c975c8e4b7fd79a89b781..99df01a32e17c9c10c0e4ada9268e52e15008162 100644 (file)
@@ -62,6 +62,7 @@ public class TestModel {
 
   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_BINARY_DATE_QNAME = QName.create(TEST_QNAME, "some-binary-data");
   public static final QName SOME_REF_QNAME = QName.create(TEST_QNAME,
       "some-ref");
   public static final QName MYIDENTITY_QNAME = QName.create(TEST_QNAME,
@@ -282,114 +283,115 @@ public class TestModel {
 
   }
 
-  public static ContainerNode createTestContainer() {
-
-
-    // Create a list of shoes
-    // This is to test leaf list entry
-    final LeafSetEntryNode<Object> nike =
-        ImmutableLeafSetEntryNodeBuilder
-            .create()
-            .withNodeIdentifier(
-                new YangInstanceIdentifier.NodeWithValue(QName.create(
-                    TEST_QNAME, "shoe"), "nike")).withValue("nike").build();
-
-    final LeafSetEntryNode<Object> puma =
-        ImmutableLeafSetEntryNodeBuilder
-            .create()
-            .withNodeIdentifier(
-                new YangInstanceIdentifier.NodeWithValue(QName.create(
-                    TEST_QNAME, "shoe"), "puma")).withValue("puma").build();
-
-    final LeafSetNode<Object> 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<Object> cap1 =
-        ImmutableLeafSetEntryNodeBuilder
-            .create()
-            .withNodeIdentifier(
-                new YangInstanceIdentifier.NodeWithValue(QName.create(
-                    TEST_QNAME, "capability"), DESC_QNAME))
-            .withValue(DESC_QNAME).build();
-
-    final LeafSetNode<Object> capabilities =
-        ImmutableLeafSetNodeBuilder
-            .create()
-            .withNodeIdentifier(
-                new YangInstanceIdentifier.NodeIdentifier(QName.create(
-                    TEST_QNAME, "capability"))).withChild(cap1).build();
-
-    ContainerNode switchFeatures =
-        ImmutableContainerNodeBuilder
-            .create()
-            .withNodeIdentifier(
-                new YangInstanceIdentifier.NodeIdentifier(SWITCH_FEATURES_QNAME))
-            .withChild(capabilities).build();
-
-    // Create a leaf list with numbers
-    final LeafSetEntryNode<Object> five =
-        ImmutableLeafSetEntryNodeBuilder
-            .create()
-            .withNodeIdentifier(
-                (new YangInstanceIdentifier.NodeWithValue(QName.create(
-                    TEST_QNAME, "number"), 5))).withValue(5).build();
-    final LeafSetEntryNode<Object> fifteen =
-        ImmutableLeafSetEntryNodeBuilder
-            .create()
-            .withNodeIdentifier(
-                (new YangInstanceIdentifier.NodeWithValue(QName.create(
-                    TEST_QNAME, "number"), 15))).withValue(15).build();
-    final LeafSetNode<Object> 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 a bits leaf
+  public static DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, ContainerNode> createBaseTestContainerBuilder() {
+      // Create a list of shoes
+      // This is to test leaf list entry
+      final LeafSetEntryNode<Object> nike =
+              ImmutableLeafSetEntryNodeBuilder
+                      .create()
+                      .withNodeIdentifier(
+                              new YangInstanceIdentifier.NodeWithValue(QName.create(
+                                      TEST_QNAME, "shoe"), "nike")).withValue("nike").build();
+
+      final LeafSetEntryNode<Object> puma =
+              ImmutableLeafSetEntryNodeBuilder
+                      .create()
+                      .withNodeIdentifier(
+                              new YangInstanceIdentifier.NodeWithValue(QName.create(
+                                      TEST_QNAME, "shoe"), "puma")).withValue("puma").build();
+
+      final LeafSetNode<Object> 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<Object> cap1 =
+              ImmutableLeafSetEntryNodeBuilder
+                      .create()
+                      .withNodeIdentifier(
+                              new YangInstanceIdentifier.NodeWithValue(QName.create(
+                                      TEST_QNAME, "capability"), DESC_QNAME))
+                      .withValue(DESC_QNAME).build();
+
+      final LeafSetNode<Object> capabilities =
+              ImmutableLeafSetNodeBuilder
+                      .create()
+                      .withNodeIdentifier(
+                              new YangInstanceIdentifier.NodeIdentifier(QName.create(
+                                      TEST_QNAME, "capability"))).withChild(cap1).build();
+
+      ContainerNode switchFeatures =
+              ImmutableContainerNodeBuilder
+                      .create()
+                      .withNodeIdentifier(
+                              new YangInstanceIdentifier.NodeIdentifier(SWITCH_FEATURES_QNAME))
+                      .withChild(capabilities).build();
+
+      // Create a leaf list with numbers
+      final LeafSetEntryNode<Object> five =
+              ImmutableLeafSetEntryNodeBuilder
+                      .create()
+                      .withNodeIdentifier(
+                              (new YangInstanceIdentifier.NodeWithValue(QName.create(
+                                      TEST_QNAME, "number"), 5))).withValue(5).build();
+      final LeafSetEntryNode<Object> fifteen =
+              ImmutableLeafSetEntryNodeBuilder
+                      .create()
+                      .withNodeIdentifier(
+                              (new YangInstanceIdentifier.NodeWithValue(QName.create(
+                                      TEST_QNAME, "number"), 15))).withValue(15).build();
+      final LeafSetNode<Object> 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 a bits leaf
       NormalizedNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, Object, LeafNode<Object>>
-          myBits = Builders.leafBuilder().withNodeIdentifier(
-          new YangInstanceIdentifier.NodeIdentifier(
-              QName.create(TEST_QNAME, "my-bits"))).withValue(
-          ImmutableSet.of("foo", "bar"));
+              myBits = Builders.leafBuilder().withNodeIdentifier(
+              new YangInstanceIdentifier.NodeIdentifier(
+                      QName.create(TEST_QNAME, "my-bits"))).withValue(
+              ImmutableSet.of("foo", "bar"));
 
 
       // Create the document
-    return ImmutableContainerNodeBuilder
-        .create()
-        .withNodeIdentifier(
-            new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME))
-        .withChild(myBits.build())
-        .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();
+      return ImmutableContainerNodeBuilder
+              .create()
+              .withNodeIdentifier(
+                      new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME))
+              .withChild(myBits.build())
+              .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());
+  }
 
+  public static ContainerNode createTestContainer() {
+      return createBaseTestContainerBuilder().build();
   }
 
   public static MapEntryNode createAugmentedListEntry(int id, String name) {
index 246cc682cd7ae277f36e152392209c8577c3785d..a1fbc1fdad1f897d265bbd6813d7a36962b70a3f 100644 (file)
@@ -107,6 +107,10 @@ module odl-datastore-test {
             }
         }
 
+        leaf some-binary-data {
+            type binary;
+        }
+
 
     }
 }
index d7e7d56d495d4e66f24d6c85ca12fc9d46b10104..bd42a9cdd9a547ae572b017c4bb3c9ef467b5329 100644 (file)
@@ -80,7 +80,6 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal-inmemory-datastore</artifactId>
-      <version>1.2.0-SNAPSHOT</version>
     </dependency>
 
     <dependency>
     <dependency>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>sal-clustering-commons</artifactId>
-        <version>1.2.0-SNAPSHOT</version>
     </dependency>
 
     <dependency>
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-simple</artifactId>
-      <version>${slf4j.version}</version>
       <scope>test</scope>
     </dependency>
 
index 1a0a5dd6591c9a653ae2079b938d6448e59c036f..061e1ab448f97ce9ad08541be9b0b1b6d4e73c30 100644 (file)
@@ -13,12 +13,6 @@ import com.google.common.base.Preconditions;
 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;
@@ -27,6 +21,11 @@ import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+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;
 
 public class ConfigurationImpl implements Configuration {
 
@@ -40,15 +39,15 @@ public class ConfigurationImpl implements Configuration {
     // Look up maps to speed things up
 
     // key = memberName, value = list of shardNames
-    private Map<String, List<String>> memberShardNames = new HashMap<>();
+    private final Map<String, List<String>> memberShardNames = new HashMap<>();
 
     // key = shardName, value = list of replicaNames (replicaNames are the same as memberNames)
-    private Map<String, List<String>> shardReplicaNames = new HashMap<>();
+    private final Map<String, List<String>> shardReplicaNames = new HashMap<>();
 
 
-    public ConfigurationImpl(String moduleShardsConfigPath,
+    public ConfigurationImpl(final String moduleShardsConfigPath,
 
-        String modulesConfigPath){
+        final String modulesConfigPath){
 
         Preconditions.checkNotNull(moduleShardsConfigPath, "moduleShardsConfigPath should not be null");
         Preconditions.checkNotNull(modulesConfigPath, "modulesConfigPath should not be null");
@@ -80,7 +79,7 @@ public class ConfigurationImpl implements Configuration {
         readModules(modulesConfig);
     }
 
-    @Override public List<String> getMemberShardNames(String memberName){
+    @Override public List<String> getMemberShardNames(final String memberName){
 
         Preconditions.checkNotNull(memberName, "memberName should not be null");
 
@@ -88,7 +87,7 @@ public class ConfigurationImpl implements Configuration {
             return memberShardNames.get(memberName);
         }
 
-        List<String> shards = new ArrayList();
+        List<String> shards = new ArrayList<>();
         for(ModuleShard ms : moduleShards){
             for(Shard s : ms.getShards()){
                 for(String m : s.getReplicas()){
@@ -105,7 +104,7 @@ public class ConfigurationImpl implements Configuration {
 
     }
 
-    @Override public Optional<String> getModuleNameFromNameSpace(String nameSpace) {
+    @Override public Optional<String> getModuleNameFromNameSpace(final String nameSpace) {
 
         Preconditions.checkNotNull(nameSpace, "nameSpace should not be null");
 
@@ -125,7 +124,7 @@ public class ConfigurationImpl implements Configuration {
         return map;
     }
 
-    @Override public List<String> getShardNamesFromModuleName(String moduleName) {
+    @Override public List<String> getShardNamesFromModuleName(final String moduleName) {
 
         Preconditions.checkNotNull(moduleName, "moduleName should not be null");
 
@@ -139,10 +138,10 @@ public class ConfigurationImpl implements Configuration {
             }
         }
 
-        return Collections.EMPTY_LIST;
+        return Collections.emptyList();
     }
 
-    @Override public List<String> getMembersFromShardName(String shardName) {
+    @Override public List<String> getMembersFromShardName(final String shardName) {
 
         Preconditions.checkNotNull(shardName, "shardName should not be null");
 
@@ -159,8 +158,8 @@ public class ConfigurationImpl implements Configuration {
                 }
             }
         }
-        shardReplicaNames.put(shardName, Collections.EMPTY_LIST);
-        return Collections.EMPTY_LIST;
+        shardReplicaNames.put(shardName, Collections.<String>emptyList());
+        return Collections.emptyList();
     }
 
     @Override public Set<String> getAllShardNames() {
@@ -175,7 +174,7 @@ public class ConfigurationImpl implements Configuration {
 
 
 
-    private void readModules(Config modulesConfig) {
+    private void readModules(final Config modulesConfig) {
         List<? extends ConfigObject> modulesConfigObjectList =
             modulesConfig.getObjectList("modules");
 
@@ -186,7 +185,7 @@ public class ConfigurationImpl implements Configuration {
         }
     }
 
-    private void readModuleShards(Config moduleShardsConfig) {
+    private void readModuleShards(final Config moduleShardsConfig) {
         List<? extends ConfigObject> moduleShardsConfigObjectList =
             moduleShardsConfig.getObjectList("module-shards");
 
@@ -214,7 +213,7 @@ public class ConfigurationImpl implements Configuration {
         private final String moduleName;
         private final List<Shard> shards;
 
-        public ModuleShard(String moduleName, List<Shard> shards) {
+        public ModuleShard(final String moduleName, final List<Shard> shards) {
             this.moduleName = moduleName;
             this.shards = shards;
         }
@@ -232,7 +231,7 @@ public class ConfigurationImpl implements Configuration {
         private final String name;
         private final List<String> replicas;
 
-        Shard(String name, List<String> replicas) {
+        Shard(final String name, final List<String> replicas) {
             this.name = name;
             this.replicas = replicas;
         }
@@ -252,7 +251,7 @@ public class ConfigurationImpl implements Configuration {
         private final String nameSpace;
         private final ShardStrategy shardStrategy;
 
-        Module(String name, String nameSpace, String shardStrategy) {
+        Module(final String name, final String nameSpace, final String shardStrategy) {
             this.name = name;
             this.nameSpace = nameSpace;
             if(ModuleShardStrategy.NAME.equals(shardStrategy)){
@@ -280,11 +279,11 @@ public class ConfigurationImpl implements Configuration {
 
         private final ConfigObject configObject;
 
-        ConfigObjectWrapper(ConfigObject configObject){
+        ConfigObjectWrapper(final ConfigObject configObject){
             this.configObject = configObject;
         }
 
-        public String stringValue(String name){
+        public String stringValue(final String name){
             return configObject.get(name).unwrapped().toString();
         }
     }
index b467ee4ddbf56c456c2e9f0f62381eefa173e31d..93f9e6b7de1e2085f01d36c74a37b84ff7ecb4d2 100644 (file)
@@ -9,18 +9,17 @@
 package org.opendaylight.controller.cluster.datastore;
 
 import akka.actor.ActorSelection;
-import akka.dispatch.Futures;
+import akka.dispatch.OnComplete;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.List;
 import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionChain;
 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
 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 scala.concurrent.Await;
 import scala.concurrent.Future;
-
-import java.util.Collections;
-import java.util.List;
+import scala.concurrent.Promise;
 
 /**
  * TransactionChainProxy acts as a proxy for a DOMStoreTransactionChain created on a remote shard
@@ -28,7 +27,7 @@ import java.util.List;
 public class TransactionChainProxy implements DOMStoreTransactionChain{
     private final ActorContext actorContext;
     private final String transactionChainId;
-    private volatile List<Future<ActorSelection>> cohortFutures = Collections.emptyList();
+    private volatile SimpleEntry<Object, List<Future<ActorSelection>>> previousTxReadyFutures;
 
     public TransactionChainProxy(ActorContext actorContext) {
         this.actorContext = actorContext;
@@ -37,20 +36,17 @@ public class TransactionChainProxy implements DOMStoreTransactionChain{
 
     @Override
     public DOMStoreReadTransaction newReadOnlyTransaction() {
-        return new TransactionProxy(actorContext,
-            TransactionProxy.TransactionType.READ_ONLY, this);
+        return new ChainedTransactionProxy(actorContext, TransactionProxy.TransactionType.READ_ONLY);
     }
 
     @Override
     public DOMStoreReadWriteTransaction newReadWriteTransaction() {
-        return new TransactionProxy(actorContext,
-            TransactionProxy.TransactionType.READ_WRITE, this);
+        return new ChainedTransactionProxy(actorContext, TransactionProxy.TransactionType.READ_WRITE);
     }
 
     @Override
     public DOMStoreWriteTransaction newWriteOnlyTransaction() {
-        return new TransactionProxy(actorContext,
-            TransactionProxy.TransactionType.WRITE_ONLY, this);
+        return new ChainedTransactionProxy(actorContext, TransactionProxy.TransactionType.WRITE_ONLY);
     }
 
     @Override
@@ -63,17 +59,62 @@ public class TransactionChainProxy implements DOMStoreTransactionChain{
         return transactionChainId;
     }
 
-    public void onTransactionReady(List<Future<ActorSelection>> cohortFutures){
-        this.cohortFutures = cohortFutures;
-    }
+    private class ChainedTransactionProxy extends TransactionProxy {
+
+        ChainedTransactionProxy(ActorContext actorContext, TransactionType transactionType) {
+            super(actorContext, transactionType, transactionChainId);
+        }
+
+        @Override
+        protected void onTransactionReady(List<Future<ActorSelection>> cohortFutures) {
+            if(!cohortFutures.isEmpty()) {
+                previousTxReadyFutures = new SimpleEntry<>(getIdentifier(), cohortFutures);
+            } else {
+                previousTxReadyFutures = null;
+            }
+        }
+
+        /**
+         * This method is overridden to ensure the previous Tx's ready operations complete
+         * before we create the next shard Tx in the chain to avoid creation failures if the
+         * previous Tx's ready operations haven't completed yet.
+         */
+        @Override
+        protected Future<Object> sendCreateTransaction(final ActorSelection shard,
+                final Object serializedCreateMessage) {
+            // Check if there are any previous ready Futures. Also make sure the previous ready
+            // Futures aren't for this Tx as deadlock would occur if tried to wait on our own
+            // Futures. This may happen b/c the shard Tx creates are done async so it's possible
+            // for the client to ready this Tx before we've even attempted to create a shard Tx.
+            if(previousTxReadyFutures == null ||
+                    previousTxReadyFutures.getKey().equals(getIdentifier())) {
+                return super.sendCreateTransaction(shard, serializedCreateMessage);
+            }
+
+            // Combine the ready Futures into 1.
+            Future<Iterable<ActorSelection>> combinedFutures = akka.dispatch.Futures.sequence(
+                    previousTxReadyFutures.getValue(), actorContext.getActorSystem().dispatcher());
+
+            // Add a callback for completion of the combined Futures.
+            final Promise<Object> createTxPromise = akka.dispatch.Futures.promise();
+            OnComplete<Iterable<ActorSelection>> onComplete = new OnComplete<Iterable<ActorSelection>>() {
+                @Override
+                public void onComplete(Throwable failure, Iterable<ActorSelection> notUsed) {
+                    if(failure != null) {
+                        // A Ready Future failed so fail the returned Promise.
+                        createTxPromise.failure(failure);
+                    } else {
+                        // Send the CreateTx message and use the resulting Future to complete the
+                        // returned Promise.
+                        createTxPromise.completeWith(actorContext.executeOperationAsync(shard,
+                                serializedCreateMessage));
+                    }
+                }
+            };
+
+            combinedFutures.onComplete(onComplete, actorContext.getActorSystem().dispatcher());
 
-    public void waitTillCurrentTransactionReady(){
-        try {
-            Await.result(Futures
-                .sequence(this.cohortFutures, actorContext.getActorSystem().dispatcher()),
-                actorContext.getOperationDuration());
-        } catch (Exception e) {
-            throw new IllegalStateException("Failed when waiting for transaction on a chain to become ready", e);
+            return createTxPromise.future();
         }
     }
 }
index ffb1ab7c55064ecf7683e1857800b256c9c82a1d..d93bae22e08d9fddb3f1ac7d9c12aa4a278d0ff6 100644 (file)
@@ -21,6 +21,14 @@ 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.SettableFuture;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
+import javax.annotation.concurrent.GuardedBy;
 import org.opendaylight.controller.cluster.datastore.exceptions.NoShardLeaderException;
 import org.opendaylight.controller.cluster.datastore.identifiers.TransactionIdentifier;
 import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction;
@@ -50,15 +58,6 @@ import scala.concurrent.Future;
 import scala.concurrent.Promise;
 import scala.concurrent.duration.FiniteDuration;
 
-import javax.annotation.concurrent.GuardedBy;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicLong;
-
 /**
  * TransactionProxy acts as a proxy for one or more transactions that were created on a remote shard
  * <p>
@@ -182,23 +181,23 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
     private final TransactionType transactionType;
     private final ActorContext actorContext;
     private final TransactionIdentifier identifier;
-    private final TransactionChainProxy transactionChainProxy;
+    private final String transactionChainId;
     private final SchemaContext schemaContext;
     private boolean inReadyState;
 
     public TransactionProxy(ActorContext actorContext, TransactionType transactionType) {
-        this(actorContext, transactionType, null);
+        this(actorContext, transactionType, "");
     }
 
     public TransactionProxy(ActorContext actorContext, TransactionType transactionType,
-            TransactionChainProxy transactionChainProxy) {
+            String transactionChainId) {
         this.actorContext = Preconditions.checkNotNull(actorContext,
             "actorContext should not be null");
         this.transactionType = Preconditions.checkNotNull(transactionType,
             "transactionType should not be null");
         this.schemaContext = Preconditions.checkNotNull(actorContext.getSchemaContext(),
             "schemaContext should not be null");
-        this.transactionChainProxy = transactionChainProxy;
+        this.transactionChainId = transactionChainId;
 
         String memberName = actorContext.getCurrentMemberName();
         if(memberName == null){
@@ -237,6 +236,18 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
         return recordedOperationFutures;
     }
 
+    @VisibleForTesting
+    boolean hasTransactionContext() {
+        for(TransactionFutureCallback txFutureCallback : txFutureCallbackMap.values()) {
+            TransactionContext transactionContext = txFutureCallback.getTransactionContext();
+            if(transactionContext != null) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
     @Override
     public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(
             final YangInstanceIdentifier path) {
@@ -433,14 +444,32 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
             }
         }
 
-        if(transactionChainProxy != null){
-            transactionChainProxy.onTransactionReady(cohortFutures);
-        }
+        onTransactionReady(cohortFutures);
 
         return new ThreePhaseCommitCohortProxy(actorContext, cohortFutures,
                 identifier.toString());
     }
 
+    /**
+     * Method for derived classes to be notified when the transaction has been readied.
+     *
+     * @param cohortFutures the cohort Futures for each shard transaction.
+     */
+    protected void onTransactionReady(List<Future<ActorSelection>> cohortFutures) {
+    }
+
+    /**
+     * Method called to send a CreateTransaction message to a shard.
+     *
+     * @param shard the shard actor to send to
+     * @param serializedCreateMessage the serialized message to send
+     * @return the response Future
+     */
+    protected Future<Object> sendCreateTransaction(ActorSelection shard,
+            Object serializedCreateMessage) {
+        return actorContext.executeOperationAsync(shard, serializedCreateMessage);
+    }
+
     @Override
     public Object getIdentifier() {
         return this.identifier;
@@ -502,10 +531,7 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
     }
 
     public String getTransactionChainId() {
-        if(transactionChainProxy == null){
-            return "";
-        }
-        return transactionChainProxy.getTransactionChainId();
+        return transactionChainId;
     }
 
     /**
@@ -591,7 +617,7 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
          * Performs a CreateTransaction try async.
          */
         private void tryCreateTransaction() {
-            Future<Object> createTxFuture = actorContext.executeOperationAsync(primaryShard,
+            Future<Object> createTxFuture = sendCreateTransaction(primaryShard,
                     new CreateTransaction(identifier.toString(),
                             TransactionProxy.this.transactionType.ordinal(),
                             getTransactionChainId()).toSerializable());
@@ -626,29 +652,42 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
             // respect to #addTxOperationOnComplete to handle timing issues and ensure no
             // TransactionOperation is missed and that they are processed in the order they occurred.
             synchronized(txOperationsOnComplete) {
+                // Store the new TransactionContext locally until we've completed invoking the
+                // TransactionOperations. This avoids thread timing issues which could cause
+                // out-of-order TransactionOperations. Eg, on a modification operation, if the
+                // TransactionContext is non-null, then we directly call the TransactionContext.
+                // However, at the same time, the code may be executing the cached
+                // TransactionOperations. So to avoid thus timing, we don't publish the
+                // TransactionContext until after we've executed all cached TransactionOperations.
+                TransactionContext localTransactionContext;
                 if(failure != null) {
                     LOG.debug("Tx {} Creating NoOpTransaction because of error: {}", identifier,
                             failure.getMessage());
 
-                    transactionContext = new NoOpTransactionContext(failure, identifier);
+                    localTransactionContext = new NoOpTransactionContext(failure, identifier);
                 } else if (response.getClass().equals(CreateTransactionReply.SERIALIZABLE_CLASS)) {
-                    createValidTransactionContext(CreateTransactionReply.fromSerializable(response));
+                    localTransactionContext = createValidTransactionContext(
+                            CreateTransactionReply.fromSerializable(response));
                 } else {
                     IllegalArgumentException exception = new IllegalArgumentException(String.format(
                         "Invalid reply type %s for CreateTransaction", response.getClass()));
 
-                    transactionContext = new NoOpTransactionContext(exception, identifier);
+                    localTransactionContext = new NoOpTransactionContext(exception, identifier);
                 }
 
                 for(TransactionOperation oper: txOperationsOnComplete) {
-                    oper.invoke(transactionContext);
+                    oper.invoke(localTransactionContext);
                 }
 
                 txOperationsOnComplete.clear();
+
+                // We're done invoking the TransactionOperations so we can now publish the
+                // TransactionContext.
+                transactionContext = localTransactionContext;
             }
         }
 
-        private void createValidTransactionContext(CreateTransactionReply reply) {
+        private TransactionContext createValidTransactionContext(CreateTransactionReply reply) {
             String transactionPath = reply.getTransactionPath();
 
             LOG.debug("Tx {} Received transaction actor path {}", identifier, transactionPath);
@@ -669,7 +708,7 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
             // Check if TxActor is created in the same node
             boolean isTxActorLocal = actorContext.isLocalPath(transactionPath);
 
-            transactionContext = new TransactionContextImpl(transactionPath, transactionActor, identifier,
+            return new TransactionContextImpl(transactionPath, transactionActor, identifier,
                 actorContext, schemaContext, isTxActorLocal, reply.getVersion());
         }
     }
index 9c8909c2dd0f339e00ec64ccda57b098d1fd4567..4d121bae0adbc1aa0dee6d2888b0982293c70810 100644 (file)
@@ -11,12 +11,12 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages;
 
 public class CanCommitTransactionReply implements SerializableMessage {
-    public static Class<ThreePhaseCommitCohortMessages.CanCommitTransactionReply> SERIALIZABLE_CLASS =
+    public static final Class<ThreePhaseCommitCohortMessages.CanCommitTransactionReply> SERIALIZABLE_CLASS =
             ThreePhaseCommitCohortMessages.CanCommitTransactionReply.class;
 
     private final Boolean canCommit;
 
-    public CanCommitTransactionReply(Boolean canCommit) {
+    public CanCommitTransactionReply(final Boolean canCommit) {
         this.canCommit = canCommit;
     }
 
@@ -29,7 +29,7 @@ public class CanCommitTransactionReply implements SerializableMessage {
         return ThreePhaseCommitCohortMessages.CanCommitTransactionReply.newBuilder().setCanCommit(canCommit).build();
     }
 
-    public static CanCommitTransactionReply fromSerializable(Object message) {
+    public static CanCommitTransactionReply fromSerializable(final Object message) {
         return new CanCommitTransactionReply(
                 ((ThreePhaseCommitCohortMessages.CanCommitTransactionReply) message).getCanCommit());
     }
index a54ee6209c8d75b36681cfec470f44a7bcbae593..f711d6f7b5aa9a1c7230e47f4aa33caa8a538b5c 100644 (file)
@@ -11,7 +11,8 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages;
 
 public class CloseDataChangeListenerRegistration implements SerializableMessage {
-  public static final Class SERIALIZABLE_CLASS = ListenerRegistrationMessages.CloseDataChangeListenerRegistration.class;
+  public static final Class<ListenerRegistrationMessages.CloseDataChangeListenerRegistration> SERIALIZABLE_CLASS =
+          ListenerRegistrationMessages.CloseDataChangeListenerRegistration.class;
   @Override
   public Object toSerializable() {
     return ListenerRegistrationMessages.CloseDataChangeListenerRegistration.newBuilder().build();
index faf73c87ebe4ef6bdb8926ccfc3742ecc86d9ebe..9d8225c23a98b8d96dbc2307fe8653db9fc1a5d5 100644 (file)
@@ -11,7 +11,8 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages;
 
 public class CloseDataChangeListenerRegistrationReply implements SerializableMessage{
-  public static Class SERIALIZABLE_CLASS = ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply.class;
+  public static final Class<ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply> SERIALIZABLE_CLASS =
+          ListenerRegistrationMessages.CloseDataChangeListenerRegistrationReply.class;
 
   @Override
   public Object toSerializable() {
index 451e39cf6a75d2ac0777c60d25de969c0d0fd2ef..c73111f2dbde517989214c7bd5a17145df63bc2c 100644 (file)
@@ -11,7 +11,8 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
 
 public class CloseTransaction implements SerializableMessage{
-  public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.CloseTransaction.class;
+  public static final Class<ShardTransactionMessages.CloseTransaction> SERIALIZABLE_CLASS =
+          ShardTransactionMessages.CloseTransaction.class;
   @Override
   public Object toSerializable() {
     return ShardTransactionMessages.CloseTransaction.newBuilder().build();
index 74de6c5aeacd3a39e777512980745d9190d7838c..7db39b77a3063878f5fad44cbb61b3594b7b720f 100644 (file)
@@ -11,11 +11,11 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages;
 
 public class CloseTransactionChain implements SerializableMessage {
-    public static final Class SERIALIZABLE_CLASS =
+    public static final Class<ShardTransactionChainMessages.CloseTransactionChain> SERIALIZABLE_CLASS =
         ShardTransactionChainMessages.CloseTransactionChain.class;
     private final String transactionChainId;
 
-    public CloseTransactionChain(String transactionChainId){
+    public CloseTransactionChain(final String transactionChainId){
         this.transactionChainId = transactionChainId;
     }
 
@@ -25,7 +25,7 @@ public class CloseTransactionChain implements SerializableMessage {
             .setTransactionChainId(transactionChainId).build();
     }
 
-    public static CloseTransactionChain fromSerializable(Object message){
+    public static CloseTransactionChain fromSerializable(final Object message){
         ShardTransactionChainMessages.CloseTransactionChain closeTransactionChain
             = (ShardTransactionChainMessages.CloseTransactionChain) message;
 
index 23699b7be6c64cb103241329ad9fa72a585cf10b..c001ae185a6dc9641f08f2440d7825624936cb1d 100644 (file)
@@ -11,7 +11,8 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages;
 
 public class CloseTransactionChainReply implements SerializableMessage {
-  public static final Class SERIALIZABLE_CLASS = ShardTransactionChainMessages.CloseTransactionChainReply.class;
+  public static final Class<ShardTransactionChainMessages.CloseTransactionChainReply> SERIALIZABLE_CLASS =
+          ShardTransactionChainMessages.CloseTransactionChainReply.class;
   @Override
   public Object toSerializable() {
     return ShardTransactionChainMessages.CloseTransactionChainReply.newBuilder().build();
index 666d182aaff24c9e3d7a8da86a5de061dc4e0999..124eeb2235f04d64e30dd33c581166a1edb347fc 100644 (file)
@@ -11,7 +11,8 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
 
 public class CloseTransactionReply implements SerializableMessage {
-  public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.CloseTransactionReply.class;
+  public static final Class<ShardTransactionMessages.CloseTransactionReply> SERIALIZABLE_CLASS =
+          ShardTransactionMessages.CloseTransactionReply.class;
   @Override
   public Object toSerializable() {
     return ShardTransactionMessages.CloseTransactionReply.newBuilder().build();
index 14620f15d98ffece07905a73cdd7d18222e9c023..83e68c9cb41882c2b7c377f96aaecb5f5a07f328 100644 (file)
@@ -12,18 +12,19 @@ import org.opendaylight.controller.protobuff.messages.transaction.ShardTransacti
 
 public class CreateTransactionReply implements SerializableMessage {
 
-    public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.CreateTransactionReply.class;
+    public static final Class<ShardTransactionMessages.CreateTransactionReply> SERIALIZABLE_CLASS =
+            ShardTransactionMessages.CreateTransactionReply.class;
     private final String transactionPath;
     private final String transactionId;
     private final int version;
 
-    public CreateTransactionReply(String transactionPath,
-        String transactionId) {
+    public CreateTransactionReply(final String transactionPath,
+        final String transactionId) {
         this(transactionPath, transactionId, CreateTransaction.CURRENT_VERSION);
     }
 
-    public CreateTransactionReply(String transactionPath,
-                                  String transactionId, int version) {
+    public CreateTransactionReply(final String transactionPath,
+                                  final String transactionId, final int version) {
         this.transactionPath = transactionPath;
         this.transactionId = transactionId;
         this.version = version;
@@ -42,6 +43,7 @@ public class CreateTransactionReply implements SerializableMessage {
         return version;
     }
 
+    @Override
     public Object toSerializable(){
         return ShardTransactionMessages.CreateTransactionReply.newBuilder()
             .setTransactionActorPath(transactionPath)
@@ -50,7 +52,7 @@ public class CreateTransactionReply implements SerializableMessage {
             .build();
     }
 
-    public static CreateTransactionReply fromSerializable(Object serializable){
+    public static CreateTransactionReply fromSerializable(final Object serializable){
         ShardTransactionMessages.CreateTransactionReply o = (ShardTransactionMessages.CreateTransactionReply) serializable;
         return new CreateTransactionReply(o.getTransactionActorPath(), o.getTransactionId(), o.getMessageVersion());
     }
index cffe985d18630beff2ba53b48b35f532cd100db3..e10a40729220941761a925350b5ac25288b0e90c 100644 (file)
@@ -11,7 +11,8 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.datachange.notification.DataChangeListenerMessages;
 
 public class DataChangedReply implements SerializableMessage {
-  public static final Class SERIALIZABLE_CLASS = DataChangeListenerMessages.DataChangedReply.class;
+  public static final Class<DataChangeListenerMessages.DataChangedReply> SERIALIZABLE_CLASS =
+          DataChangeListenerMessages.DataChangedReply.class;
   @Override
   public Object toSerializable() {
     return DataChangeListenerMessages.DataChangedReply.newBuilder().build();
index d52daabd845456b990f4f79300906134ec3744bb..84b8df167607701ea35caf4c32fa301451744e83 100644 (file)
@@ -14,11 +14,12 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
 public class DataExists implements SerializableMessage{
 
-    public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.DataExists.class;
+    public static final Class<ShardTransactionMessages.DataExists> SERIALIZABLE_CLASS =
+            ShardTransactionMessages.DataExists.class;
 
     private final YangInstanceIdentifier path;
 
-    public DataExists(YangInstanceIdentifier path) {
+    public DataExists(final YangInstanceIdentifier path) {
         this.path = path;
     }
 
@@ -32,7 +33,7 @@ public class DataExists implements SerializableMessage{
                 InstanceIdentifierUtils.toSerializable(path)).build();
     }
 
-    public static DataExists fromSerializable(Object serializable){
+    public static DataExists fromSerializable(final Object serializable){
         ShardTransactionMessages.DataExists o = (ShardTransactionMessages.DataExists) serializable;
         return new DataExists(InstanceIdentifierUtils.fromSerializable(o.getInstanceIdentifierPathArguments()));
     }
index 04fafa10e29fc66f66f89faca14f9021a33b50a1..24ca6464543911c9d4c6d05fe1f3f2d8731c920e 100644 (file)
@@ -11,13 +11,12 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
 
 public class DataExistsReply implements SerializableMessage{
-
-
-    public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.DataExistsReply.class;
+    public static final Class<ShardTransactionMessages.DataExistsReply> SERIALIZABLE_CLASS =
+            ShardTransactionMessages.DataExistsReply.class;
 
     private final boolean exists;
 
-    public DataExistsReply(boolean exists) {
+    public DataExistsReply(final boolean exists) {
         this.exists = exists;
     }
 
@@ -30,7 +29,7 @@ public class DataExistsReply implements SerializableMessage{
             .setExists(exists).build();
     }
 
-    public static DataExistsReply fromSerializable(Object serializable){
+    public static DataExistsReply fromSerializable(final Object serializable){
         ShardTransactionMessages.DataExistsReply o = (ShardTransactionMessages.DataExistsReply) serializable;
         return new DataExistsReply(o.getExists());
     }
index 6d3051c8c7ab9779ca252082868e95e30f8a962c..81bc1026e44e823dcb6485e32673fa52c27eeb84 100644 (file)
@@ -14,11 +14,11 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
 public class DeleteData implements SerializableMessage {
 
-    public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.DeleteData.class;
+    public static final Class<ShardTransactionMessages.DeleteData> SERIALIZABLE_CLASS = ShardTransactionMessages.DeleteData.class;
 
     private final YangInstanceIdentifier path;
 
-    public DeleteData(YangInstanceIdentifier path) {
+    public DeleteData(final YangInstanceIdentifier path) {
         this.path = path;
     }
 
@@ -31,7 +31,7 @@ public class DeleteData implements SerializableMessage {
             .setInstanceIdentifierPathArguments(InstanceIdentifierUtils.toSerializable(path)).build();
     }
 
-    public static DeleteData fromSerializable(Object serializable){
+    public static DeleteData fromSerializable(final Object serializable){
         ShardTransactionMessages.DeleteData o = (ShardTransactionMessages.DeleteData) serializable;
         return new DeleteData(InstanceIdentifierUtils.fromSerializable(o.getInstanceIdentifierPathArguments()));
     }
index 8e2a7b72951a27b5d2b1fe039ed619db5ac62ffd..2e02664e1dcd41bc032fb2be2a2913baf0e000f5 100644 (file)
@@ -11,7 +11,8 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
 
 public class DeleteDataReply implements SerializableMessage{
-  public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.DeleteDataReply.class;
+  public static final Class<ShardTransactionMessages.DeleteDataReply> SERIALIZABLE_CLASS =
+          ShardTransactionMessages.DeleteDataReply.class;
   @Override
   public Object toSerializable() {
     return ShardTransactionMessages.DeleteDataReply.newBuilder().build();
index 81b1c3bbb1e3dab609b903ed5b40f57e8da07523..92d6d728477aac50dfb68975db69c299249537dc 100644 (file)
@@ -11,7 +11,8 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
 
 public class MergeDataReply implements SerializableMessage{
-  public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.MergeDataReply.class;
+  public static final Class<ShardTransactionMessages.MergeDataReply> SERIALIZABLE_CLASS =
+          ShardTransactionMessages.MergeDataReply.class;
 
   @Override
   public Object toSerializable() {
index dae4cec3c3a606c059771e9335317d1d75c233d7..3cec7e74a6793d47f5575fec2e151b84e1e7cd0b 100644 (file)
@@ -12,7 +12,8 @@ import org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommit
 
 public class PreCommitTransaction implements SerializableMessage{
 
-  public static final Class SERIALIZABLE_CLASS = ThreePhaseCommitCohortMessages.PreCommitTransaction.class;
+  public static final Class<ThreePhaseCommitCohortMessages.PreCommitTransaction> SERIALIZABLE_CLASS =
+          ThreePhaseCommitCohortMessages.PreCommitTransaction.class;
 
   @Override
   public Object toSerializable() {
index fc07bfcb4b786793f02125bfad01f77088bcfe33..d158049409a9a7e23230da76c16ab5b514377ae6 100644 (file)
@@ -12,7 +12,8 @@ import org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommit
 
 public class PreCommitTransactionReply implements SerializableMessage{
 
-  public static final Class SERIALIZABLE_CLASS = ThreePhaseCommitCohortMessages.PreCommitTransactionReply.class;
+  public static final Class<ThreePhaseCommitCohortMessages.PreCommitTransactionReply> SERIALIZABLE_CLASS =
+          ThreePhaseCommitCohortMessages.PreCommitTransactionReply.class;
 
   @Override
   public Object toSerializable() {
index a2f6701524a7f4d2f42a4ce93b4463d368414659..a5565020edc171e43d550f7ace0a8dc6a80739e3 100644 (file)
@@ -10,10 +10,10 @@ package org.opendaylight.controller.cluster.datastore.messages;
 
 
 public class PrimaryFound implements SerializableMessage {
-  public static final Class SERIALIZABLE_CLASS = PrimaryFound.class;
+  public static final Class<PrimaryFound> SERIALIZABLE_CLASS = PrimaryFound.class;
   private final String primaryPath;
 
-  public PrimaryFound(String primaryPath) {
+  public PrimaryFound(final String primaryPath) {
     this.primaryPath = primaryPath;
   }
 
@@ -22,13 +22,19 @@ public class PrimaryFound implements SerializableMessage {
   }
 
   @Override
-  public boolean equals(Object o) {
-    if (this == o) return true;
-    if (o == null || getClass() != o.getClass()) return false;
+  public boolean equals(final Object o) {
+    if (this == o) {
+        return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+        return false;
+    }
 
     PrimaryFound that = (PrimaryFound) o;
 
-    if (!primaryPath.equals(that.primaryPath)) return false;
+    if (!primaryPath.equals(that.primaryPath)) {
+        return false;
+    }
 
     return true;
   }
@@ -51,7 +57,7 @@ public class PrimaryFound implements SerializableMessage {
     return  this;
   }
 
-  public static PrimaryFound fromSerializable(Object message){
+  public static PrimaryFound fromSerializable(final Object message){
     return (PrimaryFound) message;
   }
 }
index 731a5364db247d52642e31da6e105ea655793196..b47c91b6e5802ee7896ff30ba2b7d1035d8fc338 100644 (file)
@@ -11,11 +11,11 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import com.google.common.base.Preconditions;
 
 public class PrimaryNotFound implements SerializableMessage {
-  public static final Class SERIALIZABLE_CLASS = PrimaryNotFound.class;
+  public static final Class<PrimaryNotFound> SERIALIZABLE_CLASS = PrimaryNotFound.class;
 
     private final String shardName;
 
-    public PrimaryNotFound(String shardName){
+    public PrimaryNotFound(final String shardName){
 
         Preconditions.checkNotNull(shardName, "shardName should not be null");
 
@@ -23,13 +23,19 @@ public class PrimaryNotFound implements SerializableMessage {
     }
 
     @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
+    public boolean equals(final Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
 
         PrimaryNotFound that = (PrimaryNotFound) o;
 
-        if (shardName != null ? !shardName.equals(that.shardName) : that.shardName != null) return false;
+        if (shardName != null ? !shardName.equals(that.shardName) : that.shardName != null) {
+            return false;
+        }
 
         return true;
     }
@@ -44,7 +50,7 @@ public class PrimaryNotFound implements SerializableMessage {
     return this;
   }
 
-  public static PrimaryNotFound fromSerializable(Object message){
+  public static PrimaryNotFound fromSerializable(final Object message){
     return (PrimaryNotFound) message;
   }
 }
index d743d99fcc12cee6b4da25d306d9d97a567ede0a..a8a3e7d071b7af89135f529523caf8215b279cb0 100644 (file)
@@ -13,10 +13,11 @@ import org.opendaylight.controller.protobuff.messages.transaction.ShardTransacti
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
 public class ReadData {
-  public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.ReadData.class;
+  public static final Class<ShardTransactionMessages.ReadData> SERIALIZABLE_CLASS =
+          ShardTransactionMessages.ReadData.class;
   private final YangInstanceIdentifier path;
 
-  public ReadData(YangInstanceIdentifier path) {
+  public ReadData(final YangInstanceIdentifier path) {
     this.path = path;
   }
 
@@ -30,7 +31,7 @@ public class ReadData {
         .build();
   }
 
-  public static ReadData fromSerializable(Object serializable){
+  public static ReadData fromSerializable(final Object serializable){
     ShardTransactionMessages.ReadData o = (ShardTransactionMessages.ReadData) serializable;
     return new ReadData(InstanceIdentifierUtils.fromSerializable(o.getInstanceIdentifierPathArguments()));
   }
index 3a51d9850b78ae1272fb419bbec7068bfd81bbea..581caefd04e9fb83263a06cba9b6014f3b92109d 100644 (file)
@@ -11,7 +11,8 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
 
 public class ReadyTransaction implements SerializableMessage{
-  public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.ReadyTransaction.class;
+  public static final Class<ShardTransactionMessages.ReadyTransaction> SERIALIZABLE_CLASS =
+          ShardTransactionMessages.ReadyTransaction.class;
 
   @Override
   public Object toSerializable() {
index 8d980d283db9c9187733e44c4f685287c83a97ea..bbfbbaa80b0f5966565f7156725e3eea0c1affcb 100644 (file)
@@ -13,10 +13,11 @@ import akka.actor.ActorSystem;
 import org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages;
 
 public class RegisterChangeListenerReply implements SerializableMessage{
-  public static final Class SERIALIZABLE_CLASS = ListenerRegistrationMessages.RegisterChangeListenerReply.class;
+  public static final Class<ListenerRegistrationMessages.RegisterChangeListenerReply> SERIALIZABLE_CLASS =
+          ListenerRegistrationMessages.RegisterChangeListenerReply.class;
   private final ActorPath listenerRegistrationPath;
 
-  public RegisterChangeListenerReply(ActorPath listenerRegistrationPath) {
+  public RegisterChangeListenerReply(final ActorPath listenerRegistrationPath) {
     this.listenerRegistrationPath = listenerRegistrationPath;
   }
 
@@ -30,7 +31,7 @@ public class RegisterChangeListenerReply implements SerializableMessage{
             .setListenerRegistrationPath(listenerRegistrationPath.toString()).build();
   }
 
-  public static RegisterChangeListenerReply fromSerializable(ActorSystem actorSystem,Object serializable){
+  public static RegisterChangeListenerReply fromSerializable(final ActorSystem actorSystem,final Object serializable){
     ListenerRegistrationMessages.RegisterChangeListenerReply o = (ListenerRegistrationMessages.RegisterChangeListenerReply) serializable;
     return new RegisterChangeListenerReply(
         actorSystem.actorFor(o.getListenerRegistrationPath()).path()
index 5404fb65103557235ae8e56f95eebd645ea11b9d..876105de18abf7c4beee7b1c7afca342fc4086b2 100644 (file)
@@ -11,7 +11,8 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
 
 public class WriteDataReply implements SerializableMessage{
-  public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.WriteDataReply.class;
+  public static final Class<ShardTransactionMessages.WriteDataReply> SERIALIZABLE_CLASS =
+          ShardTransactionMessages.WriteDataReply.class;
   @Override
   public Object toSerializable() {
     return ShardTransactionMessages.WriteDataReply.newBuilder().build();
index 24c4c6c50a63fe171ca001bafe25ec7ee62e0970..2f9d77660aba4d76b671b91df000baae5c5780ba 100644 (file)
@@ -20,18 +20,19 @@ 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 WriteModification {
+    private static final long serialVersionUID = 1L;
 
-    public MergeModification(YangInstanceIdentifier path, NormalizedNode data,
-        SchemaContext schemaContext) {
+    public MergeModification(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data,
+        final SchemaContext schemaContext) {
         super(path, data, schemaContext);
     }
 
     @Override
-    public void apply(DOMStoreWriteTransaction transaction) {
+    public void apply(final DOMStoreWriteTransaction transaction) {
         transaction.merge(path, data);
     }
 
-    public static MergeModification fromSerializable(Object serializable, SchemaContext schemaContext) {
+    public static MergeModification fromSerializable(final Object serializable, final SchemaContext schemaContext) {
         PersistentMessages.Modification o = (PersistentMessages.Modification) serializable;
         Decoded decoded = new NormalizedNodeToNodeCodec(schemaContext).decode(o.getPath(), o.getData());
         return new MergeModification(decoded.getDecodedPath(), decoded.getDecodedNode(), schemaContext);
index 53cc35a88be26f2ba9f9e0fda8994e8fdfb20584..b2964086fd976b03516df0872d007f2f0a124af6 100644 (file)
@@ -21,22 +21,22 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
  * WriteModification stores all the parameters required to write data to the specified path
  */
 public class WriteModification extends AbstractModification {
-
-    protected final NormalizedNode data;
+    private static final long serialVersionUID = 1L;
+    protected final NormalizedNode<?, ?> data;
     private final SchemaContext schemaContext;
 
-    public WriteModification(YangInstanceIdentifier path, NormalizedNode data, SchemaContext schemaContext) {
+    public WriteModification(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data, final SchemaContext schemaContext) {
         super(path);
         this.data = data;
         this.schemaContext = schemaContext;
     }
 
     @Override
-    public void apply(DOMStoreWriteTransaction transaction) {
+    public void apply(final DOMStoreWriteTransaction transaction) {
         transaction.write(path, data);
     }
 
-    public NormalizedNode getData() {
+    public NormalizedNode<?, ?> getData() {
         return data;
     }
 
@@ -51,7 +51,7 @@ public class WriteModification extends AbstractModification {
                 .build();
     }
 
-    public static WriteModification fromSerializable(Object serializable, SchemaContext schemaContext) {
+    public static WriteModification fromSerializable(final Object serializable, final SchemaContext schemaContext) {
         PersistentMessages.Modification o = (PersistentMessages.Modification) serializable;
         Decoded decoded = new NormalizedNodeToNodeCodec(schemaContext).decode(o.getPath(), o.getData());
         return new WriteModification(decoded.getDecodedPath(), decoded.getDecodedNode(), schemaContext);
index f4ab8fab6f768e84bd48c15ebc83e862315e09eb..62fb65482b09d366289107f93df14050340688c4 100644 (file)
@@ -10,26 +10,25 @@ package org.opendaylight.controller.cluster.datastore.shardstrategy;
 
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
-import org.opendaylight.controller.cluster.datastore.Configuration;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
+import org.opendaylight.controller.cluster.datastore.Configuration;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
 public class ShardStrategyFactory {
     private static Map<String, ShardStrategy> moduleNameToStrategyMap =
-        new ConcurrentHashMap();
+        new ConcurrentHashMap<>();
 
     private static final String UNKNOWN_MODULE_NAME = "unknown";
     private static Configuration configuration;
 
 
-    public static void setConfiguration(Configuration configuration){
+    public static void setConfiguration(final Configuration configuration){
         ShardStrategyFactory.configuration = configuration;
         moduleNameToStrategyMap = configuration.getModuleNameToShardStrategyMap();
     }
 
-    public static ShardStrategy getStrategy(YangInstanceIdentifier path) {
+    public static ShardStrategy getStrategy(final YangInstanceIdentifier path) {
         Preconditions.checkState(configuration != null, "configuration should not be missing");
         Preconditions.checkNotNull(path, "path should not be null");
 
@@ -44,7 +43,7 @@ public class ShardStrategyFactory {
     }
 
 
-    private static String getModuleName(YangInstanceIdentifier path) {
+    private static String getModuleName(final YangInstanceIdentifier path) {
         String namespace = path.getPathArguments().iterator().next().getNodeType().getNamespace().toASCIIString();
 
         Optional<String> optional =
index 8c253596b8b752c264f81cced7090087fc02879b..afc060318ce783a8a8041e4b38c008181df3e16f 100644 (file)
@@ -1,17 +1,15 @@
 package org.opendaylight.controller.cluster.datastore;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 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 java.util.Set;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
 public class ConfigurationImplTest {
 
index c79d76203589c51126dbd281adfd7dcaf4712db4..55250dd5e9cd3ea71c0356f5313c09d930700c00 100644 (file)
@@ -3,6 +3,11 @@ package org.opendaylight.controller.cluster.datastore;
 
 import akka.actor.ActorRef;
 import akka.actor.Props;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.datastore.messages.DataChanged;
@@ -17,18 +22,12 @@ import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
 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 MockDataChangedEvent implements AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> {
-    Map<YangInstanceIdentifier,NormalizedNode<?,?>> createdData = new HashMap();
-    Map<YangInstanceIdentifier,NormalizedNode<?,?>> updatedData = new HashMap();
-    Map<YangInstanceIdentifier,NormalizedNode<?,?>> originalData = new HashMap();
+    Map<YangInstanceIdentifier,NormalizedNode<?,?>> createdData = new HashMap<>();
+    Map<YangInstanceIdentifier,NormalizedNode<?,?>> updatedData = new HashMap<>();
+    Map<YangInstanceIdentifier,NormalizedNode<?,?>> originalData = new HashMap<>();
 
 
 
@@ -88,7 +87,7 @@ public class DataChangeListenerProxyTest extends AbstractActorTest {
 
         Assert.assertTrue(messages instanceof List);
 
-        List<Object> listMessages = (List<Object>) messages;
+        List<?> listMessages = (List<?>) messages;
 
         Assert.assertEquals(1, listMessages.size());
 
index cec7ce1e3fc250a84231f84e83d97996bbe2e55a..12c566d33de786db62bfad3ec86a56939edbe1c2 100644 (file)
@@ -1,11 +1,17 @@
 package org.opendaylight.controller.cluster.datastore;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import akka.actor.ActorRef;
 import akka.actor.ActorSystem;
 import akka.actor.PoisonPill;
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Uninterruptibles;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.datastore.exceptions.NoShardLeaderException;
 import org.opendaylight.controller.cluster.datastore.exceptions.NotInitializedException;
@@ -26,16 +32,10 @@ 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.YangInstanceIdentifier;
+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.model.api.SchemaContext;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
 
 public class DistributedDataStoreIntegrationTest extends AbstractActorTest {
 
@@ -77,10 +77,7 @@ public class DistributedDataStoreIntegrationTest extends AbstractActorTest {
 
             DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
 
-            Boolean canCommit = cohort.canCommit().get(5, TimeUnit.SECONDS);
-            assertEquals("canCommit", true, canCommit);
-            cohort.preCommit().get(5, TimeUnit.SECONDS);
-            cohort.commit().get(5, TimeUnit.SECONDS);
+            doCommit(cohort);
 
             // Verify the data in the store
 
@@ -131,10 +128,7 @@ public class DistributedDataStoreIntegrationTest extends AbstractActorTest {
 
             // 5. Commit the Tx
 
-            Boolean canCommit = cohort.canCommit().get(5, TimeUnit.SECONDS);
-            assertEquals("canCommit", true, canCommit);
-            cohort.preCommit().get(5, TimeUnit.SECONDS);
-            cohort.commit().get(5, TimeUnit.SECONDS);
+            doCommit(cohort);
 
             // 6. Verify the data in the store
 
@@ -219,9 +213,7 @@ public class DistributedDataStoreIntegrationTest extends AbstractActorTest {
 
             // Wait for the Tx commit to complete.
 
-            assertEquals("canCommit", true, txCohort.get().canCommit().get(5, TimeUnit.SECONDS));
-            txCohort.get().preCommit().get(5, TimeUnit.SECONDS);
-            txCohort.get().commit().get(5, TimeUnit.SECONDS);
+            doCommit(txCohort.get());
 
             // Verify the data in the store
 
@@ -552,10 +544,8 @@ public class DistributedDataStoreIntegrationTest extends AbstractActorTest {
 
     @Test
     public void testTransactionChain() throws Exception{
-        System.setProperty("shard.persistent", "true");
         new IntegrationTestKit(getSystem()) {{
-            DistributedDataStore dataStore =
-                    setupDistributedDataStore("transactionChainIntegrationTest", "test-1");
+            DistributedDataStore dataStore = setupDistributedDataStore("testTransactionChain", "test-1");
 
             // 1. Create a Tx chain and write-only Tx
 
@@ -566,30 +556,76 @@ public class DistributedDataStoreIntegrationTest extends AbstractActorTest {
 
             // 2. Write some data
 
-            NormalizedNode<?, ?> containerNode = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
-            writeTx.write(TestModel.TEST_PATH, containerNode);
+            NormalizedNode<?, ?> testNode = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
+            writeTx.write(TestModel.TEST_PATH, testNode);
 
             // 3. Ready the Tx for commit
 
-            DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
+            final DOMStoreThreePhaseCommitCohort cohort1 = writeTx.ready();
 
-            // 4. Commit the Tx
+            // 4. Commit the Tx on another thread that first waits for the second read Tx.
 
-            Boolean canCommit = cohort.canCommit().get(5, TimeUnit.SECONDS);
-            assertEquals("canCommit", true, canCommit);
-            cohort.preCommit().get(5, TimeUnit.SECONDS);
-            cohort.commit().get(5, TimeUnit.SECONDS);
+            final CountDownLatch continueCommit1 = new CountDownLatch(1);
+            final CountDownLatch commit1Done = new CountDownLatch(1);
+            final AtomicReference<Exception> commit1Error = new AtomicReference<>();
+            new Thread() {
+                @Override
+                public void run() {
+                    try {
+                        continueCommit1.await();
+                        doCommit(cohort1);
+                    } catch (Exception e) {
+                        commit1Error.set(e);
+                    } finally {
+                        commit1Done.countDown();
+                    }
+                }
+            }.start();
 
-            // 5. Verify the data in the store
+            // 5. Create a new read Tx from the chain to read and verify the data from the first
+            // Tx is visible after being readied.
 
             DOMStoreReadTransaction readTx = txChain.newReadOnlyTransaction();
-
             Optional<NormalizedNode<?, ?>> optional = readTx.read(TestModel.TEST_PATH).get(5, TimeUnit.SECONDS);
             assertEquals("isPresent", true, optional.isPresent());
-            assertEquals("Data node", containerNode, optional.get());
+            assertEquals("Data node", testNode, optional.get());
+
+            // 6. Create a new RW Tx from the chain, write more data, and ready it
+
+            DOMStoreReadWriteTransaction rwTx = txChain.newReadWriteTransaction();
+            MapNode outerNode = ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build();
+            rwTx.write(TestModel.OUTER_LIST_PATH, outerNode);
+
+            DOMStoreThreePhaseCommitCohort cohort2 = rwTx.ready();
+
+            // 7. Create a new read Tx from the chain to read the data from the last RW Tx to
+            // verify it is visible.
+
+            readTx = txChain.newReadOnlyTransaction();
+            optional = readTx.read(TestModel.OUTER_LIST_PATH).get(5, TimeUnit.SECONDS);
+            assertEquals("isPresent", true, optional.isPresent());
+            assertEquals("Data node", outerNode, optional.get());
+
+            // 8. Wait for the 2 commits to complete and close the chain.
+
+            continueCommit1.countDown();
+            Uninterruptibles.awaitUninterruptibly(commit1Done, 5, TimeUnit.SECONDS);
+
+            if(commit1Error.get() != null) {
+                throw commit1Error.get();
+            }
+
+            doCommit(cohort2);
 
             txChain.close();
 
+            // 9. Create a new read Tx from the data store and verify committed data.
+
+            readTx = dataStore.newReadOnlyTransaction();
+            optional = readTx.read(TestModel.OUTER_LIST_PATH).get(5, TimeUnit.SECONDS);
+            assertEquals("isPresent", true, optional.isPresent());
+            assertEquals("Data node", outerNode, optional.get());
+
             cleanup(dataStore);
         }};
     }
@@ -600,7 +636,10 @@ public class DistributedDataStoreIntegrationTest extends AbstractActorTest {
             DistributedDataStore dataStore =
                     setupDistributedDataStore("testChangeListenerRegistration", "test-1");
 
-            MockDataChangeListener listener = new MockDataChangeListener(3);
+            testWriteTransaction(dataStore, TestModel.TEST_PATH,
+                    ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+
+            MockDataChangeListener listener = new MockDataChangeListener(1);
 
             ListenerRegistration<MockDataChangeListener>
                     listenerReg = dataStore.registerChangeListener(TestModel.TEST_PATH, listener,
@@ -608,8 +647,13 @@ public class DistributedDataStoreIntegrationTest extends AbstractActorTest {
 
             assertNotNull("registerChangeListener returned null", listenerReg);
 
-            testWriteTransaction(dataStore, TestModel.TEST_PATH,
-                    ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+            // Wait for the initial notification
+
+            listener.waitForChangeEvents(TestModel.TEST_PATH);
+
+            listener.reset(2);
+
+            // Write 2 updates.
 
             testWriteTransaction(dataStore, TestModel.OUTER_LIST_PATH,
                     ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build());
@@ -619,7 +663,9 @@ public class DistributedDataStoreIntegrationTest extends AbstractActorTest {
             testWriteTransaction(dataStore, listPath,
                     ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1));
 
-            listener.waitForChangeEvents(TestModel.TEST_PATH, TestModel.OUTER_LIST_PATH, listPath );
+            // Wait for the 2 updates.
+
+            listener.waitForChangeEvents(TestModel.OUTER_LIST_PATH, listPath);
 
             listenerReg.close();
 
@@ -694,10 +740,7 @@ public class DistributedDataStoreIntegrationTest extends AbstractActorTest {
 
             // 4. Commit the Tx
 
-            Boolean canCommit = cohort.canCommit().get(5, TimeUnit.SECONDS);
-            assertEquals("canCommit", true, canCommit);
-            cohort.preCommit().get(5, TimeUnit.SECONDS);
-            cohort.commit().get(5, TimeUnit.SECONDS);
+            doCommit(cohort);
 
             // 5. Verify the data in the store
 
@@ -708,6 +751,13 @@ public class DistributedDataStoreIntegrationTest extends AbstractActorTest {
             assertEquals("Data node", nodeToWrite, optional.get());
         }
 
+        void doCommit(final DOMStoreThreePhaseCommitCohort cohort) throws Exception {
+            Boolean canCommit = cohort.canCommit().get(5, TimeUnit.SECONDS);
+            assertEquals("canCommit", true, canCommit);
+            cohort.preCommit().get(5, TimeUnit.SECONDS);
+            cohort.commit().get(5, TimeUnit.SECONDS);
+        }
+
         void cleanup(DistributedDataStore dataStore) {
             dataStore.getActorContext().getShardManager().tell(PoisonPill.getInstance(), null);
         }
index c6bb0d6b37061b8055d4065a990cc2acad21c935..e5b5643297b88d49ab74bffdf90637a61988a72e 100644 (file)
@@ -1,5 +1,16 @@
 package org.opendaylight.controller.cluster.datastore;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.opendaylight.controller.cluster.datastore.messages.CreateTransaction.CURRENT_VERSION;
 import akka.actor.ActorRef;
 import akka.actor.PoisonPill;
 import akka.actor.Props;
@@ -16,6 +27,16 @@ import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
 import com.google.common.util.concurrent.Uninterruptibles;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -80,29 +101,6 @@ import scala.concurrent.Await;
 import scala.concurrent.Future;
 import scala.concurrent.duration.FiniteDuration;
 
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.inOrder;
-import static org.mockito.Mockito.mock;
-import static org.opendaylight.controller.cluster.datastore.messages.CreateTransaction.CURRENT_VERSION;
-
 
 public class ShardTest extends AbstractActorTest {
 
@@ -308,6 +306,7 @@ public class ShardTest extends AbstractActorTest {
         }};
     }
 
+    @SuppressWarnings("serial")
     @Test
     public void testPeerAddressResolved() throws Exception {
         new ShardTestKit(getSystem()) {{
@@ -509,7 +508,7 @@ public class ShardTest extends AbstractActorTest {
         shard.tell(PoisonPill.getInstance(), ActorRef.noSender());
     }
 
-    private CompositeModificationPayload newPayload(Modification... mods) {
+    private CompositeModificationPayload newPayload(final Modification... mods) {
         MutableCompositeModification compMod = new MutableCompositeModification();
         for(Modification mod: mods) {
             compMod.addModification(mod);
@@ -518,15 +517,15 @@ public class ShardTest extends AbstractActorTest {
         return new CompositeModificationPayload(compMod.toSerializable());
     }
 
-    private DOMStoreThreePhaseCommitCohort setupMockWriteTransaction(String cohortName,
-            InMemoryDOMDataStore dataStore, YangInstanceIdentifier path, NormalizedNode data,
-            MutableCompositeModification modification) {
+    private DOMStoreThreePhaseCommitCohort setupMockWriteTransaction(final String cohortName,
+            final InMemoryDOMDataStore dataStore, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data,
+            final MutableCompositeModification modification) {
         return setupMockWriteTransaction(cohortName, dataStore, path, data, modification, null);
     }
 
-    private DOMStoreThreePhaseCommitCohort setupMockWriteTransaction(String cohortName,
-            InMemoryDOMDataStore dataStore, YangInstanceIdentifier path, NormalizedNode data,
-            MutableCompositeModification modification,
+    private DOMStoreThreePhaseCommitCohort setupMockWriteTransaction(final String cohortName,
+            final InMemoryDOMDataStore dataStore, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data,
+            final MutableCompositeModification modification,
             final Function<DOMStoreThreePhaseCommitCohort,ListenableFuture<Void>> preCommit) {
 
         DOMStoreWriteTransaction tx = dataStore.newWriteOnlyTransaction();
@@ -536,14 +535,14 @@ public class ShardTest extends AbstractActorTest {
 
         doAnswer(new Answer<ListenableFuture<Boolean>>() {
             @Override
-            public ListenableFuture<Boolean> answer(InvocationOnMock invocation) {
+            public ListenableFuture<Boolean> answer(final InvocationOnMock invocation) {
                 return realCohort.canCommit();
             }
         }).when(cohort).canCommit();
 
         doAnswer(new Answer<ListenableFuture<Void>>() {
             @Override
-            public ListenableFuture<Void> answer(InvocationOnMock invocation) throws Throwable {
+            public ListenableFuture<Void> answer(final InvocationOnMock invocation) throws Throwable {
                 if(preCommit != null) {
                     return preCommit.apply(realCohort);
                 } else {
@@ -554,14 +553,14 @@ public class ShardTest extends AbstractActorTest {
 
         doAnswer(new Answer<ListenableFuture<Void>>() {
             @Override
-            public ListenableFuture<Void> answer(InvocationOnMock invocation) throws Throwable {
+            public ListenableFuture<Void> answer(final InvocationOnMock invocation) throws Throwable {
                 return realCohort.commit();
             }
         }).when(cohort).commit();
 
         doAnswer(new Answer<ListenableFuture<Void>>() {
             @Override
-            public ListenableFuture<Void> answer(InvocationOnMock invocation) throws Throwable {
+            public ListenableFuture<Void> answer(final InvocationOnMock invocation) throws Throwable {
                 return realCohort.abort();
             }
         }).when(cohort).abort();
@@ -658,12 +657,12 @@ public class ShardTest extends AbstractActorTest {
             class OnFutureComplete extends OnComplete<Object> {
                 private final Class<?> expRespType;
 
-                OnFutureComplete(Class<?> expRespType) {
+                OnFutureComplete(final Class<?> expRespType) {
                     this.expRespType = expRespType;
                 }
 
                 @Override
-                public void onComplete(Throwable error, Object resp) {
+                public void onComplete(final Throwable error, final Object resp) {
                     if(error != null) {
                         caughtEx.set(new AssertionError(getClass().getSimpleName() + " failure", error));
                     } else {
@@ -676,7 +675,7 @@ public class ShardTest extends AbstractActorTest {
                     }
                 }
 
-                void onSuccess(Object resp) throws Exception {
+                void onSuccess(final Object resp) throws Exception {
                 }
             }
 
@@ -686,7 +685,7 @@ public class ShardTest extends AbstractActorTest {
                 }
 
                 @Override
-                public void onComplete(Throwable error, Object resp) {
+                public void onComplete(final Throwable error, final Object resp) {
                     super.onComplete(error, resp);
                     commitLatch.countDown();
                 }
@@ -695,13 +694,13 @@ public class ShardTest extends AbstractActorTest {
             class OnCanCommitFutureComplete extends OnFutureComplete {
                 private final String transactionID;
 
-                OnCanCommitFutureComplete(String transactionID) {
+                OnCanCommitFutureComplete(final String transactionID) {
                     super(CanCommitTransactionReply.SERIALIZABLE_CLASS);
                     this.transactionID = transactionID;
                 }
 
                 @Override
-                void onSuccess(Object resp) throws Exception {
+                void onSuccess(final Object resp) throws Exception {
                     CanCommitTransactionReply canCommitReply =
                             CanCommitTransactionReply.fromSerializable(resp);
                     assertEquals("Can commit", true, canCommitReply.getCanCommit());
@@ -828,7 +827,7 @@ public class ShardTest extends AbstractActorTest {
             final CountDownLatch latch = new CountDownLatch(1);
             canCommitFuture.onComplete(new OnComplete<Object>() {
                 @Override
-                public void onComplete(Throwable t, Object resp) {
+                public void onComplete(final Throwable t, final Object resp) {
                     latch.countDown();
                 }
             }, getSystem().dispatcher());
@@ -948,7 +947,7 @@ public class ShardTest extends AbstractActorTest {
                             new AbortTransaction(transactionID).toSerializable(), timeout);
                     abortFuture.onComplete(new OnComplete<Object>() {
                         @Override
-                        public void onComplete(Throwable e, Object resp) {
+                        public void onComplete(final Throwable e, final Object resp) {
                             abortComplete.countDown();
                         }
                     }, getSystem().dispatcher());
@@ -1195,7 +1194,7 @@ public class ShardTest extends AbstractActorTest {
             final CountDownLatch latch = new CountDownLatch(1);
             canCommitFuture.onComplete(new OnComplete<Object>() {
                 @Override
-                public void onComplete(Throwable t, Object resp) {
+                public void onComplete(final Throwable t, final Object resp) {
                     latch.countDown();
                 }
             }, getSystem().dispatcher());
@@ -1220,7 +1219,8 @@ public class ShardTest extends AbstractActorTest {
         testCreateSnapshot(false, "testCreateSnapshotWithNonPersistentData");
     }
 
-    public void testCreateSnapshot(boolean persistent, final String shardActorName) throws IOException, InterruptedException {
+    @SuppressWarnings("serial")
+    public void testCreateSnapshot(final boolean persistent, final String shardActorName) throws IOException, InterruptedException {
         final DatastoreContext dataStoreContext = DatastoreContext.newBuilder().
                 shardJournalRecoveryLogBatchSize(3).shardSnapshotBatchCount(5000).persistent(persistent).build();
 
@@ -1232,7 +1232,7 @@ public class ShardTest extends AbstractActorTest {
                     return new Shard(shardID, Collections.<ShardIdentifier,String>emptyMap(),
                             dataStoreContext, SCHEMA_CONTEXT) {
                         @Override
-                        protected void commitSnapshot(long sequenceNumber) {
+                        protected void commitSnapshot(final long sequenceNumber) {
                             super.commitSnapshot(sequenceNumber);
                             latch.get().countDown();
                         }
@@ -1275,7 +1275,7 @@ public class ShardTest extends AbstractActorTest {
         commitTransaction(putTransaction);
 
 
-        NormalizedNode expected = readStore(store);
+        NormalizedNode<?, ?> expected = readStore(store);
 
         DOMStoreWriteTransaction writeTransaction = store.newWriteOnlyTransaction();
 
@@ -1284,7 +1284,7 @@ public class ShardTest extends AbstractActorTest {
 
         commitTransaction(writeTransaction);
 
-        NormalizedNode actual = readStore(store);
+        NormalizedNode<?, ?> actual = readStore(store);
 
         assertEquals(expected, actual);
 
@@ -1325,7 +1325,7 @@ public class ShardTest extends AbstractActorTest {
     }
 
 
-    private NormalizedNode readStore(InMemoryDOMDataStore store) throws ReadFailedException {
+    private NormalizedNode<?, ?> readStore(final InMemoryDOMDataStore store) throws ReadFailedException {
         DOMStoreReadTransaction transaction = store.newReadOnlyTransaction();
         CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read =
             transaction.read(YangInstanceIdentifier.builder().build());
@@ -1339,7 +1339,7 @@ public class ShardTest extends AbstractActorTest {
         return normalizedNode;
     }
 
-    private void commitTransaction(DOMStoreWriteTransaction transaction) {
+    private void commitTransaction(final DOMStoreWriteTransaction transaction) {
         DOMStoreThreePhaseCommitCohort commitCohort = transaction.ready();
         ListenableFuture<Void> future =
             commitCohort.preCommit();
@@ -1355,13 +1355,13 @@ public class ShardTest extends AbstractActorTest {
         return new AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>() {
             @Override
             public void onDataChanged(
-                AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change) {
+                final AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change) {
 
             }
         };
     }
 
-    static NormalizedNode<?,?> readStore(TestActorRef<Shard> shard, YangInstanceIdentifier id)
+    static NormalizedNode<?,?> readStore(final TestActorRef<Shard> shard, final YangInstanceIdentifier id)
             throws ExecutionException, InterruptedException {
         DOMStoreReadTransaction transaction = shard.underlyingActor().getDataStore().newReadOnlyTransaction();
 
@@ -1376,7 +1376,7 @@ public class ShardTest extends AbstractActorTest {
         return node;
     }
 
-    private void writeToStore(TestActorRef<Shard> shard, YangInstanceIdentifier id, NormalizedNode<?,?> node)
+    private void writeToStore(final TestActorRef<Shard> shard, final YangInstanceIdentifier id, final NormalizedNode<?,?> node)
         throws ExecutionException, InterruptedException {
         DOMStoreWriteTransaction transaction = shard.underlyingActor().getDataStore().newWriteOnlyTransaction();
 
@@ -1387,10 +1387,11 @@ public class ShardTest extends AbstractActorTest {
         commitCohort.commit().get();
     }
 
+    @SuppressWarnings("serial")
     private static final class DelegatingShardCreator implements Creator<Shard> {
         private final Creator<Shard> delegate;
 
-        DelegatingShardCreator(Creator<Shard> delegate) {
+        DelegatingShardCreator(final Creator<Shard> delegate) {
             this.delegate = delegate;
         }
 
index 45b00f5f31b72c3d628be7957a09804c7e6b26be..5781c19b252717c24c1795d83131ea6c158bcf32 100644 (file)
 
 package org.opendaylight.controller.cluster.datastore;
 
+import akka.actor.ActorRef;
+import akka.actor.Props;
+import akka.pattern.AskTimeoutException;
+import akka.testkit.TestActorRef;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
 import java.util.Collections;
 import java.util.concurrent.TimeUnit;
 import org.junit.BeforeClass;
@@ -29,12 +35,6 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import scala.concurrent.Await;
 import scala.concurrent.Future;
 import scala.concurrent.duration.Duration;
-import akka.actor.ActorRef;
-import akka.actor.Props;
-import akka.pattern.AskTimeoutException;
-import akka.testkit.TestActorRef;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
 
 /**
  * Covers negative test cases
@@ -66,7 +66,7 @@ public class ShardTransactionFailureTest extends AbstractActorTest {
     }
 
     private ActorRef createShard(){
-        return getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, datastoreContext,
+        return getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.<ShardIdentifier, String>emptyMap(), datastoreContext,
                 TestModel.createTestContext()));
     }
 
index c869be82d24bcbbd0cedca4b5a6e2a9001c46fad..4ccc9430ace37605e002fbcf8800279b85fa4fcd 100644 (file)
@@ -4,6 +4,13 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+import akka.actor.ActorRef;
+import akka.actor.Props;
+import akka.actor.Terminated;
+import akka.testkit.JavaTestKit;
+import akka.testkit.TestActorRef;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
 import java.util.Collections;
 import java.util.concurrent.TimeUnit;
 import org.junit.BeforeClass;
@@ -39,13 +46,6 @@ 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 scala.concurrent.duration.Duration;
-import akka.actor.ActorRef;
-import akka.actor.Props;
-import akka.actor.Terminated;
-import akka.testkit.JavaTestKit;
-import akka.testkit.TestActorRef;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
 
 public class ShardTransactionTest extends AbstractActorTest {
     private static ListeningExecutorService storeExecutor =
@@ -71,7 +71,7 @@ public class ShardTransactionTest extends AbstractActorTest {
 
     private ActorRef createShard(){
         return getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
-            Collections.EMPTY_MAP, datastoreContext, TestModel.createTestContext()));
+            Collections.<ShardIdentifier, String>emptyMap(), datastoreContext, TestModel.createTestContext()));
     }
 
     @Test
index 3394cdc959757e167cb71988cf3d8e208fde041d..b895b75fcde1ee7421b324492319c59d0bfc6d93 100644 (file)
@@ -1,5 +1,6 @@
 package org.opendaylight.controller.cluster.datastore.shardstrategy;
 
+import static org.junit.Assert.assertEquals;
 import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
@@ -10,8 +11,6 @@ import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
-import static junit.framework.Assert.assertEquals;
-
 public class ModuleShardStrategyTest {
     @Rule
     public ExpectedException expectedEx = ExpectedException.none();
index ab74ba811a6348c4969a2408644b0e48502af076..10e832780d26ca7e8603e14ef82fbeac0e57b16e 100644 (file)
@@ -1,5 +1,7 @@
 package org.opendaylight.controller.cluster.datastore.shardstrategy;
 
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
@@ -9,9 +11,6 @@ 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
index 06c5767bd030c1b5872969025902566a7cc3e27c..4ef7d65857b3c86a76d405eeca52c888f6f9fc55 100644 (file)
@@ -9,43 +9,42 @@
 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;
 import java.util.Set;
+import org.opendaylight.controller.cluster.datastore.Configuration;
+import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategy;
 
 public class MockConfiguration implements Configuration{
-    @Override public List<String> getMemberShardNames(String memberName) {
+    @Override public List<String> getMemberShardNames(final String memberName) {
         return Arrays.asList("default");
     }
 
     @Override public Optional<String> getModuleNameFromNameSpace(
-        String nameSpace) {
+        final String nameSpace) {
         return Optional.absent();
     }
 
     @Override
     public Map<String, ShardStrategy> getModuleNameToShardStrategyMap() {
-        return Collections.EMPTY_MAP;
+        return Collections.emptyMap();
     }
 
     @Override public List<String> getShardNamesFromModuleName(
-        String moduleName) {
-        return Collections.EMPTY_LIST;
+        final String moduleName) {
+        return Collections.emptyList();
     }
 
-    @Override public List<String> getMembersFromShardName(String shardName) {
+    @Override public List<String> getMembersFromShardName(final 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;
+        return Collections.emptyList();
     }
 
     @Override public Set<String> getAllShardNames() {
index f2f49d1bf3e21f048b393d5f5c14a6e9595e05d6..5bbdcae93c2241cd8b9e7a87613735b69841973d 100644 (file)
@@ -9,6 +9,10 @@ package org.opendaylight.controller.cluster.datastore.utils;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import com.google.common.collect.Lists;
+import com.google.common.util.concurrent.Uninterruptibles;
+import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
@@ -16,8 +20,6 @@ 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.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import com.google.common.collect.Lists;
-import com.google.common.util.concurrent.Uninterruptibles;
 
 /**
  * A mock DataChangeListener implementation.
@@ -27,14 +29,21 @@ import com.google.common.util.concurrent.Uninterruptibles;
 public class MockDataChangeListener implements
                          AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> {
 
-    private final List<AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>>>
-                                                               changeList = Lists.newArrayList();
-    private final CountDownLatch changeLatch;
-    private final int expChangeEventCount;
+    private final List<AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>>> changeList =
+            Collections.synchronizedList(Lists.<AsyncDataChangeEvent<YangInstanceIdentifier,
+                                                NormalizedNode<?, ?>>>newArrayList());
+
+    private volatile CountDownLatch changeLatch;
+    private int expChangeEventCount;
 
     public MockDataChangeListener(int expChangeEventCount) {
+        reset(expChangeEventCount);
+    }
+
+    public void reset(int expChangeEventCount) {
         changeLatch = new CountDownLatch(expChangeEventCount);
         this.expChangeEventCount = expChangeEventCount;
+        changeList.clear();
     }
 
     @Override
@@ -44,8 +53,13 @@ public class MockDataChangeListener implements
     }
 
     public void waitForChangeEvents(YangInstanceIdentifier... expPaths) {
-        assertEquals("Change notifications complete", true,
-                Uninterruptibles.awaitUninterruptibly(changeLatch, 5, TimeUnit.SECONDS));
+        boolean done = Uninterruptibles.awaitUninterruptibly(changeLatch, 5, TimeUnit.SECONDS);
+        if(!done) {
+            fail(String.format("Missing change notifications. Expected: %d. Actual: %d",
+                    expChangeEventCount, (expChangeEventCount - changeLatch.getCount())));
+        }
+
+        assertEquals("Change notifications complete", true, done);
 
         for(int i = 0; i < expPaths.length; i++) {
             assertTrue(String.format("Change %d does not contain %s", (i+1), expPaths[i]),
index 3bad4689506525bf683254534d44036ff8a61d7e..a2c44b063091fd45829624cde07230e325222336 100644 (file)
@@ -11,13 +11,12 @@ package org.opendaylight.controller.cluster.datastore.utils;
 import akka.actor.ActorRef;
 import akka.actor.ActorSystem;
 import akka.actor.Props;
-import junit.framework.Assert;
-
 import java.util.List;
+import org.junit.Assert;
 
 public class TestUtils {
 
-    public static void assertFirstSentMessage(ActorSystem actorSystem, ActorRef actorRef, Class clazz){
+    public static void assertFirstSentMessage(final ActorSystem actorSystem, final ActorRef actorRef, final Class<?> clazz){
         ActorContext testContext = new ActorContext(actorSystem, actorSystem.actorOf(
             Props.create(DoNothingActor.class)), new MockClusterWrapper(), new MockConfiguration());
         Object messages = testContext
@@ -27,7 +26,7 @@ public class TestUtils {
 
         Assert.assertTrue(messages instanceof List);
 
-        List<Object> listMessages = (List<Object>) messages;
+        List<?> listMessages = (List<?>) messages;
 
         Assert.assertEquals(1, listMessages.size());
 
index 6860872b75fddaf0c952af3943a8713f977531f5..93b552a6dabad014d698146981d83ce27a644117 100644 (file)
@@ -31,7 +31,7 @@ public class CarsModel {
     public static final QName CAR_PRICE_QNAME = QName.create(CAR_QNAME, "price");
 
 
-    public static NormalizedNode create(){
+    public static NormalizedNode<?, ?> create(){
 
         // Create a list builder
         CollectionNodeBuilder<MapEntryNode, MapNode> cars =
@@ -63,7 +63,7 @@ public class CarsModel {
 
     }
 
-    public static NormalizedNode emptyContainer(){
+    public static NormalizedNode<?, ?> emptyContainer(){
         return ImmutableContainerNodeBuilder.create()
             .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(BASE_QNAME))
             .build();
index e637920e7855c9859ee9cab249f31b20766e9ef2..a7cb14f0b3ac1964c16008f67e8c443e182b0bc4 100644 (file)
@@ -30,7 +30,7 @@ public class PeopleModel {
 
 
 
-    public static NormalizedNode create(){
+    public static NormalizedNode<?, ?> create(){
 
         // Create a list builder
         CollectionNodeBuilder<MapEntryNode, MapNode> cars =
@@ -62,7 +62,7 @@ public class PeopleModel {
 
     }
 
-    public static NormalizedNode emptyContainer(){
+    public static NormalizedNode<?, ?> emptyContainer(){
         return ImmutableContainerNodeBuilder.create()
             .withNodeIdentifier(
                 new YangInstanceIdentifier.NodeIdentifier(BASE_QNAME))
index 2300f9d130bcea6049326b3e42b2ac3084df6051..b814bc392e365f8d9f0503eae6c3f81128d35f22 100644 (file)
@@ -8,7 +8,7 @@
 
 package org.opendaylight.controller.md.cluster.datastore.model;
 
-import junit.framework.Assert;
+import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec;
 import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
index e8919d0ee1a4c277541d842b6763e9ca18a9f747..d2d864cd4f932146a9af95fb5e7c7afb75f18a2e 100644 (file)
@@ -15,7 +15,6 @@
     <version>1.2.0-SNAPSHOT</version>\r
   </parent>\r
   <artifactId>sal-dom-xsql-config</artifactId>\r
-  <groupId>org.opendaylight.controller</groupId>\r
   <description>Configuration files for md-sal</description>\r
   <packaging>jar</packaging>\r
   <properties>\r
index 893a45aaa2df41eadc71a1a62215493fda3d4a04..2e5f8078a377e980d88e7c52e337f4fb265108e2 100644 (file)
@@ -43,6 +43,7 @@ import org.opendaylight.yangtools.yang.data.impl.SimpleNodeTOImpl;
 import org.opendaylight.yangtools.yang.data.impl.util.CompositeNodeBuilder;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -344,9 +345,14 @@ public class NetconfMessageTransformUtil {
         Preconditions.checkNotNull(rpcName);
         Preconditions.checkNotNull(schemaContext);
 
-        final NodeContainerProxy rpcBodyProxy = new NodeContainerProxy(rpcName, schemaContext.getChildNodes());
-        return new NodeContainerProxy(NETCONF_RPC_QNAME, Sets.<DataSchemaNode>newHashSet(rpcBodyProxy));
+        for (final RpcDefinition rpcDefinition : schemaContext.getOperations()) {
+            if(rpcDefinition.getQName().equals(rpcName)) {
+                final NodeContainerProxy rpcBodyProxy = new NodeContainerProxy(rpcName, rpcDefinition.getInput().getChildNodes());
+                return new NodeContainerProxy(NETCONF_RPC_QNAME, Sets.<DataSchemaNode>newHashSet(rpcBodyProxy));
+            }
+        }
 
+        throw new IllegalArgumentException("Rpc " + rpcName + " not found in schema context " + schemaContext + ". Unable to invoke Rpc");
     }
 
     public static CompositeNodeTOImpl wrap(final QName name, final Node<?> node) {
index e744e11bc9212fc58666654b454a804e1e7f06ce..4bf2e8463e616188125600bbaff2d4c0da8c6db7 100644 (file)
@@ -253,37 +253,4 @@ public class NetconfToRpcRequestTest {
         assertEquals(streamName.getLocalName(), "stream-name");
     }
 
-    @Test
-    public void testNoSchemaContextToRpcRequest() throws Exception {
-        final String exampleNamespace = "http://example.net/me/my-own/1.0";
-        final String exampleRevision = "2014-07-22";
-        final QName myOwnMethodRpcQName = QName.create(exampleNamespace, exampleRevision, "my-own-method");
-
-        final CompositeNodeBuilder<ImmutableCompositeNode> rootBuilder = ImmutableCompositeNode.builder();
-        rootBuilder.setQName(myOwnMethodRpcQName);
-
-        final CompositeNodeBuilder<ImmutableCompositeNode> inputBuilder = ImmutableCompositeNode.builder();
-        inputBuilder.setQName(QName.create(exampleNamespace, exampleRevision, "input"));
-        inputBuilder.addLeaf(QName.create(exampleNamespace, exampleRevision, "my-first-parameter"), "14");
-        inputBuilder.addLeaf(QName.create(exampleNamespace, exampleRevision, "another-parameter"), "fred");
-
-        rootBuilder.add(inputBuilder.toInstance());
-        final ImmutableCompositeNode root = rootBuilder.toInstance();
-
-        final NetconfMessage message = messageTransformer.toRpcRequest(myOwnMethodRpcQName, root);
-        assertNotNull(message);
-
-        final Document xmlDoc = message.getDocument();
-        final org.w3c.dom.Node rpcChild = xmlDoc.getFirstChild();
-        assertEquals(rpcChild.getLocalName(), "rpc");
-
-        final org.w3c.dom.Node myOwnMethodNode = rpcChild.getFirstChild();
-        assertEquals(myOwnMethodNode.getLocalName(), "my-own-method");
-
-        final org.w3c.dom.Node firstParamNode = myOwnMethodNode.getFirstChild();
-        assertEquals(firstParamNode.getLocalName(), "my-first-parameter");
-
-        final org.w3c.dom.Node secParamNode = firstParamNode.getNextSibling();
-        assertEquals(secParamNode.getLocalName(), "another-parameter");
-    }
 }
index edba4e11da8661a69660b89051286b4faaa4854e..2b3015243fa175ebc48dc40a839af4b5bbf63fd6 100644 (file)
                             org.opendaylight.controller.netconf.confignetconfconnector.util,
                             org.opendaylight.controller.netconf.confignetconfconnector.osgi,
                             org.opendaylight.controller.netconf.confignetconfconnector.exception,</Private-Package>
-            <Import-Package>com.google.common.base,
-                            com.google.common.collect,
-                            javax.annotation,
-                            javax.management,
-                            javax.management.openmbean,
-                            org.opendaylight.controller.config.api,
-                            org.opendaylight.controller.config.api.jmx,
-                            org.opendaylight.controller.config.yangjmxgenerator,
-                            org.opendaylight.controller.config.yangjmxgenerator.attribute,
-                            org.opendaylight.controller.netconf.api,
-                            org.opendaylight.controller.netconf.mapping.api,
-                            org.opendaylight.controller.netconf.util.mapping,
-                            org.opendaylight.controller.netconf.util.xml,
-                            org.opendaylight.controller.netconf.util.exception,
-                            org.opendaylight.yangtools.yang.common,
-                            org.opendaylight.yangtools.yang.model.api,
-                            org.osgi.framework,
-                            org.osgi.util.tracker,
-                            org.slf4j,
-                            org.w3c.dom,
-                            com.google.common.io,
-                            org.opendaylight.yangtools.yang.model.api.type,
-                            org.opendaylight.yangtools.sal.binding.generator.spi,
-                            org.opendaylight.yangtools.sal.binding.yang.types,
-                            org.opendaylight.controller.config.util
-              </Import-Package>
+            <Import-Package>*</Import-Package>
             <Export-Package></Export-Package>
           </instructions>
         </configuration>
index 7fd8928928feb8814b0eb003c61e2c51152beef5..551da722c06732b60219d80044b3d6ca5319f3fa 100644 (file)
@@ -8,20 +8,23 @@
 
 package org.opendaylight.controller.netconf.confignetconfconnector.operations.runtimerpc;
 
-import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
-import com.google.common.collect.Maps;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.management.ObjectName;
 
 import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
 import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
 import org.opendaylight.controller.netconf.confignetconfconnector.mapping.rpc.ModuleRpcs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.Modules;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.modules.Module;
 
-import javax.management.ObjectName;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Strings;
+import com.google.common.collect.Maps;
 
 /**
  * Represents parsed xpath to runtime bean instance
@@ -46,6 +49,11 @@ public final class RuntimeRpcElementResolved {
         return moduleName;
     }
 
+    @VisibleForTesting
+    Map<String, String> getAdditionalAttributes() {
+        return additionalAttributes;
+    }
+
     public String getInstanceName() {
         return instanceName;
     }
@@ -70,22 +78,45 @@ public final class RuntimeRpcElementResolved {
         return ObjectNameUtil.createRuntimeBeanName(moduleName, instanceName, additionalAttributesJavaNames);
     }
 
+    /**
+     * Pattern for an absolute instance identifier xpath pointing to a runtime bean instance e.g:
+     * <pre>
+     * /modules/module[name=instanceName][type=moduleType]
+     * </pre>
+     * or
+     * <pre>
+     * /a:modules/a:module[a:name=instanceName][a:type=moduleType]
+     * </pre>
+     */
     private static final String xpathPatternBlueprint =
-            "/" + XmlNetconfConstants.MODULES_KEY
-            + "/" + XmlNetconfConstants.MODULE_KEY
-            + "\\["
-
-            + "(?<key1>type|name)"
-            + "='(?<value1>[^']+)'"
-            + "( and |\\]\\[)"
-            + "(?<key2>type|name)"
-            + "='(?<value2>[^']+)'"
-
-            + "\\]"
-            + "(?<additional>.*)";
+            "/" + getRegExForPrefixedName(Modules.QNAME.getLocalName())+ "/" + getRegExForPrefixedName(Module.QNAME.getLocalName())
+
+                    + "\\["
+                    + "(?<key1>" + getRegExForPrefixedName(XmlNetconfConstants.TYPE_KEY) + "|" + getRegExForPrefixedName(XmlNetconfConstants.NAME_KEY) + ")"
+                    + "=('|\")?(?<value1>[^'\"\\]]+)('|\")?"
+                    + "( and |\\]\\[)"
+                    + "(?<key2>" + getRegExForPrefixedName(XmlNetconfConstants.TYPE_KEY) + "|" + getRegExForPrefixedName(XmlNetconfConstants.NAME_KEY) + ")"
+                    + "=('|\")?(?<value2>[^'\"\\]]+)('|\")?"
+                    + "\\]"
+
+                    + "(?<additional>.*)";
+
+    /**
+     * Return reg ex that matches either the name with or without a prefix
+     */
+    private static String getRegExForPrefixedName(final String name) {
+        return "([^:]+:)?" + name;
+    }
 
     private static final Pattern xpathPattern = Pattern.compile(xpathPatternBlueprint);
-    private static final String additionalPatternBlueprint = "(?<additionalKey>.+)\\[(.+)='(?<additionalValue>.+)'\\]";
+
+    /**
+     * Pattern for additional path elements inside xpath for instance identifier pointing to an inner runtime bean e.g:
+     * <pre>
+     * /modules/module[name=instanceName and type=moduleType]/inner[key=b]
+     * </pre>
+     */
+    private static final String additionalPatternBlueprint = getRegExForPrefixedName("(?<additionalKey>.+)") + "\\[(?<prefixedKey>" + getRegExForPrefixedName("(.+)") + ")=('|\")?(?<additionalValue>[^'\"\\]]+)('|\")?\\]";
     private static final Pattern additionalPattern = Pattern.compile(additionalPatternBlueprint);
 
     public static RuntimeRpcElementResolved fromXpath(String xpath, String elementName, String namespace) {
@@ -115,20 +146,19 @@ public final class RuntimeRpcElementResolved {
         PatternGroupResolver(String key1, String value1,  String value2, String additional) {
             this.key1 = Preconditions.checkNotNull(key1);
             this.value1 = Preconditions.checkNotNull(value1);
-
             this.value2 = Preconditions.checkNotNull(value2);
-
             this.additional = Preconditions.checkNotNull(additional);
         }
 
         String getModuleName() {
-            return key1.equals(XmlNetconfConstants.TYPE_KEY) ? value1 : value2;
+            return key1.contains(XmlNetconfConstants.TYPE_KEY) ? value1 : value2;
         }
 
         String getInstanceName() {
-            return key1.equals(XmlNetconfConstants.NAME_KEY) ? value1 : value2;
+            return key1.contains(XmlNetconfConstants.NAME_KEY) ? value1 : value2;
         }
 
+
         Map<String, String> getAdditionalKeys(String elementName, String moduleName) {
             HashMap<String, String> additionalAttributes = Maps.newHashMap();
 
@@ -141,7 +171,7 @@ public final class RuntimeRpcElementResolved {
                 Preconditions
                         .checkState(
                                 matcher.matches(),
-                                "Attribute %s not in required form on rpc element %s, required format for additional attributes is  %s",
+                                "Attribute %s not in required form on rpc element %s, required format for additional attributes is: %s",
                                 additionalKeyValue, elementName, additionalPatternBlueprint);
                 String name = matcher.group("additionalKey");
                 runtimeBeanYangName = name;
diff --git a/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/runtimerpc/RuntimeRpcElementResolvedTest.java b/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/runtimerpc/RuntimeRpcElementResolvedTest.java
new file mode 100644 (file)
index 0000000..816e118
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * 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.netconf.confignetconfconnector.operations.runtimerpc;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+@RunWith(Parameterized.class)
+public class RuntimeRpcElementResolvedTest {
+
+    private static final String MODULE_TYPE = "moduleType";
+    private static final String INSTANCE_NAME = "instanceName";
+    @Parameterized.Parameter(0)
+    public String xpath;
+    @Parameterized.Parameter(1)
+    public Map<String, String> additional;
+
+    @Parameterized.Parameters(name = "{index}: parsed({0}) contains moduleName:{1} and instanceName:{2}")
+    public static Collection<Object[]> data() {
+        return Arrays.asList(new Object[][] {
+                // With namespaces
+                { "/a:modules/a:module[a:name='instanceName'][a:type='moduleType']/b:listener-state[b:peer-id='127.0.0.1']",
+                        new HashMap<String, String>() {{
+                            put("listener-state", "127.0.0.1");
+                        }}},
+                { "/a:modules/a:module[a:name='instanceName'][a:type='moduleType']",
+                        null},
+
+                // Without namespaces
+                { "/modules/module[name=instanceName][type=moduleType]", null},
+                { "/modules/module[type=moduleType][name='instanceName']", null},
+                { "/modules/module[name=\'instanceName\'][type=\"moduleType\"]", null},
+                { "/modules/module[type=moduleType and name=instanceName]", null},
+                { "/modules/module[name=\"instanceName\" and type=moduleType]", null},
+                { "/modules/module[type=\"moduleType\" and name=instanceName]", null},
+                { "/modules/module[name=\'instanceName\' and type=\"moduleType\"]", null},
+
+                // With inner beans
+                { "/modules/module[name=instanceName and type=\"moduleType\"]/inner[key=b]", Collections.singletonMap("inner", "b")},
+                { "/modules/module[name=instanceName and type=moduleType]/inner[key=b]", Collections.singletonMap("inner", "b")},
+                { "/modules/module[name=instanceName and type=moduleType]/inner[key=\'b\']", Collections.singletonMap("inner", "b")},
+                { "/modules/module[name=instanceName and type=moduleType]/inner[key=\"b\"]", Collections.singletonMap("inner", "b")},
+
+                { "/modules/module[name=instanceName and type=\"moduleType\"]/inner[key2=a]/inner2[key=b]",
+                        new HashMap<String, String>() {{
+                            put("inner", "a");
+                            put("inner2", "b");
+                        }}
+                },
+        });
+    }
+
+    @Test
+    public void testFromXpath() throws Exception {
+        final RuntimeRpcElementResolved resolved = RuntimeRpcElementResolved.fromXpath(xpath, "element", "namespace");
+        assertEquals(MODULE_TYPE, resolved.getModuleName());
+        assertEquals(INSTANCE_NAME, resolved.getInstanceName());
+        if (additional != null) {
+            assertEquals(additional, resolved.getAdditionalAttributes());
+        }
+    }
+}
index 5fceac06dd51c4b0798159571764b4826191b906..5a744fda14f2f1bc5cac2e2a7aec57bde9817d04 100644 (file)
@@ -8,13 +8,12 @@
 
 package org.opendaylight.controller.netconf.monitoring;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertTrue;
-import static junit.framework.TestCase.fail;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.doThrow;
-
 import java.util.Collections;
 import org.hamcrest.CoreMatchers;
 import org.junit.Before;
index 40493569d68adaf9ec54f9249cbe7fac8ab11bdc..b5b9f3c060f5bdf6c98abf832c256ab894ad95c2 100644 (file)
@@ -8,6 +8,12 @@
 
 package org.opendaylight.controller.netconf.monitoring.osgi;
 
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
 import java.util.Arrays;
 import org.junit.Before;
 import org.junit.Test;
@@ -18,10 +24,6 @@ import org.osgi.framework.Filter;
 import org.osgi.framework.ServiceListener;
 import org.osgi.framework.ServiceReference;
 
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.*;
-
 public class NetconfMonitoringActivatorTest {
 
     @Mock
@@ -34,7 +36,7 @@ public class NetconfMonitoringActivatorTest {
         MockitoAnnotations.initMocks(this);
         doReturn(filter).when(context).createFilter(anyString());
         doNothing().when(context).addServiceListener(any(ServiceListener.class), anyString());
-        ServiceReference[] refs = new ServiceReference[2];
+        ServiceReference<?>[] refs = new ServiceReference[2];
         doReturn(Arrays.asList(refs)).when(context).getServiceReferences(any(Class.class), anyString());
         doReturn(refs).when(context).getServiceReferences(anyString(), anyString());
     }
index 2a53a6ce45925e0223f4c5df508e4b4bf1a1245b..b992b0e44f363deaba01eeca50d9194d40fefc81 100644 (file)
@@ -8,6 +8,12 @@
 
 package org.opendaylight.controller.netconf.monitoring.osgi;
 
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
 import java.util.Hashtable;
 import org.junit.Before;
 import org.junit.Test;
@@ -20,18 +26,14 @@ import org.osgi.framework.Filter;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
 
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyCollection;
-import static org.mockito.Mockito.*;
-
 public class NetconfMonitoringServiceTrackerTest {
 
     @Mock
-    private ServiceReference reference;
+    private ServiceReference<NetconfMonitoringService> reference;
     @Mock
     private BundleContext context;
     @Mock
-    private ServiceRegistration serviceRegistration;
+    private ServiceRegistration<?> serviceRegistration;
     @Mock
     private Filter filter;
     @Mock
index 93475129d2b61687968ee7c05ce8bef6ff58fa62..556bece43f372b28b5c0aea12d096152638dd2a3 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.controller.netconf.nettyutil.handler;
 import static org.junit.Assert.assertEquals;
 import static org.mockito.Matchers.anyObject;
 import static org.mockito.Mockito.doAnswer;
-
 import com.google.common.collect.Lists;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
@@ -50,7 +49,7 @@ public class ChunkedFramingMechanismEncoderTest {
     @Test
     public void testEncode() throws Exception {
         final List<ByteBuf> chunks = Lists.newArrayList();
-        doAnswer(new Answer() {
+        doAnswer(new Answer<Object>() {
             @Override
             public Object answer(final InvocationOnMock invocation) throws Throwable {
                 chunks.add((ByteBuf) invocation.getArguments()[0]);
index 4a8db176fed7e21c60ed9db6c9f3365343bc3cb8..8bc0fb8e8242efcc640ea4a1b1ffc4a9f88818f6 100644 (file)
@@ -8,15 +8,14 @@
 
 package org.opendaylight.controller.netconf.nettyutil.handler;
 
-import static org.junit.Assert.*;
-
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
 import com.google.common.collect.Lists;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import org.custommonkey.xmlunit.XMLUnit;
index 212eabb290656cb676c6cf6f925ee132f2b43242..b4c9e1e95083dd94b21d57318ef989dca355bdd2 100644 (file)
@@ -22,10 +22,17 @@ import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.verifyZeroInteractions;
-
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelPromise;
 import java.io.IOException;
 import java.net.SocketAddress;
-
 import org.apache.sshd.ClientChannel;
 import org.apache.sshd.ClientSession;
 import org.apache.sshd.SshClient;
@@ -52,17 +59,6 @@ import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
 
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.SettableFuture;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelPromise;
-
 public class AsyncSshHandlerTest {
 
     @Mock
@@ -126,7 +122,7 @@ public class AsyncSshHandlerTest {
     private <T extends SshFuture<T>> ListenableFuture<SshFutureListener<T>> stubAddListener(final T future) {
         final SettableFuture<SshFutureListener<T>> listenerSettableFuture = SettableFuture.create();
 
-        doAnswer(new Answer() {
+        doAnswer(new Answer<Object>() {
             @Override
             public Object answer(final InvocationOnMock invocation) throws Throwable {
                 listenerSettableFuture.set((SshFutureListener<T>) invocation.getArguments()[0]);
index b6f5854aa331140cf21c1de433c5f4a9263e6201..b7ebc51b70712a5ebabc322018c5707636113d13 100644 (file)
@@ -8,8 +8,8 @@
 
 package org.opendaylight.controller.netconf.util.mapping;
 
+import com.google.common.base.Optional;
 import java.util.Map;
-
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
 import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
 import org.opendaylight.controller.netconf.mapping.api.HandlingPriority;
@@ -17,20 +17,15 @@ import org.opendaylight.controller.netconf.mapping.api.NetconfOperation;
 import org.opendaylight.controller.netconf.mapping.api.NetconfOperationChainedExecution;
 import org.opendaylight.controller.netconf.util.xml.XmlElement;
 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
-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 com.google.common.base.Optional;
-
 public abstract class AbstractNetconfOperation implements NetconfOperation {
     private final String netconfSessionIdForReporting;
-    private static final Logger logger = LoggerFactory.getLogger(AbstractNetconfOperation.class);
 
-    protected AbstractNetconfOperation(String netconfSessionIdForReporting) {
+    protected AbstractNetconfOperation(final String netconfSessionIdForReporting) {
         this.netconfSessionIdForReporting = netconfSessionIdForReporting;
     }
 
@@ -39,7 +34,7 @@ public abstract class AbstractNetconfOperation implements NetconfOperation {
     }
 
     @Override
-    public HandlingPriority canHandle(Document message) throws NetconfDocumentedException {
+    public HandlingPriority canHandle(final Document message) throws NetconfDocumentedException {
         OperationNameAndNamespace operationNameAndNamespace = null;
         operationNameAndNamespace = new OperationNameAndNamespace(message);
         return canHandle(operationNameAndNamespace.getOperationName(), operationNameAndNamespace.getNamespace());
@@ -49,7 +44,7 @@ public abstract class AbstractNetconfOperation implements NetconfOperation {
         private final String operationName, namespace;
         private final XmlElement operationElement;
 
-        public OperationNameAndNamespace(Document message) throws NetconfDocumentedException {
+        public OperationNameAndNamespace(final Document message) throws NetconfDocumentedException {
             XmlElement requestElement = null;
             requestElement = getRequestElementWithCheck(message);
             operationElement = requestElement.getOnlyChildElement();
@@ -70,12 +65,12 @@ public abstract class AbstractNetconfOperation implements NetconfOperation {
         }
     }
 
-    protected static XmlElement getRequestElementWithCheck(Document message) throws NetconfDocumentedException {
+    protected static XmlElement getRequestElementWithCheck(final Document message) throws NetconfDocumentedException {
         return XmlElement.fromDomElementWithExpected(message.getDocumentElement(), XmlNetconfConstants.RPC_KEY,
                 XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
     }
 
-    protected HandlingPriority canHandle(String operationName, String operationNamespace) {
+    protected HandlingPriority canHandle(final String operationName, final String operationNamespace) {
         return operationName.equals(getOperationName()) && operationNamespace.equals(getOperationNamespace())
                 ? getHandlingPriority()
                 : HandlingPriority.CANNOT_HANDLE;
@@ -92,8 +87,8 @@ public abstract class AbstractNetconfOperation implements NetconfOperation {
     protected abstract String getOperationName();
 
     @Override
-    public Document handle(Document requestMessage,
-            NetconfOperationChainedExecution subsequentOperation) throws NetconfDocumentedException {
+    public Document handle(final Document requestMessage,
+            final NetconfOperationChainedExecution subsequentOperation) throws NetconfDocumentedException {
 
         XmlElement requestElement = getRequestElementWithCheck(requestMessage);
 
index b8605d823066330e2a4c0b0650a2024f12c063f6..47d0d4c7ccc56294d85e753f603e6c8bd951f2c0 100644 (file)
@@ -7,14 +7,13 @@
  */
 package org.opendaylight.controller.netconf.util;
 
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
 import org.junit.Test;
 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
 import org.w3c.dom.Document;
 
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-import static org.junit.matchers.JUnitMatchers.containsString;
-
 public class NetconfUtilTest {
 
     @Test
index c39ac8eb10ec043cbdbe6b2a9183b75def68436b..5a9d07f6b1689455eae43a6dff82f6c5984803b7 100644 (file)
@@ -9,32 +9,32 @@
 package org.opendaylight.controller.netconf.util.messages;
 
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 import com.google.common.base.Optional;
 import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.internal.util.collections.Sets;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
 
 public class NetconfHelloMessageTest {
 
     Set<String> caps;
 
     @Before
-    public void setUp() throws Exception {
+    public void setUp() {
         caps = Sets.newSet("cap1");
     }
 
     @Test
-    public void testConstructor() throws Exception {
+    public void testConstructor() throws NetconfDocumentedException {
         NetconfHelloMessageAdditionalHeader additionalHeader = new NetconfHelloMessageAdditionalHeader("name","host","1","transp","id");
         NetconfHelloMessage message = NetconfHelloMessage.createClientHello(caps, Optional.of(additionalHeader));
-        assertTrue(message.isHelloMessage(message));
+        assertTrue(NetconfHelloMessage.isHelloMessage(message));
         assertEquals(Optional.of(additionalHeader), message.getAdditionalHeader());
 
         NetconfHelloMessage serverMessage = NetconfHelloMessage.createServerHello(caps, 100L);
-        assertTrue(serverMessage.isHelloMessage(serverMessage));
+        assertTrue(NetconfHelloMessage.isHelloMessage(serverMessage));
     }
 }
index cca89aed593b1857db18940ad93a57efd4ad53fe..d5ff3380d28b7493b1b7e18962fc1bdbc4505e16 100644 (file)
@@ -8,13 +8,12 @@
 
 package org.opendaylight.controller.netconf.util.messages;
 
-import com.google.common.base.Charsets;
-import java.util.Arrays;
-import org.junit.Test;
-
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
+import com.google.common.base.Charsets;
+import org.junit.Test;
 
+@Deprecated
 public class NetconfMessageHeaderTest {
     @Test
     public void testGet() throws Exception {
index 741d0d24520022cc5ee4cbb997f9140c6d1a1124..ebee41145ab1d77c2296bf21ded57c83b172d98e 100644 (file)
@@ -8,20 +8,18 @@
 
 package org.opendaylight.controller.netconf.util.osgi;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import com.google.common.base.Optional;
 import io.netty.channel.local.LocalAddress;
 import java.net.InetSocketAddress;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.netconf.util.NetconfUtil;
 import org.osgi.framework.BundleContext;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-
 public class NetconfConfigUtilTest {
 
     private BundleContext bundleContext;