org.apache.flink.util.function.BiFunctionWithException Java Examples
The following examples show how to use
org.apache.flink.util.function.BiFunctionWithException.
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: SubtaskCheckpointCoordinatorImpl.java From flink with Apache License 2.0 | 6 votes |
SubtaskCheckpointCoordinatorImpl( CheckpointStorageWorkerView checkpointStorage, String taskName, StreamTaskActionExecutor actionExecutor, CloseableRegistry closeableRegistry, ExecutorService executorService, Environment env, AsyncExceptionHandler asyncExceptionHandler, boolean unalignedCheckpointEnabled, BiFunctionWithException<ChannelStateWriter, Long, CompletableFuture<Void>, IOException> prepareInputSnapshot, int maxRecordAbortedCheckpoints) throws IOException { this( checkpointStorage, taskName, actionExecutor, closeableRegistry, executorService, env, asyncExceptionHandler, prepareInputSnapshot, maxRecordAbortedCheckpoints, unalignedCheckpointEnabled ? openChannelStateWriter(taskName, checkpointStorage) : ChannelStateWriter.NO_OP); }
Example #2
Source File: SubtaskCheckpointCoordinatorImpl.java From flink with Apache License 2.0 | 6 votes |
SubtaskCheckpointCoordinatorImpl( CheckpointStorageWorkerView checkpointStorage, String taskName, StreamTaskActionExecutor actionExecutor, CloseableRegistry closeableRegistry, ExecutorService executorService, Environment env, AsyncExceptionHandler asyncExceptionHandler, boolean unalignedCheckpointEnabled, BiFunctionWithException<ChannelStateWriter, Long, CompletableFuture<Void>, IOException> prepareInputSnapshot) throws IOException { this(checkpointStorage, taskName, actionExecutor, closeableRegistry, executorService, env, asyncExceptionHandler, unalignedCheckpointEnabled, prepareInputSnapshot, DEFAULT_MAX_RECORD_ABORTED_CHECKPOINTS); }
Example #3
Source File: TestingJobGraphStore.java From flink with Apache License 2.0 | 6 votes |
private TestingJobGraphStore( ThrowingConsumer<JobGraphListener, ? extends Exception> startConsumer, ThrowingRunnable<? extends Exception> stopRunnable, FunctionWithException<Collection<JobID>, Collection<JobID>, ? extends Exception> jobIdsFunction, BiFunctionWithException<JobID, Map<JobID, JobGraph>, JobGraph, ? extends Exception> recoverJobGraphFunction, ThrowingConsumer<JobGraph, ? extends Exception> putJobGraphConsumer, ThrowingConsumer<JobID, ? extends Exception> removeJobGraphConsumer, ThrowingConsumer<JobID, ? extends Exception> releaseJobGraphConsumer, Collection<JobGraph> initialJobGraphs) { this.startConsumer = startConsumer; this.stopRunnable = stopRunnable; this.jobIdsFunction = jobIdsFunction; this.recoverJobGraphFunction = recoverJobGraphFunction; this.putJobGraphConsumer = putJobGraphConsumer; this.removeJobGraphConsumer = removeJobGraphConsumer; this.releaseJobGraphConsumer = releaseJobGraphConsumer; for (JobGraph initialJobGraph : initialJobGraphs) { storedJobs.put(initialJobGraph.getJobID(), initialJobGraph); } }
Example #4
Source File: TestingExecutor.java From flink with Apache License 2.0 | 6 votes |
TestingExecutor( List<SupplierWithException<TypedResult<List<Tuple2<Boolean, Row>>>, SqlExecutionException>> resultChanges, List<SupplierWithException<TypedResult<Integer>, SqlExecutionException>> snapshotResults, List<SupplierWithException<List<Row>, SqlExecutionException>> resultPages, BiConsumerWithException<String, String, SqlExecutionException> useCatalogConsumer, BiConsumerWithException<String, String, SqlExecutionException> useDatabaseConsumer, BiFunctionWithException<String, String, TableResult, SqlExecutionException> executeSqlConsumer, TriFunctionWithException<String, String, String, Void, SqlExecutionException> setSessionPropertyFunction, FunctionWithException<String, Void, SqlExecutionException> resetSessionPropertiesFunction) { this.resultChanges = resultChanges; this.snapshotResults = snapshotResults; this.resultPages = resultPages; this.useCatalogConsumer = useCatalogConsumer; this.useDatabaseConsumer = useDatabaseConsumer; this.executeSqlConsumer = executeSqlConsumer; this.setSessionPropertyFunction = setSessionPropertyFunction; this.resetSessionPropertiesFunction = resetSessionPropertiesFunction; helper = new SqlParserHelper(); helper.registerTables(); }
Example #5
Source File: PojoSerializerSnapshotData.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private static BiFunctionWithException<DataInputView, String, TypeSerializerSnapshot<?>, IOException> snapshotReader(ClassLoader cl) { return (input, unused) -> { try { return TypeSerializerSnapshot.readVersionedSnapshot(input, cl); } catch (Throwable t) { LOG.warn("Exception while reading serializer snapshot.", t); return null; } }; }
Example #6
Source File: SubtaskCheckpointCoordinatorImpl.java From flink with Apache License 2.0 | 5 votes |
@VisibleForTesting SubtaskCheckpointCoordinatorImpl( CheckpointStorageWorkerView checkpointStorage, String taskName, StreamTaskActionExecutor actionExecutor, CloseableRegistry closeableRegistry, ExecutorService executorService, Environment env, AsyncExceptionHandler asyncExceptionHandler, BiFunctionWithException<ChannelStateWriter, Long, CompletableFuture<Void>, IOException> prepareInputSnapshot, int maxRecordAbortedCheckpoints, ChannelStateWriter channelStateWriter) throws IOException { this.checkpointStorage = new CachingCheckpointStorageWorkerView(checkNotNull(checkpointStorage)); this.taskName = checkNotNull(taskName); this.checkpoints = new HashMap<>(); this.lock = new Object(); this.executorService = checkNotNull(executorService); this.env = checkNotNull(env); this.asyncExceptionHandler = checkNotNull(asyncExceptionHandler); this.actionExecutor = checkNotNull(actionExecutor); this.channelStateWriter = checkNotNull(channelStateWriter); this.prepareInputSnapshot = prepareInputSnapshot; this.abortedCheckpointIds = createAbortedCheckpointSetWithLimitSize(maxRecordAbortedCheckpoints); this.lastCheckpointId = -1L; closeableRegistry.registerCloseable(this); this.closed = false; }
Example #7
Source File: ChannelPersistenceITCase.java From flink with Apache License 2.0 | 5 votes |
private byte[] read(TaskStateSnapshot taskStateSnapshot, int size, BiFunctionWithException<ChannelStateReader, MemorySegment, ReadResult, Exception> readFn) throws Exception { byte[] dst = new byte[size]; HeapMemorySegment mem = HeapMemorySegment.FACTORY.wrap(dst); try { checkState(NO_MORE_DATA == readFn.apply(new ChannelStateReaderImpl(taskStateSnapshot), mem)); } finally { mem.free(); } return dst; }
Example #8
Source File: MetadataV2V3SerializerBase.java From flink with Apache License 2.0 | 5 votes |
static <T extends StateObject> StateObjectCollection<T> deserializeCollection( DataInputStream dis, DeserializationContext context, BiFunctionWithException<DataInputStream, DeserializationContext, T, IOException> s) throws IOException { int size = dis.readInt(); List<T> result = new ArrayList<>(); for (int i = 0; i < size; i++) { result.add(s.apply(dis, context)); } return new StateObjectCollection<>(result); }
Example #9
Source File: LinkedOptionalMapSerializer.java From flink with Apache License 2.0 | 5 votes |
@Nullable private static <T> T tryReadFrame(DataInputView in, String keyName, BiFunctionWithException<DataInputView, String, T, IOException> reader) throws IOException { final int bufferSize = in.readInt(); final byte[] buffer = new byte[bufferSize]; in.readFully(buffer); DataInputDeserializer frame = new DataInputDeserializer(buffer); return reader.apply(frame, keyName); }
Example #10
Source File: LinkedOptionalMapSerializer.java From flink with Apache License 2.0 | 5 votes |
public static <K, V> LinkedOptionalMap<K, V> readOptionalMap( DataInputView in, BiFunctionWithException<DataInputView, String, K, IOException> keyReader, BiFunctionWithException<DataInputView, String, V, IOException> valueReader) throws IOException { final long header = in.readLong(); checkState(header == HEADER, "Corrupted stream received header %s", header); long mapSize = in.readInt(); LinkedOptionalMap<K, V> map = new LinkedOptionalMap<>(); for (int i = 0; i < mapSize; i++) { String keyName = in.readUTF(); final K key; if (in.readBoolean()) { key = tryReadFrame(in, keyName, keyReader); } else { key = null; } final V value; if (in.readBoolean()) { value = tryReadFrame(in, keyName, valueReader); } else { value = null; } map.put(keyName, key, value); } return map; }
Example #11
Source File: PojoSerializerSnapshotData.java From flink with Apache License 2.0 | 5 votes |
private static BiFunctionWithException<DataInputView, String, Class<?>, IOException> classReader(ClassLoader cl) { return (input, className) -> { try { // input is ignored because we don't write the actual class as value. return Class.forName(className, false, cl); } catch (Throwable t) { LOG.warn(String.format("Exception while reading class %s", className), t); return null; } }; }
Example #12
Source File: PojoSerializerSnapshotData.java From flink with Apache License 2.0 | 5 votes |
private static BiFunctionWithException<DataInputView, String, TypeSerializerSnapshot<?>, IOException> snapshotReader(ClassLoader cl) { return (input, unused) -> { try { return TypeSerializerSnapshot.readVersionedSnapshot(input, cl); } catch (Throwable t) { LOG.warn("Exception while reading serializer snapshot.", t); return null; } }; }
Example #13
Source File: PojoSerializerSnapshotData.java From flink with Apache License 2.0 | 5 votes |
private static BiFunctionWithException<DataInputView, String, Field, IOException> fieldReader(ClassLoader cl) { return (input, fieldName) -> { try { return PojoFieldUtils.readField(input, cl); } catch (Throwable t) { LOG.warn(String.format("Exception while reading field %s", fieldName), t); return null; } }; }
Example #14
Source File: LinkedOptionalMapSerializer.java From flink with Apache License 2.0 | 5 votes |
@Nullable private static <T> T tryReadFrame(DataInputView in, String keyName, BiFunctionWithException<DataInputView, String, T, IOException> reader) throws IOException { final int bufferSize = in.readInt(); final byte[] buffer = new byte[bufferSize]; in.readFully(buffer); DataInputDeserializer frame = new DataInputDeserializer(buffer); return reader.apply(frame, keyName); }
Example #15
Source File: LinkedOptionalMapSerializer.java From flink with Apache License 2.0 | 5 votes |
public static <K, V> LinkedOptionalMap<K, V> readOptionalMap( DataInputView in, BiFunctionWithException<DataInputView, String, K, IOException> keyReader, BiFunctionWithException<DataInputView, String, V, IOException> valueReader) throws IOException { final long header = in.readLong(); checkState(header == HEADER, "Corrupted stream received header %s", header); long mapSize = in.readInt(); LinkedOptionalMap<K, V> map = new LinkedOptionalMap<>(); for (int i = 0; i < mapSize; i++) { String keyName = in.readUTF(); final K key; if (in.readBoolean()) { key = tryReadFrame(in, keyName, keyReader); } else { key = null; } final V value; if (in.readBoolean()) { value = tryReadFrame(in, keyName, valueReader); } else { value = null; } map.put(keyName, key, value); } return map; }
Example #16
Source File: PojoSerializerSnapshotData.java From flink with Apache License 2.0 | 5 votes |
private static BiFunctionWithException<DataInputView, String, Class<?>, IOException> classReader(ClassLoader cl) { return (input, className) -> { try { // input is ignored because we don't write the actual class as value. return Class.forName(className, false, cl); } catch (Throwable t) { LOG.warn(String.format("Exception while reading class %s", className), t); return null; } }; }
Example #17
Source File: PojoSerializerSnapshotData.java From flink with Apache License 2.0 | 5 votes |
private static BiFunctionWithException<DataInputView, String, TypeSerializerSnapshot<?>, IOException> snapshotReader(ClassLoader cl) { return (input, unused) -> { try { return TypeSerializerSnapshot.readVersionedSnapshot(input, cl); } catch (Throwable t) { LOG.warn("Exception while reading serializer snapshot.", t); return null; } }; }
Example #18
Source File: PojoSerializerSnapshotData.java From flink with Apache License 2.0 | 5 votes |
private static BiFunctionWithException<DataInputView, String, Field, IOException> fieldReader(ClassLoader cl) { return (input, fieldName) -> { try { return PojoFieldUtils.readField(input, cl); } catch (Throwable t) { LOG.warn(String.format("Exception while reading field %s", fieldName), t); return null; } }; }
Example #19
Source File: LinkedOptionalMapSerializer.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Nullable private static <T> T tryReadFrame(DataInputView in, String keyName, BiFunctionWithException<DataInputView, String, T, IOException> reader) throws IOException { final int bufferSize = in.readInt(); final byte[] buffer = new byte[bufferSize]; in.readFully(buffer); DataInputDeserializer frame = new DataInputDeserializer(buffer); return reader.apply(frame, keyName); }
Example #20
Source File: LinkedOptionalMapSerializer.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public static <K, V> LinkedOptionalMap<K, V> readOptionalMap( DataInputView in, BiFunctionWithException<DataInputView, String, K, IOException> keyReader, BiFunctionWithException<DataInputView, String, V, IOException> valueReader) throws IOException { final long header = in.readLong(); checkState(header == HEADER, "Corrupted stream received header %d", header); long mapSize = in.readInt(); LinkedOptionalMap<K, V> map = new LinkedOptionalMap<>(); for (int i = 0; i < mapSize; i++) { String keyName = in.readUTF(); final K key; if (in.readBoolean()) { key = tryReadFrame(in, keyName, keyReader); } else { key = null; } final V value; if (in.readBoolean()) { value = tryReadFrame(in, keyName, valueReader); } else { value = null; } map.put(keyName, key, value); } return map; }
Example #21
Source File: PojoSerializerSnapshotData.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private static BiFunctionWithException<DataInputView, String, Class<?>, IOException> classReader(ClassLoader cl) { return (input, className) -> { try { // input is ignored because we don't write the actual class as value. return Class.forName(className, false, cl); } catch (Throwable t) { LOG.warn(String.format("Exception while reading class %s", className), t); return null; } }; }
Example #22
Source File: PojoSerializerSnapshotData.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private static BiFunctionWithException<DataInputView, String, Field, IOException> fieldReader(ClassLoader cl) { return (input, fieldName) -> { try { return PojoFieldUtils.readField(input, cl); } catch (Throwable t) { LOG.warn(String.format("Exception while reading field %s", fieldName), t); return null; } }; }
Example #23
Source File: TestingExecutorBuilder.java From flink with Apache License 2.0 | 4 votes |
public final TestingExecutorBuilder setExecuteSqlConsumer( BiFunctionWithException<String, String, TableResult, SqlExecutionException> setExecuteUpdateConsumer) { this.setExecuteSqlConsumer = setExecuteUpdateConsumer; return this; }
Example #24
Source File: InMemorySubmittedJobGraphStore.java From flink with Apache License 2.0 | 4 votes |
public void setRecoverJobGraphFunction(BiFunctionWithException<JobID, Map<JobID, SubmittedJobGraph>, SubmittedJobGraph, ? extends Exception> recoverJobGraphFunction) { this.recoverJobGraphFunction = Preconditions.checkNotNull(recoverJobGraphFunction); }
Example #25
Source File: InMemorySubmittedJobGraphStore.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
public void setRecoverJobGraphFunction(BiFunctionWithException<JobID, Map<JobID, SubmittedJobGraph>, SubmittedJobGraph, ? extends Exception> recoverJobGraphFunction) { this.recoverJobGraphFunction = Preconditions.checkNotNull(recoverJobGraphFunction); }
Example #26
Source File: TestingClassLoaderLease.java From flink with Apache License 2.0 | 4 votes |
public TestingClassLoaderLease(BiFunctionWithException<Collection<PermanentBlobKey>, Collection<URL>, ClassLoader, IOException> getOrResolveClassLoaderFunction, Runnable closeRunnable) { this.getOrResolveClassLoaderFunction = getOrResolveClassLoaderFunction; this.closeRunnable = closeRunnable; }
Example #27
Source File: TestingClassLoaderLease.java From flink with Apache License 2.0 | 4 votes |
public Builder setGetOrResolveClassLoaderFunction(BiFunctionWithException<Collection<PermanentBlobKey>, Collection<URL>, ClassLoader, IOException> getOrResolveClassLoaderFunction) { this.getOrResolveClassLoaderFunction = getOrResolveClassLoaderFunction; return this; }
Example #28
Source File: TestingJobGraphStore.java From flink with Apache License 2.0 | 4 votes |
public Builder setRecoverJobGraphFunction(BiFunctionWithException<JobID, Map<JobID, JobGraph>, JobGraph, ? extends Exception> recoverJobGraphFunction) { this.recoverJobGraphFunction = recoverJobGraphFunction; return this; }
Example #29
Source File: MockSubtaskCheckpointCoordinatorBuilder.java From flink with Apache License 2.0 | 4 votes |
public MockSubtaskCheckpointCoordinatorBuilder setPrepareInputSnapshot(BiFunctionWithException<ChannelStateWriter, Long, CompletableFuture<Void>, IOException> prepareInputSnapshot) { this.prepareInputSnapshot = prepareInputSnapshot; return this; }