Package org.jscsi.exception

Examples of org.jscsi.exception.InternetSCSIException


    /** {@inheritDoc} */
    public final void execute () throws InternetSCSIException {

        final ProtocolDataUnit protocolDataUnit = connection.receive();

        if (!(protocolDataUnit.getBasicHeaderSegment().getParser() instanceof LogoutResponseParser)) { throw new InternetSCSIException("This PDU type (" + protocolDataUnit.getBasicHeaderSegment().getParser() + ") is not expected. "); }

        final LogoutResponseParser parser = (LogoutResponseParser) protocolDataUnit.getBasicHeaderSegment().getParser();

        if (parser.getResponse() == LogoutResponse.CONNECTION_CLOSED_SUCCESSFULLY) {
            // exception rethrow
            try {
                // FIXME: Implement Connection close
                connection.getSession().close();
            } catch (IOException e) {
                throw new InternetSCSIException("Closing the connection throws this error: " + e.getLocalizedMessage());
            }
        } else {
            throw new InternetSCSIException("The connection could not be closed successfully.");
        }

        // return false;
    }
View Full Code Here


             * This is an error. The jSCSI Target does not send NOP-In ping messages, which would be the only legal
             * reason for the initiator sending a NOP-Out with the TargetTransferTag equal to 0xffffffff. And even if
             * the jSCSI Target was sending pings, the echo would be processed in a dedicated stage. Therefore, we treat
             * this as an error. Close the connection.
             */
            throw new InternetSCSIException("NOP-Out PDU TargetTransferTag = " + parser.getTargetTransferTag() + " in PingStage");
        }

        // decide whether or not response is necessary
        if (bhs.getInitiatorTaskTag() == RESERVED_TAG_VALUE) return;// send no response

View Full Code Here

                case WELL_KNOWN_LUNS_ONLY :
                case ALL :
                    reportLunsParameterData = new ReportLunsParameterData(session.getTargetServer().getConfig().getLogicalUnitNumber());
                    break;
                default :
                    throw new InternetSCSIException();
                    /*
                     * Unreachable, this case has already been checked in the ReportLunsCDB constructor
                     */
            }

View Full Code Here

     * @return The length (in bytes), which are read from <code>pdu</code>.
     * @throws InternetSCSIException If any violation of the iSCSI-Standard emerge.
     */
    final int deserialize (final ProtocolDataUnit protocolDataUnit, final ByteBuffer src) throws InternetSCSIException {

        if (src.remaining() < BHS_FIXED_SIZE) { throw new InternetSCSIException("This Protocol Data Unit does not contain" + " an valid Basic Header Segment."); }

        final int firstLine = src.getInt();
        immediateFlag = Utils.isBitSet(firstLine & IMMEDIATE_FLAG_MASK);
        final int code = (firstLine & OPERATION_CODE_MASK) >> Constants.THREE_BYTES_SHIFT;
        operationCode = OperationCode.valueOf((byte) code);
View Full Code Here

            case EXTENDED_CDB :
            case EXPECTED_BIDIRECTIONAL_READ_DATA_LENGTH :
                break;

            default :
                throw new InternetSCSIException("AHS Package is not valid.");
        }

        // this field is AHSType independent
        specificField.rewind();
        Utils.isReserved(specificField.get());

        switch (type) {
            case EXTENDED_CDB :
                break;

            case EXPECTED_BIDIRECTIONAL_READ_DATA_LENGTH :
                Utils.isExpected(specificField.limit(), EXPECTED_BIDIRECTIONAL_SPECIFIC_FIELD_LENGTH);
                Utils.isExpected(length, EXPECTED_BIDIRECTIONAL_LENGTH);
                break;

            default :
                throw new InternetSCSIException("Unknown additional header segment type.");
        }

        specificField.rewind();
    }
View Full Code Here

            // message is checked correctly
            return;
        } while (false);

        throw new InternetSCSIException(exceptionMessage);
    }
View Full Code Here

                            break;
                        case DEVICE_IDENTIFICATION :
                            responseData = session.getTargetServer().getDeviceIdentificationVpdPage();
                            break;
                        default :
                            throw new InternetSCSIException();
                    }
                }

                // The part from the targetfullfeaturephase
View Full Code Here

                connection = new TargetConnection(socketChannel, true);
                try {
                    final ProtocolDataUnit pdu = connection.receivePdu();
                    // confirm OpCode-
                    if (pdu.getBasicHeaderSegment().getOpCode() != OperationCode.LOGIN_REQUEST) throw new InternetSCSIException();
                    // get initiatorSessionID
                   
                    LoginRequestParser parser = (LoginRequestParser) pdu.getBasicHeaderSegment().getParser();
                    ISID initiatorSessionID = parser.getInitiatorSessionID();
View Full Code Here

            default :
                exceptionMessage = "This format is not supported.";
        }

        if (exceptionMessage.length() > 0) {
            throw new InternetSCSIException(exceptionMessage);
        } else {
            // no error occured... Nice! :-)
        }
    }
View Full Code Here

            // split the key and value of a key-value pair
            String[] keyValue;
            for (int i = 0; i < data.length; i++) {
                keyValue = data[i].split(KEY_VALUE_DELIMITER);
                if (keyValue.length != NUMBER_OF_TOKENS) { throw new InternetSCSIException("This PDU does not contain a valid key-value-pair."); }

                settings.add(OperationalTextKey.valueOfEx(keyValue[KEY_INDEX]), keyValue[VALUE_INDEX]);
            }
        } catch (UnsupportedEncodingException e) {
            if (LOGGER.isErrorEnabled()) {
                LOGGER.error("Unsupported Encoding: " + e.getLocalizedMessage());
            }

            // exception rethrow
            throw new InternetSCSIException(e.getMessage());
        }

    }
View Full Code Here

TOP

Related Classes of org.jscsi.exception.InternetSCSIException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.