/** {@inheritDoc} */
public final void execute () throws InternetSCSIException {
ProtocolDataUnit protocolDataUnit;
final IDataSegment loginResponse = DataSegmentFactory.create(DataSegmentFormat.TEXT, connection.getSettingAsInt(OperationalTextKey.MAX_RECV_DATA_SEGMENT_LENGTH));
do {
protocolDataUnit = connection.receive();
if (!(protocolDataUnit.getBasicHeaderSegment().getParser() instanceof LoginResponseParser)) {
break;
}
loginResponse.append(protocolDataUnit.getDataSegment(), protocolDataUnit.getBasicHeaderSegment().getDataSegmentLength());
} while (!protocolDataUnit.getBasicHeaderSegment().isFinalFlag());
// extract Target Session Handle Identifying Handle
final LoginResponseParser parser = (LoginResponseParser) protocolDataUnit.getBasicHeaderSegment().getParser();
connection.getSession().setTargetSessionIdentifyingHandle(parser.getTargetSessionIdentifyingHandle());
// Set the Expected Status Sequence Number to the initial value received
// from the target. Then add the constant 2 to this value, because the
// incrementExpectedStatusSequence() method was already invoked.
connection.setExpectedStatusSequenceNumber(parser.getStatusSequenceNumber() + 1);// TODO was +2
// check parameters....
LOGGER.info("Retrieving these login parameters:\n" + loginResponse.getSettings());
connection.update(loginResponse.getSettings());
LOGGER.info("Updated settings to these:\n" + connection.getSettings());
LOGGER.info("Nextstage is : " + nextStage);
// is a transit to the next stage possible