예제 #1
0
  /**
   * Cancel a job
   *
   * @return
   * @throws IOException
   */
  @RequestMapping(
      value = "/{jobId}/cancel",
      method = {RequestMethod.PUT})
  @ResponseBody
  public JobInstance cancel(@PathVariable String jobId) {

    try {
      final JobInstance jobInstance = jobService.getJobInstance(jobId);
      return jobService.cancelJob(jobInstance);
    } catch (Exception e) {
      logger.error(e.getLocalizedMessage(), e);
      throw new InternalErrorException(e);
    }
  }
예제 #2
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
   */
  @Override
  public void afterPropertiesSet() throws Exception {
    String timeZone = jobService.getKylinConfig().getTimeZone();
    TimeZone tzone = TimeZone.getTimeZone(timeZone);
    TimeZone.setDefault(tzone);

    final KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv();
    String serverMode = kylinConfig.getServerMode();

    if (Constant.SERVER_MODE_JOB.equals(serverMode.toLowerCase())
        || Constant.SERVER_MODE_ALL.equals(serverMode.toLowerCase())) {
      logger.info("Initializing Job Engine ....");

      new Thread(
              new Runnable() {
                @Override
                public void run() {
                  try {
                    DefaultScheduler scheduler = DefaultScheduler.getInstance();
                    scheduler.init(new JobEngineConfig(kylinConfig), new ZookeeperJobLock());
                    if (!scheduler.hasStarted()) {
                      logger.error("scheduler has not been started");
                      System.exit(1);
                    }
                  } catch (Exception e) {
                    throw new RuntimeException(e);
                  }
                }
              })
          .start();
    }
  }
예제 #3
0
  /**
   * get all cube jobs
   *
   * @return
   * @throws IOException
   */
  @RequestMapping(
      value = "",
      method = {RequestMethod.GET})
  @ResponseBody
  public List<JobInstance> list(JobListRequest jobRequest) {

    List<JobInstance> jobInstanceList = Collections.emptyList();
    List<JobStatusEnum> statusList = new ArrayList<JobStatusEnum>();

    if (null != jobRequest.getStatus()) {
      for (int status : jobRequest.getStatus()) {
        statusList.add(JobStatusEnum.getByCode(status));
      }
    }

    try {
      jobInstanceList =
          jobService.listAllJobs(
              jobRequest.getCubeName(),
              jobRequest.getProjectName(),
              statusList,
              jobRequest.getLimit(),
              jobRequest.getOffset());
    } catch (Exception e) {
      logger.error(e.getLocalizedMessage(), e);
      throw new InternalErrorException(e);
    }
    return jobInstanceList;
  }
예제 #4
0
 /**
  * Get a job step output
  *
  * @return
  * @throws IOException
  */
 @RequestMapping(
     value = "/{jobId}/steps/{stepId}/output",
     method = {RequestMethod.GET})
 @ResponseBody
 public Map<String, String> getStepOutput(
     @PathVariable String jobId, @PathVariable String stepId) {
   Map<String, String> result = new HashMap<String, String>();
   result.put("jobId", jobId);
   result.put("stepId", String.valueOf(stepId));
   result.put("cmd_output", jobService.getExecutableManager().getOutput(stepId).getVerboseMsg());
   return result;
 }
예제 #5
0
  /**
   * Get a cube job
   *
   * @return
   * @throws IOException
   */
  @RequestMapping(
      value = "/{jobId}",
      method = {RequestMethod.GET})
  @ResponseBody
  public JobInstance get(@PathVariable String jobId) {
    JobInstance jobInstance = null;
    try {
      jobInstance = jobService.getJobInstance(jobId);
    } catch (Exception e) {
      logger.error(e.getLocalizedMessage(), e);
      throw new InternalErrorException(e);
    }

    return jobInstance;
  }