Search in sources :

Example 1 with HExecutionEngine

use of org.apache.pig.backend.hadoop.executionengine.HExecutionEngine in project zeppelin by apache.

the class BasePigInterpreter method cancel.

@Override
public void cancel(InterpreterContext context) {
    LOGGER.info("Cancel paragraph:" + context.getParagraphId());
    PigScriptListener listener = listenerMap.get(context.getParagraphId());
    if (listener != null) {
        Set<String> jobIds = listener.getJobIds();
        if (jobIds.isEmpty()) {
            LOGGER.info("No job is started, so can not cancel paragraph:" + context.getParagraphId());
        }
        for (String jobId : jobIds) {
            LOGGER.info("Kill jobId:" + jobId);
            HExecutionEngine engine = (HExecutionEngine) getPigServer().getPigContext().getExecutionEngine();
            try {
                Field launcherField = HExecutionEngine.class.getDeclaredField("launcher");
                launcherField.setAccessible(true);
                Launcher launcher = (Launcher) launcherField.get(engine);
                // It doesn't work for Tez Engine due to PIG-5035
                launcher.killJob(jobId, new Configuration());
            } catch (NoSuchFieldException | BackendException | IllegalAccessException e) {
                LOGGER.error("Fail to cancel paragraph:" + context.getParagraphId(), e);
            }
        }
    } else {
        LOGGER.warn("No PigScriptListener found, can not cancel paragraph:" + context.getParagraphId());
    }
}
Also used : Field(java.lang.reflect.Field) HExecutionEngine(org.apache.pig.backend.hadoop.executionengine.HExecutionEngine) Configuration(org.apache.hadoop.conf.Configuration) Launcher(org.apache.pig.backend.hadoop.executionengine.Launcher) BackendException(org.apache.pig.backend.BackendException)

Aggregations

Field (java.lang.reflect.Field)1 Configuration (org.apache.hadoop.conf.Configuration)1 BackendException (org.apache.pig.backend.BackendException)1 HExecutionEngine (org.apache.pig.backend.hadoop.executionengine.HExecutionEngine)1 Launcher (org.apache.pig.backend.hadoop.executionengine.Launcher)1