@Override protected HandshakeProperties doHandshake(Peer peer) throws IOException, HandshakeException { HttpServerCommunicationsSession commsSession = (HttpServerCommunicationsSession) peer.getCommunicationsSession(); final String transactionId = commsSession.getTransactionId(); HandshakeProperties confirmed = null; if (!StringUtils.isEmpty(transactionId)) { // If handshake is already done, use it. confirmed = transactionManager.getHandshakenProperties(transactionId); } if (confirmed == null) { // If it's not, then do handshake. confirmed = new HandshakeProperties(); confirmed.setCommsIdentifier(transactionId); validateHandshakeRequest(confirmed, peer, commsSession.getHandshakeParams()); } logger.debug("{} Done handshake, confirmed={}", this, confirmed); return confirmed; }
@Override public String toString() { String commid = handshakeProperties != null ? handshakeProperties.getCommsIdentifier() : null; return getClass().getSimpleName() + "[CommsID=" + commid + "]"; } }
@Override public long getRequestExpiration() { return handshakeProperties.getExpirationMillis(); }
case GZIP: { useGzip = Boolean.parseBoolean(value); confirmed.setUseGzip(useGzip); break; confirmed.setExpirationMillis(Long.parseLong(value)); break; case BATCH_COUNT: confirmed.setBatchCount(Integer.parseInt(value)); break; case BATCH_SIZE: confirmed.setBatchBytes(Long.parseLong(value)); break; case BATCH_DURATION: confirmed.setBatchDurationNanos(TimeUnit.MILLISECONDS.toNanos(Long.parseLong(value))); break; case PORT_IDENTIFIER: {
OutputStream os = new DataOutputStream(commsSession.getOutput().getOutputStream()); while (continueTransaction) { final boolean useGzip = handshakeProperties.isUseGzip(); final OutputStream flowFileOutputStream = useGzip ? new CompressionOutputStream(os) : os; logger.debug("{} Sending {} to {}", new Object[]{this, flowFile, peer}); double batchDurationNanos = handshakeProperties.getBatchDurationNanos(); if (sendingNanos >= batchDurationNanos && batchDurationNanos > 0L) { poll = false; double batchBytes = handshakeProperties.getBatchBytes(); if (bytesSent >= batchBytes && batchBytes > 0L) { poll = false; double batchCount = handshakeProperties.getBatchCount(); if (flowFilesSent.size() >= batchCount && batchCount > 0) { poll = false;
@Override protected HandshakeProperties doHandshake(Peer peer) throws IOException, HandshakeException { HandshakeProperties confirmed = new HandshakeProperties(); final DataOutputStream dos = new DataOutputStream(commsSession.getOutput().getOutputStream()); confirmed.setCommsIdentifier(dis.readUTF()); transitUriPrefix = transitUriPrefix + "/"; confirmed.setTransitUriPrefix(transitUriPrefix);
@Override protected String createTransitUri(Peer peer, String sourceFlowFileIdentifier) { String transitUriPrefix = handshakeProperties.getTransitUriPrefix(); return (transitUriPrefix == null) ? peer.getUrl() : transitUriPrefix + sourceFlowFileIdentifier; } }
while (continueTransaction) { final long startNanos = System.nanoTime(); final InputStream flowFileInputStream = handshakeProperties.isUseGzip() ? new CompressionInputStream(dis) : dis; final CheckedInputStream checkedInputStream = new CheckedInputStream(flowFileInputStream, crc); flowFile = session.putAllAttributes(flowFile, dataPacket.getAttributes()); if (handshakeProperties.isUseGzip()) {
case GZIP: { useGzip = Boolean.parseBoolean(value); confirmed.setUseGzip(useGzip); break; confirmed.setExpirationMillis(Long.parseLong(value)); break; case BATCH_COUNT: confirmed.setBatchCount(Integer.parseInt(value)); break; case BATCH_SIZE: confirmed.setBatchBytes(Long.parseLong(value)); break; case BATCH_DURATION: confirmed.setBatchDurationNanos(TimeUnit.MILLISECONDS.toNanos(Long.parseLong(value))); break; case PORT_IDENTIFIER: {
OutputStream os = new DataOutputStream(commsSession.getOutput().getOutputStream()); while (continueTransaction) { final boolean useGzip = handshakeProperties.isUseGzip(); final OutputStream flowFileOutputStream = useGzip ? new CompressionOutputStream(os) : os; logger.debug("{} Sending {} to {}", new Object[]{this, flowFile, peer}); double batchDurationNanos = handshakeProperties.getBatchDurationNanos(); if (sendingNanos >= batchDurationNanos && batchDurationNanos > 0L) { poll = false; double batchBytes = handshakeProperties.getBatchBytes(); if (bytesSent >= batchBytes && batchBytes > 0L) { poll = false; double batchCount = handshakeProperties.getBatchCount(); if (flowFilesSent.size() >= batchCount && batchCount > 0) { poll = false;
@Override protected HandshakeProperties doHandshake(Peer peer) throws IOException, HandshakeException { HandshakeProperties confirmed = new HandshakeProperties(); final DataOutputStream dos = new DataOutputStream(commsSession.getOutput().getOutputStream()); confirmed.setCommsIdentifier(dis.readUTF()); transitUriPrefix = transitUriPrefix + "/"; confirmed.setTransitUriPrefix(transitUriPrefix);
@Override protected String createTransitUri(Peer peer, String sourceFlowFileIdentifier) { String transitUriPrefix = handshakeProperties.getTransitUriPrefix(); return (transitUriPrefix == null) ? peer.getUrl() : transitUriPrefix + sourceFlowFileIdentifier; } }
while (continueTransaction) { final long startNanos = System.nanoTime(); final InputStream flowFileInputStream = handshakeProperties.isUseGzip() ? new CompressionInputStream(dis) : dis; final CheckedInputStream checkedInputStream = new CheckedInputStream(flowFileInputStream, crc); flowFile = session.putAllAttributes(flowFile, dataPacket.getAttributes()); if (handshakeProperties.isUseGzip()) {
@Override protected HandshakeProperties doHandshake(Peer peer) throws IOException, HandshakeException { HttpServerCommunicationsSession commsSession = (HttpServerCommunicationsSession) peer.getCommunicationsSession(); final String transactionId = commsSession.getTransactionId(); HandshakeProperties confirmed = null; if (!StringUtils.isEmpty(transactionId)) { // If handshake is already done, use it. confirmed = transactionManager.getHandshakenProperties(transactionId); } if (confirmed == null) { // If it's not, then do handshake. confirmed = new HandshakeProperties(); confirmed.setCommsIdentifier(transactionId); validateHandshakeRequest(confirmed, peer, commsSession.getHandshakeParams()); } logger.debug("{} Done handshake, confirmed={}", this, confirmed); return confirmed; }
@Override public long getRequestExpiration() { return handshakeProperties.getExpirationMillis(); }
@Override public String toString() { String commid = handshakeProperties != null ? handshakeProperties.getCommsIdentifier() : null; return getClass().getSimpleName() + "[CommsID=" + commid + "]"; } }