Java Code Examples for org.apache.flink.util.function.FunctionWithException#apply()
The following examples show how to use
org.apache.flink.util.function.FunctionWithException#apply() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DelimitedInputFormatTest.java From flink with Apache License 2.0 | 6 votes |
private void testDelimiterOnBufferBoundary(FunctionWithException<String, FileInputSplit, IOException> splitCreator) throws IOException { String[] records = new String[]{"1234567890<DEL?NO!>1234567890", "1234567890<DEL?NO!>1234567890", "<DEL?NO!>"}; String delimiter = "<DELIM>"; String fileContent = StringUtils.join(records, delimiter); final FileInputSplit split = splitCreator.apply(fileContent); final Configuration parameters = new Configuration(); format.setBufferSize(12); format.setDelimiter(delimiter); format.configure(parameters); format.open(split); for (String record : records) { String value = format.nextRecord(null); assertEquals(record, value); } assertNull(format.nextRecord(null)); assertTrue(format.reachedEnd()); format.close(); }
Example 2
Source File: AkkaRpcActorOversizedResponseMessageTest.java From flink with Apache License 2.0 | 5 votes |
private <T> T runLocalMessageResponseTest(String payload, FunctionWithException<MessageRpcGateway, T, Exception> rpcCall) throws Exception { final MessageRpcEndpoint rpcEndpoint = new MessageRpcEndpoint(rpcService1, payload); try { rpcEndpoint.start(); MessageRpcGateway rpcGateway = rpcService1.connect(rpcEndpoint.getAddress(), MessageRpcGateway.class).get(); return rpcCall.apply(rpcGateway); } finally { RpcUtils.terminateRpcEndpoint(rpcEndpoint, TIMEOUT); } }
Example 3
Source File: MonotonicTTLTimeProvider.java From flink with Apache License 2.0 | 5 votes |
@GuardedBy("lock") static <T, E extends Throwable> T doWithFrozenTime(FunctionWithException<Long, T, E> action) throws E { synchronized (lock) { final long timestampBeforeUpdate = freeze(); T result = action.apply(timestampBeforeUpdate); final long timestampAfterUpdate = unfreezeTime(); checkState(timestampAfterUpdate == timestampBeforeUpdate, "Timestamps before and after the update do not match."); return result; } }
Example 4
Source File: AkkaRpcActorOversizedResponseMessageTest.java From flink with Apache License 2.0 | 5 votes |
private <T> T runLocalMessageResponseTest(String payload, FunctionWithException<MessageRpcGateway, T, Exception> rpcCall) throws Exception { final MessageRpcEndpoint rpcEndpoint = new MessageRpcEndpoint(rpcService1, payload); try { rpcEndpoint.start(); MessageRpcGateway rpcGateway = rpcService1.connect(rpcEndpoint.getAddress(), MessageRpcGateway.class).get(); return rpcCall.apply(rpcGateway); } finally { RpcUtils.terminateRpcEndpoint(rpcEndpoint, TIMEOUT); } }
Example 5
Source File: AkkaRpcActorOversizedResponseMessageTest.java From flink with Apache License 2.0 | 5 votes |
private <T> T runRemoteMessageResponseTest(String payload, FunctionWithException<MessageRpcGateway, T, Exception> rpcCall) throws Exception { final MessageRpcEndpoint rpcEndpoint = new MessageRpcEndpoint(rpcService1, payload); try { rpcEndpoint.start(); MessageRpcGateway rpcGateway = rpcService2.connect(rpcEndpoint.getAddress(), MessageRpcGateway.class).get(); return rpcCall.apply(rpcGateway); } finally { RpcUtils.terminateRpcEndpoint(rpcEndpoint, TIMEOUT); } }
Example 6
Source File: ChannelStateHandleSerializer.java From flink with Apache License 2.0 | 5 votes |
private static <Info, Handle extends AbstractChannelStateHandle<Info>> Handle deserializeChannelStateHandle( FunctionWithException<DataInputStream, Info, IOException> infoReader, TriFunctionWithException<StreamStateHandle, StateContentMetaInfo, Info, Handle, IOException> handleBuilder, DataInputStream dis, MetadataV2V3SerializerBase.DeserializationContext context) throws IOException { final Info info = infoReader.apply(dis); int offsetsSize = dis.readInt(); final List<Long> offsets = new ArrayList<>(offsetsSize); for (int i = 0; i < offsetsSize; i++) { offsets.add(dis.readLong()); } final long size = dis.readLong(); return handleBuilder.apply(deserializeStreamStateHandle(dis, context), new StateContentMetaInfo(offsets, size), info); }
Example 7
Source File: RefCountedBufferingFileStream.java From flink with Apache License 2.0 | 5 votes |
public static RefCountedBufferingFileStream restore( final FunctionWithException<File, RefCountedFileWithStream, IOException> tmpFileProvider, final File initialTmpFile) throws IOException { return new RefCountedBufferingFileStream( tmpFileProvider.apply(initialTmpFile), BUFFER_SIZE); }
Example 8
Source File: RefCountedBufferingFileStream.java From flink with Apache License 2.0 | 5 votes |
public static RefCountedBufferingFileStream openNew( final FunctionWithException<File, RefCountedFileWithStream, IOException> tmpFileProvider) throws IOException { return new RefCountedBufferingFileStream( tmpFileProvider.apply(null), BUFFER_SIZE); }
Example 9
Source File: SlotManagerTest.java From flink with Apache License 2.0 | 5 votes |
private static FunctionWithException<ResourceProfile, Collection<ResourceProfile>, ResourceManagerException> convert(FunctionWithException<ResourceProfile, Integer, ResourceManagerException> function) { return (ResourceProfile resourceProfile) -> { final int slots = function.apply(resourceProfile); final ArrayList<ResourceProfile> result = new ArrayList<>(slots); for (int i = 0; i < slots; i++) { result.add(resourceProfile); } return result; }; }
Example 10
Source File: RefCountedBufferingFileStream.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public static RefCountedBufferingFileStream openNew( final FunctionWithException<File, RefCountedFile, IOException> tmpFileProvider) throws IOException { return new RefCountedBufferingFileStream( tmpFileProvider.apply(null), BUFFER_SIZE); }
Example 11
Source File: AkkaRpcActorOversizedResponseMessageTest.java From flink with Apache License 2.0 | 5 votes |
private <T> T runRemoteMessageResponseTest(String payload, FunctionWithException<MessageRpcGateway, T, Exception> rpcCall) throws Exception { final MessageRpcEndpoint rpcEndpoint = new MessageRpcEndpoint(rpcService1, payload); try { rpcEndpoint.start(); MessageRpcGateway rpcGateway = rpcService2.connect(rpcEndpoint.getAddress(), MessageRpcGateway.class).get(); return rpcCall.apply(rpcGateway); } finally { RpcUtils.terminateRpcEndpoint(rpcEndpoint, TIMEOUT); } }
Example 12
Source File: RefCountedBufferingFileStream.java From flink with Apache License 2.0 | 5 votes |
public static RefCountedBufferingFileStream restore( final FunctionWithException<File, RefCountedFile, IOException> tmpFileProvider, final File initialTmpFile) throws IOException { return new RefCountedBufferingFileStream( tmpFileProvider.apply(initialTmpFile), BUFFER_SIZE); }
Example 13
Source File: RefCountedBufferingFileStream.java From flink with Apache License 2.0 | 5 votes |
public static RefCountedBufferingFileStream openNew( final FunctionWithException<File, RefCountedFile, IOException> tmpFileProvider) throws IOException { return new RefCountedBufferingFileStream( tmpFileProvider.apply(null), BUFFER_SIZE); }
Example 14
Source File: SlotManagerTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private static FunctionWithException<ResourceProfile, Collection<ResourceProfile>, ResourceManagerException> convert(FunctionWithException<ResourceProfile, Integer, ResourceManagerException> function) { return (ResourceProfile resourceProfile) -> { final int slots = function.apply(resourceProfile); final ArrayList<ResourceProfile> result = new ArrayList<>(slots); for (int i = 0; i < slots; i++) { result.add(resourceProfile); } return result; }; }
Example 15
Source File: AkkaRpcActorOversizedResponseMessageTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private <T> T runLocalMessageResponseTest(String payload, FunctionWithException<MessageRpcGateway, T, Exception> rpcCall) throws Exception { final MessageRpcEndpoint rpcEndpoint = new MessageRpcEndpoint(rpcService1, payload); try { rpcEndpoint.start(); MessageRpcGateway rpcGateway = rpcService1.connect(rpcEndpoint.getAddress(), MessageRpcGateway.class).get(); return rpcCall.apply(rpcGateway); } finally { RpcUtils.terminateRpcEndpoint(rpcEndpoint, TIMEOUT); } }
Example 16
Source File: AkkaRpcActorOversizedResponseMessageTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private <T> T runRemoteMessageResponseTest(String payload, FunctionWithException<MessageRpcGateway, T, Exception> rpcCall) throws Exception { final MessageRpcEndpoint rpcEndpoint = new MessageRpcEndpoint(rpcService1, payload); try { rpcEndpoint.start(); MessageRpcGateway rpcGateway = rpcService2.connect(rpcEndpoint.getAddress(), MessageRpcGateway.class).get(); return rpcCall.apply(rpcGateway); } finally { RpcUtils.terminateRpcEndpoint(rpcEndpoint, TIMEOUT); } }
Example 17
Source File: RefCountedBufferingFileStream.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public static RefCountedBufferingFileStream restore( final FunctionWithException<File, RefCountedFile, IOException> tmpFileProvider, final File initialTmpFile) throws IOException { return new RefCountedBufferingFileStream( tmpFileProvider.apply(initialTmpFile), BUFFER_SIZE); }