/** * Read the payload from the buffer. * * @param buffer the buffer to read from. * @throws IOException if an error occures during payload finishing. */ private void readPayloadFromBuffer(final ByteBuffer buffer) throws IOException { int toRead = payload.length - payloadOffset; int available = buffer.remaining(); toRead = Math.min(toRead, available); getLogger().debug("Reading %d payload bytes", toRead); buffer.get(payload, payloadOffset, toRead); payloadOffset += toRead; if (payloadOffset == payload.length) { finishedPayload(payload); } }
/** * Read the payload from the buffer. * * @param buffer the buffer to read from. * @throws IOException if an error occures during payload finishing. */ private void readPayloadFromBuffer(final ByteBuffer buffer) throws IOException { int toRead = payload.length - payloadOffset; int available = buffer.remaining(); toRead = Math.min(toRead, available); getLogger().debug("Reading %d payload bytes", toRead); buffer.get(payload, payloadOffset, toRead); payloadOffset += toRead; if (payloadOffset == payload.length) { finishedPayload(payload); } }
@Override protected void finishedPayload(byte[] pl) throws IOException { if (errorCode == SASL_CONTINUE) { getCallback().receivedStatus(new OperationStatus(true, new String(pl))); transitionState(OperationState.COMPLETE); } else if(errorCode == 0) { getCallback().receivedStatus(new OperationStatus(true, "")); transitionState(OperationState.COMPLETE); } else { super.finishedPayload(pl); } }
@Override protected void finishedPayload(byte[] pl) throws IOException { if (errorCode == SASL_CONTINUE) { getCallback().receivedStatus(new OperationStatus(true, new String(pl))); transitionState(OperationState.COMPLETE); } else if (errorCode == 0) { getCallback().receivedStatus(new OperationStatus(true, "")); transitionState(OperationState.COMPLETE); } else { super.finishedPayload(pl); } }
@Override protected void finishedPayload(byte[] pl) throws IOException { if (errorCode == SASL_CONTINUE) { getCallback().receivedStatus(new OperationStatus(true, new String(pl), StatusCode.SUCCESS)); transitionState(OperationState.COMPLETE); } else if (errorCode == 0) { getCallback().receivedStatus(new OperationStatus(true, "", StatusCode.SUCCESS)); transitionState(OperationState.COMPLETE); } else { super.finishedPayload(pl); } }
@Override protected void finishedPayload(byte[] pl) throws IOException { if (errorCode == SASL_CONTINUE) { getCallback().receivedStatus(new OperationStatus(true, new String(pl))); transitionState(OperationState.COMPLETE); } else if (errorCode == 0) { getCallback().receivedStatus(new OperationStatus(true, "")); transitionState(OperationState.COMPLETE); } else { super.finishedPayload(pl); } }
@Override protected void finishedPayload(byte[] pl) throws IOException { if (errorCode == SASL_CONTINUE) { getCallback().receivedStatus(new OperationStatus(true, new String(pl), StatusCode.SUCCESS)); transitionState(OperationState.COMPLETE); } else if (errorCode == 0) { getCallback().receivedStatus(new OperationStatus(true, "", StatusCode.SUCCESS)); transitionState(OperationState.COMPLETE); } else { super.finishedPayload(pl); } }
finishedPayload(EMPTY_BYTES); } else if (payload != null) { int toRead = payload.length - payloadOffset; finishedPayload(payload);
finishedPayload(EMPTY_BYTES); } else if (payload != null) { int toRead = payload.length - payloadOffset; finishedPayload(payload);
finishedPayload(EMPTY_BYTES); } else if(payload != null) { int toRead=payload.length - payloadOffset; finishedPayload(payload);
finishedPayload(EMPTY_BYTES); } else if(payload != null) { int toRead=payload.length - payloadOffset; finishedPayload(payload);
/** * Read from the incoming {@link ByteBuffer}. * * Reading from the buffer is done in stages, depending on how much data * can be read at once. First, the header is read and then parsed (24 * bytes, indicated by {@link #MIN_RECV_PACKET}). Then, the payload is read * (if one is available for this operation and can be loaded fully). * * @param buffer the buffer to read from. * @throws IOException if an error happened during parsing/reading. */ @Override public void readFromBuffer(final ByteBuffer buffer) throws IOException { if (headerOffset < MIN_RECV_PACKET) { readHeaderFromBuffer(buffer); if (headerOffset == MIN_RECV_PACKET) { parseHeaderFromBuffer(); } } if (headerOffset >= MIN_RECV_PACKET && payload == null) { finishedPayload(EMPTY_BYTES); } else if (payload != null) { readPayloadFromBuffer(buffer); } else { getLogger().debug("Only read %d of the %d needed to fill a header", headerOffset, MIN_RECV_PACKET); } }
/** * Read from the incoming {@link ByteBuffer}. * * Reading from the buffer is done in stages, depending on how much data * can be read at once. First, the header is read and then parsed (24 * bytes, indicated by {@link #MIN_RECV_PACKET}). Then, the payload is read * (if one is available for this operation and can be loaded fully). * * @param buffer the buffer to read from. * @throws IOException if an error happened during parsing/reading. */ @Override public void readFromBuffer(final ByteBuffer buffer) throws IOException { if (headerOffset < MIN_RECV_PACKET) { readHeaderFromBuffer(buffer); if (headerOffset == MIN_RECV_PACKET) { parseHeaderFromBuffer(); } } if (headerOffset >= MIN_RECV_PACKET && payload == null) { finishedPayload(EMPTY_BYTES); } else if (payload != null) { readPayloadFromBuffer(buffer); } else { getLogger().debug("Only read %d of the %d needed to fill a header", headerOffset, MIN_RECV_PACKET); } }