public static List<Integer> getSupportedVersions(final String codecName) { final FlowFileCodec codec = createCodec(codecName); return codec.getSupportedVersions(); }
public static FlowFileCodec createCodec(final String codecName, final int version) { final FlowFileCodec codec = createCodec(codecName); final VersionNegotiator negotiator = codec.getVersionNegotiator(); if (!negotiator.isVersionSupported(version)) { throw new IllegalArgumentException("FlowFile Codec " + codecName + " does not support version " + version); } negotiator.setVersion(version); return codec; }
@SuppressWarnings("unchecked") public static <T extends FlowFileCodec> T receiveCodecNegotiation(final DataInputStream dis, final DataOutputStream dos) throws IOException, HandshakeException { final String codecName = dis.readUTF(); final int version = dis.readInt(); final T codec = (T) RemoteResourceManager.createCodec(codecName, version); final VersionNegotiator negotiator = codec.getVersionNegotiator(); if (negotiator.isVersionSupported(version)) { dos.write(RESOURCE_OK); dos.flush(); negotiator.setVersion(version); return codec; } 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 FlowFileCodec " + codecName); } dos.write(DIFFERENT_RESOURCE_VERSION); dos.writeInt(preferred); dos.flush(); return receiveCodecNegotiation(dis, dos); } }
public static boolean isCodecSupported(final String codecName, final int version) { if (!isCodecSupported(codecName)) { return false; } final FlowFileCodec codec = createCodec(codecName); final VersionNegotiator negotiator = codec.getVersionNegotiator(); return (negotiator.isVersionSupported(version)); }
public static List<Integer> getSupportedVersions(final String codecName) { final FlowFileCodec codec = createCodec(codecName); return codec.getSupportedVersions(); }
public static FlowFileCodec createCodec(final String codecName, final int version) { final FlowFileCodec codec = createCodec(codecName); final VersionNegotiator negotiator = codec.getVersionNegotiator(); if (!negotiator.isVersionSupported(version)) { throw new IllegalArgumentException("FlowFile Codec " + codecName + " does not support version " + version); } negotiator.setVersion(version); return codec; }
@SuppressWarnings("unchecked") public static <T extends FlowFileCodec> T receiveCodecNegotiation(final DataInputStream dis, final DataOutputStream dos) throws IOException, HandshakeException { final String codecName = dis.readUTF(); final int version = dis.readInt(); final T codec = (T) RemoteResourceManager.createCodec(codecName, version); final VersionNegotiator negotiator = codec.getVersionNegotiator(); if (negotiator.isVersionSupported(version)) { dos.write(RESOURCE_OK); dos.flush(); negotiator.setVersion(version); return codec; } 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 FlowFileCodec " + codecName); } dos.write(DIFFERENT_RESOURCE_VERSION); dos.writeInt(preferred); dos.flush(); return receiveCodecNegotiation(dis, dos); } }
public static boolean isCodecSupported(final String codecName, final int version) { if (!isCodecSupported(codecName)) { return false; } final FlowFileCodec codec = createCodec(codecName); final VersionNegotiator negotiator = codec.getVersionNegotiator(); return (negotiator.isVersionSupported(version)); }