Java Code Examples for org.apache.zeppelin.interpreter.InterpreterContext#getParagraphId()

The following examples show how to use org.apache.zeppelin.interpreter.InterpreterContext#getParagraphId() . 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: JDBCInterpreter.java    From zeppelin with Apache License 2.0 6 votes vote down vote up
@Override
public void cancel(InterpreterContext context) {

  if (isRefreshMode(context)) {
    LOGGER.info("Shutdown refreshExecutorService for paragraph: {}", context.getParagraphId());
    ScheduledExecutorService executorService =
            refreshExecutorServices.get(context.getParagraphId());
    if (executorService != null) {
      executorService.shutdownNow();
    }
    paragraphCancelMap.put(context.getParagraphId(), true);
    return;
  }

  LOGGER.info("Cancel current query statement.");
  String paragraphId = context.getParagraphId();
  JDBCUserConfigurations jdbcUserConfigurations =
          getJDBCConfiguration(context.getAuthenticationInfo().getUser());
  try {
    jdbcUserConfigurations.cancelStatement(paragraphId);
  } catch (SQLException e) {
    LOGGER.error("Error while cancelling...", e);
  }
}
 
Example 2
Source File: BaseLivyInterpreter.java    From zeppelin with Apache License 2.0 5 votes vote down vote up
@Override
public int getProgress(InterpreterContext context) {
  if (sharedInterpreter != null && sharedInterpreter.isSupported()) {
    return sharedInterpreter.getProgress(context);
  }

  if (livyVersion.isGetProgressSupported()) {
    String paraId = context.getParagraphId();
    Integer progress = paragraphId2StmtProgressMap.get(paraId);
    return progress == null ? 0 : progress;
  }
  return 0;
}
 
Example 3
Source File: RemoteInterpreter.java    From zeppelin with Apache License 2.0 5 votes vote down vote up
private RemoteInterpreterContext convert(InterpreterContext ic) {
  return new RemoteInterpreterContext(ic.getNoteId(), ic.getNoteName(), ic.getParagraphId(),
      ic.getReplName(), ic.getParagraphTitle(), ic.getParagraphText(),
      gson.toJson(ic.getAuthenticationInfo()), gson.toJson(ic.getConfig()), ic.getGui().toJson(),
      gson.toJson(ic.getNoteGui()),
      ic.getLocalProperties());
}
 
Example 4
Source File: Utils.java    From zeppelin with Apache License 2.0 5 votes vote down vote up
public static String buildJobGroupId(InterpreterContext context) {
  String uName = "anonymous";
  if (context.getAuthenticationInfo() != null) {
    uName = getUserName(context.getAuthenticationInfo());
  }
  return "zeppelin|" + uName + "|" + context.getNoteId() + "|" + context.getParagraphId();
}
 
Example 5
Source File: JobManager.java    From zeppelin with Apache License 2.0 5 votes vote down vote up
public void addJob(InterpreterContext context, JobClient jobClient) {
  String paragraphId = context.getParagraphId();
  JobClient previousJobClient = this.jobs.put(paragraphId, jobClient);
  FlinkJobProgressPoller thread = new FlinkJobProgressPoller(flinkWebUrl, jobClient.getJobID(), context);
  thread.setName("JobProgressPoller-Thread-" + paragraphId);
  thread.start();
  this.jobProgressPollerMap.put(jobClient.getJobID(), thread);
  if (previousJobClient != null) {
    LOGGER.warn("There's another Job {} that is associated with paragraph {}",
            jobClient.getJobID(), paragraphId);
  }
}