@Override public void cancel() throws Exception { requestTermination(); super.cancel(); }
@Override public void cancel() throws Exception { this.running = false; if (LOG.isDebugEnabled()) { LOG.debug(formatLogString("Cancelling task code")); } try { if (this.driver != null) { this.driver.cancel(); } } finally { closeLocalStrategiesAndCaches(); } }
@Override public void closeTask() throws Exception { BatchTask.closeUserCode(this.mapper); }
@Override public String formatLogString(String message) { return constructLogString(message, getEnvironment().getTaskInfo().getTaskName(), this); }
LOG.debug(formatLogString("Start registering input and output.")); Configuration taskConf = getTaskConfiguration(); this.config = new TaskConfig(taskConf); String headName = getEnvironment().getTaskInfo().getTaskName().split("->")[0].trim(); this.metrics = getEnvironment().getMetricGroup() .addOperator(headName.startsWith("CHAIN") ? headName.substring(6) : headName); this.metrics.getIOMetricGroup().reuseInputMetricsForTask(); initInputReaders(); initBroadcastInputReaders(); initOutputs(); LOG.debug(formatLogString("Finished registering input and output.")); LOG.debug(formatLogString("Start task code.")); this.runtimeUdfContext = createRuntimeContext(metrics); initInputsSerializersAndComparators(numInputs, numComparators); initBroadcastInputsSerializers(numBroadcastInputs); final int numberOfEventsUntilInterrupt = getTaskConfig().getNumberOfEventsUntilInterruptInIterativeGate(i); LOG.debug(formatLogString("Input [" + i + "] reads in supersteps with [" + + numberOfEventsUntilInterrupt + "] event(s) till next superstep."));
throw new Exception("The data preparation for task '" + this.getEnvironment().getTaskInfo().getTaskName() + "' , caused an error: " + t.getMessage(), t); BatchTask.openChainedTasks(this.chainedTasks, this); BatchTask.closeChainedTasks(this.chainedTasks, this); BatchTask.cancelChainedTasks(this.chainedTasks); BatchTask.logAndThrowException(ex, this);
BatchTask.openChainedTasks(this.chainedTasks, this); BatchTask.closeChainedTasks(this.chainedTasks, this); } catch (Throwable ignored) {} BatchTask.cancelChainedTasks(this.chainedTasks); BatchTask.logAndThrowException(ex, this); BatchTask.clearWriters(eventualOutputs);
/** * Utility function that composes a string for logging purposes. The string includes the given message and * the index of the task in its task group together with the number of tasks in the task group. * * @param message The main message for the log. * @param taskName The name of the task. * @return The string ready for logging. */ private String getLogString(String message, String taskName) { return BatchTask.constructLogString(message, taskName, this); }
/** * Creates all the serializers and comparators. */ protected void initInputsSerializersAndComparators(int numInputs, int numComparators) throws Exception { this.inputSerializers = new TypeSerializerFactory<?>[numInputs]; this.inputComparators = numComparators > 0 ? new TypeComparator<?>[numComparators] : null; this.inputIterators = new MutableObjectIterator<?>[numInputs]; ClassLoader userCodeClassLoader = getUserCodeClassLoader(); for (int i = 0; i < numInputs; i++) { final TypeSerializerFactory<?> serializerFactory = this.config.getInputSerializer(i, userCodeClassLoader); this.inputSerializers[i] = serializerFactory; this.inputIterators[i] = createInputIterator(this.inputReaders[i], this.inputSerializers[i]); } // ---------------- create the driver's comparators --------------------- for (int i = 0; i < numComparators; i++) { if (this.inputComparators != null) { final TypeComparatorFactory<?> comparatorFactory = this.config.getDriverComparator(i, userCodeClassLoader); this.inputComparators[i] = comparatorFactory.createComparator(); } } }
@Override protected void closeLocalStrategiesAndCaches() { try { super.closeLocalStrategiesAndCaches(); } finally { if (this.driver instanceof ResettableDriver) { final ResettableDriver<?, ?> resDriver = (ResettableDriver<?, ?>) this.driver; try { resDriver.teardown(); } catch (Throwable t) { log.error("Error while shutting down an iterative operator.", t); } } } }
BatchTask.clearReaders(new MutableReader<?>[]{inputReader});
LOG.debug(formatLogString("Start registering input and output.")); Configuration taskConf = getTaskConfiguration(); this.config = new TaskConfig(taskConf); String headName = getEnvironment().getTaskInfo().getTaskName().split("->")[0].trim(); this.metrics = getEnvironment().getMetricGroup() .addOperator(headName.startsWith("CHAIN") ? headName.substring(6) : headName); this.metrics.getIOMetricGroup().reuseInputMetricsForTask(); initInputReaders(); initBroadcastInputReaders(); initOutputs(); LOG.debug(formatLogString("Finished registering input and output.")); LOG.debug(formatLogString("Start task code.")); this.runtimeUdfContext = createRuntimeContext(metrics); initInputsSerializersAndComparators(numInputs, numComparators); initBroadcastInputsSerializers(numBroadcastInputs); final int numberOfEventsUntilInterrupt = getTaskConfig().getNumberOfEventsUntilInterruptInIterativeGate(i); LOG.debug(formatLogString("Input [" + i + "] reads in supersteps with [" + + numberOfEventsUntilInterrupt + "] event(s) till next superstep."));
throw new Exception("The data preparation for task '" + this.getEnvironment().getTaskInfo().getTaskName() + "' , caused an error: " + t.getMessage(), t); BatchTask.openChainedTasks(this.chainedTasks, this); BatchTask.closeChainedTasks(this.chainedTasks, this); BatchTask.cancelChainedTasks(this.chainedTasks); BatchTask.logAndThrowException(ex, this);
BatchTask.openChainedTasks(this.chainedTasks, this); BatchTask.closeChainedTasks(this.chainedTasks, this); } catch (Throwable ignored) {} BatchTask.cancelChainedTasks(this.chainedTasks); BatchTask.logAndThrowException(ex, this); BatchTask.clearWriters(eventualOutputs);
/** * Utility function that composes a string for logging purposes. The string includes the given message and * the index of the task in its task group together with the number of tasks in the task group. * * @param message The main message for the log. * @param taskName The name of the task. * @return The string ready for logging. */ private String getLogString(String message, String taskName) { return BatchTask.constructLogString(message, taskName, this); }
@Override public String formatLogString(String message) { return constructLogString(message, getEnvironment().getTaskInfo().getTaskName(), this); }
/** * Creates all the serializers and comparators. */ protected void initInputsSerializersAndComparators(int numInputs, int numComparators) throws Exception { this.inputSerializers = new TypeSerializerFactory<?>[numInputs]; this.inputComparators = numComparators > 0 ? new TypeComparator<?>[numComparators] : null; this.inputIterators = new MutableObjectIterator<?>[numInputs]; ClassLoader userCodeClassLoader = getUserCodeClassLoader(); for (int i = 0; i < numInputs; i++) { final TypeSerializerFactory<?> serializerFactory = this.config.getInputSerializer(i, userCodeClassLoader); this.inputSerializers[i] = serializerFactory; this.inputIterators[i] = createInputIterator(this.inputReaders[i], this.inputSerializers[i]); } // ---------------- create the driver's comparators --------------------- for (int i = 0; i < numComparators; i++) { if (this.inputComparators != null) { final TypeComparatorFactory<?> comparatorFactory = this.config.getDriverComparator(i, userCodeClassLoader); this.inputComparators[i] = comparatorFactory.createComparator(); } } }
@Override protected void closeLocalStrategiesAndCaches() { try { super.closeLocalStrategiesAndCaches(); } finally { if (this.driver instanceof ResettableDriver) { final ResettableDriver<?, ?> resDriver = (ResettableDriver<?, ?>) this.driver; try { resDriver.teardown(); } catch (Throwable t) { log.error("Error while shutting down an iterative operator.", t); } } } }
BatchTask.clearReaders(new MutableReader<?>[]{inputReader});
LOG.debug(formatLogString("Start registering input and output.")); Configuration taskConf = getTaskConfiguration(); this.config = new TaskConfig(taskConf); String headName = getEnvironment().getTaskInfo().getTaskName().split("->")[0].trim(); this.metrics = getEnvironment().getMetricGroup() .getOrAddOperator(headName.startsWith("CHAIN") ? headName.substring(6) : headName); this.metrics.getIOMetricGroup().reuseInputMetricsForTask(); initInputReaders(); initBroadcastInputReaders(); initOutputs(); LOG.debug(formatLogString("Finished registering input and output.")); LOG.debug(formatLogString("Start task code.")); this.runtimeUdfContext = createRuntimeContext(metrics); initInputsSerializersAndComparators(numInputs, numComparators); initBroadcastInputsSerializers(numBroadcastInputs); final int numberOfEventsUntilInterrupt = getTaskConfig().getNumberOfEventsUntilInterruptInIterativeGate(i); LOG.debug(formatLogString("Input [" + i + "] reads in supersteps with [" + + numberOfEventsUntilInterrupt + "] event(s) till next superstep."));