org.embulk.spi.Exec.doWith()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(100)

本文整理了Java中org.embulk.spi.Exec.doWith()方法的一些代码示例,展示了Exec.doWith()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Exec.doWith()方法的具体详情如下:
包路径:org.embulk.spi.Exec
类名称:Exec
方法名:doWith

Exec.doWith介绍

暂无

代码示例

代码示例来源:origin: embulk/embulk

public ConfigDiff guess(ExecSession exec, final ConfigSource config) {
  try {
    return Exec.doWith(exec, new ExecAction<ConfigDiff>() {
        public ConfigDiff run() {
          try (SetCurrentThreadName dontCare = new SetCurrentThreadName("guess")) {
            return doGuess(config);
          }
        }
      });
  } catch (ExecutionException ex) {
    if (ex.getCause() instanceof RuntimeException) {
      throw (RuntimeException) ex.getCause();
    }
    if (ex.getCause() instanceof Error) {
      throw (Error) ex.getCause();
    }
    throw new RuntimeException(ex.getCause());
  }
}

代码示例来源:origin: embulk/embulk

public ExecutionResult run(ExecSession exec, final ConfigSource config) {
  try {
    return Exec.doWith(exec, new ExecAction<ExecutionResult>() {
        public ExecutionResult run() {
          try (SetCurrentThreadName dontCare = new SetCurrentThreadName("transaction")) {
            return doRun(config);
          }
        }
      });
  } catch (ExecutionException ex) {
    if (ex.getCause() instanceof RuntimeException) {
      throw (RuntimeException) ex.getCause();
    }
    if (ex.getCause() instanceof Error) {
      throw (Error) ex.getCause();
    }
    throw new RuntimeException(ex.getCause());
  }
}

代码示例来源:origin: embulk/embulk

public PreviewResult preview(ExecSession exec, final ConfigSource config) {
  try {
    return Exec.doWith(exec.forPreview(), new ExecAction<PreviewResult>() {
        public PreviewResult run() {
          try (SetCurrentThreadName dontCare = new SetCurrentThreadName("preview")) {
            return doPreview(config);
          }
        }
      });
  } catch (Exception ex) {
    if (ex.getCause() instanceof RuntimeException) {
      throw (RuntimeException) ex.getCause();
    }
    throw new RuntimeException(ex.getCause());
  }
}

代码示例来源:origin: embulk/embulk

public void cleanup(final ConfigSource config, final ResumeState resume) {
  try {
    ExecSession exec = ExecSession.builder(injector).fromExecConfig(resume.getExecSessionConfigSource()).build();
    Exec.doWith(exec, new ExecAction<Void>() {
        public Void run() {
          try (SetCurrentThreadName dontCare = new SetCurrentThreadName("cleanup")) {
            doCleanup(config, resume);
            return null;
          }
        }
      });
    exec.cleanup();
  } catch (ExecutionException ex) {
    if (ex.getCause() instanceof RuntimeException) {
      throw (RuntimeException) ex.getCause();
    }
    if (ex.getCause() instanceof Error) {
      throw (Error) ex.getCause();
    }
    throw new RuntimeException(ex.getCause());
  }
}

代码示例来源:origin: embulk/embulk

public ExecutionResult resume(final ConfigSource config, final ResumeState resume) {
  try {
    ExecSession exec = ExecSession.builder(injector).fromExecConfig(resume.getExecSessionConfigSource()).build();
    ExecutionResult result = Exec.doWith(exec, new ExecAction<ExecutionResult>() {
        public ExecutionResult run() {
          try (SetCurrentThreadName dontCare = new SetCurrentThreadName("resume")) {
            return doResume(config, resume);
          }
        }
      });
    exec.cleanup();
    return result;
  } catch (ExecutionException ex) {
    if (ex.getCause() instanceof RuntimeException) {
      throw (RuntimeException) ex.getCause();
    }
    if (ex.getCause() instanceof Error) {
      throw (Error) ex.getCause();
    }
    throw new RuntimeException(ex.getCause());
  }
}

代码示例来源:origin: embulk/embulk

public void evaluate() throws Throwable {
    try {
      Exec.doWith(exec, new ExecAction<Void>() {
          public Void run() {
            try {
              superStatement.evaluate();
            } catch (Throwable ex) {
              throw new RuntimeExecutionException(ex);
            }
            return null;
          }
        });
    } catch (RuntimeException ex) {
      throw ex.getCause();
    } finally {
      exec.cleanup();
    }
  }
};

相关文章