once switch role is configured. Currently application were getting notified when switch Description message
received by the controller, and application assume that switch is configured and ready to use.
This patch, send the desc request when switch role is configured and it's ready to use
Change-Id: I8a02c209c4796b7aa01161257d523139fdc9c881
Signed-off-by: Anil Vishnoi <vishnoianil@gmail.com>
*/
Optional<BigInteger> sendEmptyTableFeatureRequest();
+ /**
+ * Method send port/desc multipart request to the switch to fetch the initial details.
+ */
+
+ public abstract void requestSwitchDetails();
+
}
import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
import org.opendaylight.openflowplugin.openflow.md.core.session.PortFeaturesUtil;
import org.opendaylight.openflowplugin.openflow.md.queue.QueueKeeperFactory;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatus;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortDescCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEvent;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEvent;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener;
public void onHandshakeSuccessfull(GetFeaturesOutput featureOutput,
Short negotiatedVersion) {
postHandshakeBasic(featureOutput, negotiatedVersion);
-
- // post-handshake actions
- if (version == OFConstants.OFP_VERSION_1_3) {
- requestPorts();
- }
-
- requestDesc();
}
@Override
OFSessionUtil.setRole(sessionContext);
}
- /*
- * Send an OFPMP_DESC request message to the switch
- */
- private void requestDesc() {
- MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
- builder.setType(MultipartType.OFPMPDESC);
- builder.setVersion(getVersion());
- builder.setFlags(new MultipartRequestFlags(false));
- builder.setMultipartRequestBody(new MultipartRequestDescCaseBuilder()
- .build());
- builder.setXid(getSessionContext().getNextXid());
- getConnectionAdapter().multipartRequest(builder.build());
- }
-
- private void requestPorts() {
- MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
- builder.setType(MultipartType.OFPMPPORTDESC);
- builder.setVersion(getVersion());
- builder.setFlags(new MultipartRequestFlags(false));
- builder.setMultipartRequestBody(new MultipartRequestPortDescCaseBuilder()
- .build());
- builder.setXid(getSessionContext().getNextXid());
- getConnectionAdapter().multipartRequest(builder.build());
- }
-
- private void requestGroupFeatures() {
- MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
- mprInput.setType(MultipartType.OFPMPGROUPFEATURES);
- mprInput.setVersion(getVersion());
- mprInput.setFlags(new MultipartRequestFlags(false));
- mprInput.setXid(getSessionContext().getNextXid());
-
- MultipartRequestGroupFeaturesCaseBuilder mprGroupFeaturesBuild = new MultipartRequestGroupFeaturesCaseBuilder();
- mprInput.setMultipartRequestBody(mprGroupFeaturesBuild.build());
-
- LOG.debug("Send group features statistics request :{}",
- mprGroupFeaturesBuild);
- getConnectionAdapter().multipartRequest(mprInput.build());
-
- }
-
- private void requestMeterFeatures() {
- MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
- mprInput.setType(MultipartType.OFPMPMETERFEATURES);
- mprInput.setVersion(getVersion());
- mprInput.setFlags(new MultipartRequestFlags(false));
- mprInput.setXid(getSessionContext().getNextXid());
-
- MultipartRequestMeterFeaturesCaseBuilder mprMeterFeaturesBuild = new MultipartRequestMeterFeaturesCaseBuilder();
- mprInput.setMultipartRequestBody(mprMeterFeaturesBuild.build());
-
- LOG.debug("Send meter features statistics request :{}",
- mprMeterFeaturesBuild);
- getConnectionAdapter().multipartRequest(mprInput.build());
-
- }
-
/**
* @param isBitmapNegotiationEnable the isBitmapNegotiationEnable to set
*/
newRole = OfpRole.BECOMESLAVE;
if (sessionContext != null) {
final BigInteger targetSwitchDPId = sessionContext.getFeatures().getDatapathId();
- LOG.info("setSlaveRole: Set controller as a SLAVE controller for {}", targetSwitchDPId.toString());
+ LOG.debug("setSlaveRole: Set controller as a SLAVE controller for {}", targetSwitchDPId.toString());
RolePushTask task = new RolePushTask(newRole, sessionContext);
ListenableFuture<Boolean> rolePushResult = pool.submit(task);
Futures.addCallback(rolePushResult, new FutureCallback<Boolean>(){
@Override
public void onSuccess(Boolean result){
- LOG.info("setSlaveRole: Controller is set as a SLAVE for {}", targetSwitchDPId.toString());
+ LOG.debug("setSlaveRole: Controller is set as a SLAVE for {}", targetSwitchDPId.toString());
}
@Override
public void onFailure(Throwable e){
}
});
} else {
- LOG.warn("setSlaveRole: sessionContext is not set. Session might have been removed");
+ LOG.warn("setSlaveRole: sessionContext is not set. Device is not connected anymore");
}
}
sendNodeAddedNotification(entsession.get(entity));
if(ownershipChange.wasOwner()) {
deregisterRoutedRPCForSwitch(entsession.get(entity));
- // You don't have to explictly set role to Slave in this case,
+ // You don't have to explicitly set role to Slave in this case,
// because other controller will be taking over the master role
// and that will force other controller to become slave.
}
- return;
}
-
+ return;
}
if (sessionContext != null) {
//Register the RPC, given *this* controller instance is going to be master owner.
}
});
} else {
- LOG.warn("onDeviceOwnershipChanged: sessionContext is not set. " +
- "Session might have been removed {}", entity);
+ LOG.warn("onDeviceOwnershipChanged: sessionContext is not available. Releasing ownership of the device");
+ EntityOwnershipCandidateRegistration ownershipRegistrent = entRegistrationMap.get(entity);
+ if (ownershipRegistrent != null) {
+ ownershipRegistrent.close();
+ }
}
}
entityMetadata.getContext().getNotificationEnqueuer().enqueueNotification(
entityMetadata.getWrappedNotification());
+
+ //Send multipart request to get other details of the switch.
+ entityMetadata.getOfSwitch().requestSwitchDetails();
}
private class MDSwitchMetaData {
import com.google.common.util.concurrent.ListenableFuture;
import java.math.BigInteger;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PacketOutConvertor;
import org.opendaylight.openflowplugin.api.openflow.md.core.session.IMessageDispatchService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortDescCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.ConnectionCookie;
OFRpcTask<SetConfigInput, RpcResult<SetConfigOutput>> task = OFRpcTaskFactory.createSetNodeConfigTask(rpcTaskContext, input, null);
return task.submit();
}
-
@Override
public Optional<BigInteger> sendEmptyTableFeatureRequest() {
LOG.debug("Send table feature request to {}",nodeId);
}
+ @Override
+ public void requestSwitchDetails(){
+ // post-handshake actions
+ if (version == OFConstants.OFP_VERSION_1_3) {
+ requestPorts();
+ }
+
+ requestDesc();
+ }
+
+ /*
+ * Send an OFPMP_DESC request message to the switch
+ */
+ private void requestDesc() {
+ MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
+ builder.setType(MultipartType.OFPMPDESC);
+ builder.setVersion(version);
+ builder.setFlags(new MultipartRequestFlags(false));
+ builder.setMultipartRequestBody(new MultipartRequestDescCaseBuilder()
+ .build());
+ builder.setXid(getSessionContext().getNextXid());
+ rpcTaskContext.getSession().getPrimaryConductor().getConnectionAdapter().multipartRequest(builder.build());
+ }
+
+ private void requestPorts() {
+ MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
+ builder.setType(MultipartType.OFPMPPORTDESC);
+ builder.setVersion(version);
+ builder.setFlags(new MultipartRequestFlags(false));
+ builder.setMultipartRequestBody(new MultipartRequestPortDescCaseBuilder()
+ .build());
+ builder.setXid(getSessionContext().getNextXid());
+ rpcTaskContext.getSession().getPrimaryConductor().getConnectionAdapter().multipartRequest(builder.build());
+ }
}
}
// here we expect that role on device is successfully possessed
+ LOG.info("Successfully pushing {} role to the device openflow:{}",
+ role==OfpRole.BECOMEMASTER?"MASTER":"SLAVE", dpId);
return true;
}
}
EventFactory.DEFAULT_VERSION, getFeatureResponseMsg()));
int i = 1;
- eventPlan.add(0, EventFactory.createDefaultWaitForRpcEvent(i++, "multipartRequestInput"));
- eventPlan.add(0, EventFactory.createDefaultWaitForRpcEvent(i++, "multipartRequestInput"));
executeNow();
Assert.assertEquals(ConnectionConductor.CONDUCTOR_STATE.WORKING,
eventPlan.add(0, EventFactory.createDefaultRpcResponseEvent(43,
EventFactory.DEFAULT_VERSION, getFeatureResponseMsg()));
- int i = 1;
- eventPlan.add(0, EventFactory.createDefaultWaitForRpcEvent(i++, "multipartRequestInput"));
- eventPlan.add(0, EventFactory.createDefaultWaitForRpcEvent(i++, "multipartRequestInput"));
-
executeNow();
Assert.assertEquals(ConnectionConductor.CONDUCTOR_STATE.WORKING,
eventPlan.add(0, EventFactory.createDefaultRpcResponseEvent(45,
(short) 0x01, getFeatureResponseMsg()));
- int i = 1;
- eventPlan.add(0, EventFactory.createDefaultWaitForRpcEvent(i++, "multipartRequestInput"));
-
executeNow();
Assert.assertEquals(ConnectionConductor.CONDUCTOR_STATE.WORKING,
eventPlan.add(0, EventFactory.createDefaultRpcResponseEvent(45,
(short) 0x01, getFeatureResponseMsg()));
- int i = 1;
- eventPlan.add(0, EventFactory.createDefaultWaitForRpcEvent(i++, "multipartRequestInput"));
-
executeNow();
Assert.assertEquals(ConnectionConductor.CONDUCTOR_STATE.WORKING,