From: Robert Varga Date: Fri, 23 Oct 2015 10:34:58 +0000 (+0200) Subject: Make private methods static X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=ecccb6d5b43dd73aef0d2d19349d19ee9b4728f7 Make private methods static These methods do not reference object state and therefore can be made static. Change-Id: I416e415b90647b4f700b7893fe4f64f479271fab Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/FollowerLogInformationImplTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/FollowerLogInformationImplTest.java index e2204a9d08..75496f9752 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/FollowerLogInformationImplTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/FollowerLogInformationImplTest.java @@ -55,7 +55,7 @@ public class FollowerLogInformationImplTest { // we cannot rely comfortably that the sleep will indeed sleep for the desired time // hence getting the actual elapsed time and do a match. // if the sleep has spilled over, then return the test gracefully - private long sleepWithElaspsedTimeReturned(long millis) { + private static long sleepWithElaspsedTimeReturned(long millis) { Stopwatch stopwatch = Stopwatch.createStarted(); Uninterruptibles.sleepUninterruptibly(millis, TimeUnit.MILLISECONDS); stopwatch.stop(); diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorServerConfigurationSupportTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorServerConfigurationSupportTest.java index 1b717f147d..bc73a41d21 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorServerConfigurationSupportTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorServerConfigurationSupportTest.java @@ -96,7 +96,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { } } - private DefaultConfigParamsImpl newFollowerConfigParams() { + private static DefaultConfigParamsImpl newFollowerConfigParams() { DefaultConfigParamsImpl configParams = new DefaultConfigParamsImpl(); configParams.setHeartBeatInterval(new FiniteDuration(100, TimeUnit.MILLISECONDS)); configParams.setElectionTimeoutFactor(100000); @@ -401,14 +401,14 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { expectFirstMatching(leaderActor, AddServer.class); } - private void verifyServerConfigurationPayloadEntry(ReplicatedLog log, String... cNew) { + private static void verifyServerConfigurationPayloadEntry(ReplicatedLog log, String... cNew) { ReplicatedLogEntry logEntry = log.get(log.lastIndex()); assertEquals("Last log entry payload class", ServerConfigurationPayload.class, logEntry.getData().getClass()); ServerConfigurationPayload payload = (ServerConfigurationPayload)logEntry.getData(); assertEquals("getNewServerConfig", Sets.newHashSet(cNew), Sets.newHashSet(payload.getNewServerConfig())); } - private RaftActorContext newFollowerContext(String id, TestActorRef actor) { + private static RaftActorContext newFollowerContext(String id, TestActorRef actor) { DefaultConfigParamsImpl configParams = new DefaultConfigParamsImpl(); configParams.setHeartBeatInterval(new FiniteDuration(100, TimeUnit.MILLISECONDS)); configParams.setElectionTimeoutFactor(100000); diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/ReplicatedLogImplEntryTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/ReplicatedLogImplEntryTest.java index 1fe22bcd4e..9ede21447c 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/ReplicatedLogImplEntryTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/ReplicatedLogImplEntryTest.java @@ -46,7 +46,7 @@ public class ReplicatedLogImplEntryTest { * Use this method to generate a file with a serialized ReplicatedLogImplEntry instance to be * used in tests that verify backwards compatible de-serialization. */ - private void generateSerializedFile() throws IOException { + private static void generateSerializedFile() throws IOException { String expPayloadData = "This is a test"; int expIndex = 1; int expTerm = 2; diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/SnapshotTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/SnapshotTest.java index 9302b6dcf4..a0b9cd5ee1 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/SnapshotTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/SnapshotTest.java @@ -46,7 +46,7 @@ public class SnapshotTest { } } - private Snapshot newLithiumSnapshot() { + private static Snapshot newLithiumSnapshot() { byte[] state = {1, 2, 3, 4, 5}; List entries = new ArrayList<>(); entries.add(new ReplicatedLogImplEntry(6, 2, new MockPayload("payload"))); @@ -62,7 +62,7 @@ public class SnapshotTest { * Use this method to generate a file with a serialized Snapshot instance to be * used in tests that verify backwards compatible de-serialization. */ - private void generateSerializedFile(Snapshot snapshot, String fileName) throws IOException { + private static void generateSerializedFile(Snapshot snapshot, String fileName) throws IOException { FileOutputStream fos = new FileOutputStream("src/test/resources/" + fileName); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(snapshot); diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/FollowerTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/FollowerTest.java index 51818d15b6..1b15ecb135 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/FollowerTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/FollowerTest.java @@ -87,7 +87,7 @@ public class FollowerTest extends AbstractRaftActorBehaviorTest { return context; } - private int getElectionTimeoutCount(RaftActorBehavior follower){ + private static int getElectionTimeoutCount(RaftActorBehavior follower){ if(follower instanceof TestFollower){ return ((TestFollower) follower).getElectionTimeoutCount(); } @@ -1019,7 +1019,7 @@ public class FollowerTest extends AbstractRaftActorBehaviorTest { } - private ReplicatedLogEntry newReplicatedLogEntry(long term, long index, String data) { + private static ReplicatedLogEntry newReplicatedLogEntry(long term, long index, String data) { return new MockRaftActorContext.MockReplicatedLogEntry(term, index, new MockRaftActorContext.MockPayload(data)); } diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/SnapshotTrackerTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/SnapshotTrackerTest.java index 4492dc2e7b..80348263c8 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/SnapshotTrackerTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/SnapshotTrackerTest.java @@ -162,7 +162,7 @@ public class SnapshotTrackerTest { return bs.substring(start, start + size); } - private ByteString toByteString(Map state) { + private static ByteString toByteString(Map state) { ByteArrayOutputStream b = null; ObjectOutputStream o = null; try { diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/messages/AppendEntriesTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/messages/AppendEntriesTest.java index 286cd3c9c4..aceed9ea51 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/messages/AppendEntriesTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/messages/AppendEntriesTest.java @@ -67,7 +67,7 @@ public class AppendEntriesTest { verifyAppendEntries(entries, entries2); } - private void verifyAppendEntries(AppendEntries expected, AppendEntries actual) { + private static void verifyAppendEntries(AppendEntries expected, AppendEntries actual) { assertEquals("getLeaderId", expected.getLeaderId(), actual.getLeaderId()); assertEquals("getTerm", expected.getTerm(), actual.getTerm()); assertEquals("getLeaderCommit", expected.getLeaderCommit(), actual.getLeaderCommit()); @@ -83,7 +83,7 @@ public class AppendEntriesTest { } } - private void verifyReplicatedLogEntry(ReplicatedLogEntry expected, ReplicatedLogEntry actual) { + private static void verifyReplicatedLogEntry(ReplicatedLogEntry expected, ReplicatedLogEntry actual) { assertEquals("getIndex", expected.getIndex(), actual.getIndex()); assertEquals("getTerm", expected.getTerm(), actual.getTerm()); assertEquals("getData", expected.getData().toString(), actual.getData().toString()); diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/MeteredBoundedMailbox.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/MeteredBoundedMailbox.java index 2a6aac4d79..7f3e1354cf 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/MeteredBoundedMailbox.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/MeteredBoundedMailbox.java @@ -75,7 +75,7 @@ public class MeteredBoundedMailbox implements MailboxType, ProducesMessageQueue< } } - private Gauge getQueueSizeGuage(final MeteredMessageQueue monitoredQueue ){ + private static Gauge getQueueSizeGuage(final MeteredMessageQueue monitoredQueue ){ return new Gauge() { @Override public Integer getValue() { diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodePrinter.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodePrinter.java index 9367118bf4..23f314e292 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodePrinter.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodePrinter.java @@ -14,7 +14,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; public class NormalizedNodePrinter implements NormalizedNodeVisitor { - private String spaces(int n){ + private static String spaces(int n){ StringBuilder builder = new StringBuilder(); for(int i=0;i childNames = ImmutableSet.of(QNameFactory.create("(urn:opendaylight:flow:table:statistics?revision=2013-12-15)flow-table-statistics")); return new YangInstanceIdentifier.AugmentationIdentifier(childNames); } - private YangInstanceIdentifier.NodeWithValue nodeWithValue(){ + private static YangInstanceIdentifier.NodeWithValue nodeWithValue(){ return new YangInstanceIdentifier.NodeWithValue(TestModel.TEST_QNAME, Integer.valueOf(100)); } - private YangInstanceIdentifier.NodeIdentifierWithPredicates nodeIdentifierWithPredicates(){ + private static YangInstanceIdentifier.NodeIdentifierWithPredicates nodeIdentifierWithPredicates(){ Map keys = new HashMap<>(); keys.put(TestModel.ID_QNAME, Integer.valueOf(100)); diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeStreamReaderWriterTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeStreamReaderWriterTest.java index 3c7ade0714..f468264181 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeStreamReaderWriterTest.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeStreamReaderWriterTest.java @@ -64,7 +64,7 @@ public class NormalizedNodeStreamReaderWriterTest { writer.close(); } - private NormalizedNode createTestContainer() { + private static NormalizedNode createTestContainer() { byte[] bytes1 = {1,2,3}; LeafSetEntryNode entry1 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier( new YangInstanceIdentifier.NodeWithValue(TestModel.BINARY_LEAF_LIST_QNAME, bytes1)). diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePrunerTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePrunerTest.java index cb82adc58a..26c73480ce 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePrunerTest.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePrunerTest.java @@ -148,7 +148,7 @@ public class NormalizedNodePrunerTest { } - private int countNodes(NormalizedNode normalizedNode, final String namespaceFilter){ + private static int countNodes(NormalizedNode normalizedNode, final String namespaceFilter){ if(normalizedNode == null){ return 0; } @@ -380,7 +380,7 @@ public class NormalizedNodePrunerTest { verify(normalizedNodeContainerBuilder).addChild(any(NormalizedNode.class)); } - private NormalizedNode createTestContainer() { + private static NormalizedNode createTestContainer() { byte[] bytes1 = {1,2,3}; LeafSetEntryNode entry1 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier( new YangInstanceIdentifier.NodeWithValue(TestModel.BINARY_LEAF_LIST_QNAME, bytes1)). diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtilsTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtilsTest.java index af96b324e0..8557dda4bb 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtilsTest.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtilsTest.java @@ -60,7 +60,7 @@ public class InstanceIdentifierUtilsTest { } - private void withValue(Object value) { + private static void withValue(Object value) { YangInstanceIdentifier.PathArgument p1 = new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME); YangInstanceIdentifier.PathArgument p2 = @@ -91,7 +91,7 @@ public class InstanceIdentifierUtilsTest { } - private void withPredicates(Object value) { + private static void withPredicates(Object value) { YangInstanceIdentifier.PathArgument p1 = new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME); YangInstanceIdentifier.PathArgument p2 = new YangInstanceIdentifier.NodeIdentifierWithPredicates( diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionContextFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionContextFactory.java index 5f9cc4a0d2..df32f8fcaa 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionContextFactory.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionContextFactory.java @@ -80,7 +80,7 @@ abstract class AbstractTransactionContextFactory moduleConfigMap, + private static void readModulesConfig(final Config modulesConfig, Map moduleConfigMap, Configuration configuration) { List modulesConfigObjectList = modulesConfig.getObjectList("modules"); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/CandidateListChangeListener.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/CandidateListChangeListener.java index 1ee6b6c471..833ca30e31 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/CandidateListChangeListener.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/CandidateListChangeListener.java @@ -112,7 +112,7 @@ class CandidateListChangeListener implements DOMDataTreeChangeListener { return Collections.emptyList(); } - private YangInstanceIdentifier extractEntityPath(YangInstanceIdentifier candidatePath) { + private static YangInstanceIdentifier extractEntityPath(YangInstanceIdentifier candidatePath) { List newPathArgs = new ArrayList<>(); for(PathArgument pathArg: candidatePath.getPathArguments()) { newPathArgs.add(pathArg); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnerChangeListener.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnerChangeListener.java index cc0b8a318d..bea0caa7c6 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnerChangeListener.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnerChangeListener.java @@ -79,7 +79,7 @@ class EntityOwnerChangeListener implements DOMDataTreeChangeListener { } } - private String extractOwner(LeafNode ownerLeaf) { + private static String extractOwner(LeafNode ownerLeaf) { Object value = ownerLeaf.getValue(); return value != null ? value.toString() : null; } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/TransactionRateLimiter.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/TransactionRateLimiter.java index d7cbce74a9..b83b51c874 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/TransactionRateLimiter.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/TransactionRateLimiter.java @@ -83,7 +83,7 @@ public class TransactionRateLimiter { return -1.0D; } - private double calculateNewRateLimit(Timer commitTimer, long commitTimeoutInSeconds) { + private static double calculateNewRateLimit(Timer commitTimer, long commitTimeoutInSeconds) { if(commitTimer == null) { // This can happen in unit tests. return 0; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ConcurrentDOMDataBrokerTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ConcurrentDOMDataBrokerTest.java index 44cd790a44..b1587bbcfb 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ConcurrentDOMDataBrokerTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ConcurrentDOMDataBrokerTest.java @@ -188,7 +188,7 @@ public class ConcurrentDOMDataBrokerTest { assertFailure(future, null, mockCohort1, mockCohort2, mockCohort3); } - private void assertFailure(final CheckedFuture future, + private static void assertFailure(final CheckedFuture future, final Exception expCause, final DOMStoreThreePhaseCommitCohort... mockCohorts) throws Exception { try { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationTest.java index ff80136469..1048ee1075 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationTest.java @@ -68,7 +68,7 @@ public class DataChangeListenerRegistrationTest extends AbstractActorTest { }}; } - private AsyncDataChangeListener> noOpDataChangeListener(){ + private static AsyncDataChangeListener> noOpDataChangeListener(){ return new AsyncDataChangeListener>() { @Override public void onDataChanged(final AsyncDataChangeEvent> change) { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreContextTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreContextTest.java index eee46aeb7d..6d4c5cc0b9 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreContextTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreContextTest.java @@ -113,7 +113,7 @@ public class DatastoreContextTest { Assert.assertNotSame(context, newContext); } - private void verifyCustomSettings(DatastoreContext context) { + private static void verifyCustomSettings(DatastoreContext context) { assertEquals(DEFAULT_SHARD_TRANSACTION_IDLE_TIMEOUT.toMillis() + 1, context.getShardTransactionIdleTimeout().toMillis()); assertEquals(TimeUnit.MILLISECONDS.toSeconds(DEFAULT_OPERATION_TIMEOUT_IN_MS) + 1, diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreRemotingIntegrationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreRemotingIntegrationTest.java index c29cc4eea1..c48105e8be 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreRemotingIntegrationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreRemotingIntegrationTest.java @@ -133,7 +133,7 @@ public class DistributedDataStoreRemotingIntegrationTest { leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorContext(), SHARD_NAMES); } - private void verifyCars(DOMStoreReadTransaction readTx, MapEntryNode... entries) throws Exception { + private static void verifyCars(DOMStoreReadTransaction readTx, MapEntryNode... entries) throws Exception { Optional> optional = readTx.read(CarsModel.CAR_LIST_PATH).get(5, TimeUnit.SECONDS); assertEquals("isPresent", true, optional.isPresent()); @@ -145,14 +145,14 @@ public class DistributedDataStoreRemotingIntegrationTest { assertEquals("Car list node", listBuilder.build(), optional.get()); } - private void verifyNode(DOMStoreReadTransaction readTx, YangInstanceIdentifier path, NormalizedNode expNode) + private static void verifyNode(DOMStoreReadTransaction readTx, YangInstanceIdentifier path, NormalizedNode expNode) throws Exception { Optional> optional = readTx.read(path).get(5, TimeUnit.SECONDS); assertEquals("isPresent", true, optional.isPresent()); assertEquals("Data node", expNode, optional.get()); } - private void verifyExists(DOMStoreReadTransaction readTx, YangInstanceIdentifier path) throws Exception { + private static void verifyExists(DOMStoreReadTransaction readTx, YangInstanceIdentifier path) throws Exception { Boolean exists = readTx.exists(path).get(5, TimeUnit.SECONDS); assertEquals("exists", true, exists); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/IntegrationTestKit.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/IntegrationTestKit.java index 0eedc78bb4..1a7bbb21b3 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/IntegrationTestKit.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/IntegrationTestKit.java @@ -95,7 +95,7 @@ public class IntegrationTestKit extends ShardTestKit { } } - private ActorRef findLocalShard(ActorContext actorContext, String shardName) { + private static ActorRef findLocalShard(ActorContext actorContext, String shardName) { ActorRef shard = null; for(int i = 0; i < 20 * 5 && shard == null; i++) { Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeTest.java index 26787f63d6..4064dd07e9 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeTest.java @@ -121,7 +121,7 @@ public class ShardDataTreeTest { assertEquals(expected, actual); } - private NormalizedNode getCars(ShardDataTree shardDataTree) { + private static NormalizedNode getCars(ShardDataTree shardDataTree) { ReadOnlyShardDataTreeTransaction readOnlyShardDataTreeTransaction = shardDataTree.newReadOnlyTransaction("txn-2", null); DataTreeSnapshot snapshot1 = readOnlyShardDataTreeTransaction.getSnapshot(); @@ -134,7 +134,7 @@ public class ShardDataTreeTest { return optional.get(); } - private DataTreeCandidateTip addCar(ShardDataTree shardDataTree) throws ExecutionException, InterruptedException { + private static DataTreeCandidateTip addCar(ShardDataTree shardDataTree) throws ExecutionException, InterruptedException { return doTransaction(shardDataTree, new DataTreeOperation() { @Override public void execute(DataTreeModification snapshot) { @@ -145,7 +145,7 @@ public class ShardDataTreeTest { }); } - private DataTreeCandidateTip removeCar(ShardDataTree shardDataTree) throws ExecutionException, InterruptedException { + private static DataTreeCandidateTip removeCar(ShardDataTree shardDataTree) throws ExecutionException, InterruptedException { return doTransaction(shardDataTree, new DataTreeOperation() { @Override public void execute(DataTreeModification snapshot) { @@ -158,7 +158,7 @@ public class ShardDataTreeTest { public abstract void execute(DataTreeModification snapshot); } - private DataTreeCandidateTip doTransaction(ShardDataTree shardDataTree, DataTreeOperation operation) + private static DataTreeCandidateTip doTransaction(ShardDataTree shardDataTree, DataTreeOperation operation) throws ExecutionException, InterruptedException { ReadWriteShardDataTreeTransaction transaction = shardDataTree.newReadWriteTransaction("txn-1", null); DataTreeModification snapshot = transaction.getSnapshot(); @@ -173,7 +173,7 @@ public class ShardDataTreeTest { return candidate; } - private DataTreeCandidateTip applyCandidates(ShardDataTree shardDataTree, List candidates) + private static DataTreeCandidateTip applyCandidates(ShardDataTree shardDataTree, List candidates) throws ExecutionException, InterruptedException { ReadWriteShardDataTreeTransaction transaction = shardDataTree.newReadWriteTransaction("txn-1", null); DataTreeModification snapshot = transaction.getSnapshot(); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFailureTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFailureTest.java index 0b205ac47f..8fa72b0f81 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFailureTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFailureTest.java @@ -207,7 +207,7 @@ public class ShardTransactionFailureTest extends AbstractActorTest { Await.result(future, Duration.create(3, TimeUnit.SECONDS)); } - private NormalizedNodeMessages.Node buildNormalizedNode() { + private static NormalizedNodeMessages.Node buildNormalizedNode() { return NormalizedNodeSerializer .serialize(Builders.containerBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)).build()); } 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 7c10148d43..8b5665244a 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 @@ -133,7 +133,7 @@ public class ThreePhaseCommitCohortProxyTest extends AbstractActorTest { any(ActorSelection.class), isA(requestType), any(Timeout.class)); } - private void propagateExecutionExceptionCause(ListenableFuture future) throws Throwable { + private static void propagateExecutionExceptionCause(ListenableFuture future) throws Throwable { try { future.get(5, TimeUnit.SECONDS); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java index ea88dfaf7a..fdb3683226 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java @@ -939,7 +939,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { expected, (end-start)), (end - start) <= expected); } - private Optional createDataTree(){ + private static Optional createDataTree(){ DataTree dataTree = mock(DataTree.class); Optional dataTreeOptional = Optional.of(dataTree); DataTreeSnapshot dataTreeSnapshot = mock(DataTreeSnapshot.class); @@ -951,7 +951,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { return dataTreeOptional; } - private Optional createDataTree(NormalizedNode readResponse){ + private static Optional createDataTree(NormalizedNode readResponse){ DataTree dataTree = mock(DataTree.class); Optional dataTreeOptional = Optional.of(dataTree); DataTreeSnapshot dataTreeSnapshot = mock(DataTreeSnapshot.class); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/compat/PreLithiumShardTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/compat/PreLithiumShardTest.java index f5de8a129c..b86c7d145c 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/compat/PreLithiumShardTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/compat/PreLithiumShardTest.java @@ -75,7 +75,7 @@ import scala.concurrent.duration.FiniteDuration; */ public class PreLithiumShardTest extends AbstractShardTest { - private CompositeModificationPayload newLegacyPayload(final Modification... mods) { + private static CompositeModificationPayload newLegacyPayload(final Modification... mods) { MutableCompositeModification compMod = new MutableCompositeModification(); for(Modification mod: mods) { compMod.addModification(mod); @@ -84,7 +84,7 @@ public class PreLithiumShardTest extends AbstractShardTest { return new CompositeModificationPayload(compMod.toSerializable()); } - private CompositeModificationByteStringPayload newLegacyByteStringPayload(final Modification... mods) { + private static CompositeModificationByteStringPayload newLegacyByteStringPayload(final Modification... mods) { MutableCompositeModification compMod = new MutableCompositeModification(); for(Modification mod: mods) { compMod.addModification(mod); @@ -93,7 +93,7 @@ public class PreLithiumShardTest extends AbstractShardTest { return new CompositeModificationByteStringPayload(compMod.toSerializable()); } - private ModificationPayload newModificationPayload(final Modification... mods) throws IOException { + private static ModificationPayload newModificationPayload(final Modification... mods) throws IOException { MutableCompositeModification compMod = new MutableCompositeModification(); for(Modification mod: mods) { compMod.addModification(mod); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/compat/PreLithiumTransactionProxyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/compat/PreLithiumTransactionProxyTest.java index cb7c78090f..6ca17838d0 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/compat/PreLithiumTransactionProxyTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/compat/PreLithiumTransactionProxyTest.java @@ -59,7 +59,7 @@ import scala.concurrent.Future; */ public class PreLithiumTransactionProxyTest extends AbstractTransactionProxyTest { - private WriteData eqLegacyWriteData(final NormalizedNode nodeToWrite) { + private static WriteData eqLegacyWriteData(final NormalizedNode nodeToWrite) { ArgumentMatcher matcher = new ArgumentMatcher() { @Override public boolean matches(Object argument) { @@ -75,7 +75,7 @@ public class PreLithiumTransactionProxyTest extends AbstractTransactionProxyTest return argThat(matcher); } - private MergeData eqLegacyMergeData(final NormalizedNode nodeToWrite) { + private static MergeData eqLegacyMergeData(final NormalizedNode nodeToWrite) { ArgumentMatcher matcher = new ArgumentMatcher() { @Override public boolean matches(Object argument) { @@ -91,7 +91,7 @@ public class PreLithiumTransactionProxyTest extends AbstractTransactionProxyTest return argThat(matcher); } - private DeleteData eqLegacyDeleteData(final YangInstanceIdentifier expPath) { + private static DeleteData eqLegacyDeleteData(final YangInstanceIdentifier expPath) { ArgumentMatcher matcher = new ArgumentMatcher() { @Override public boolean matches(Object argument) { @@ -103,7 +103,7 @@ public class PreLithiumTransactionProxyTest extends AbstractTransactionProxyTest return argThat(matcher); } - private CanCommitTransaction eqCanCommitTransaction(final String transactionID) { + private static CanCommitTransaction eqCanCommitTransaction(final String transactionID) { ArgumentMatcher matcher = new ArgumentMatcher() { @Override public boolean matches(Object argument) { @@ -115,7 +115,7 @@ public class PreLithiumTransactionProxyTest extends AbstractTransactionProxyTest return argThat(matcher); } - private CommitTransaction eqCommitTransaction(final String transactionID) { + private static CommitTransaction eqCommitTransaction(final String transactionID) { ArgumentMatcher matcher = new ArgumentMatcher() { @Override public boolean matches(Object argument) { @@ -127,7 +127,7 @@ public class PreLithiumTransactionProxyTest extends AbstractTransactionProxyTest return argThat(matcher); } - private Future readySerializedTxReply(String path, short version) { + private static Future readySerializedTxReply(String path, short version) { return Futures.successful(new ReadyTransactionReply(path, version).toSerializable()); } 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 1bb579848d..6025e01b13 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 @@ -259,7 +259,7 @@ public class DistributedEntityOwnershipIntegrationTest { verify(follower1MockListener, timeout(5000)).ownershipChanged(ownershipChange(ENTITY2, false, false, false)); } - private void verifyGetOwnershipState(DistributedEntityOwnershipService service, Entity entity, + private static void verifyGetOwnershipState(DistributedEntityOwnershipService service, Entity entity, boolean isOwner, boolean hasOwner) { Optional state = service.getOwnershipState(entity); assertEquals("getOwnershipState present", true, state.isPresent()); @@ -267,7 +267,7 @@ public class DistributedEntityOwnershipIntegrationTest { assertEquals("hasOwner", hasOwner, state.get().hasOwner()); } - private void verifyCandidates(DistributedDataStore dataStore, Entity entity, String... expCandidates) throws Exception { + private static void verifyCandidates(DistributedDataStore dataStore, Entity entity, String... expCandidates) throws Exception { AssertionError lastError = null; Stopwatch sw = Stopwatch.createStarted(); while(sw.elapsed(TimeUnit.MILLISECONDS) <= 5000) { @@ -291,7 +291,7 @@ public class DistributedEntityOwnershipIntegrationTest { throw lastError; } - private void verifyOwner(final DistributedDataStore dataStore, Entity entity, String expOwner) throws Exception { + private static void verifyOwner(final DistributedDataStore dataStore, Entity entity, String expOwner) { AbstractEntityOwnershipTest.verifyOwner(expOwner, entity.getType(), entity.getId(), new Function>() { @Override diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipServiceTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipServiceTest.java index 5591772afc..ce2ef2dd7a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipServiceTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipServiceTest.java @@ -280,7 +280,7 @@ public class DistributedEntityOwnershipServiceTest extends AbstractEntityOwnersh service.close(); } - private void verifyGetOwnershipState(DistributedEntityOwnershipService service, Entity entity, + private static void verifyGetOwnershipState(DistributedEntityOwnershipService service, Entity entity, boolean isOwner, boolean hasOwner) { Optional state = service.getOwnershipState(entity); assertEquals("getOwnershipState present", true, state.isPresent()); @@ -303,12 +303,12 @@ public class DistributedEntityOwnershipServiceTest extends AbstractEntityOwnersh }); } - private void verifyRegisterCandidateLocal(final TestShardPropsCreator shardPropsCreator, Entity entity) { + private static void verifyRegisterCandidateLocal(final TestShardPropsCreator shardPropsCreator, Entity entity) { RegisterCandidateLocal regCandidate = shardPropsCreator.waitForShardMessage(); assertEquals("getEntity", entity, regCandidate.getEntity()); } - private void verifyEntityOwnershipCandidateRegistration(Entity entity, EntityOwnershipCandidateRegistration reg) { + private static void verifyEntityOwnershipCandidateRegistration(Entity entity, EntityOwnershipCandidateRegistration reg) { assertNotNull("EntityOwnershipCandidateRegistration null", reg); assertEquals("getInstance", entity, reg.getInstance()); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipShardTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipShardTest.java index e78be76e23..77d8119ba2 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipShardTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipShardTest.java @@ -711,7 +711,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest { verify(listener, never()).ownershipChanged(ownershipChange(entity1)); } - private void commitModification(TestActorRef shard, NormalizedNode node, + private static void commitModification(TestActorRef shard, NormalizedNode node, JavaTestKit sender) { BatchedModifications modifications = newBatchedModifications(); modifications.addModification(new MergeModification(ENTITY_OWNERS_PATH, node)); @@ -720,7 +720,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest { sender.expectMsgClass(CommitTransactionReply.SERIALIZABLE_CLASS); } - private BatchedModifications newBatchedModifications() { + private static BatchedModifications newBatchedModifications() { BatchedModifications modifications = new BatchedModifications("tnx", DataStoreVersions.CURRENT_VERSION, ""); modifications.setDoCommitOnReady(true); modifications.setReady(true); @@ -784,8 +784,8 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest { entityId, candidateName, true); } - private void verifyOwner(final TestActorRef shard, String entityType, YangInstanceIdentifier entityId, - String localMemberName) { + private static void verifyOwner(final TestActorRef shard, String entityType, + YangInstanceIdentifier entityId, String localMemberName) { verifyOwner(localMemberName, entityType, entityId, new Function>() { @Override public NormalizedNode apply(YangInstanceIdentifier path) { @@ -811,7 +811,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest { SCHEMA_CONTEXT, memberName); } - private ShardIdentifier newShardId(String memberName) { + private static ShardIdentifier newShardId(String memberName) { return ShardIdentifier.builder().memberName(memberName).shardName("entity-ownership"). type("operational" + NEXT_SHARD_NUM.getAndIncrement()).build(); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java index efe73d38ad..6a5d6ef434 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java @@ -542,10 +542,11 @@ public class ActorContextTest extends AbstractActorTest{ }}; } - private T expectFirstMatching(ActorRef actor, Class clazz) { + private static T expectFirstMatching(ActorRef actor, Class clazz) { int count = 5000 / 50; for(int i = 0; i < count; i++) { try { + @SuppressWarnings("unchecked") T message = (T) MessageCollectorActor.getFirstMatching(actor, clazz); if(message != null) { return message;