Make private methods static 90/34390/3
authorRobert Varga <rovarga@cisco.com>
Wed, 10 Feb 2016 12:15:10 +0000 (13:15 +0100)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 11 Feb 2016 10:02:02 +0000 (10:02 +0000)
These methods do not touch object state, make them static.

Change-Id: I9d29719cee7737ea8c36fa2e8fe39d4e245dd68c
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreSnapshotRestore.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreSnapshotRestoreTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/admin/ClusterAdminRpcServiceTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/compat/PreBoronTransactionProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipIntegrationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/CanCommitTransactionReplyTest.java

index 7ef05e2..5908a86 100644 (file)
@@ -90,7 +90,7 @@ public class DatastoreSnapshotRestore {
         }
     }
 
-    private DatastoreSnapshotList deserialize(InputStream inputStream) throws IOException, ClassNotFoundException {
+    private static DatastoreSnapshotList deserialize(InputStream inputStream) throws IOException, ClassNotFoundException {
         try(ObjectInputStream ois = new ObjectInputStream(inputStream)) {
             return (DatastoreSnapshotList) ois.readObject();
         }
index 5252618..4b2013c 100644 (file)
@@ -232,8 +232,8 @@ public class DistributedDataStore implements DOMStore, SchemaContextListener,
         }
     }
 
-    private ActorRef createShardManager(ActorSystem actorSystem, ShardManager.Builder builder, String shardDispatcher,
-                                        String shardManagerId){
+    private static ActorRef createShardManager(ActorSystem actorSystem, ShardManager.Builder builder,
+            String shardDispatcher, String shardManagerId) {
         Exception lastException = null;
 
         for(int i=0;i<100;i++) {
index 4b511fa..9823521 100644 (file)
@@ -1191,7 +1191,7 @@ public class ShardManager extends AbstractUntypedPersistentActorWithMetering {
         }
     }
 
-    private Exception getServerChangeException(Class<?> serverChange, ServerChangeStatus serverChangeStatus,
+    private static Exception getServerChangeException(Class<?> serverChange, ServerChangeStatus serverChangeStatus,
                                                String leaderPath, ShardIdentifier shardId) {
         Exception failure;
         switch (serverChangeStatus) {
index 9f94731..8d85bdc 100644 (file)
@@ -253,7 +253,7 @@ public class ThreePhaseCommitCohortProxy extends AbstractThreePhaseCommitCohort<
                 CommitTransactionReply.class, true, operationCallback);
     }
 
-    private boolean successfulFuture(ListenableFuture<Void> future) {
+    private static boolean successfulFuture(ListenableFuture<Void> future) {
         if(!future.isDone()) {
             return false;
         }
index aa67e53..7adc93c 100644 (file)
@@ -80,7 +80,7 @@ public class DatastoreSnapshotRestoreTest {
         assertNull("Expected null DatastoreSnapshot", DatastoreSnapshotRestore.instance().getAndRemove("oper"));
     }
 
-    private void verifySnapshot(DatastoreSnapshot expected, DatastoreSnapshot actual) {
+    private static void verifySnapshot(DatastoreSnapshot expected, DatastoreSnapshot actual) {
         assertNotNull("DatastoreSnapshot is null", actual);
         assertEquals("getType", expected.getType(), actual.getType());
         assertTrue("ShardManager snapshots don't match", Objects.deepEquals(expected.getShardManagerSnapshot(),
index c369e32..668f56b 100644 (file)
@@ -242,7 +242,7 @@ public class ShardManagerTest extends AbstractActorTest {
         return shardManager;
     }
 
-    private void waitForShardInitialized(ActorRef shardManager, String shardName, JavaTestKit kit) {
+    private static void waitForShardInitialized(ActorRef shardManager, String shardName, JavaTestKit kit) {
         AssertionError last = null;
         Stopwatch sw = Stopwatch.createStarted();
         while(sw.elapsed(TimeUnit.SECONDS) <= 5) {
@@ -260,7 +260,7 @@ public class ShardManagerTest extends AbstractActorTest {
         throw last;
     }
 
-    private <T> T expectMsgClassOrFailure(Class<T> msgClass, JavaTestKit kit, String msg) {
+    private static <T> T expectMsgClassOrFailure(Class<T> msgClass, JavaTestKit kit, String msg) {
         Object reply = kit.expectMsgAnyClassOf(JavaTestKit.duration("5 sec"), msgClass, Failure.class);
         if(reply instanceof Failure) {
             throw new AssertionError(msg + " failed", ((Failure)reply).cause());
@@ -2156,7 +2156,7 @@ public class ShardManagerTest extends AbstractActorTest {
         boolean canIntercept(Object message);
     }
 
-    private MessageInterceptor newFindPrimaryInterceptor(final ActorRef primaryActor) {
+    private static MessageInterceptor newFindPrimaryInterceptor(final ActorRef primaryActor) {
         return new MessageInterceptor(){
             @Override
             public Object apply(Object message) {
index e5db5cb..676667d 100644 (file)
@@ -298,7 +298,7 @@ public class ThreePhaseCommitCohortProxyTest extends AbstractActorTest {
         });
     }
 
-    private CohortInfo newCohortInfoWithFailedFuture(Exception failure) {
+    private static CohortInfo newCohortInfoWithFailedFuture(Exception failure) {
         return new CohortInfo(Futures.<ActorSelection>failed(failure), new Supplier<Short>() {
             @Override
             public Short get() {
index 9ac5c7a..9bfc7e6 100644 (file)
@@ -133,7 +133,7 @@ public class ClusterAdminRpcServiceTest {
         service.close();
     }
 
-    private void verifyDatastoreSnapshot(String type, DatastoreSnapshot datastoreSnapshot, String... expShardNames) {
+    private static void verifyDatastoreSnapshot(String type, DatastoreSnapshot datastoreSnapshot, String... expShardNames) {
         assertNotNull("Missing DatastoreSnapshot for type " + type, datastoreSnapshot);
         Set<String> shardNames = new HashSet<>();
         for(DatastoreSnapshot.ShardSnapshot s: datastoreSnapshot.getShardSnapshots()) {
@@ -231,7 +231,7 @@ public class ClusterAdminRpcServiceTest {
         service.close();
     }
 
-    private NormalizedNode<?, ?> writeCarsNodeAndVerify(DistributedDataStore writeToStore,
+    private static NormalizedNode<?, ?> writeCarsNodeAndVerify(DistributedDataStore writeToStore,
             DistributedDataStore readFromStore) throws Exception {
         DOMStoreWriteTransaction writeTx = writeToStore.newWriteOnlyTransaction();
         NormalizedNode<?, ?> carsNode = CarsModel.create();
@@ -247,7 +247,7 @@ public class ClusterAdminRpcServiceTest {
         return carsNode;
     }
 
-    private void readCarsNodeAndVerify(DistributedDataStore readFromStore,
+    private static void readCarsNodeAndVerify(DistributedDataStore readFromStore,
             NormalizedNode<?, ?> expCarsNode) throws Exception {
         Optional<NormalizedNode<?, ?>> optional = readFromStore.newReadOnlyTransaction().
                 read(CarsModel.BASE_PATH).get(15, TimeUnit.SECONDS);
@@ -255,7 +255,7 @@ public class ClusterAdminRpcServiceTest {
         assertEquals("Data node", expCarsNode, optional.get());
     }
 
-    private void doAddShardReplica(MemberNode memberNode, String shardName, String... peerMemberNames)
+    private static void doAddShardReplica(MemberNode memberNode, String shardName, String... peerMemberNames)
             throws Exception {
         memberNode.waitForMembersUp(peerMemberNames);
 
@@ -280,7 +280,7 @@ public class ClusterAdminRpcServiceTest {
         service.close();
     }
 
-    private <T> T verifySuccessfulRpcResult(RpcResult<T> rpcResult) {
+    private static <T> T verifySuccessfulRpcResult(RpcResult<T> rpcResult) {
         if(!rpcResult.isSuccessful()) {
             if(rpcResult.getErrors().size() > 0) {
                 RpcError error = Iterables.getFirst(rpcResult.getErrors(), null);
@@ -293,7 +293,7 @@ public class ClusterAdminRpcServiceTest {
         return rpcResult.getResult();
     }
 
-    private void verifyFailedRpcResult(RpcResult<Void> rpcResult) {
+    private static void verifyFailedRpcResult(RpcResult<Void> rpcResult) {
         assertEquals("RpcResult", false, rpcResult.isSuccessful());
         assertEquals("RpcResult errors size", 1, rpcResult.getErrors().size());
         RpcError error = Iterables.getFirst(rpcResult.getErrors(), null);
@@ -530,7 +530,7 @@ public class ClusterAdminRpcServiceTest {
         // TODO implement
     }
 
-    private void verifyShardResults(List<ShardResult> shardResults, ShardResult... expShardResults) {
+    private static void verifyShardResults(List<ShardResult> shardResults, ShardResult... expShardResults) {
         Map<String, ShardResult> expResultsMap = new HashMap<>();
         for(ShardResult r: expShardResults) {
             expResultsMap.put(r.getShardName() + "-" + r.getDataStoreType(), r);
@@ -553,11 +553,11 @@ public class ClusterAdminRpcServiceTest {
         }
     }
 
-    private ShardResult successShardResult(String shardName, DataStoreType type) {
+    private static ShardResult successShardResult(String shardName, DataStoreType type) {
         return new ShardResultBuilder().setDataStoreType(type).setShardName(shardName).setSucceeded(true).build();
     }
 
-    private ShardResult failedShardResult(String shardName, DataStoreType type) {
+    private static ShardResult failedShardResult(String shardName, DataStoreType type) {
         return new ShardResultBuilder().setDataStoreType(type).setShardName(shardName).setSucceeded(false).build();
     }
 }
index 2ca4bca..46f55f1 100644 (file)
@@ -64,7 +64,7 @@ public class PreBoronTransactionProxyTest extends AbstractTransactionProxyTest {
         return argThat(matcher);
     }
 
-    private ShardTransactionMessages.CreateTransactionReply legacyCreateTransactionReply(ActorRef actorRef,
+    private static ShardTransactionMessages.CreateTransactionReply legacyCreateTransactionReply(ActorRef actorRef,
             int transactionVersion){
         return ShardTransactionMessages.CreateTransactionReply.newBuilder()
             .setTransactionActorPath(actorRef.path().toString())
@@ -73,7 +73,7 @@ public class PreBoronTransactionProxyTest extends AbstractTransactionProxyTest {
             .build();
     }
 
-    private ReadData eqLegacySerializedReadData(final YangInstanceIdentifier path) {
+    private static ReadData eqLegacySerializedReadData(final YangInstanceIdentifier path) {
         ArgumentMatcher<ReadData> matcher = new ArgumentMatcher<ReadData>() {
             @Override
             public boolean matches(Object argument) {
@@ -85,7 +85,7 @@ public class PreBoronTransactionProxyTest extends AbstractTransactionProxyTest {
         return argThat(matcher);
     }
 
-    private DataExists eqLegacySerializedDataExists() {
+    private static DataExists eqLegacySerializedDataExists() {
         ArgumentMatcher<DataExists> matcher = new ArgumentMatcher<DataExists>() {
             @Override
             public boolean matches(Object argument) {
index c8f4bb7..f69567c 100644 (file)
@@ -123,7 +123,7 @@ public class DistributedEntityOwnershipIntegrationTest {
         }
     }
 
-    private DistributedEntityOwnershipService newOwnershipService(DistributedDataStore datastore) {
+    private static DistributedEntityOwnershipService newOwnershipService(DistributedDataStore datastore) {
         DistributedEntityOwnershipService service = new DistributedEntityOwnershipService(datastore,
                 EntityOwnerSelectionStrategyConfig.newBuilder().build());
         service.start();
index 15c3bc7..a85f5fb 100644 (file)
@@ -29,7 +29,7 @@ public class CanCommitTransactionReplyTest {
                 CanCommitTransactionReply.class);
     }
 
-    private void testSerialization(CanCommitTransactionReply expected, Class<?> expSerialized) {
+    private static void testSerialization(CanCommitTransactionReply expected, Class<?> expSerialized) {
         Object serialized = expected.toSerializable();
         assertEquals("Serialized type", expSerialized, serialized.getClass());
 

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.