Fix checkstyle violations in /sal-connector-api and sal-dummy-distributed-datastore 34/69234/2
authorTom Pantelis <tompantelis@gmail.com>
Wed, 7 Mar 2018 21:06:58 +0000 (16:06 -0500)
committerMichael Vorburger <vorburger@redhat.com>
Fri, 9 Mar 2018 15:28:26 +0000 (15:28 +0000)
Change-Id: I9ff8db03ca921517595dc133c1b3869c3a29fa34
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/BindingAwareRpcRouter.java
opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/ConnectorListener.java
opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/RpcRouter.java
opendaylight/md-sal/sal-dummy-distributed-datastore/src/main/java/org/opendaylight/controller/dummy/datastore/DummyShard.java
opendaylight/md-sal/sal-dummy-distributed-datastore/src/main/java/org/opendaylight/controller/dummy/datastore/DummyShardManager.java
opendaylight/md-sal/sal-dummy-distributed-datastore/src/main/java/org/opendaylight/controller/dummy/datastore/Main.java

index 17221bc0af4fe1894022d6db05af3400d8c0aeb9..db10b08ff48c9cd1bf224891e8c7c3c9038f9453 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.controller.sal.connector.api;
 
 import java.util.concurrent.Future;
-
 import org.opendaylight.yangtools.concepts.Immutable;
 
 public interface BindingAwareRpcRouter extends RpcRouter<String, String, String, byte[]> {
@@ -27,6 +26,7 @@ public interface BindingAwareRpcRouter extends RpcRouter<String, String, String,
             this.payload = payload;
         }
 
+        @Override
         public BindingAwareRouteIdentifier getRoutingInformation() {
             return this.routingInformation;
         }
@@ -50,9 +50,7 @@ public interface BindingAwareRpcRouter extends RpcRouter<String, String, String,
         }
 
         /**
-         * Java class name of Rpc Context
-         *
-         *
+         * Java class name of Rpc Context.
          */
         @Override
         public String getContext() {
@@ -69,8 +67,7 @@ public interface BindingAwareRpcRouter extends RpcRouter<String, String, String,
         }
 
         /**
-         * Java class name of Rpc Type e.g org.opendaylight.AddFlowInput
-         *
+         * Java class name of Rpc Type e.g org.opendaylight.AddFlowInput.
          */
         @Override
         public String getType() {
@@ -81,39 +78,46 @@ public interface BindingAwareRpcRouter extends RpcRouter<String, String, String,
         public int hashCode() {
             final int prime = 31;
             int result = 1;
-            result = prime * result + ((content == null) ? 0 : content.hashCode());
-            result = prime * result + ((route == null) ? 0 : route.hashCode());
-            result = prime * result + ((type == null) ? 0 : type.hashCode());
+            result = prime * result + (content == null ? 0 : content.hashCode());
+            result = prime * result + (route == null ? 0 : route.hashCode());
+            result = prime * result + (type == null ? 0 : type.hashCode());
             return result;
         }
 
         @Override
         public boolean equals(Object obj) {
-            if (this == obj)
+            if (this == obj) {
                 return true;
-            if (obj == null)
+            }
+            if (obj == null) {
                 return false;
-            if (getClass() != obj.getClass())
+            }
+            if (getClass() != obj.getClass()) {
                 return false;
+            }
             BindingAwareRouteIdentifier other = (BindingAwareRouteIdentifier) obj;
             if (content == null) {
-                if (other.content != null)
+                if (other.content != null) {
                     return false;
-            } else if (!content.equals(other.content))
+                }
+            } else if (!content.equals(other.content)) {
                 return false;
+            }
             if (route == null) {
-                if (other.route != null)
+                if (other.route != null) {
                     return false;
-            } else if (!route.equals(other.route))
+                }
+            } else if (!route.equals(other.route)) {
                 return false;
+            }
             if (type == null) {
-                if (other.type != null)
+                if (other.type != null) {
                     return false;
-            } else if (!type.equals(other.type))
+                }
+            } else if (!type.equals(other.type)) {
                 return false;
+            }
             return true;
         }
-
     }
-
 }
index 935baba7a23540eddb71f732d5f9b8c8a9514cce..5f99addf2022327bfdb88da93cbf50c976dbb8c2 100644 (file)
@@ -8,12 +8,10 @@
 package org.opendaylight.controller.sal.connector.api;
 
 import java.util.Set;
-
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
 public interface ConnectorListener {
-
     void onPrefixesAnnounced(Set<YangInstanceIdentifier> prefixes);
-    void onPrefixesWithdrawn(Set<YangInstanceIdentifier> prefixes);
 
+    void onPrefixesWithdrawn(Set<YangInstanceIdentifier> prefixes);
 }
index f49f7ef5f40b2ad47213a0c682fd1bf4d4901aaf..c56560ac75f074f9ba735916c6a709e6f0de62c0 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.controller.sal.connector.api;
 import java.util.concurrent.Future;
 
 /**
+ * Interface for an RPC router.
  *
  * @author ttkacik
  *
@@ -19,31 +20,30 @@ import java.util.concurrent.Future;
  * @param <D> Data Type
  */
 public interface RpcRouter<C,T,R,D> {
-
-
-
     Future<RpcReply<D>> sendRpc(RpcRequest<C, T, R, D> input);
 
 
     /**
-     *
-     * @author
+     * Interface for an RPC request.
      *
      * @param <C> Routing Context Identifier
-        * @param <R> Route Type
-        * @param <T> Rpc Type
-        * @param <D> Data Type
+     * @param <R> Route Type
+     * @param <T> Rpc Type
+     * @param <D> Data Type
      */
     interface RpcRequest<C,T,R,D> {
 
         RouteIdentifier<C,T,R> getRoutingInformation();
+
         D getPayload();
     }
 
     interface RouteIdentifier<C,T,R> {
 
         C getContext(); // defines a routing table (e.g. NodeContext)
+
         T getType(); // rpc type
+
         R getRoute(); // e.g. (node identity)
     }
 
index 2cd5b97ceb45c3b9c2755337ce09f06932fc93ca..db9515b43ea215814d0c733d0141b56fbc4d2dd9 100644 (file)
@@ -24,10 +24,11 @@ import org.opendaylight.controller.cluster.raft.messages.RequestVoteReply;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class DummyShard extends UntypedActor{
+public class DummyShard extends UntypedActor {
+    private static final Logger LOG = LoggerFactory.getLogger(DummyShard.class);
+
     private final Configuration configuration;
     private final String followerId;
-    private final Logger LOG = LoggerFactory.getLogger(DummyShard.class);
     private long lastMessageIndex  = -1;
     private long lastMessageSize = 0;
     private Stopwatch appendEntriesWatch;
@@ -39,16 +40,16 @@ public class DummyShard extends UntypedActor{
     }
 
     @Override
-    public void onReceive(Object o) throws Exception {
-        if(o instanceof RequestVote){
-            RequestVote req = (RequestVote) o;
+    public void onReceive(Object message) throws Exception {
+        if (message instanceof RequestVote) {
+            RequestVote req = (RequestVote) message;
             sender().tell(new RequestVoteReply(req.getTerm(), true), self());
-        } else if(o instanceof AppendEntries) {
-            handleAppendEntries((AppendEntries)o);
-        } else if(o instanceof InstallSnapshot){
-            handleInstallSnapshot((InstallSnapshot) o);
+        } else if (message instanceof AppendEntries) {
+            handleAppendEntries((AppendEntries) message);
+        } else if (message instanceof InstallSnapshot) {
+            handleInstallSnapshot((InstallSnapshot) message);
         } else {
-            LOG.error("Unknown message : {}", o.getClass());
+            LOG.error("Unknown message : {}", message.getClass());
         }
     }
 
@@ -60,11 +61,11 @@ public class DummyShard extends UntypedActor{
         LOG.info("{} - Received AppendEntries message : leader term = {}, index = {}, prevLogIndex = {}, size = {}",
                 followerId, req.getTerm(),req.getLeaderCommit(), req.getPrevLogIndex(), req.getEntries().size());
 
-        if(appendEntriesWatch != null){
+        if (appendEntriesWatch != null) {
             long elapsed = appendEntriesWatch.elapsed(TimeUnit.SECONDS);
-            if(elapsed >= 5){
-                LOG.error("More than 5 seconds since last append entry, elapsed Time = {} seconds" +
-                                ", leaderCommit = {}, prevLogIndex = {}, size = {}",
+            if (elapsed >= 5) {
+                LOG.error("More than 5 seconds since last append entry, elapsed Time = {} seconds"
+                                ", leaderCommit = {}, prevLogIndex = {}, size = {}",
                         elapsed, req.getLeaderCommit(), req.getPrevLogIndex(), req.getEntries().size());
             }
             appendEntriesWatch.reset().start();
@@ -72,8 +73,9 @@ public class DummyShard extends UntypedActor{
             appendEntriesWatch = Stopwatch.createStarted();
         }
 
-        if(lastMessageIndex == req.getLeaderCommit() && req.getEntries().size() > 0 && lastMessageSize > 0){
-            LOG.error("{} - Duplicate message with leaderCommit = {} prevLogIndex = {} received", followerId, req.getLeaderCommit(), req.getPrevLogIndex());
+        if (lastMessageIndex == req.getLeaderCommit() && req.getEntries().size() > 0 && lastMessageSize > 0) {
+            LOG.error("{} - Duplicate message with leaderCommit = {} prevLogIndex = {} received", followerId,
+                    req.getLeaderCommit(), req.getPrevLogIndex());
         }
 
         lastMessageIndex = req.getLeaderCommit();
@@ -81,7 +83,7 @@ public class DummyShard extends UntypedActor{
 
         long lastIndex = req.getLeaderCommit();
         if (req.getEntries().size() > 0) {
-            for(ReplicatedLogEntry entry : req.getEntries()) {
+            for (ReplicatedLogEntry entry : req.getEntries()) {
                 lastIndex = entry.getIndex();
             }
         }
@@ -128,5 +130,4 @@ public class DummyShard extends UntypedActor{
             return new DummyShard(configuration, followerId);
         }
     }
-
 }
index 339f37e0bbe632c3c76bf09d94be1fbe71dcd9a1..abc73db9ed741c30e3c8c2d12f53ba963707cee7 100644 (file)
@@ -14,16 +14,17 @@ import akka.actor.UntypedActor;
 import akka.japi.Creator;
 
 public class DummyShardManager extends UntypedActor {
-    public DummyShardManager(Configuration configuration, String memberName, String[] shardNames, String type) throws Exception {
+    public DummyShardManager(Configuration configuration, String memberName, String[] shardNames,
+            String type) throws Exception {
         new DummyShardsCreator(configuration, context(), memberName, shardNames, type).create();
     }
 
     @Override
-    public void onReceive(Object o) throws Exception {
+    public void onReceive(Object message) throws Exception {
 
     }
 
-    public static Props props(Configuration configuration, String memberName, String[] shardNames, String type){
+    public static Props props(Configuration configuration, String memberName, String[] shardNames, String type) {
         return Props.create(new DummyShardManagerCreator(configuration, memberName, shardNames, type));
     }
 
@@ -34,7 +35,7 @@ public class DummyShardManager extends UntypedActor {
         private final String[] shardNames;
         private final String type;
 
-        public DummyShardManagerCreator(Configuration configuration, String memberName, String[] shardNames, String type) {
+        DummyShardManagerCreator(Configuration configuration, String memberName, String[] shardNames, String type) {
             this.configuration = configuration;
             this.memberName = memberName;
             this.shardNames = shardNames;
@@ -43,7 +44,7 @@ public class DummyShardManager extends UntypedActor {
 
         @Override
         public DummyShardManager create() throws Exception {
-            return new DummyShardManager(configuration, memberName, shardNames, type );
+            return new DummyShardManager(configuration, memberName, shardNames, type);
         }
     }
 
@@ -54,7 +55,8 @@ public class DummyShardManager extends UntypedActor {
         private final String[] shardNames;
         private final String type;
 
-        DummyShardsCreator(Configuration configuration, ActorContext actorSystem, String memberName, String[] shardNames, String type){
+        DummyShardsCreator(Configuration configuration, ActorContext actorSystem, String memberName,
+                String[] shardNames, String type) {
             this.configuration = configuration;
             this.actorSystem = actorSystem;
             this.memberName = memberName;
@@ -62,8 +64,8 @@ public class DummyShardManager extends UntypedActor {
             this.type = type;
         }
 
-        void create(){
-            for(String shardName : shardNames){
+        void create() {
+            for (String shardName : shardNames) {
                 String shardId = memberName + "-shard-" + shardName + "-" + type;
                 actorSystem.actorOf(DummyShard.props(configuration, shardId), shardId);
             }
index 81da1f89a645d529ef12ed10135a29416f7dfc17..3342b5de8b519e19f94582098761430a545b2542 100644 (file)
@@ -10,42 +10,45 @@ package org.opendaylight.controller.dummy.datastore;
 
 import akka.actor.ActorSystem;
 import com.typesafe.config.ConfigFactory;
+import org.kohsuke.args4j.CmdLineException;
 import org.kohsuke.args4j.CmdLineParser;
 import org.kohsuke.args4j.Option;
 
 public class Main {
-    @Option(name="-member-name", usage="Sets the member name", required = true)
+    @Option(name = "-member-name", usage = "Sets the member name", required = true)
     public String memberName;
 
-    @Option(name="-max-delay-millis", usage = "Sets the maximum delay that should be applied for any append entry. Only applies when cause-trouble is present.")
+    @Option(name = "-max-delay-millis", usage = "Sets the maximum delay that should be applied for any append entry. "
+            + "Only applies when cause-trouble is present.")
     public int maxDelayInMillis = 500;
 
-    @Option(name="-cause-trouble", usage="If present turns on artificial failures")
+    @Option(name = "-cause-trouble", usage = "If present turns on artificial failures")
     public boolean causeTrouble = false;
 
-    @Option(name="-drop-replies", usage = "If present drops replies. Only applies when cause-trouble is present.")
+    @Option(name = "-drop-replies", usage = "If present drops replies. Only applies when cause-trouble is present.")
     public boolean dropReplies = false;
 
-    public void run(){
-        ActorSystem actorSystem = ActorSystem.create("opendaylight-cluster-data", ConfigFactory.load(memberName).getConfig("odl-cluster-data"));
+    public void run() {
+        ActorSystem actorSystem = ActorSystem.create("opendaylight-cluster-data",
+                ConfigFactory.load(memberName).getConfig("odl-cluster-data"));
 
         Configuration configuration = new Configuration(maxDelayInMillis, dropReplies, causeTrouble);
 
-        actorSystem.actorOf(DummyShardManager.props(configuration, memberName, new String[] {"inventory", "default", "toaster", "topology"}, "operational"), "shardmanager-operational");
-        actorSystem.actorOf(DummyShardManager.props(configuration, memberName, new String[] {"inventory", "default", "toaster", "topology"}, "config"), "shardmanager-config");
+        actorSystem.actorOf(DummyShardManager.props(configuration, memberName,
+                new String[] {"inventory", "default", "toaster", "topology"}, "operational"),
+                "shardmanager-operational");
+        actorSystem.actorOf(DummyShardManager.props(configuration, memberName,
+                new String[] {"inventory", "default", "toaster", "topology"}, "config"), "shardmanager-config");
     }
 
     @Override
     public String toString() {
-        return "Main{" +
-                "memberName='" + memberName + '\'' +
-                ", maxDelayInMillis=" + maxDelayInMillis +
-                ", causeTrouble=" + causeTrouble +
-                ", dropReplies=" + dropReplies +
-                '}';
+        return "Main{" + "memberName='" + memberName + '\'' + ", maxDelayInMillis=" + maxDelayInMillis
+                + ", causeTrouble=" + causeTrouble + ", dropReplies=" + dropReplies + '}';
     }
 
-    public static void main(String[] args){
+    @SuppressWarnings("checkstyle:RegexpSingleLineJava")
+    public static void main(String[] args) {
         Main bean = new Main();
         CmdLineParser parser = new CmdLineParser(bean);
 
@@ -53,10 +56,9 @@ public class Main {
             parser.parseArgument(args);
             System.out.println(bean.toString());
             bean.run();
-        } catch(Exception e){
+        } catch (CmdLineException e) {
             System.err.println(e.getMessage());
             parser.printUsage(System.err);
         }
     }
-
 }