コード例 #1
0
  @Override
  public InterpreterResult interpret(String line, InterpreterContext interpreterContext) {
    try {
      if (userSessionMap.get(interpreterContext.getAuthenticationInfo().getUser()) == null) {
        try {
          userSessionMap.put(
              interpreterContext.getAuthenticationInfo().getUser(),
              livyHelper.createSession(interpreterContext, "pyspark"));
        } catch (Exception e) {
          LOGGER.error("Exception in LivyPySparkInterpreter while interpret ", e);
          return new InterpreterResult(InterpreterResult.Code.ERROR, e.getMessage());
        }
      }

      if (line == null || line.trim().length() == 0) {
        return new InterpreterResult(InterpreterResult.Code.SUCCESS, "");
      }

      return livyHelper.interpret(line, interpreterContext, userSessionMap);
    } catch (Exception e) {
      LOGGER.error("Exception in LivyPySparkInterpreter while interpret ", e);
      return new InterpreterResult(
          InterpreterResult.Code.ERROR, InterpreterUtils.getMostRelevantMessage(e));
    }
  }
コード例 #2
0
 @Override
 public void cancel(InterpreterContext context) {
   livyHelper.cancelHTTP(context.getParagraphId());
 }
コード例 #3
0
 @Override
 public void close() {
   livyHelper.closeSession(userSessionMap);
 }