org.apache.pig.backend.BackendException Java Examples

The following examples show how to use org.apache.pig.backend.BackendException. 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: MapReduceLauncher.java    From spork with Apache License 2.0 6 votes vote down vote up
@Override
public void killJob(String jobID, Configuration conf) throws BackendException {
    try {
        if (conf != null) {
            JobConf jobConf = new JobConf(conf);
            JobClient jc = new JobClient(jobConf);
            JobID id = JobID.forName(jobID);
            RunningJob job = jc.getJob(id);
            if (job == null)
                System.out.println("Job with id " + jobID + " is not active");
            else
            {
                job.killJob();
                log.info("Kill " + id + " submitted.");
            }
        }
    } catch (IOException e) {
        throw new BackendException(e);
    }
}
 
Example #2
Source File: BasePigInterpreter.java    From zeppelin with Apache License 2.0 5 votes vote down vote up
@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());
  }
}
 
Example #3
Source File: SequenceFileStoreFunc.java    From hiped2 with Apache License 2.0 5 votes vote down vote up
protected Object inferWritable(Object o) throws BackendException {
  System.out.println("Got object '" + o + "' type " + o.getClass());
  switch (DataType.findType(o)) {
    case BYTEARRAY: {
      return new BytesWritable(((DataByteArray) o).get());
    }
    case CHARARRAY: {
      return new Text(o.toString());
    }
    case INTEGER: {
      return new IntWritable((Integer) o);
    }
    case LONG: {
      return new LongWritable((Long) o);
    }
    case FLOAT: {
      return new FloatWritable((Float) o);
    }
    case DOUBLE: {
      return new DoubleWritable((Double) o);
    }
    case BOOLEAN: {
      return new BooleanWritable((Boolean) o);
    }
    case BYTE: {
      return new ByteWritable((Byte) o);
    }
  }
  throw new BackendException("Unable to translate " + o.getClass() +
      " to a Writable datatype");
}
 
Example #4
Source File: TezLauncher.java    From spork with Apache License 2.0 5 votes vote down vote up
@Override
public void kill() throws BackendException {
    if (runningJob != null) {
        try {
            runningJob.killJob();
        } catch (Exception e) {
            throw new BackendException(e);
        }
    }
    destroy();
}
 
Example #5
Source File: TezLauncher.java    From spork with Apache License 2.0 5 votes vote down vote up
@Override
public void killJob(String jobID, Configuration conf) throws BackendException {
    if (runningJob != null && runningJob.getApplicationId().toString() == jobID) {
        try {
            runningJob.killJob();
        } catch (Exception e) {
            throw new BackendException(e);
        }
    } else {
        log.info("Cannot find job: " + jobID);
    }
}
 
Example #6
Source File: SequenceFileLoader.java    From spork with Apache License 2.0 5 votes vote down vote up
protected void setKeyType(Class<?> keyClass) throws BackendException {
  this.keyType |= inferPigDataType(keyClass);
  if (keyType == DataType.ERROR) {
    LOG.warn("Unable to translate key "+key.getClass()+" to a Pig datatype");
    throw new BackendException("Unable to translate "+key.getClass()+" to a Pig datatype");
  }
}
 
Example #7
Source File: SequenceFileLoader.java    From spork with Apache License 2.0 5 votes vote down vote up
protected void setValueType(Class<?> valueClass) throws BackendException {
  this.valType |= inferPigDataType(valueClass);
  if (keyType == DataType.ERROR) {
    LOG.warn("Unable to translate key "+key.getClass()+" to a Pig datatype");
    throw new BackendException("Unable to translate "+key.getClass()+" to a Pig datatype");
  }
}
 
Example #8
Source File: Launcher.java    From spork with Apache License 2.0 4 votes vote down vote up
public abstract void killJob(String jobID, Configuration conf)
throws BackendException;
 
Example #9
Source File: SparkLauncher.java    From spork with Apache License 2.0 4 votes vote down vote up
@Override
public void kill() throws BackendException {
    // TODO Auto-generated method stub

}
 
Example #10
Source File: SparkLauncher.java    From spork with Apache License 2.0 4 votes vote down vote up
@Override
public void killJob(String jobID, Configuration conf)
        throws BackendException {
    // TODO Auto-generated method stub

}
 
Example #11
Source File: HExecutionEngine.java    From spork with Apache License 2.0 4 votes vote down vote up
@Override
public void killJob(String jobID) throws BackendException {
    if (launcher != null) {
        launcher.killJob(jobID, getJobConf());
    }
}
 
Example #12
Source File: ExecutionEngine.java    From spork with Apache License 2.0 2 votes vote down vote up
/**
 * This method is called when a user requests to kill a job associated with
 * the given job id. If it is not possible for a user to kill a job, throw a
 * exception. It is imperative for the job id's being displayed to be unique
 * such that the correct jobs are being killed when the user supplies the
 * id.
 *
 * @throws BackendException
 */
public void killJob(String jobID) throws BackendException;
 
Example #13
Source File: Launcher.java    From spork with Apache License 2.0 votes vote down vote up
public abstract void kill() throws BackendException;