Cleanup warnings around methods being potentially static 00/51900/2
authorRobert Varga <rovarga@cisco.com>
Wed, 15 Feb 2017 11:13:36 +0000 (12:13 +0100)
committerTom Pantelis <tpanteli@brocade.com>
Wed, 15 Feb 2017 15:25:00 +0000 (15:25 +0000)
These are private methods and they do not touch state, hence they
can be made static.

Change-Id: I1d9adf70d9121e01b2ac8e03a1198c1ba73716fb
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/actors/ShardSnapshotActor.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipShard.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardSnapshotState.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractShardTest.java

index e7529fb4bfcf3b9f1003fce0c03ae26fd943c3a6..5eeed91ee3bc8a49878c6e7719119aff249394ff 100644 (file)
@@ -71,7 +71,7 @@ public final class ShardSnapshotActor extends AbstractUntypedActorWithMetering {
         }
     }
 
-    private void onSerializeSnapshot(SerializeSnapshot request) {
+    private static void onSerializeSnapshot(final SerializeSnapshot request) {
         Optional<OutputStream> installSnapshotStream = request.getInstallSnapshotStream();
         if (installSnapshotStream.isPresent()) {
             try {
index 47de1195e428507599d82f81f04c1907e49654c1..e57874a3ad58d7c5559a174549e3ded2817d7001 100644 (file)
@@ -88,7 +88,7 @@ class EntityOwnershipShard extends Shard {
     private final EntityOwnershipStatistics entityOwnershipStatistics;
     private boolean removeAllInitialCandidates = true;
 
-    protected EntityOwnershipShard(Builder builder) {
+    protected EntityOwnershipShard(final Builder builder) {
         super(builder);
         this.localMemberName = builder.localMemberName;
         this.commitCoordinator = new EntityOwnershipShardCommitCoordinator(builder.localMemberName, LOG);
@@ -98,12 +98,12 @@ class EntityOwnershipShard extends Shard {
         this.entityOwnershipStatistics.init(getDataStore());
     }
 
-    private static DatastoreContext noPersistenceDatastoreContext(DatastoreContext datastoreContext) {
+    private static DatastoreContext noPersistenceDatastoreContext(final DatastoreContext datastoreContext) {
         return DatastoreContext.newBuilderFrom(datastoreContext).persistent(false).build();
     }
 
     @Override
-    protected void onDatastoreContext(DatastoreContext context) {
+    protected void onDatastoreContext(final DatastoreContext context) {
         super.onDatastoreContext(noPersistenceDatastoreContext(context));
     }
 
@@ -142,13 +142,13 @@ class EntityOwnershipShard extends Shard {
         }
     }
 
-    private void onRemoveAllCandidates(RemoveAllCandidates message) {
+    private void onRemoveAllCandidates(final RemoveAllCandidates message) {
         LOG.debug("{}: onRemoveAllCandidates: {}", persistenceId(), message);
 
         removeCandidateFromEntities(message.getMemberName());
     }
 
-    private void onSelectOwner(SelectOwner selectOwner) {
+    private void onSelectOwner(final SelectOwner selectOwner) {
         LOG.debug("{}: onSelectOwner: {}", persistenceId(), selectOwner);
 
         String currentOwner = getCurrentOwner(selectOwner.getEntityPath());
@@ -166,7 +166,7 @@ class EntityOwnershipShard extends Shard {
         }
     }
 
-    private void onRegisterCandidateLocal(RegisterCandidateLocal registerCandidate) {
+    private void onRegisterCandidateLocal(final RegisterCandidateLocal registerCandidate) {
         LOG.debug("{}: onRegisterCandidateLocal: {}", persistenceId(), registerCandidate);
 
         listenerSupport.setHasCandidateForEntity(registerCandidate.getEntity());
@@ -178,7 +178,7 @@ class EntityOwnershipShard extends Shard {
         getSender().tell(SuccessReply.INSTANCE, getSelf());
     }
 
-    private void onUnregisterCandidateLocal(UnregisterCandidateLocal unregisterCandidate) {
+    private void onUnregisterCandidateLocal(final UnregisterCandidateLocal unregisterCandidate) {
         LOG.debug("{}: onUnregisterCandidateLocal: {}", persistenceId(), unregisterCandidate);
 
         DOMEntity entity = unregisterCandidate.getEntity();
@@ -223,7 +223,7 @@ class EntityOwnershipShard extends Shard {
         });
     }
 
-    private void onUnregisterListenerLocal(UnregisterListenerLocal unregisterListener) {
+    private void onUnregisterListenerLocal(final UnregisterListenerLocal unregisterListener) {
         LOG.debug("{}: onUnregisterListenerLocal: {}", persistenceId(), unregisterListener);
 
         listenerSupport.removeEntityOwnershipListener(unregisterListener.getEntityType(),
@@ -258,7 +258,7 @@ class EntityOwnershipShard extends Shard {
         }
     }
 
-    void possiblyRemoveAllInitialCandidates(ActorSelection leader) {
+    void possiblyRemoveAllInitialCandidates(final ActorSelection leader) {
         // The following handles removing all candidates on startup when re-joining with a remote leader. When a
         // follower is detected as down, the leader will re-assign new owners to entities that were owned by the
         // down member but doesn't remove the down member as a candidate, as the down node may actually be isolated
@@ -341,7 +341,7 @@ class EntityOwnershipShard extends Shard {
     }
 
     @Override
-    protected void onLeaderChanged(String oldLeader, String newLeader) {
+    protected void onLeaderChanged(final String oldLeader, final String newLeader) {
         boolean isLeader = isLeader();
         LOG.debug("{}: onLeaderChanged: oldLeader: {}, newLeader: {}, isLeader: {}", persistenceId(), oldLeader,
                 newLeader, isLeader);
@@ -406,7 +406,7 @@ class EntityOwnershipShard extends Shard {
         LOG.debug("{}: new downPeerMemberNames: {}", persistenceId(), downPeerMemberNames);
     }
 
-    private void onCandidateRemoved(CandidateRemoved message) {
+    private void onCandidateRemoved(final CandidateRemoved message) {
         LOG.debug("{}: onCandidateRemoved: {}", persistenceId(), message);
 
         if (isLeader()) {
@@ -417,12 +417,12 @@ class EntityOwnershipShard extends Shard {
         }
     }
 
-    private EntityOwnerSelectionStrategy getEntityOwnerElectionStrategy(YangInstanceIdentifier entityPath) {
+    private EntityOwnerSelectionStrategy getEntityOwnerElectionStrategy(final YangInstanceIdentifier entityPath) {
         final String entityType = EntityOwnersModel.entityTypeFromEntityPath(entityPath);
         return strategyConfig.createStrategy(entityType, entityOwnershipStatistics.byEntityType(entityType));
     }
 
-    private void onCandidateAdded(CandidateAdded message) {
+    private void onCandidateAdded(final CandidateAdded message) {
         if (!isLeader()) {
             return;
         }
@@ -456,7 +456,7 @@ class EntityOwnershipShard extends Shard {
         }
     }
 
-    private void onPeerDown(PeerDown peerDown) {
+    private void onPeerDown(final PeerDown peerDown) {
         LOG.info("{}: onPeerDown: {}", persistenceId(), peerDown);
 
         MemberName downMemberName = peerDown.getMemberName();
@@ -472,7 +472,7 @@ class EntityOwnershipShard extends Shard {
         }
     }
 
-    private void selectNewOwnerForEntitiesOwnedBy(Set<String> ownedBy) {
+    private void selectNewOwnerForEntitiesOwnedBy(final Set<String> ownedBy) {
         final BatchedModifications modifications = commitCoordinator.newBatchedModifications();
         searchForEntitiesOwnedBy(ownedBy, (entityTypeNode, entityNode) -> {
             YangInstanceIdentifier entityPath = YangInstanceIdentifier.builder(ENTITY_TYPES_PATH)
@@ -496,7 +496,7 @@ class EntityOwnershipShard extends Shard {
         commitCoordinator.commitModifications(modifications, this);
     }
 
-    private void onPeerUp(PeerUp peerUp) {
+    private void onPeerUp(final PeerUp peerUp) {
         LOG.debug("{}: onPeerUp: {}", persistenceId(), peerUp);
 
         downPeerMemberNames.remove(peerUp.getMemberName());
@@ -518,7 +518,7 @@ class EntityOwnershipShard extends Shard {
         }
     }
 
-    private Collection<String> getCandidateNames(MapEntryNode entity) {
+    private static Collection<String> getCandidateNames(final MapEntryNode entity) {
         Collection<MapEntryNode> candidates = ((MapNode)entity.getChild(CANDIDATE_NODE_ID).get()).getValue();
         Collection<String> candidateNames = new ArrayList<>(candidates.size());
         for (MapEntryNode candidate: candidates) {
@@ -528,7 +528,7 @@ class EntityOwnershipShard extends Shard {
         return candidateNames;
     }
 
-    private void searchForEntitiesOwnedBy(Set<String> ownedBy, EntityWalker walker) {
+    private void searchForEntitiesOwnedBy(final Set<String> ownedBy, final EntityWalker walker) {
         LOG.debug("{}: Searching for entities owned by {}", persistenceId(), ownedBy);
 
         searchForEntities((entityTypeNode, entityNode) -> {
@@ -561,12 +561,12 @@ class EntityOwnershipShard extends Shard {
         commitCoordinator.commitModifications(modifications, this);
     }
 
-    private static boolean hasCandidate(MapEntryNode entity, MemberName candidateName) {
+    private static boolean hasCandidate(final MapEntryNode entity, final MemberName candidateName) {
         return ((MapNode)entity.getChild(CANDIDATE_NODE_ID).get()).getChild(candidateNodeKey(candidateName.getName()))
                 .isPresent();
     }
 
-    private void searchForEntities(EntityWalker walker) {
+    private void searchForEntities(final EntityWalker walker) {
         Optional<NormalizedNode<?, ?>> possibleEntityTypes = getDataStore().readNode(ENTITY_TYPES_PATH);
         if (!possibleEntityTypes.isPresent()) {
             return;
@@ -585,7 +585,7 @@ class EntityOwnershipShard extends Shard {
         }
     }
 
-    private void writeNewOwner(YangInstanceIdentifier entityPath, String newOwner) {
+    private void writeNewOwner(final YangInstanceIdentifier entityPath, final String newOwner) {
         LOG.debug("{}: Writing new owner {} for entity {}", persistenceId(), newOwner, entityPath);
 
         commitCoordinator.commitModification(new WriteModification(entityPath.node(ENTITY_OWNER_QNAME),
@@ -595,8 +595,8 @@ class EntityOwnershipShard extends Shard {
     /**
      * Schedule a new owner selection job. Cancelling any outstanding job if it has not been cancelled.
      */
-    private void scheduleOwnerSelection(YangInstanceIdentifier entityPath, Collection<String> allCandidates,
-                                       EntityOwnerSelectionStrategy strategy) {
+    private void scheduleOwnerSelection(final YangInstanceIdentifier entityPath, final Collection<String> allCandidates,
+                                       final EntityOwnerSelectionStrategy strategy) {
         cancelOwnerSelectionTask(entityPath);
 
         LOG.debug("{}: Scheduling owner selection after {} ms", persistenceId(), strategy.getSelectionDelayInMillis());
@@ -608,15 +608,15 @@ class EntityOwnershipShard extends Shard {
         entityToScheduledOwnershipTask.put(entityPath, lastScheduledTask);
     }
 
-    private void cancelOwnerSelectionTask(YangInstanceIdentifier entityPath) {
+    private void cancelOwnerSelectionTask(final YangInstanceIdentifier entityPath) {
         final Cancellable lastScheduledTask = entityToScheduledOwnershipTask.get(entityPath);
         if (lastScheduledTask != null && !lastScheduledTask.isCancelled()) {
             lastScheduledTask.cancel();
         }
     }
 
-    private String newOwner(String currentOwner, Collection<String> candidates,
-            EntityOwnerSelectionStrategy ownerSelectionStrategy) {
+    private String newOwner(final String currentOwner, final Collection<String> candidates,
+            final EntityOwnerSelectionStrategy ownerSelectionStrategy) {
         Collection<String> viableCandidates = getViableCandidates(candidates);
         if (viableCandidates.isEmpty()) {
             return "";
@@ -624,7 +624,7 @@ class EntityOwnershipShard extends Shard {
         return ownerSelectionStrategy.newOwner(currentOwner, viableCandidates);
     }
 
-    private Collection<String> getViableCandidates(Collection<String> candidates) {
+    private Collection<String> getViableCandidates(final Collection<String> candidates) {
         Collection<String> viableCandidates = new ArrayList<>();
 
         for (String candidate : candidates) {
@@ -635,7 +635,7 @@ class EntityOwnershipShard extends Shard {
         return viableCandidates;
     }
 
-    private String getCurrentOwner(YangInstanceIdentifier entityId) {
+    private String getCurrentOwner(final YangInstanceIdentifier entityId) {
         Optional<NormalizedNode<?, ?>> optionalEntityOwner = getDataStore().readNode(entityId.node(ENTITY_OWNER_QNAME));
         if (optionalEntityOwner.isPresent()) {
             return optionalEntityOwner.get().getValue().toString();
@@ -660,13 +660,13 @@ class EntityOwnershipShard extends Shard {
             super(EntityOwnershipShard.class);
         }
 
-        Builder localMemberName(MemberName newLocalMemberName) {
+        Builder localMemberName(final MemberName newLocalMemberName) {
             checkSealed();
             this.localMemberName = newLocalMemberName;
             return this;
         }
 
-        Builder ownerSelectionStrategyConfig(EntityOwnerSelectionStrategyConfig newOwnerSelectionStrategyConfig) {
+        Builder ownerSelectionStrategyConfig(final EntityOwnerSelectionStrategyConfig newOwnerSelectionStrategyConfig) {
             checkSealed();
             this.ownerSelectionStrategyConfig = newOwnerSelectionStrategyConfig;
             return this;
index d4556cd374b18ff5e105382805b0bb70cdcab3f6..f56d6ce01fb7804f597957758e8d7449209bcab8 100644 (file)
@@ -47,14 +47,14 @@ public class ShardSnapshotState implements Snapshot.State {
             snapshotState.snapshot.serialize(toOutputStream(out));
         }
 
-        private OutputStream toOutputStream(final ObjectOutput out) {
+        private static OutputStream toOutputStream(final ObjectOutput out) {
             if (out instanceof OutputStream) {
                 return (OutputStream) out;
             }
 
             return new OutputStream() {
                 @Override
-                public void write(int value) throws IOException {
+                public void write(final int value) throws IOException {
                     out.write(value);
                 }
             };
@@ -65,7 +65,7 @@ public class ShardSnapshotState implements Snapshot.State {
             snapshotState = new ShardSnapshotState(ShardDataTreeSnapshot.deserialize(toInputStream(in)));
         }
 
-        private InputStream toInputStream(final ObjectInput in) {
+        private static InputStream toInputStream(final ObjectInput in) {
             if (in instanceof InputStream) {
                 return (InputStream) in;
             }
@@ -88,7 +88,7 @@ public class ShardSnapshotState implements Snapshot.State {
             + "aren't serialized. FindBugs does not recognize this.")
     private final ShardDataTreeSnapshot snapshot;
 
-    public ShardSnapshotState(@Nonnull ShardDataTreeSnapshot snapshot) {
+    public ShardSnapshotState(@Nonnull final ShardDataTreeSnapshot snapshot) {
         this.snapshot = Preconditions.checkNotNull(snapshot);
     }
 
@@ -97,7 +97,6 @@ public class ShardSnapshotState implements Snapshot.State {
         return snapshot;
     }
 
-    @SuppressWarnings("static-method")
     private Object writeReplace() {
         return new Proxy(this);
     }
index 8da5bf738718c24b45a575dd03b7e612c6b0de14..3a676586eb4d6afb4f002adb48c5ad86ac2d5e71 100644 (file)
@@ -490,7 +490,7 @@ public abstract class AbstractShardTest extends AbstractActorTest {
         }
 
         @SuppressWarnings("unchecked")
-        private <T> FutureCallback<T> mockFutureCallback(final FutureCallback<T> actual) {
+        private static <T> FutureCallback<T> mockFutureCallback(final FutureCallback<T> actual) {
             FutureCallback<T> mock = mock(FutureCallback.class);
             doAnswer(invocation -> {
                 actual.onFailure(invocation.getArgumentAt(0, Throwable.class));