private void initialize() throws IOException { try { if (direction == TransferDirection.RECEIVE) { // Indicate that we would like to have some data RequestType.RECEIVE_FLOWFILES.writeRequestType(dos); dos.flush(); final Response dataAvailableCode = Response.read(dis); switch (dataAvailableCode.getCode()) { case MORE_DATA: logger.debug("{} {} Indicates that data is available", this, peer); this.dataAvailable = true; break; case NO_MORE_DATA: logger.debug("{} No data available from {}", peer); this.dataAvailable = false; return; default: throw new ProtocolException("Got unexpected response when asking for data: " + dataAvailableCode); } } else { // Indicate that we would like to have some data RequestType.SEND_FLOWFILES.writeRequestType(dos); dos.flush(); } } catch (final Exception e) { error(); throw e; } }
public static Response read(final DataInputStream in) throws IOException, ProtocolException { final ResponseCode code = ResponseCode.readCode(in); final String message = code.containsMessage() ? in.readUTF() : null; return new Response(code, message); }
switch (confirmTransactionResponse.getCode()) { case CONFIRM_TRANSACTION: break; if (transactionConfirmationResponse.getCode() == ResponseCode.CONFIRM_TRANSACTION) { final String receivedCRC = transactionConfirmationResponse.getMessage();
@Override public boolean isDestinationFull() { if (!handshakeComplete) { throw new IllegalStateException("Handshake has not completed successfully"); } return handshakeResponse.getCode() == ResponseCode.PORTS_DESTINATION_FULL; }
@Override protected Response readTransactionResponse() throws IOException { return Response.read(dis); }
if (transactionConfirmationResponse.getCode() == ResponseCode.CONFIRM_TRANSACTION) { final String receivedCRC = transactionConfirmationResponse.getMessage(); if (transactionResponse.getCode() == ResponseCode.TRANSACTION_FINISHED_BUT_DESTINATION_FULL) { peer.penalize(port.getIdentifier(), port.getYieldPeriod(TimeUnit.MILLISECONDS)); } else if (transactionResponse.getCode() != ResponseCode.TRANSACTION_FINISHED) { throw new ProtocolException("After sending data, expected TRANSACTION_FINISHED response but got " + transactionResponse);
@Override public boolean isPortInvalid() { if (!handshakeComplete) { throw new IllegalStateException("Handshake has not completed successfully"); } return handshakeResponse.getCode() == ResponseCode.PORT_NOT_IN_VALID_STATE; }
protected Response readTransactionResponse(boolean isTransfer, CommunicationsSession commsSession) throws IOException { final DataInputStream dis = new DataInputStream(commsSession.getInput().getInputStream()); return Response.read(dis); }
switch (transactionResponse.getCode()) { case CONTINUE_TRANSACTION: logger.debug("{} Received ContinueTransaction indicator from {}", this, peer); break; case CANCEL_TRANSACTION: logger.info("{} Received CancelTransaction indicator from {} with explanation {}", this, peer, transactionResponse.getMessage()); session.rollback(); return 0;
@Override public boolean isPortUnknown() { if (!handshakeComplete) { throw new IllegalStateException("Handshake has not completed successfully"); } return handshakeResponse.getCode() == ResponseCode.UNKNOWN_PORT; }
return Response.read(new DataInputStream(bis));
if (transactionConfirmationResponse.getCode() == ResponseCode.CONFIRM_TRANSACTION) { final String receivedCRC = transactionConfirmationResponse.getMessage(); if (transactionResponse.getCode() == ResponseCode.TRANSACTION_FINISHED_BUT_DESTINATION_FULL) { peer.penalize(port.getIdentifier(), port.getYieldPeriod(TimeUnit.MILLISECONDS)); } else if (transactionResponse.getCode() != ResponseCode.TRANSACTION_FINISHED) { throw new ProtocolException("After sending data, expected TRANSACTION_FINISHED response but got " + transactionResponse);
if (transactionResponse.getCode() == ResponseCode.TRANSACTION_FINISHED_BUT_DESTINATION_FULL) { peer.penalize(destinationId, penaltyMillis); backoff = true; } else if (transactionResponse.getCode() != ResponseCode.TRANSACTION_FINISHED) { throw new ProtocolException("After sending data to " + peer + ", expected TRANSACTION_FINISHED response but got " + transactionResponse);
return Response.read(new DataInputStream(bis));
switch (transactionResponse.getCode()) { case CONTINUE_TRANSACTION: logger.debug("{} Received ContinueTransaction indicator from {}", this, peer); break; case CANCEL_TRANSACTION: logger.info("{} Received CancelTransaction indicator from {} with explanation {}", this, peer, transactionResponse.getMessage()); session.rollback(); return 0;
switch (dataAvailableCode.getCode()) { case CONTINUE_TRANSACTION: logger.debug("{} {} Indicates Transaction should continue", this, peer);
protected Response readTransactionResponse(boolean isTransfer, CommunicationsSession commsSession) throws IOException { final DataInputStream dis = new DataInputStream(commsSession.getInput().getInputStream()); return Response.read(dis); }
logger.debug("{} Received {} from {}", this, confirmTransactionResponse, peer); switch (confirmTransactionResponse.getCode()) { case CONFIRM_TRANSACTION: break;
return Response.read(new DataInputStream(bis));