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 7ef05e273fb3ab54099c74e86570c785821e1be8..5908a869776cabf1fc1910b88e4ffb0f34cfe37d 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 5252618fa16b9c06dd910f23a3831f8ffc145072..4b2013cd287bd4a91d4e6aa06bf61a1402328ca2 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 4b511fa376fee65c6533e5d5e3ecf8bc2948ccd7..9823521e4722a7d77da5ea3b446c011fee53a4fa 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 9f94731b59a65370e0aa9bf7784e202aab9e992d..8d85bdcb666a24755a567db6fffa7d18c1fb9feb 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 aa67e53faa02debdc3b427f672b02efbfdc9efbe..7adc93c8f3d3bec2f9d9d3089b4f4fda82ed2975 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 c369e327921fe4479383eefead471a236a23ff89..668f56bbc72f26541dd4e84a34ced611fa174113 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 e5db5cbbaf50950c69063d3f43bb8ef3894e87bd..676667d8c211d6b9b7b0dd44c7cfd1fd52a1b24a 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 9ac5c7af61d635a71cf040094efb3605760e0cc0..9bfc7e6b1a55fc37b6527bd2b03ffdde48e71f62 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 2ca4bcab4a2db3c2f77ed9faa91c21de29189e3a..46f55f1760a3d0f1fe85e33d959475ae1638be47 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 c8f4bb7b86d7aced0bff61c3cb91a89be49c1ee2..f69567c6a45c1dfe1ebf73ed2ab440b901358464 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 15c3bc7a375cd7f4c8cbdce7cd8bda7c0960197f..a85f5fbbd8e900cade30387bbf1dcd76932899fe 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());