Fix CS warnings in cds-access-client and enable enforcement 71/47471/3
authorTom Pantelis <tpanteli@brocade.com>
Tue, 25 Oct 2016 04:49:04 +0000 (00:49 -0400)
committerTom Pantelis <tpanteli@brocade.com>
Tue, 25 Oct 2016 18:03:05 +0000 (18:03 +0000)
Fixed checkstyle warnings and enabled enforcement. Most of the
warnings/changes were for:
 - variable name too short
 - correct ordering of @Nonnull annotations
 - line too long
 - javadocs

Change-Id: Ib888dbf909282079bff6320ce718d5a4da3ed31a
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
16 files changed:
opendaylight/md-sal/cds-access-client/pom.xml
opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/AbstractClientActorBehavior.java
opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/AbstractClientActorContext.java
opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/BackendInfo.java
opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/BackendInfoResolver.java
opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ClientActorBehavior.java
opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ClientActorContext.java
opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/EmptyQueue.java
opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/InitialClientActorContext.java
opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/RecoveredClientActorBehavior.java
opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/SavingClientActorBehavior.java
opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/SequencedQueue.java
opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/AbstractClientActorTest.java
opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/ClientActorContextTest.java
opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/SequencedQueueEntryTest.java
opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/SequencedQueueTest.java

index 1ed37ff..376be8c 100644 (file)
         </dependency>
     </dependencies>
 
+    <build>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-checkstyle-plugin</artifactId>
+          <configuration>
+            <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+          </configuration>
+        </plugin>
+      </plugins>
+    </build>
+
     <scm>
         <connection>scm:git:http://git.opendaylight.org/gerrit/controller.git</connection>
         <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
index e564359..0a49fc0 100644 (file)
@@ -14,8 +14,7 @@ import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 /**
- * Base behavior attached to {@link AbstractClientActor}. Exposes
- * @author user
+ * Base behavior attached to {@link AbstractClientActor}.
  *
  * @param <C> Type of associated context
  *
@@ -25,7 +24,7 @@ import javax.annotation.Nullable;
 public abstract class AbstractClientActorBehavior<C extends AbstractClientActorContext> {
     private final C context;
 
-    AbstractClientActorBehavior(final @Nonnull C context) {
+    AbstractClientActorBehavior(@Nonnull final C context) {
         // Hidden to prevent outside subclasses. Users instantiated this via ClientActorBehavior
         this.context = Preconditions.checkNotNull(context);
     }
@@ -35,7 +34,8 @@ public abstract class AbstractClientActorBehavior<C extends AbstractClientActorC
      *
      * @return A client actor context instance.
      */
-    protected final @Nonnull C context() {
+    @Nonnull
+    protected final C context() {
         return context;
     }
 
@@ -45,7 +45,8 @@ public abstract class AbstractClientActorBehavior<C extends AbstractClientActorC
      *
      * @return Persistence identifier
      */
-    protected final @Nonnull String persistenceId() {
+    @Nonnull
+    protected final String persistenceId() {
         return context.persistenceId();
     }
 
@@ -54,7 +55,8 @@ public abstract class AbstractClientActorBehavior<C extends AbstractClientActorC
      *
      * @return Actor associated with this behavior
      */
-    public final @Nonnull ActorRef self() {
+    @Nonnull
+    public final ActorRef self() {
         return context.self();
     }
 
@@ -64,7 +66,8 @@ public abstract class AbstractClientActorBehavior<C extends AbstractClientActorC
      * @param command Command message
      * @return Behavior which should be used with the next message. Return null if this actor should shut down.
      */
-    abstract @Nullable AbstractClientActorBehavior<?> onReceiveCommand(@Nonnull Object command);
+    @Nullable
+    abstract AbstractClientActorBehavior<?> onReceiveCommand(@Nonnull Object command);
 
     /**
      * Implementation-internal method for handling an incoming recovery message coming from persistence.
@@ -72,5 +75,6 @@ public abstract class AbstractClientActorBehavior<C extends AbstractClientActorC
      * @param recover Recover message
      * @return Behavior which should be used with the next message. Return null if this actor should shut down.
      */
-    abstract @Nullable AbstractClientActorBehavior<?> onReceiveRecover(@Nonnull Object recover);
+    @Nullable
+    abstract AbstractClientActorBehavior<?> onReceiveRecover(@Nonnull Object recover);
 }
index 0ca3545..7899358 100644 (file)
@@ -13,8 +13,8 @@ import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.concepts.Mutable;
 
 /**
- * Common, externally-invisible superclass of contexts associated with a {@link AbstractClientActor}. End users pass this
- * object via opaque {@link ClientActorContext}.
+ * Common, externally-invisible superclass of contexts associated with a {@link AbstractClientActor}. End users pass
+ * this object via opaque {@link ClientActorContext}.
  *
  * @author Robert Varga
  */
@@ -22,16 +22,18 @@ abstract class AbstractClientActorContext implements Mutable {
     private final String persistenceId;
     private final ActorRef self;
 
-    AbstractClientActorContext(final @Nonnull ActorRef self, final @Nonnull String persistenceId) {
+    AbstractClientActorContext(@Nonnull final ActorRef self, @Nonnull final String persistenceId) {
         this.persistenceId = Preconditions.checkNotNull(persistenceId);
         this.self = Preconditions.checkNotNull(self);
     }
 
-    final @Nonnull String persistenceId() {
+    @Nonnull
+    final String persistenceId() {
         return persistenceId;
     }
 
-    public final @Nonnull ActorRef self() {
+    @Nonnull
+    public final ActorRef self() {
         return self;
     }
 }
index bdffb08..a5a579d 100644 (file)
@@ -17,6 +17,7 @@ import org.opendaylight.controller.cluster.access.ABIVersion;
  * Basic information about how to talk to the backend. ClientActorBehavior uses this information to dispatch requests
  * to the backend.
  *
+ * <p>
  * This class is not final so concrete actor behavior implementations may subclass it and track more information about
  * the backend. The {@link #hashCode()} and {@link #equals(Object)} methods are made final to ensure subclasses compare
  * on identity.
index cb64809..7180573 100644 (file)
@@ -61,7 +61,7 @@ public abstract class BackendInfoResolver<T extends BackendInfo> {
      * @param cookie Backend cookie
      * @param info Previous information to be invalidated
      */
-    public final void invalidateBackend(final long cookie, final @Nonnull CompletionStage<? extends BackendInfo> info) {
+    public final void invalidateBackend(final long cookie, @Nonnull final CompletionStage<? extends BackendInfo> info) {
         if (backends.remove(cookie, Preconditions.checkNotNull(info))) {
             LOG.trace("Invalidated cache %s -> %s", Long.toUnsignedString(cookie), info);
             invalidateBackendInfo(info);
@@ -75,7 +75,8 @@ public abstract class BackendInfoResolver<T extends BackendInfo> {
      * @param cookie Backend cookie
      * @return A {@link CompletableFuture} resulting in information about the backend
      */
-    protected abstract @Nonnull CompletableFuture<T> resolveBackendInfo(final @Nonnull Long cookie);
+    @Nonnull
+    protected abstract CompletableFuture<T> resolveBackendInfo(@Nonnull final Long cookie);
 
     /**
      * Invalidate previously-resolved shard information. This method is invoked when a timeout is detected
index 8939ec9..43b621c 100644 (file)
@@ -34,12 +34,13 @@ public abstract class ClientActorBehavior extends RecoveredClientActorBehavior<C
         implements Identifiable<ClientIdentifier> {
     private static final Logger LOG = LoggerFactory.getLogger(ClientActorBehavior.class);
 
-    protected ClientActorBehavior(final @Nonnull ClientActorContext context) {
+    protected ClientActorBehavior(@Nonnull final ClientActorContext context) {
         super(context);
     }
 
     @Override
-    public final @Nonnull ClientIdentifier getIdentifier() {
+    @Nonnull
+    public final ClientIdentifier getIdentifier() {
         return context().getIdentifier();
     }
 
@@ -145,6 +146,7 @@ public abstract class ClientActorBehavior extends RecoveredClientActorBehavior<C
             needBackend = queue.runTimeout();
         } catch (NoProgressException e) {
             // Uh-oh, no progress. The queue has already killed itself, now we need to remove it
+            LOG.debug("{}: No progress made - removing queue", persistenceId(), e);
             context().removeQueue(queue);
             return this;
         }
@@ -157,10 +159,9 @@ public abstract class ClientActorBehavior extends RecoveredClientActorBehavior<C
     }
 
     /**
-     * Halt And Catch Fire.
-     *
-     * Halt processing on this client. Implementations need to ensure they initiate state flush procedures. No attempt
-     * to use this instance should be made after this method returns. Any such use may result in undefined behavior.
+     * Halt And Catch Fire. Halt processing on this client. Implementations need to ensure they initiate state flush
+     * procedures. No attempt to use this instance should be made after this method returns. Any such use may result
+     * in undefined behavior.
      *
      * @param cause Failure cause
      */
@@ -169,17 +170,19 @@ public abstract class ClientActorBehavior extends RecoveredClientActorBehavior<C
     /**
      * Override this method to handle any command which is not handled by the base behavior.
      *
-     * @param command
+     * @param command the command to process
      * @return Next behavior to use, null if this actor should shut down.
      */
-    protected abstract @Nullable ClientActorBehavior onCommand(@Nonnull Object command);
+    @Nullable
+    protected abstract ClientActorBehavior onCommand(@Nonnull Object command);
 
     /**
      * Override this method to provide a backend resolver instance.
      *
-     * @return
+     * @return a backend resolver instance
      */
-    protected abstract @Nonnull BackendInfoResolver<?> resolver();
+    @Nonnull
+    protected abstract BackendInfoResolver<?> resolver();
 
     /**
      * Send a request to the backend and invoke a specified callback when it finishes. This method is safe to invoke
index e8993c0..26e6835 100644 (file)
@@ -31,6 +31,7 @@ import scala.concurrent.duration.FiniteDuration;
 /**
  * An actor context associated with this {@link AbstractClientActor}.
  *
+ * <p>
  * Time-keeping in a client actor is based on monotonic time. The precision of this time can be expected to be the
  * same as {@link System#nanoTime()}, but it is not tied to that particular clock. Actor clock is exposed as
  * a {@link Ticker}, which can be obtained via {@link #ticker()}.
@@ -57,7 +58,8 @@ public class ClientActorContext extends AbstractClientActorContext implements Id
     }
 
     @Override
-    public @Nonnull ClientIdentifier getIdentifier() {
+    @Nonnull
+    public ClientIdentifier getIdentifier() {
         return identifier;
     }
 
@@ -68,7 +70,8 @@ public class ClientActorContext extends AbstractClientActorContext implements Id
      *
      * @return Client actor time source
      */
-    public @Nonnull Ticker ticker() {
+    @Nonnull
+    public Ticker ticker() {
         return Ticker.systemTicker();
     }
 
@@ -77,11 +80,11 @@ public class ClientActorContext extends AbstractClientActorContext implements Id
      *
      * @param command Block of code which needs to be execute
      */
-    public void executeInActor(final @Nonnull InternalCommand command) {
+    public void executeInActor(@Nonnull final InternalCommand command) {
         self().tell(Preconditions.checkNotNull(command), ActorRef.noSender());
     }
 
-    public Cancellable executeInActor(final @Nonnull InternalCommand command, final FiniteDuration delay) {
+    public Cancellable executeInActor(@Nonnull final InternalCommand command, final FiniteDuration delay) {
         return scheduler.scheduleOnce(Preconditions.checkNotNull(delay), self(), Preconditions.checkNotNull(command),
             executionContext, ActorRef.noSender());
     }
index 6ec8ec8..3199db3 100644 (file)
@@ -8,11 +8,14 @@
 package org.opendaylight.controller.cluster.access.client;
 
 /**
+ * Abstract base class class for a behavior whose actor has recovered from persistence.
+ *
  * @param <C> Concrete context type
  *
  * @author Robert Varga
  */
-abstract class RecoveredClientActorBehavior<C extends AbstractClientActorContext> extends AbstractClientActorBehavior<C> {
+abstract class RecoveredClientActorBehavior<C extends AbstractClientActorContext>
+        extends AbstractClientActorBehavior<C> {
 
     RecoveredClientActorBehavior(final C context) {
         super(context);
index 5fc3ef3..8f6e991 100644 (file)
@@ -46,7 +46,8 @@ final class SavingClientActorBehavior extends RecoveredClientActorBehavior<Initi
             LOG.debug("{}: got command: {}", persistenceId(), command);
         } else if (command instanceof DeleteSnapshotsFailure) {
             // Not treating this as a fatal error.
-            LOG.warn("{}: failed to delete prior snapshots", persistenceId(), ((DeleteSnapshotsFailure) command).cause());
+            LOG.warn("{}: failed to delete prior snapshots", persistenceId(),
+                    ((DeleteSnapshotsFailure) command).cause());
         } else {
             LOG.debug("{}: stashing command {}", persistenceId(), command);
             context().stash();
@@ -56,4 +57,4 @@ final class SavingClientActorBehavior extends RecoveredClientActorBehavior<Initi
         context().unstash();
         return context().createBehavior(myId);
     }
-}
\ No newline at end of file
+}
index 5cf7873..0e8d1b9 100644 (file)
@@ -28,6 +28,8 @@ import org.slf4j.LoggerFactory;
 import scala.concurrent.duration.FiniteDuration;
 
 /*
+ * A queue that processes entries in sequence.
+ *
  * TODO: make this class and its users thread-safe. This will require some atomic state-keeping so that timeouts,
  *       retries and enqueues work as expected.
  */
@@ -118,7 +120,7 @@ final class SequencedQueue {
      * 2) The request has been enqueued and transmitted, but the caller needs to schedule a new timer
      * 3) The request has been enqueued, but the caller needs to request resolution of backend information and that
      *    process needs to complete before transmission occurs
-     *
+     * <p/>
      * These options are covered via returning an {@link Optional}. The caller needs to examine it and decode
      * the scenarios above according to the following rules:
      * - if is null, the first case applies
@@ -271,7 +273,8 @@ final class SequencedQueue {
         transmitEntries(pending, toSend);
     }
 
-    Optional<FiniteDuration> setBackendInfo(final CompletionStage<? extends BackendInfo> proof, final BackendInfo backend) {
+    Optional<FiniteDuration> setBackendInfo(final CompletionStage<? extends BackendInfo> proof,
+            final BackendInfo backend) {
         Preconditions.checkNotNull(backend);
         if (!proof.equals(backendProof)) {
             LOG.debug("Ignoring resolution {} while waiting for {}", proof, this.backendProof);
index 34abbe5..b4e64c8 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.controller.cluster.access.client;
 
 import static org.junit.Assert.assertSame;
+
 import akka.actor.ActorRef;
 import akka.actor.Scheduler;
 import akka.dispatch.Dispatcher;
@@ -23,7 +24,8 @@ import org.opendaylight.controller.cluster.access.concepts.MemberName;
 
 public class ClientActorContextTest {
     private static final MemberName MEMBER_NAME = MemberName.forName("member-1");
-    private static final FrontendType FRONTEND_TYPE = FrontendType.forName(ClientActorContextTest.class.getSimpleName());
+    private static final FrontendType FRONTEND_TYPE =
+            FrontendType.forName(ClientActorContextTest.class.getSimpleName());
     private static final FrontendIdentifier FRONTEND_ID = FrontendIdentifier.create(MEMBER_NAME, FRONTEND_TYPE);
     private static final ClientIdentifier CLIENT_ID = ClientIdentifier.create(FRONTEND_ID, 0);
     private static final String PERSISTENCE_ID = ClientActorContextTest.class.getSimpleName();
@@ -44,7 +46,8 @@ public class ClientActorContextTest {
 
     @Test
     public void testMockingControl() {
-        ClientActorContext ctx = new ClientActorContext(mockSelf, mockScheduler, mockDispatcher, PERSISTENCE_ID, CLIENT_ID);
+        ClientActorContext ctx = new ClientActorContext(mockSelf, mockScheduler, mockDispatcher,
+                PERSISTENCE_ID, CLIENT_ID);
         assertSame(CLIENT_ID, ctx.getIdentifier());
         assertSame(PERSISTENCE_ID, ctx.persistenceId());
         assertSame(mockSelf, ctx.self());
@@ -52,7 +55,8 @@ public class ClientActorContextTest {
 
     @Test
     public void testTicker() {
-        ClientActorContext ctx = new ClientActorContext(mockSelf, mockScheduler, mockDispatcher, PERSISTENCE_ID, CLIENT_ID);
+        ClientActorContext ctx = new ClientActorContext(mockSelf, mockScheduler, mockDispatcher,
+                PERSISTENCE_ID, CLIENT_ID);
         assertSame(Ticker.systemTicker(), ctx.ticker());
     }
 }
index 1b56e53..8cc990c 100644 (file)
@@ -15,6 +15,7 @@ import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.verify;
+
 import akka.actor.ActorRef;
 import akka.actor.ActorSystem;
 import akka.testkit.TestProbe;
@@ -54,7 +55,8 @@ public class SequencedQueueEntryTest {
         }
 
         @Override
-        protected AbstractRequestFailureProxy<WritableIdentifier, MockFailure> externalizableProxy(final ABIVersion version) {
+        protected AbstractRequestFailureProxy<WritableIdentifier, MockFailure> externalizableProxy(
+                final ABIVersion version) {
             return null;
         }
 
@@ -193,12 +195,12 @@ public class SequencedQueueEntryTest {
         assertRequestEquals(mockRequest, mockActor.receiveOne(Duration.apply(5, TimeUnit.SECONDS)));
     }
 
-     private static void assertRequestEquals(final Request<?, ?> expected, final Object o) {
-         assertTrue(o instanceof RequestEnvelope);
+    private static void assertRequestEquals(final Request<?, ?> expected, final Object obj) {
+        assertTrue(obj instanceof RequestEnvelope);
 
-         final RequestEnvelope actual = (RequestEnvelope) o;
-         assertEquals(0, actual.getSessionId());
-         assertEquals(0, actual.getTxSequence());
-         assertEquals(expected.getTarget(), actual.getMessage().getTarget());
+        final RequestEnvelope actual = (RequestEnvelope) obj;
+        assertEquals(0, actual.getSessionId());
+        assertEquals(0, actual.getTxSequence());
+        assertEquals(expected.getTarget(), actual.getMessage().getTarget());
     }
 }
index 305ec31..72be005 100644 (file)
@@ -17,6 +17,7 @@ import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
+
 import akka.actor.ActorRef;
 import akka.actor.ActorSystem;
 import akka.testkit.TestProbe;
@@ -58,7 +59,8 @@ public class SequencedQueueTest {
         }
 
         @Override
-        protected AbstractRequestFailureProxy<WritableIdentifier, MockFailure> externalizableProxy(final ABIVersion version) {
+        protected AbstractRequestFailureProxy<WritableIdentifier, MockFailure> externalizableProxy(
+                final ABIVersion version) {
             return null;
         }
 
@@ -162,7 +164,7 @@ public class SequencedQueueTest {
         assertTrue(queue.hasCompleted());
     }
 
-    @Test(expected=IllegalStateException.class)
+    @Test(expected = IllegalStateException.class)
     public void testClosedEnqueueRequest() {
         queue.close();
 
@@ -186,7 +188,7 @@ public class SequencedQueueTest {
         assertSame(mockCause, captor.getValue().getCause());
     }
 
-    @Test(expected=IllegalStateException.class)
+    @Test(expected = IllegalStateException.class)
     public void testPoisonPerformsClose() {
         // Implies close()
         queue.poison(mockCause);
@@ -216,7 +218,7 @@ public class SequencedQueueTest {
         assertFalse(queue.expectProof(proof));
     }
 
-    @Test(expected=NullPointerException.class)
+    @Test(expected = NullPointerException.class)
     public void testSetBackendNull() {
         final CompletableFuture<BackendInfo> proof = new CompletableFuture<>();
         assertTrue(queue.expectProof(proof));
@@ -339,7 +341,7 @@ public class SequencedQueueTest {
         assertTrue(ret);
     }
 
-    @Test(expected=NoProgressException.class)
+    @Test(expected = NoProgressException.class)
     public void testRunTimeoutWithoutProgressExact() throws NoProgressException {
         queue.enqueueRequest(mockRequest, mockCallback);
 
@@ -349,7 +351,7 @@ public class SequencedQueueTest {
         queue.runTimeout();
     }
 
-    @Test(expected=NoProgressException.class)
+    @Test(expected = NoProgressException.class)
     public void testRunTimeoutWithoutProgressMore() throws NoProgressException {
         queue.enqueueRequest(mockRequest, mockCallback);
 
@@ -440,10 +442,10 @@ public class SequencedQueueTest {
         assertRequestEquals(expected, sequence, mockActor.receiveOne(FiniteDuration.apply(5, TimeUnit.SECONDS)));
     }
 
-    private static void assertRequestEquals(final Request<?, ?> expected, final long sequence, final Object o) {
-        assertTrue(o instanceof RequestEnvelope);
+    private static void assertRequestEquals(final Request<?, ?> expected, final long sequence, final Object obj) {
+        assertTrue(obj instanceof RequestEnvelope);
 
-        final RequestEnvelope actual = (RequestEnvelope) o;
+        final RequestEnvelope actual = (RequestEnvelope) obj;
         assertEquals(0, actual.getSessionId());
         assertEquals(sequence, actual.getTxSequence());
         assertSame(expected, actual.getMessage());

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