// --------------------------------------------------------------------------
/** {@inheritDoc} */
public final void execute () throws InternetSCSIException {
final ProtocolDataUnit protocolDataUnit = connection.receive();
// first, we extract capacity informations
if (!(protocolDataUnit.getBasicHeaderSegment().getParser() instanceof DataInParser)) {
// In newer versions of iscsi targets there the target tells the initiator
// that the status is cleared using a scsi response. It's defined in the RFC 3720 on page 78 (or
// at least mentioned, it's
// actually defined in SAM-2 and). This is why we have to ask for capacity informations once again
// receiving this
// Response to our capacity request.
if (protocolDataUnit.getBasicHeaderSegment().getParser() instanceof SCSIResponseParser) {
connection.nextState(new CapacityRequestState(connection, capacityInformation, TaskAttributes.SIMPLE));
super.stateFollowing = true;
return;
} else {
throw new InternetSCSIException(protocolDataUnit.getBasicHeaderSegment().getParser().getClass().getSimpleName() + " is not the expected type of PDU.");
}
}
/**
* The server responded using the data-in-parser.
*/
final DataInParser parser = (DataInParser) protocolDataUnit.getBasicHeaderSegment().getParser();
capacityInformation.deserialize(protocolDataUnit.getDataSegment());
if (!parser.isStatusFlag() || parser.getStatus() != SCSIStatus.GOOD) {
// receive SCSI Response PDU and check status (no phase
// collapse)
final ProtocolDataUnit scsiPdu = connection.receive();
if (scsiPdu.getBasicHeaderSegment().getOpCode() == OperationCode.SCSI_RESPONSE) {
final SCSIResponseParser scsiParser = (SCSIResponseParser) scsiPdu.getBasicHeaderSegment().getParser();
if (scsiParser.getStatus() == SCSIStatus.GOOD) return;// done
}
throw new InternetSCSIException("Error: Task did not finish successfully.");
}