@Override protected void writeTransactionResponse(ResponseCode response, String explanation) throws IOException { if(explanation == null){ response.writeResponse(dos); } else { response.writeResponse(dos, explanation); } } }
@Override public String createTransitUri(String sourceFlowFileIdentifier) { return commsSession.createTransitUri(url, sourceFlowFileIdentifier); } }
SocketClientTransaction(final int protocolVersion, final String destinationId, final Peer peer, final FlowFileCodec codec, final TransferDirection direction, final boolean useCompression, final int penaltyMillis, final EventReporter eventReporter) throws IOException { super(peer, direction, useCompression, codec, eventReporter, protocolVersion, penaltyMillis, destinationId); this.dis = new DataInputStream(peer.getCommunicationsSession().getInput().getInputStream()); this.dos = new DataOutputStream(peer.getCommunicationsSession().getOutput().getOutputStream()); initialize(); }
protected void writeTransactionResponse(boolean isTransfer, ResponseCode response, CommunicationsSession commsSession, String explanation) throws IOException { final DataOutputStream dos = new DataOutputStream(commsSession.getOutput().getOutputStream()); if (explanation == null) { response.writeResponse(dos); } else { response.writeResponse(dos, explanation); } }
protected Response readTransactionResponse(boolean isTransfer, CommunicationsSession commsSession) throws IOException { final DataInputStream dis = new DataInputStream(commsSession.getInput().getInputStream()); return Response.read(dis); }
@Override public void shutdown(final Peer peer) throws IOException { readyForFileTransfer = false; final CommunicationsSession commsSession = peer.getCommunicationsSession(); final DataOutputStream dos = new DataOutputStream(commsSession.getOutput().getOutputStream()); logger.debug("{} Shutting down with {}", this, peer); // Indicate that we would like to have some data RequestType.SHUTDOWN.writeRequestType(dos); dos.flush(); }
@Override public RequestType getRequestType(final Peer peer) throws IOException { if (!handshakeCompleted) { throw new IllegalStateException("Handshake has not been completed"); } if (shutdown) { throw new IllegalStateException("Protocol is shutdown"); } logger.debug("{} Reading Request Type from {} using {}", new Object[]{this, peer, peer.getCommunicationsSession()}); final RequestType requestType = RequestType.readRequestType(new DataInputStream(peer.getCommunicationsSession().getInput().getInputStream())); logger.debug("{} Got Request Type {} from {}", new Object[]{this, requestType, peer}); return requestType; }
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); }
@Override public boolean isPortInvalid() { if (!handshakeComplete) { throw new IllegalStateException("Handshake has not completed successfully"); } return handshakeResponse.getCode() == ResponseCode.PORT_NOT_IN_VALID_STATE; }
public static ResponseCode fromSequence(final byte[] value) { final int code = value[3] & 0xFF; return fromCode(code); }
@Override protected Response readTransactionResponse() throws IOException { return Response.read(dis); }
@Override public String getDistinguishedName() { return commsSession.getUserDn(); }
@Override public long getRequestExpiration() { return handshakeProperties.getExpirationMillis(); }
protected final void writeTransactionResponse(boolean isTransfer, ResponseCode response, CommunicationsSession commsSession) throws IOException { writeTransactionResponse(isTransfer, response, commsSession, null); }
public boolean isExpired() { // use double the protocol's expiration because the sender may send data for a bit before // the timeout starts being counted, and we don't want to timeout before the sender does. // is this a good idea...??? long expiration = protocol.getRequestExpiration() * 2; if (expiration <= 0L) { return false; } if (expiration < 500L) { expiration = 500L; } return System.currentTimeMillis() > creationTime + expiration; } }
@Override protected String createTransitUri(Peer peer, String sourceFlowFileIdentifier) { String transitUriPrefix = handshakeProperties.getTransitUriPrefix(); return (transitUriPrefix == null) ? peer.getUrl() : transitUriPrefix + sourceFlowFileIdentifier; } }
private int transferFlowFiles(final ProcessContext context, final ProcessSession session, final FlowFileCodec codec, final FlowFileRequest request) throws IOException, ProtocolException { return request.getProtocol().transferFlowFiles(request.getPeer(), context, session, codec); }
@Override public boolean isPortUnknown() { if (!handshakeComplete) { throw new IllegalStateException("Handshake has not completed successfully"); } return handshakeResponse.getCode() == ResponseCode.UNKNOWN_PORT; }
@Override public boolean isDestinationFull() { if (!handshakeComplete) { throw new IllegalStateException("Handshake has not completed successfully"); } return handshakeResponse.getCode() == ResponseCode.PORTS_DESTINATION_FULL; }