gpt4 book ai didi

org.apache.helix.task.WorkflowContext.getJobState()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-27 03:13:05 26 4
gpt4 key购买 nike

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

WorkflowContext.getJobState介绍

暂无

代码示例

代码示例来源:origin: apache/incubator-gobblin

WorkflowContext workflowContext = TaskDriver.getWorkflowContext(helixManager, workFlowName);
if (workflowContext != null) {
 TaskState jobState = workflowContext.getJobState(TaskUtil.getNamespacedJobName(workFlowName, jobName));
 switch (jobState) {
  case STOPPED:

代码示例来源:origin: apache/incubator-gobblin

static void waitJobInitialization(
  HelixManager helixManager,
  String workFlowName,
  String jobName,
  long timeoutMillis) throws Exception {
 WorkflowContext workflowContext = TaskDriver.getWorkflowContext(helixManager, workFlowName);
 // If the helix job is deleted from some other thread or a completely external process,
 // method waitJobCompletion() needs to differentiate between the cases where
 // 1) workflowContext did not get initialized ever, in which case we need to keep waiting, or
 // 2) it did get initialized but deleted soon after, in which case we should stop waiting
 // To overcome this issue, we wait here till workflowContext gets initialized
 long start = System.currentTimeMillis();
 while (workflowContext == null || workflowContext.getJobState(TaskUtil.getNamespacedJobName(workFlowName, jobName)) == null) {
  if (System.currentTimeMillis() - start > timeoutMillis) {
   log.error("Job cannot be initialized within {} milliseconds, considered as an error", timeoutMillis);
   throw new JobException("Job cannot be initialized within {} milliseconds, considered as an error");
  }
  workflowContext = TaskDriver.getWorkflowContext(helixManager, workFlowName);
  Thread.sleep(1000);
  log.info("Waiting for work flow initialization.");
 }
 log.info("Work flow {} initialized", workFlowName);
}

代码示例来源:origin: apache/incubator-gobblin

static boolean isJobFinished(String workflowName, String jobName, HelixManager helixManager) {
 WorkflowContext workflowContext = TaskDriver.getWorkflowContext(helixManager, workflowName);
 if (workflowContext == null) {
  // this workflow context doesn't exist, considered as finished.
  return true;
 }
 TaskState jobState = workflowContext.getJobState(TaskUtil.getNamespacedJobName(workflowName, jobName));
 switch (jobState) {
  case STOPPED:
  case FAILED:
  case COMPLETED:
  case ABORTED:
  case TIMED_OUT:
   return true;
  default:
   return false;
 }
}

代码示例来源:origin: apache/incubator-pinot

/**
 * Get the task state for the given task name.
 *
 * @param taskName Task name
 * @return Task state
 */
public synchronized TaskState getTaskState(@Nonnull String taskName) {
 String taskType = getTaskType(taskName);
 return _taskDriver.getWorkflowContext(getHelixJobQueueName(taskType)).getJobState(getHelixJobName(taskName));
}

代码示例来源:origin: apache/incubator-gobblin

/**
  * Deletes the stopped Helix Workflow.
  * Caller should stop the Workflow before calling this method.
  * @param helixManager helix manager
  * @param workFlowName workflow needed to be deleted
  * @param jobName helix job name
  * @throws InterruptedException
  */
 private static void deleteStoppedHelixJob(HelixManager helixManager, String workFlowName, String jobName)
   throws InterruptedException {
  WorkflowContext workflowContext = TaskDriver.getWorkflowContext(helixManager, workFlowName);
  while (workflowContext.getJobState(TaskUtil.getNamespacedJobName(workFlowName, jobName)) != STOPPED) {
   log.info("Waiting for job {} to stop...", jobName);
   workflowContext = TaskDriver.getWorkflowContext(helixManager, workFlowName);
   Thread.sleep(1000);
  }
  // deleting the entire workflow, as one workflow contains only one job
  new TaskDriver(helixManager).deleteAndWaitForCompletion(workFlowName, 10000L);
  log.info("Workflow deleted.");
 }
}

代码示例来源:origin: org.apache.helix/helix-core

public static boolean isJobStarted(String job, WorkflowContext workflowContext) {
  TaskState jobState = workflowContext.getJobState(job);
  return (jobState != null && jobState != TaskState.NOT_STARTED);
 }
}

代码示例来源:origin: apache/helix

public static boolean isJobStarted(String job, WorkflowContext workflowContext) {
 TaskState jobState = workflowContext.getJobState(job);
 return (jobState != null && jobState != TaskState.NOT_STARTED);
}

代码示例来源:origin: apache/helix

/**
 * Checks if the workflow has been stopped.
 * @param ctx Workflow context containing task states
 * @param cfg Workflow config containing set of tasks
 * @return returns true if all tasks are {@link TaskState#STOPPED}, false otherwise.
 */
private static boolean isWorkflowStopped(WorkflowContext ctx, WorkflowConfig cfg) {
 for (String job : cfg.getJobDag().getAllNodes()) {
  if (ctx.getJobState(job) != TaskState.STOPPED && ctx.getJobState(job) != null) {
   return false;
  }
 }
 return true;
}

代码示例来源:origin: org.apache.helix/helix-core

/**
 * Checks if the workflow has been stopped.
 * @param ctx Workflow context containing task states
 * @param cfg Workflow config containing set of tasks
 * @return returns true if all tasks are {@link TaskState#STOPPED}, false otherwise.
 */
private static boolean isWorkflowStopped(WorkflowContext ctx, WorkflowConfig cfg) {
 for (String job : cfg.getJobDag().getAllNodes()) {
  if (ctx.getJobState(job) != TaskState.STOPPED && ctx.getJobState(job) != null) {
   return false;
  }
 }
 return true;
}

代码示例来源:origin: com.linkedin.gobblin/gobblin-cluster

private void waitForJobCompletion() throws InterruptedException {
 while (true) {
  WorkflowContext workflowContext = TaskDriver.getWorkflowContext(this.helixManager, this.helixQueueName);
  if (workflowContext != null) {
   org.apache.helix.task.TaskState helixJobState = workflowContext.getJobState(this.jobResourceName);
   if (helixJobState == org.apache.helix.task.TaskState.COMPLETED ||
     helixJobState == org.apache.helix.task.TaskState.FAILED ||
     helixJobState == org.apache.helix.task.TaskState.STOPPED) {
    return;
   }
  }
  Thread.sleep(1000);
 }
}

代码示例来源:origin: apache/helix

@Override public boolean verify() throws Exception {
  WorkflowContext ctx = driver.getWorkflowContext(workflowName);
  return ctx == null || ctx.getJobState(namespacedJobName) == null
    || ctx.getJobState(namespacedJobName) == TaskState.NOT_STARTED;
 }
}, _default_timeout);

代码示例来源:origin: org.apache.helix/helix-core

/**
 * Count the number of jobs in a workflow that are not in final state.
 * @param workflowCfg
 * @param workflowCtx
 * @return
 */
public static int getInCompleteJobCount(WorkflowConfig workflowCfg, WorkflowContext workflowCtx) {
 int inCompleteCount = 0;
 for (String jobName : workflowCfg.getJobDag().getAllNodes()) {
  TaskState jobState = workflowCtx.getJobState(jobName);
  if (jobState == TaskState.IN_PROGRESS || jobState == TaskState.STOPPED) {
   ++inCompleteCount;
  }
 }
 return inCompleteCount;
}

代码示例来源:origin: apache/helix

/**
 * Count the number of jobs in a workflow that are not in final state.
 * @param workflowCfg
 * @param workflowCtx
 * @return
 */
public static int getInCompleteJobCount(WorkflowConfig workflowCfg, WorkflowContext workflowCtx) {
 int inCompleteCount = 0;
 for (String jobName : workflowCfg.getJobDag().getAllNodes()) {
  TaskState jobState = workflowCtx.getJobState(jobName);
  if (jobState == TaskState.IN_PROGRESS || jobState == TaskState.STOPPED
    || jobState == TaskState.STOPPING) {
   ++inCompleteCount;
  }
 }
 return inCompleteCount;
}

代码示例来源:origin: org.apache.gobblin/gobblin-cluster

/**
  * Deletes the stopped Helix Workflow.
  * Caller should stop the Workflow before calling this method.
  * @param helixManager helix manager
  * @param workFlowName workflow needed to be deleted
  * @param jobName helix job name
  * @throws InterruptedException
  */
 private static void deleteStoppedHelixJob(HelixManager helixManager, String workFlowName, String jobName)
   throws InterruptedException {
  WorkflowContext workflowContext = TaskDriver.getWorkflowContext(helixManager, workFlowName);
  while (workflowContext.getJobState(TaskUtil.getNamespacedJobName(workFlowName, jobName)) != STOPPED) {
   log.info("Waiting for job {} to stop...", jobName);
   workflowContext = TaskDriver.getWorkflowContext(helixManager, workFlowName);
   Thread.sleep(1000);
  }
  // deleting the entire workflow, as one workflow contains only one job
  new TaskDriver(helixManager).deleteAndWaitForCompletion(workFlowName, 10000L);
  log.info("Workflow deleted.");
 }
}

代码示例来源:origin: org.apache.helix/helix-core

/**
 * Checks if the workflow has completed.
 * @param ctx Workflow context containing job states
 * @param cfg Workflow config containing set of jobs
 * @return returns true if all tasks are {@link TaskState#COMPLETED}, false otherwise.
 */
private static boolean isWorkflowComplete(WorkflowContext ctx, WorkflowConfig cfg) {
 if (!cfg.isTerminable()) {
  return false;
 }
 for (String job : cfg.getJobDag().getAllNodes()) {
  if (ctx.getJobState(job) != TaskState.COMPLETED) {
   return false;
  }
 }
 return true;
}

代码示例来源:origin: apache/helix

/**
 * Checks if the workflow has completed.
 * @param ctx Workflow context containing job states
 * @param cfg Workflow config containing set of jobs
 * @return returns true if all tasks are {@link TaskState#COMPLETED}, false otherwise.
 */
private static boolean isWorkflowComplete(WorkflowContext ctx, WorkflowConfig cfg) {
 if (!cfg.isTerminable()) {
  return false;
 }
 for (String job : cfg.getJobDag().getAllNodes()) {
  if (ctx.getJobState(job) != TaskState.COMPLETED) {
   return false;
  }
 }
 return true;
}

代码示例来源:origin: apache/helix

public void refreshJobsStatus(TaskDriver driver) {
 for (Map.Entry<String, JobMonitor> jobMonitor : _perTypeJobMonitorMap.entrySet()) {
  jobMonitor.getValue().resetJobGauge();
 }
 for (String workflow : driver.getWorkflows().keySet()) {
  if (workflow.isEmpty()) {
   continue;
  }
  WorkflowConfig workflowConfig = driver.getWorkflowConfig(workflow);
  if (workflowConfig == null) {
   continue;
  }
  Set<String> allJobs = workflowConfig.getJobDag().getAllNodes();
  WorkflowContext workflowContext = driver.getWorkflowContext(workflow);
  for (String job : allJobs) {
   TaskState currentState = workflowContext == null ? TaskState.NOT_STARTED : workflowContext.getJobState(job);
   updateJobGauges(workflowConfig.getJobTypes() == null ? null : workflowConfig.getJobTypes().get(job),
     currentState);
  }
 }
}

代码示例来源:origin: org.apache.helix/helix-core

/**
 * Checks if the workflow has been stopped.
 * @param ctx Workflow context containing task states
 * @param cfg Workflow config containing set of tasks
 * @return returns true if all tasks are {@link TaskState#STOPPED}, false otherwise.
 */
protected boolean isWorkflowStopped(WorkflowContext ctx, WorkflowConfig cfg) {
 for (String job : cfg.getJobDag().getAllNodes()) {
  TaskState jobState = ctx.getJobState(job);
  if (jobState != null
    && (jobState.equals(TaskState.IN_PROGRESS) || jobState.equals(TaskState.STOPPING))) {
   return false;
  }
 }
 return true;
}

代码示例来源:origin: apache/helix

/**
 * Checks if the workflow has been stopped.
 * @param ctx Workflow context containing task states
 * @param cfg Workflow config containing set of tasks
 * @return returns true if all tasks are {@link TaskState#STOPPED}, false otherwise.
 */
protected boolean isWorkflowStopped(WorkflowContext ctx, WorkflowConfig cfg) {
 for (String job : cfg.getJobDag().getAllNodes()) {
  TaskState jobState = ctx.getJobState(job);
  if (jobState != null
    && (jobState.equals(TaskState.IN_PROGRESS) || jobState.equals(TaskState.STOPPING))) {
   return false;
  }
 }
 return true;
}

代码示例来源:origin: org.apache.helix/helix-core

public void refreshJobsStatus(TaskDriver driver) {
 for (JobMonitor jobMonitor : _perTypeJobMonitorMap.values()) {
  jobMonitor.resetJobGauge();
 }
 for (String workflow : driver.getWorkflows().keySet()) {
  if (workflow.isEmpty()) {
   continue;
  }
  WorkflowConfig workflowConfig = driver.getWorkflowConfig(workflow);
  if (workflowConfig == null) {
   continue;
  }
  Set<String> allJobs = workflowConfig.getJobDag().getAllNodes();
  WorkflowContext workflowContext = driver.getWorkflowContext(workflow);
  for (String job : allJobs) {
   TaskState currentState = workflowContext == null ? TaskState.NOT_STARTED : workflowContext.getJobState(job);
   updateJobGauges(workflowConfig.getJobTypes() == null ? null : workflowConfig.getJobTypes().get(job),
     currentState);
  }
 }
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com