X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fopenflow%2Fmd%2Fcore%2FHandshakeManagerImpl.java;h=9392e8ee7eea9b6ab175af0ce2a39ddc5c00e1fb;hb=6e5df2b3308ffdc906dc1ef84a4ddde37f8080f6;hp=db955001ea46f46548912f07eaed7225d6bba2a4;hpb=f4157da212b437a7732f17c9c32fec7c9e93aee0;p=openflowplugin.git diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/HandshakeManagerImpl.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/HandshakeManagerImpl.java index db955001ea..9392e8ee7e 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/HandshakeManagerImpl.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/HandshakeManagerImpl.java @@ -7,12 +7,16 @@ */ package org.opendaylight.openflowplugin.openflow.md.core; +import com.google.common.util.concurrent.FutureCallback; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.JdkFutureAdapters; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.SettableFuture; import java.util.List; import java.util.Objects; import java.util.concurrent.Future; - import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter; -import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor; +import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.openflowplugin.api.openflow.md.core.ErrorHandler; import org.opendaylight.openflowplugin.api.openflow.md.core.HandshakeListener; import org.opendaylight.openflowplugin.api.openflow.md.core.HandshakeManager; @@ -26,18 +30,10 @@ import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.JdkFutureAdapters; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.SettableFuture; - -/** - * @author mirehak - * - */ public class HandshakeManagerImpl implements HandshakeManager { + private static final long activeXID = 20L; + private static final Logger LOG = LoggerFactory .getLogger(HandshakeManagerImpl.class); @@ -61,9 +57,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 versionOrder) { @@ -89,7 +85,7 @@ public class HandshakeManagerImpl implements HandshakeManager { } LOG.trace("handshake STARTED"); - setActiveXid(20L); + setActiveXid(activeXID); try { if (receivedHello == null) { @@ -116,15 +112,15 @@ public class HandshakeManagerImpl implements HandshakeManager { handleStepByStepVersionNegotiation(remoteVersion); } } catch (Exception ex) { - errorHandler.handleException(ex, null); + errorHandler.handleException(ex); LOG.trace("ret - shake fail - closing"); handshakeListener.onHandshakeFailure(); } } /** - * @param remoteVersion - * @throws Exception + * @param remoteVersion remote version + * @throws Exception exception */ private void handleStepByStepVersionNegotiation(final Short remoteVersion) throws Exception { LOG.debug("remoteVersion:{} lastProposedVersion:{}, highestVersion:{}", @@ -142,7 +138,7 @@ public class HandshakeManagerImpl implements HandshakeManager { try { stepByStepVersionSubStep(remoteVersion, lastProposedVersion); } catch (Exception e) { - errorHandler.handleException(e, null); + errorHandler.handleException(e); handshakeListener.onHandshakeFailure(); } } @@ -176,8 +172,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; @@ -195,8 +191,8 @@ public class HandshakeManagerImpl implements HandshakeManager { } /** - * @param elements - * @throws Exception + * @param elements version elements + * @throws Exception exception */ private void handleVersionBitmapNegotiation(List elements) throws Exception { final Short proposedVersion = proposeCommonBitmapVersion(elements); @@ -225,7 +221,7 @@ public class HandshakeManagerImpl implements HandshakeManager { /** * - * @return + * @return next tx id */ private Long getNextXid() { activeXid += 1; @@ -233,14 +229,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)) { @@ -256,8 +252,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 list) { Short supportedHighestVersion = null; @@ -265,7 +261,7 @@ public class HandshakeManagerImpl implements HandshakeManager { for(Elements element : list) { List bitmap = element.getVersionBitmap(); // check for version bitmap - for(short bitPos : ConnectionConductor.versionOrder) { + for(short bitPos : OFConstants.VERSION_ORDER) { // with all the version it should work. if(bitmap.get(bitPos % Integer.SIZE)) { supportedHighestVersion = bitPos; @@ -285,8 +281,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; @@ -305,8 +301,8 @@ 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 sendHelloMessage(Short helloVersion, final Long helloXid) throws Exception { @@ -358,8 +354,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 @@ -387,7 +383,7 @@ public class HandshakeManagerImpl implements HandshakeManager { featureOutput.getAuxiliaryId()); LOG.trace("handshake SETTLED: version={}, datapathId={}, auxiliaryId={}", version, featureOutput.getDatapathId(), featureOutput.getAuxiliaryId()); - handshakeListener.onHandshakeSuccessfull(featureOutput, proposedVersion); + handshakeListener.onHandshakeSuccessful(featureOutput, proposedVersion); } else { // handshake failed LOG.warn("issuing disconnect during handshake [{}]", connectionAdapter.getRemoteAddress());