Fix checkstyle error for java 8 build success
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / HandshakeManagerImpl.java
index 179178b230def4974f0e4136408ae10d1566ca24..0a4e98c47d8204b266a72d09db9b5fb6a0ae3cd3 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.openflowplugin.openflow.md.core;
 import java.util.List;
 import java.util.Objects;
 import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
 
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
 import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor;
@@ -39,6 +38,8 @@ import com.google.common.util.concurrent.SettableFuture;
  */
 public class HandshakeManagerImpl implements HandshakeManager {
 
+    private static final long activeXID = 20L;
+
     private static final Logger LOG = LoggerFactory
             .getLogger(HandshakeManagerImpl.class);
 
@@ -51,8 +52,8 @@ public class HandshakeManagerImpl implements HandshakeManager {
     private Short version;
     private ErrorHandler errorHandler;
 
-    private long maxTimeout = 8000;
-    private TimeUnit maxTimeoutUnit = TimeUnit.MILLISECONDS;
+
+
     private Short highestVersion;
 
     private Long activeXid;
@@ -62,9 +63,9 @@ public class HandshakeManagerImpl implements HandshakeManager {
     private boolean useVersionBitmap;
 
     /**
-     * @param connectionAdapter
-     * @param highestVersion
-     * @param versionOrder
+     * @param connectionAdapter connection adaptor for switch
+     * @param highestVersion highest openflow version
+     * @param versionOrder list of version in order for connection protocol negotiation
      */
     public HandshakeManagerImpl(ConnectionAdapter connectionAdapter, Short highestVersion,
             List<Short> versionOrder) {
@@ -90,7 +91,7 @@ public class HandshakeManagerImpl implements HandshakeManager {
         }
 
         LOG.trace("handshake STARTED");
-        setActiveXid(20L);
+        setActiveXid(activeXID);
 
         try {
             if (receivedHello == null) {
@@ -124,8 +125,8 @@ public class HandshakeManagerImpl implements HandshakeManager {
     }
 
     /**
-     * @param remoteVersion
-     * @throws Exception
+     * @param remoteVersion remote version
+     * @throws Exception exception
      */
     private void handleStepByStepVersionNegotiation(final Short remoteVersion) throws Exception {
         LOG.debug("remoteVersion:{} lastProposedVersion:{}, highestVersion:{}",
@@ -160,7 +161,7 @@ public class HandshakeManagerImpl implements HandshakeManager {
     }
 
     private void stepByStepVersionSubStep(Short remoteVersion, Short lastProposedVersion) throws Exception {
-        if (remoteVersion == lastProposedVersion) {
+        if (remoteVersion.equals(lastProposedVersion)) {
             postHandshake(lastProposedVersion, getNextXid());
             LOG.trace("ret - OK - switch answered with lastProposedVersion");
         } else {
@@ -177,8 +178,8 @@ public class HandshakeManagerImpl implements HandshakeManager {
     }
 
     /**
-     * @param remoteVersion
-     * @throws Exception
+     * @param remoteVersion remote version
+     * @throws Exception exception
      */
     private void handleLowerVersionProposal(Short remoteVersion) throws Exception {
         Short proposedVersion;
@@ -196,8 +197,8 @@ public class HandshakeManagerImpl implements HandshakeManager {
     }
 
     /**
-     * @param elements
-     * @throws Exception
+     * @param elements version elements
+     * @throws Exception exception
      */
     private void handleVersionBitmapNegotiation(List<Elements> elements) throws Exception {
         final Short proposedVersion = proposeCommonBitmapVersion(elements);
@@ -226,7 +227,7 @@ public class HandshakeManagerImpl implements HandshakeManager {
 
     /**
      *
-     * @return
+     * @return next tx id
      */
     private Long getNextXid() {
         activeXid += 1;
@@ -234,14 +235,14 @@ public class HandshakeManagerImpl implements HandshakeManager {
     }
 
     /**
-     * @param xid
+     * @param xid tx id
      */
     private void setActiveXid(Long xid) {
         this.activeXid = xid;
     }
 
     /**
-     * @param remoteVersion
+     * @param remoteVersion remove version
      */
     private void checkNegotiationStalling(Short remoteVersion) {
         if (lastReceivedVersion != null && lastReceivedVersion.equals(remoteVersion)) {
@@ -257,8 +258,8 @@ public class HandshakeManagerImpl implements HandshakeManager {
 
     /**
      * find common highest supported bitmap version
-     * @param list
-     * @return
+     * @param list bitmap list
+     * @return proposed bitmap value
      */
     protected Short proposeCommonBitmapVersion(List<Elements> list) {
         Short supportedHighestVersion = null;
@@ -286,8 +287,8 @@ public class HandshakeManagerImpl implements HandshakeManager {
 
     /**
      * find supported version based on remoteVersion
-     * @param remoteVersion
-     * @return
+     * @param remoteVersion openflow version supported by remote entity
+     * @return openflow version
      */
     protected short proposeNextVersion(short remoteVersion) {
         Short proposal = null;
@@ -306,13 +307,13 @@ public class HandshakeManagerImpl implements HandshakeManager {
 
     /**
      * send hello reply without versionBitmap
-     * @param helloVersion
-     * @param helloXid
+     * @param helloVersion initial hello version for openflow connection negotiation
+     * @param helloXid transaction id
      * @throws Exception
      */
     private ListenableFuture<Void> sendHelloMessage(Short helloVersion, final Long helloXid) throws Exception {
-        
-        
+
+
         HelloInput helloInput = MessageFactory.createHelloInput(helloVersion, helloXid, versionOrder);
 
         final SettableFuture<Void> resultFtr = SettableFuture.create();
@@ -359,8 +360,8 @@ public class HandshakeManagerImpl implements HandshakeManager {
 
     /**
      * after handshake set features, register to session
-     * @param proposedVersion
-     * @param xid
+     * @param proposedVersion proposed openflow version
+     * @param xid transaction id
      */
     protected void postHandshake(final Short proposedVersion, final Long xid) {
         // set version