@Override public void tryHandleCheckpointException(CheckpointMetaData checkpointMetaData, Exception exception) { try { synchronousCheckpointExceptionHandler.tryHandleCheckpointException(checkpointMetaData, exception); } catch (Exception unhandled) { AsynchronousException asyncException = new AsynchronousException(unhandled); owner.handleAsyncException("Failure in asynchronous checkpoint materialization", asyncException); } } }
@Override public boolean triggerCheckpoint(CheckpointMetaData checkpointMetaData, CheckpointOptions checkpointOptions) throws Exception { if (!externallyInducedCheckpoints) { return super.triggerCheckpoint(checkpointMetaData, checkpointOptions); } else { // we do not trigger checkpoints here, we simply state whether we can trigger them synchronized (getCheckpointLock()) { return isRunning(); } } } }
/** * Returns a {@link CheckpointExceptionHandler} that either causes a task to fail completely or to just declines * checkpoint on exception, depending on the parameter flag. */ public CheckpointExceptionHandler createCheckpointExceptionHandler( boolean failTaskOnCheckpointException, Environment environment) { if (failTaskOnCheckpointException) { return new FailingCheckpointExceptionHandler(); } else { return new DecliningCheckpointExceptionHandler(environment); } }
@Override public long currentTimeMillis() { return processingTimeService.getCurrentProcessingTime(); } };
@Override protected void init() throws Exception { getProcessingTimeService().registerTimer(0, new ProcessingTimeCallback() { @Override public void onProcessingTime(long timestamp) throws Exception { classLoaders.add(Thread.currentThread().getContextClassLoader()); syncLatch.trigger(); } }); }
private <IN, OT extends StreamOperator<IN>> OperatorChain<IN, OT> createOperatorChain( StreamConfig streamConfig, Environment environment, StreamTask<IN, OT> task) { return new OperatorChain<>(task, StreamTask.createRecordWriters(streamConfig, environment)); }
/** * Gets the execution config defined on the execution environment of the job to which this * operator belongs. * * @return The job's execution config. */ public ExecutionConfig getExecutionConfig() { return container.getExecutionConfig(); }
/** * Returns the {@link ProcessingTimeService} responsible for getting the current * processing time and registering timers. */ protected ProcessingTimeService getProcessingTimeService() { return container.getProcessingTimeService(); }
@Override public boolean shutdownServiceUninterruptible(long timeoutMs) { shutdownService(); return true; }
@Override public String toString() { return "AsynchronousException{" + getCause() + "}"; } }
@Override public void collect(StreamRecord<T> record) { if (this.outputTag != null) { // we are only responsible for emitting to the main input return; } pushToOperator(record); }
@Override protected void run() throws Exception { if (!stopped) { super.run(); } }
@Override public void collect(StreamRecord<T> record) { if (this.outputTag != null) { // we are only responsible for emitting to the main input return; } pushToOperator(record); }
@Override public AbstractStateBackend createFromConfig(Configuration config) { return new TestSpyWrapperStateBackend(createInnerBackend(config)); }
/** * Invoke the Task. This resets the output of any previous invocation. This will start a new * Thread to execute the Task in. Use {@link #waitForTaskCompletion()} to wait for the * Task thread to finish running. * */ public void invoke() throws Exception { invoke(createEnvironment()); }
@Override protected ProcessingTimeService getProcessingTimeService() { if (testProcessingTimeService == null) { testProcessingTimeService = new TestProcessingTimeService(); } return testProcessingTimeService; } }
/** * Waits for the task completion. * * @throws Exception */ public void waitForTaskCompletion() throws Exception { waitForTaskCompletion(Long.MAX_VALUE); }
/** * Waits for the task to be running. * * @throws Exception */ public void waitForTaskRunning() throws Exception { waitForTaskRunning(Long.MAX_VALUE); }
@Override protected void cancelTask() { holder.cancel(); // do not interrupt the lock holder here, to simulate spawned threads that // we cannot properly interrupt on cancellation }
@Override public boolean shutdownAndAwaitPending(long time, TimeUnit timeUnit) throws InterruptedException { shutdownService(); return true; }