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;
*/
public class HandshakeManagerImpl implements HandshakeManager {
+ private static final long activeXID = 20L;
+
private static final Logger LOG = LoggerFactory
.getLogger(HandshakeManagerImpl.class);
private Short version;
private ErrorHandler errorHandler;
- private long maxTimeout = 8000;
- private TimeUnit maxTimeoutUnit = TimeUnit.MILLISECONDS;
+
+
private Short highestVersion;
private Long activeXid;
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) {
}
/**
- * @param remoteVersion
- * @throws Exception
+ * @param remoteVersion remote version
+ * @throws Exception exception
*/
private void handleStepByStepVersionNegotiation(final Short remoteVersion) throws Exception {
LOG.debug("remoteVersion:{} lastProposedVersion:{}, highestVersion:{}",
}
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 {
}
/**
- * @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;
/**
* 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 {
-
-
+
+
HelloInput helloInput = MessageFactory.createHelloInput(helloVersion, helloXid, versionOrder);
final SettableFuture<Void> resultFtr = SettableFuture.create();
/**
* 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