*/
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;
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);
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) {
}
LOG.trace("handshake STARTED");
- setActiveXid(20L);
+ setActiveXid(activeXID);
try {
if (receivedHello == null) {
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:{}",
try {
stepByStepVersionSubStep(remoteVersion, lastProposedVersion);
} catch (Exception e) {
- errorHandler.handleException(e, null);
+ errorHandler.handleException(e);
handshakeListener.onHandshakeFailure();
}
}
}
/**
- * @param remoteVersion
- * @throws Exception
+ * @param remoteVersion remote version
+ * @throws Exception exception
*/
private void handleLowerVersionProposal(Short remoteVersion) throws Exception {
Short proposedVersion;
}
/**
- * @param elements
- * @throws Exception
+ * @param elements version elements
+ * @throws Exception exception
*/
private void handleVersionBitmapNegotiation(List<Elements> elements) throws Exception {
final Short proposedVersion = proposeCommonBitmapVersion(elements);
/**
*
- * @return
+ * @return next tx id
*/
private Long getNextXid() {
activeXid += 1;
}
/**
- * @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)) {
/**
* 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;
for(Elements element : list) {
List<Boolean> 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;
/**
* 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;
/**
* 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 {
/**
* 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
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());