From 600e07c2adb213b614cad127070f1e7ff074b42b Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 10 Feb 2016 13:15:10 +0100 Subject: [PATCH] Make private methods static These methods do not touch object state, make them static. Change-Id: I9d29719cee7737ea8c36fa2e8fe39d4e245dd68c Signed-off-by: Robert Varga --- .../datastore/DatastoreSnapshotRestore.java | 2 +- .../datastore/DistributedDataStore.java | 4 ++-- .../cluster/datastore/ShardManager.java | 2 +- .../datastore/ThreePhaseCommitCohortProxy.java | 2 +- .../DatastoreSnapshotRestoreTest.java | 2 +- .../cluster/datastore/ShardManagerTest.java | 6 +++--- .../ThreePhaseCommitCohortProxyTest.java | 2 +- .../admin/ClusterAdminRpcServiceTest.java | 18 +++++++++--------- .../compat/PreBoronTransactionProxyTest.java | 6 +++--- ...tributedEntityOwnershipIntegrationTest.java | 2 +- .../CanCommitTransactionReplyTest.java | 2 +- 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreSnapshotRestore.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreSnapshotRestore.java index 7ef05e273f..5908a86977 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreSnapshotRestore.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreSnapshotRestore.java @@ -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(); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java index 5252618fa1..4b2013cd28 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java @@ -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++) { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java index 4b511fa376..9823521e47 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java @@ -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) { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxy.java index 9f94731b59..8d85bdcb66 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxy.java @@ -253,7 +253,7 @@ public class ThreePhaseCommitCohortProxy extends AbstractThreePhaseCommitCohort< CommitTransactionReply.class, true, operationCallback); } - private boolean successfulFuture(ListenableFuture future) { + private static boolean successfulFuture(ListenableFuture future) { if(!future.isDone()) { return false; } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreSnapshotRestoreTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreSnapshotRestoreTest.java index aa67e53faa..7adc93c8f3 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreSnapshotRestoreTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreSnapshotRestoreTest.java @@ -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(), diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java index c369e32792..668f56bbc7 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java @@ -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 expectMsgClassOrFailure(Class msgClass, JavaTestKit kit, String msg) { + private static T expectMsgClassOrFailure(Class 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) { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxyTest.java index e5db5cbbaf..676667d8c2 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxyTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxyTest.java @@ -298,7 +298,7 @@ public class ThreePhaseCommitCohortProxyTest extends AbstractActorTest { }); } - private CohortInfo newCohortInfoWithFailedFuture(Exception failure) { + private static CohortInfo newCohortInfoWithFailedFuture(Exception failure) { return new CohortInfo(Futures.failed(failure), new Supplier() { @Override public Short get() { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/admin/ClusterAdminRpcServiceTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/admin/ClusterAdminRpcServiceTest.java index 9ac5c7af61..9bfc7e6b1a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/admin/ClusterAdminRpcServiceTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/admin/ClusterAdminRpcServiceTest.java @@ -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 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> 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 verifySuccessfulRpcResult(RpcResult rpcResult) { + private static T verifySuccessfulRpcResult(RpcResult 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 rpcResult) { + private static void verifyFailedRpcResult(RpcResult 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 shardResults, ShardResult... expShardResults) { + private static void verifyShardResults(List shardResults, ShardResult... expShardResults) { Map 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(); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/compat/PreBoronTransactionProxyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/compat/PreBoronTransactionProxyTest.java index 2ca4bcab4a..46f55f1760 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/compat/PreBoronTransactionProxyTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/compat/PreBoronTransactionProxyTest.java @@ -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 matcher = new ArgumentMatcher() { @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 matcher = new ArgumentMatcher() { @Override public boolean matches(Object argument) { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipIntegrationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipIntegrationTest.java index c8f4bb7b86..f69567c6a4 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipIntegrationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipIntegrationTest.java @@ -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(); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/CanCommitTransactionReplyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/CanCommitTransactionReplyTest.java index 15c3bc7a37..a85f5fbbd8 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/CanCommitTransactionReplyTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/CanCommitTransactionReplyTest.java @@ -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()); -- 2.36.6