Fix remaining CS warnings in sal-distributed-datastore 99/47499/3
authorTom Pantelis <tpanteli@brocade.com>
Tue, 25 Oct 2016 12:04:08 +0000 (08:04 -0400)
committerTom Pantelis <tpanteli@brocade.com>
Tue, 25 Oct 2016 19:12:48 +0000 (19:12 +0000)
Fixed remaining warnings and enabled enforcement. Most of the
warnings/changes were for:
 - white space before beginning brace
 - line too long
 - illegal catching of Exception (suppressed)
 - variable name too short
 - javadoc issues

Change-Id: I5ae5cf9276e0884595137d551a311e8322b2e25e
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
21 files changed:
opendaylight/md-sal/sal-distributed-datastore/pom.xml
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractClientHistory.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractProxyHistory.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractProxyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/ClientLocalHistory.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/ClientTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/ClientTransactionCommitCohort.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/DirectTransactionCommitCohort.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/DistributedDataStoreClient.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/DistributedDataStoreClientActor.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/DistributedDataStoreClientBehavior.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/EmptyTransactionCommitCohort.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/GetClientRequest.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/LocalAbortable.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/LocalProxyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/ModuleShardBackendResolver.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/RemoteProxyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/VotingFuture.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LeaderLocalDelegateFactory.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContextWrapper.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterChangeListenerReply.java

index b944633..394d381 100644 (file)
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <configuration>
+          <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+        </configuration>
+      </plugin>
       <plugin>
         <groupId>org.jacoco</groupId>
         <artifactId>jacoco-maven-plugin</artifactId>
index 593944f..b164157 100644 (file)
@@ -82,7 +82,7 @@ abstract class AbstractClientHistory extends LocalAbortable implements Identifia
     }
 
     /**
-     * Callback invoked from {@link ClientTransaction} when a transaction has been sub
+     * Callback invoked from {@link ClientTransaction} when a transaction has been submitted.
      *
      * @param transaction Transaction handle
      */
index 9093c08..f21be06 100644 (file)
@@ -33,7 +33,8 @@ abstract class AbstractProxyHistory implements Identifiable<LocalHistoryIdentifi
     static AbstractProxyHistory create(final DistributedDataStoreClientBehavior client,
             final Optional<ShardBackendInfo> backendInfo, final LocalHistoryIdentifier identifier) {
         final Optional<DataTree> dataTree = backendInfo.flatMap(ShardBackendInfo::getDataTree);
-        return dataTree.isPresent() ? new LocalProxyHistory(client, identifier, dataTree.get()) : new RemoteProxyHistory(client, identifier);
+        return dataTree.isPresent() ? new LocalProxyHistory(client, identifier, dataTree.get())
+                : new RemoteProxyHistory(client, identifier);
     }
 
     @Override
@@ -49,6 +50,6 @@ abstract class AbstractProxyHistory implements Identifiable<LocalHistoryIdentifi
         return doCreateTransactionProxy(client, new TransactionIdentifier(identifier, txId.getTransactionId()));
     }
 
-    abstract AbstractProxyTransaction doCreateTransactionProxy(DistributedDataStoreClientBehavior client,
+    abstract AbstractProxyTransaction doCreateTransactionProxy(DistributedDataStoreClientBehavior clientBehavior,
             TransactionIdentifier txId);
 }
index 8ff8b8e..cc1651a 100644 (file)
@@ -34,9 +34,11 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 /**
  * Class translating transaction operations towards a particular backend shard.
  *
+ * <p>
  * This class is not safe to access from multiple application threads, as is usual for transactions. Internal state
  * transitions coming from interactions with backend are expected to be thread-safe.
  *
+ * <p>
  * This class interacts with the queueing mechanism in ClientActorBehavior, hence once we arrive at a decision
  * to use either a local or remote implementation, we are stuck with it. We can re-evaluate on the next transaction.
  *
@@ -90,7 +92,7 @@ abstract class AbstractProxyTransaction implements Identifiable<TransactionIdent
     }
 
     /**
-     * Seal this transaction before it is either
+     * Seals this transaction when ready.
      */
     final void seal() {
         checkSealed();
@@ -111,6 +113,20 @@ abstract class AbstractProxyTransaction implements Identifiable<TransactionIdent
         doAbort();
     }
 
+    void abort(final VotingFuture<Void> ret) {
+        checkSealed();
+
+        sendRequest(new TransactionAbortRequest(getIdentifier(), nextSequence(), localActor()), t -> {
+            if (t instanceof TransactionAbortSuccess) {
+                ret.voteYes();
+            } else if (t instanceof RequestFailure) {
+                ret.voteNo(((RequestFailure<?, ?>) t).getCause());
+            } else {
+                ret.voteNo(new IllegalStateException("Unhandled response " + t.getClass()));
+            }
+        });
+    }
+
     /**
      * Commit this transaction, possibly in a coordinated fashion.
      *
@@ -133,20 +149,6 @@ abstract class AbstractProxyTransaction implements Identifiable<TransactionIdent
         return ret;
     }
 
-    void abort(final VotingFuture<Void> ret) {
-        checkSealed();
-
-        sendRequest(new TransactionAbortRequest(getIdentifier(), nextSequence(), localActor()), t -> {
-            if (t instanceof TransactionAbortSuccess) {
-                ret.voteYes();
-            } else if (t instanceof RequestFailure) {
-                ret.voteNo(((RequestFailure<?, ?>) t).getCause());
-            } else {
-                ret.voteNo(new IllegalStateException("Unhandled response " + t.getClass()));
-            }
-        });
-    }
-
     void canCommit(final VotingFuture<?> ret) {
         checkSealed();
 
@@ -164,7 +166,7 @@ abstract class AbstractProxyTransaction implements Identifiable<TransactionIdent
     void preCommit(final VotingFuture<?> ret) {
         checkSealed();
 
-        sendRequest(new TransactionPreCommitRequest(getIdentifier(), nextSequence(), localActor()), t-> {
+        sendRequest(new TransactionPreCommitRequest(getIdentifier(), nextSequence(), localActor()), t -> {
             if (t instanceof TransactionPreCommitSuccess) {
                 ret.voteYes();
             } else if (t instanceof RequestFailure) {
@@ -178,7 +180,7 @@ abstract class AbstractProxyTransaction implements Identifiable<TransactionIdent
     void doCommit(final VotingFuture<?> ret) {
         checkSealed();
 
-        sendRequest(new TransactionDoCommitRequest(getIdentifier(), nextSequence(), localActor()), t-> {
+        sendRequest(new TransactionDoCommitRequest(getIdentifier(), nextSequence(), localActor()), t -> {
             if (t instanceof TransactionCommitSuccess) {
                 ret.voteYes();
             } else if (t instanceof RequestFailure) {
@@ -189,6 +191,8 @@ abstract class AbstractProxyTransaction implements Identifiable<TransactionIdent
         });
     }
 
+    abstract TransactionRequest<?> doCommit(boolean coordinated);
+
     abstract void doDelete(final YangInstanceIdentifier path);
 
     abstract void doMerge(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data);
@@ -197,11 +201,10 @@ abstract class AbstractProxyTransaction implements Identifiable<TransactionIdent
 
     abstract CheckedFuture<Boolean, ReadFailedException> doExists(final YangInstanceIdentifier path);
 
-    abstract CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> doRead(final YangInstanceIdentifier path);
+    abstract CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> doRead(
+            final YangInstanceIdentifier path);
 
     abstract void doSeal();
 
     abstract void doAbort();
-
-    abstract TransactionRequest<?> doCommit(boolean coordinated);
 }
index be94e3e..807cf98 100644 (file)
@@ -18,6 +18,7 @@ import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier
  * Client-side view of a local history. This class tracks all state related to a particular history and routes
  * frontend requests towards the backend.
  *
+ * <p>
  * This interface is used by the world outside of the actor system and in the actor system it is manifested via
  * its client actor. That requires some state transfer with {@link DistributedDataStoreClientBehavior}. In order to
  * reduce request latency, all messages are carbon-copied (and enqueued first) to the client actor.
index e8e75e9..0a1c8be 100644 (file)
@@ -27,22 +27,28 @@ import org.slf4j.LoggerFactory;
 /**
  * Client-side view of a free-standing transaction.
  *
+ * <p>
  * This interface is used by the world outside of the actor system and in the actor system it is manifested via
  * its client actor. That requires some state transfer with {@link DistributedDataStoreClientBehavior}. In order to
  * reduce request latency, all messages are carbon-copied (and enqueued first) to the client actor.
  *
+ * <p>
  * It is internally composed of multiple {@link RemoteProxyTransaction}s, each responsible for a component shard.
  *
+ * <p>
  * Implementation is quite a bit complex, and involves cooperation with {@link AbstractClientHistory} for tracking
  * gaps in transaction identifiers seen by backends.
  *
+ * <p>
  * These gaps need to be accounted for in the transaction setup message sent to a particular backend, so it can verify
  * that the requested transaction is in-sequence. This is critical in ensuring that transactions (which are independent
  * entities from message queueing perspective) do not get reodered -- thus allowing multiple in-flight transactions.
  *
+ * <p>
  * Alternative would be to force visibility by sending an abort request to all potential backends, but that would mean
  * that even empty transactions increase load on all shards -- which would be a scalability issue.
  *
+ * <p>
  * Yet another alternative would be to introduce inter-transaction dependencies to the queueing layer in client actor,
  * but that would require additional indirection and complexity.
  *
index 2521c38..a7de89a 100644 (file)
@@ -15,9 +15,6 @@ import java.util.List;
 final class ClientTransactionCommitCohort extends AbstractTransactionCommitCohort {
     private final List<AbstractProxyTransaction> proxies;
 
-    /**
-     * @param clientTransaction
-     */
     ClientTransactionCommitCohort(final Collection<AbstractProxyTransaction> proxies) {
         this.proxies = ImmutableList.copyOf(proxies);
     }
@@ -64,4 +61,4 @@ final class ClientTransactionCommitCohort extends AbstractTransactionCommitCohor
 
         return ret;
     }
-}
\ No newline at end of file
+}
index 007ac53..49b281a 100644 (file)
@@ -19,9 +19,6 @@ import com.google.common.util.concurrent.ListenableFuture;
 final class DirectTransactionCommitCohort extends AbstractTransactionCommitCohort {
     private final AbstractProxyTransaction proxy;
 
-    /**
-     * @param clientTransaction
-     */
     DirectTransactionCommitCohort(final AbstractProxyTransaction proxy) {
         this.proxy = Preconditions.checkNotNull(proxy);
     }
index 0d22d56..273fd89 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.yangtools.concepts.Identifiable;
  * Client interface for interacting with the frontend actor. This interface is the primary access point through
  * which the DistributedDataStore frontend interacts with backend Shards.
  *
+ * <p>
  * Keep this interface as clean as possible, as it needs to be implemented in thread-safe and highly-efficient manner.
  *
  * @author Robert Varga
index de2c195..45875ba 100644 (file)
@@ -45,14 +45,16 @@ public final class DistributedDataStoreClientActor extends AbstractClientActor {
         return new DistributedDataStoreClientBehavior(context, actorContext);
     }
 
-    public static Props props(final @Nonnull MemberName memberName, @Nonnull final String storeName, final ActorContext ctx) {
+    public static Props props(@Nonnull final MemberName memberName, @Nonnull final String storeName,
+            final ActorContext ctx) {
         final String name = "datastore-" + storeName;
         final FrontendIdentifier frontendId = FrontendIdentifier.create(memberName, FrontendType.forName(name));
         return Props.create(DistributedDataStoreClientActor.class,
             () -> new DistributedDataStoreClientActor(frontendId, ctx));
     }
 
-    public static DistributedDataStoreClient getDistributedDataStoreClient(final @Nonnull ActorRef actor,
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    public static DistributedDataStoreClient getDistributedDataStoreClient(@Nonnull final ActorRef actor,
             final long timeout, final TimeUnit unit) {
         try {
             return (DistributedDataStoreClient) Await.result(ExplicitAsk.ask(actor, GET_CLIENT_FACTORY,
index e3e781e..eb1dd17 100644 (file)
@@ -29,21 +29,26 @@ import org.slf4j.LoggerFactory;
  * {@link ClientActorBehavior} acting as an intermediary between the backend actors and the DistributedDataStore
  * frontend.
  *
+ * <p>
  * This class is not visible outside of this package because it breaks the actor containment. Services provided to
  * Java world outside of actor containment are captured in {@link DistributedDataStoreClient}.
  *
+ * <p>
  * IMPORTANT: this class breaks actor containment via methods implementing {@link DistributedDataStoreClient} contract.
  *            When touching internal state, be mindful of the execution context from which execution context, Actor
  *            or POJO, is the state being accessed or modified.
  *
+ * <p>
  * THREAD SAFETY: this class must always be kept thread-safe, so that both the Actor System thread and the application
  *                threads can run concurrently. All state transitions must be made in a thread-safe manner. When in
  *                doubt, feel free to synchronize on this object.
  *
+ * <p>
  * PERFORMANCE: this class lies in a performance-critical fast path. All code needs to be concise and efficient, but
  *              performance must not come at the price of correctness. Any optimizations need to be carefully analyzed
  *              for correctness and performance impact.
  *
+ * <p>
  * TRADE-OFFS: part of the functionality runs in application threads without switching contexts, which makes it ideal
  *             for performing work and charging applications for it. That has two positive effects:
  *             - CPU usage is distributed across applications, minimizing work done in the actor thread
@@ -123,6 +128,7 @@ final class DistributedDataStoreClientBehavior extends ClientActorBehavior imple
     //
     //
 
+    @SuppressWarnings("checkstyle:IllegalCatch")
     private static <K, V extends LocalAbortable> V returnIfOperational(final Map<K , V> map, final K key, final V value,
             final Throwable aborted) {
         Verify.verify(map.put(key, value) == null);
index 7032660..0884ed4 100644 (file)
@@ -14,6 +14,7 @@ import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCoh
  * An {@link AbstractTransactionCommitCohort} for use with empty transactions. This relies on the fact that no backends
  * have been touched, hence all state book-keeping needs to happen only locally and shares fate with the coordinator.
  *
+ * <p>
  * Therefore all methods can finish immediately without any effects.
  *
  * @author Robert Varga
index 4bfd1c4..2b67854 100644 (file)
@@ -18,11 +18,11 @@ import com.google.common.base.Preconditions;
 final class GetClientRequest {
     private final ActorRef replyTo;
 
-    public GetClientRequest(final ActorRef replyTo) {
+    GetClientRequest(final ActorRef replyTo) {
         this.replyTo = Preconditions.checkNotNull(replyTo);
     }
 
     ActorRef getReplyTo() {
         return replyTo;
     }
-}
\ No newline at end of file
+}
index 5b0708f..a6d86de 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.controller.cluster.databroker.actors.dds;
  * Common interface for client histories and client transactions, which can be aborted immediately without replicating
  * the effect to the backend. This is needed for abrupt shutdowns.
  *
+ * <p>
  * Since classes which need to expose this functionality do not need a base class, this is an abstract class and not
  * an interface -- which allows us to not leak the {@link #localAbort(Throwable)} method.
  *
index b5eadb5..576fa67 100644 (file)
@@ -29,10 +29,12 @@ import org.slf4j.LoggerFactory;
  * An {@link AbstractProxyTransaction} for dispatching a transaction towards a shard leader which is co-located with
  * the client instance.
  *
+ * <p>
  * It requires a {@link DataTreeSnapshot}, which is used to instantiated a new {@link DataTreeModification}. Operations
  * are then performed on this modification and once the transaction is submitted, the modification is sent to the shard
  * leader.
  *
+ * <p>
  * This class is not thread-safe as usual with transactions. Since it does not interact with the backend until the
  * transaction is submitted, at which point this class gets out of the picture, this is not a cause for concern.
  *
index 495681c..de115f0 100644 (file)
@@ -93,10 +93,10 @@ final class ModuleShardBackendResolver extends BackendInfoResolver<ShardBackendI
                 if (cookie == null) {
                     cookie = nextShard++;
 
-                    Builder<String, Long> b = ImmutableBiMap.builder();
-                    b.putAll(shards);
-                    b.put(shardName, cookie);
-                    shards = b.build();
+                    Builder<String, Long> builder = ImmutableBiMap.builder();
+                    builder.putAll(shards);
+                    builder.put(shardName, cookie);
+                    shards = builder.build();
                 }
             }
         }
@@ -132,9 +132,9 @@ final class ModuleShardBackendResolver extends BackendInfoResolver<ShardBackendI
             return new ShardBackendInfo(success.getBackend(),
                 nextSessionId.getAndIncrement(), success.getVersion(), shardName, UnsignedLong.fromLongBits(cookie),
                 success.getDataTree(), success.getMaxMessages());
-        }).whenComplete((info, t) -> {
-            if (t != null) {
-                ret.completeExceptionally(t);
+        }).whenComplete((info, throwablw) -> {
+            if (throwablw != null) {
+                ret.completeExceptionally(throwablw);
             } else {
                 ret.complete(info);
             }
index bb21223..26d718d 100644 (file)
@@ -39,9 +39,11 @@ import org.slf4j.LoggerFactory;
  * An {@link AbstractProxyTransaction} for dispatching a transaction towards a shard leader whose location is currently
  * not known or is known to be not co-located with the client.
  *
+ * <p>
  * It packages operations and sends them via the client actor queue to the shard leader. That queue is responsible for
  * maintaining any submitted operations until the leader is discovered.
  *
+ * <p>
  * This class is not safe to access from multiple application threads, as is usual for transactions. Its internal state
  * transitions based on backend responses are thread-safe.
  *
@@ -193,7 +195,8 @@ final class RemoteProxyTransaction extends AbstractProxyTransaction {
         }
     }
 
-    private void completeRead(final SettableFuture<Optional<NormalizedNode<?, ?>>> future, final Response<?, ?> response) {
+    private void completeRead(final SettableFuture<Optional<NormalizedNode<?, ?>>> future,
+            final Response<?, ?> response) {
         LOG.debug("Read request completed with {}", response);
 
         if (response instanceof ReadTransactionSuccess) {
index b6aba31..01298df 100644 (file)
@@ -22,6 +22,7 @@ import javax.annotation.concurrent.GuardedBy;
  * an exception. This exception corresponds to the cause reported by the first 'no' vote, with all subsequent votes
  * added as suppressed exceptions.
  *
+ * <p>
  * Implementation is geared toward positive votes. Negative votes have to synchronize and therefore are more likely
  * to see contention.
  *
@@ -53,7 +54,7 @@ class VotingFuture<T> extends AbstractFuture<T> {
         if (castVote()) {
             synchronized (failures) {
                 resolveResult();
-             }
+            }
         }
     }
 
index 8e22d5f..fbd974a 100644 (file)
@@ -64,5 +64,6 @@ abstract class LeaderLocalDelegateFactory<M, D, I> extends DelegateFactory<M, D,
      * @param hasLeader true if the shard knows about leader ID
      */
     abstract void onLeadershipChange(boolean isLeader, boolean hasLeader);
+
     abstract void onMessage(M message, boolean isLeader, boolean hasLeader);
 }
index 6dae7ce..3fb129f 100644 (file)
@@ -109,13 +109,13 @@ class TransactionContextWrapper {
             // in case a TransactionOperation results in another transaction operation being
             // queued (eg a put operation from a client read Future callback that is notified
             // synchronously).
-            Collection<TransactionOperation> operationsBatch = null;
+            final Collection<TransactionOperation> operationsBatch;
             synchronized (queuedTxOperations) {
                 if (queuedTxOperations.isEmpty()) {
                     // We're done invoking the TransactionOperations so we can now publish the
                     // TransactionContext.
                     localTransactionContext.operationHandOffComplete();
-                    if (!localTransactionContext.usesOperationLimiting()){
+                    if (!localTransactionContext.usesOperationLimiting()) {
                         limiter.releaseAll();
                     }
                     transactionContext = localTransactionContext;
index cc594ca..f7031e4 100644 (file)
@@ -11,7 +11,7 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import akka.actor.ActorPath;
 import akka.actor.ActorRef;
 
-public class RegisterChangeListenerReply{
+public class RegisterChangeListenerReply {
     private final ActorRef listenerRegistration;
 
     public RegisterChangeListenerReply(final ActorRef listenerRegistration) {

©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.