switch (requestType) { case NEGOTIATE_FLOWFILE_CODEC: protocol.negotiateCodec(peer); break; case RECEIVE_FLOWFILES: protocol.getPort().transferFlowFiles(peer, protocol); break; case SEND_FLOWFILES: protocol.getPort().receiveFlowFiles(peer, protocol); break; case REQUEST_PEER_LIST: isSiteToSiteSecure, 0); // TotalFlowFiles doesn't matter if it's a standalone NiFi. protocol.sendPeerList(peer, nodeInfo, self); break; case SHUTDOWN: protocol.shutdown(peer); break;
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; } }
@SuppressWarnings("unchecked") public static <T extends ServerProtocol> T receiveServerProtocolNegotiation(final DataInputStream dis, final DataOutputStream dos) throws IOException, HandshakeException { final String protocolName = dis.readUTF(); final int version = dis.readInt(); final T protocol = (T) RemoteResourceManager.createServerProtocol(protocolName); final VersionNegotiator negotiator = protocol.getVersionNegotiator(); if (negotiator.isVersionSupported(version)) { dos.write(RESOURCE_OK); dos.flush(); negotiator.setVersion(version); return protocol; } else { final Integer preferred = negotiator.getPreferredVersion(version); if (preferred == null) { dos.write(ABORT); dos.flush(); throw new HandshakeException("Unable to negotiate an acceptable version of the ServerProtocol " + protocolName); } dos.write(DIFFERENT_RESOURCE_VERSION); dos.writeInt(preferred); dos.flush(); return receiveServerProtocolNegotiation(dis, dos); } }
private int receiveFlowFiles(final ProcessContext context, final ProcessSession session, final FlowFileCodec codec, final FlowFileRequest receiveRequest) throws IOException, ProtocolException { return receiveRequest.getProtocol().receiveFlowFiles(receiveRequest.getPeer(), context, session, codec); }
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); }
final FlowFileCodec codec = protocol.getPreNegotiatedCodec(); if (codec == null) { responseQueue.add(new ProcessingResult(new BadRequestException("None of the supported FlowFile Codecs supplied is compatible with this instance")));
private int receiveFlowFiles(final ProcessContext context, final ProcessSession session, final FlowFileCodec codec, final FlowFileRequest receiveRequest) throws IOException, ProtocolException { return receiveRequest.getProtocol().receiveFlowFiles(receiveRequest.getPeer(), context, session, codec); }
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); }
final FlowFileCodec codec = protocol.getPreNegotiatedCodec(); if (codec == null) { responseQueue.add(new ProcessingResult(new BadRequestException("None of the supported FlowFile Codecs supplied is compatible with this instance")));
switch (requestType) { case NEGOTIATE_FLOWFILE_CODEC: protocol.negotiateCodec(peer); break; case RECEIVE_FLOWFILES: protocol.getPort().transferFlowFiles(peer, protocol); break; case SEND_FLOWFILES: protocol.getPort().receiveFlowFiles(peer, protocol); break; case REQUEST_PEER_LIST: isSiteToSiteSecure, 0); // TotalFlowFiles doesn't matter if it's a standalone NiFi. protocol.sendPeerList(peer, nodeInfo, self); break; case SHUTDOWN: protocol.shutdown(peer); break;
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; } }
@SuppressWarnings("unchecked") public static <T extends ServerProtocol> T receiveServerProtocolNegotiation(final DataInputStream dis, final DataOutputStream dos) throws IOException, HandshakeException { final String protocolName = dis.readUTF(); final int version = dis.readInt(); final T protocol = (T) RemoteResourceManager.createServerProtocol(protocolName); final VersionNegotiator negotiator = protocol.getVersionNegotiator(); if (negotiator.isVersionSupported(version)) { dos.write(RESOURCE_OK); dos.flush(); negotiator.setVersion(version); return protocol; } else { final Integer preferred = negotiator.getPreferredVersion(version); if (preferred == null) { dos.write(ABORT); dos.flush(); throw new HandshakeException("Unable to negotiate an acceptable version of the ServerProtocol " + protocolName); } dos.write(DIFFERENT_RESOURCE_VERSION); dos.writeInt(preferred); dos.flush(); return receiveServerProtocolNegotiation(dis, dos); } }