gpt4 book ai didi

co.cask.cdap.api.workflow.WorkflowSpecification.getName()方法的使用及代码示例

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

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

WorkflowSpecification.getName介绍

暂无

代码示例

代码示例来源:origin: cdapio/cdap

private void verifyWorkflowNodeList(ApplicationSpecification appSpec, WorkflowSpecification workflowSpec,
                  List<WorkflowNode> nodeList, Set<String> existingNodeNames) {
 for (WorkflowNode n : nodeList) {
  if (existingNodeNames.contains(n.getNodeId())) {
   throw new RuntimeException(String.format("Node '%s' already exists in workflow '%s'.", n.getNodeId(),
                        workflowSpec.getName()));
  }
  existingNodeNames.add(n.getNodeId());
  verifyWorkflowNode(appSpec, workflowSpec, n, existingNodeNames);
 }
}

代码示例来源:origin: cdapio/cdap

private void verifyWorkflowFork(ApplicationSpecification appSpec, WorkflowSpecification workflowSpec,
                WorkflowNode node, Set<String> existingNodeNames) {
 WorkflowForkNode forkNode = (WorkflowForkNode) node;
 Preconditions.checkNotNull(forkNode.getBranches(), String.format("Fork is added in the Workflow '%s' without" +
                                   " any branches", workflowSpec.getName()));
 for (List<WorkflowNode> branch : forkNode.getBranches()) {
  verifyWorkflowNodeList(appSpec, workflowSpec, branch, existingNodeNames);
 }
}

代码示例来源:origin: co.cask.cdap/cdap-app-fabric

private void verifyWorkflowFork(ApplicationSpecification appSpec, WorkflowSpecification workflowSpec,
                WorkflowNode node, Set<String> existingNodeNames) {
 WorkflowForkNode forkNode = (WorkflowForkNode) node;
 Preconditions.checkNotNull(forkNode.getBranches(), String.format("Fork is added in the Workflow '%s' without" +
                                   " any branches", workflowSpec.getName()));
 for (List<WorkflowNode> branch : forkNode.getBranches()) {
  verifyWorkflowNodeList(appSpec, workflowSpec, branch, existingNodeNames);
 }
}

代码示例来源:origin: co.cask.cdap/cdap-app-fabric

private void verifyWorkflowNodeList(ApplicationSpecification appSpec, WorkflowSpecification workflowSpec,
                  List<WorkflowNode> nodeList, Set<String> existingNodeNames) {
 for (WorkflowNode n : nodeList) {
  if (existingNodeNames.contains(n.getNodeId())) {
   throw new RuntimeException(String.format("Node '%s' already exists in workflow '%s'.", n.getNodeId(),
                        workflowSpec.getName()));
  }
  existingNodeNames.add(n.getNodeId());
  verifyWorkflowNode(appSpec, workflowSpec, n, existingNodeNames);
 }
}

代码示例来源:origin: caskdata/cdap

@Override
public JsonElement serialize(WorkflowSpecification src, Type typeOfSrc, JsonSerializationContext context) {
 JsonObject jsonObj = new JsonObject();
 jsonObj.add("className", new JsonPrimitive(src.getClassName()));
 jsonObj.add("name", new JsonPrimitive(src.getName()));
 jsonObj.add("description", new JsonPrimitive(src.getDescription()));
 jsonObj.add("plugins", serializeMap(src.getPlugins(), context, Plugin.class));
 jsonObj.add("properties", serializeMap(src.getProperties(), context, String.class));
 jsonObj.add("nodes", serializeList(src.getNodes(), context, WorkflowNode.class));
 jsonObj.add("localDatasetSpecs", serializeMap(src.getLocalDatasetSpecs(), context, DatasetCreationSpec.class));
 return jsonObj;
}

代码示例来源:origin: co.cask.cdap/cdap-proto

@Override
public JsonElement serialize(WorkflowSpecification src, Type typeOfSrc, JsonSerializationContext context) {
 JsonObject jsonObj = new JsonObject();
 jsonObj.add("className", new JsonPrimitive(src.getClassName()));
 jsonObj.add("name", new JsonPrimitive(src.getName()));
 jsonObj.add("description", new JsonPrimitive(src.getDescription()));
 jsonObj.add("plugins", serializeMap(src.getPlugins(), context, Plugin.class));
 jsonObj.add("properties", serializeMap(src.getProperties(), context, String.class));
 jsonObj.add("nodes", serializeList(src.getNodes(), context, WorkflowNode.class));
 jsonObj.add("localDatasetSpecs", serializeMap(src.getLocalDatasetSpecs(), context, DatasetCreationSpec.class));
 return jsonObj;
}

代码示例来源:origin: co.cask.cdap/cdap-app-fabric

@Override
public void addWorkflow(Workflow workflow) {
 Preconditions.checkArgument(workflow != null, "Workflow cannot be null.");
 DefaultWorkflowConfigurer configurer = new DefaultWorkflowConfigurer(workflow, this,
                                    deployNamespace, artifactId,
                                    artifactRepository, pluginInstantiator);
 workflow.configure(configurer);
 WorkflowSpecification spec = configurer.createSpecification();
 addDatasetsAndPlugins(configurer);
 workflows.put(spec.getName(), spec);
}

代码示例来源:origin: cdapio/cdap

@Override
public void addWorkflow(Workflow workflow) {
 Preconditions.checkArgument(workflow != null, "Workflow cannot be null.");
 DefaultWorkflowConfigurer configurer = new DefaultWorkflowConfigurer(workflow, this,
                                    deployNamespace, artifactId,
                                    artifactRepository, pluginInstantiator);
 workflow.configure(configurer);
 WorkflowSpecification spec = configurer.createSpecification();
 addDatasetsAndPlugins(configurer);
 workflows.put(spec.getName(), spec);
}

代码示例来源:origin: co.cask.cdap/cdap-app-fabric

private void verifyWorkflowNode(ApplicationSpecification appSpec, WorkflowSpecification workflowSpec,
                WorkflowNode node, Set<String> existingNodeNames) {
 WorkflowNodeType nodeType = node.getType();
 // TODO CDAP-5640 Add check so that node id in the Workflow should not be same as name of the Workflow.
 if (node.getNodeId().equals(workflowSpec.getName())) {
  String msg = String.format("Node used in Workflow has same name as that of Workflow '%s'." +
                 " This will conflict while getting the Workflow token details associated with" +
                 " the node. Please use name for the node other than the name of the Workflow.",
                workflowSpec.getName());
  LOG.warn(msg);
 }
 switch (nodeType) {
  case ACTION:
   verifyWorkflowAction(appSpec, node);
   break;
  case FORK:
   verifyWorkflowFork(appSpec, workflowSpec, node, existingNodeNames);
   break;
  case CONDITION:
   verifyWorkflowCondition(appSpec, workflowSpec, node, existingNodeNames);
   break;
  default:
   break;
 }
}

代码示例来源:origin: cdapio/cdap

private void verifyWorkflowNode(ApplicationSpecification appSpec, WorkflowSpecification workflowSpec,
                WorkflowNode node, Set<String> existingNodeNames) {
 WorkflowNodeType nodeType = node.getType();
 // TODO CDAP-5640 Add check so that node id in the Workflow should not be same as name of the Workflow.
 if (node.getNodeId().equals(workflowSpec.getName())) {
  String msg = String.format("Node used in Workflow has same name as that of Workflow '%s'." +
                 " This will conflict while getting the Workflow token details associated with" +
                 " the node. Please use name for the node other than the name of the Workflow.",
                workflowSpec.getName());
  LOG.warn(msg);
 }
 switch (nodeType) {
  case ACTION:
   verifyWorkflowAction(appSpec, node);
   break;
  case FORK:
   verifyWorkflowFork(appSpec, workflowSpec, node, existingNodeNames);
   break;
  case CONDITION:
   verifyWorkflowCondition(appSpec, workflowSpec, node, existingNodeNames);
   break;
  default:
   break;
 }
}

代码示例来源:origin: cdapio/cdap

@Override
protected void run() throws Exception {
 LOG.info("Starting workflow execution for '{}' with Run id '{}'", workflowSpec.getName(), workflowRunId.getRun());
 LOG.trace("Workflow specification is {}", workflowSpec);
 workflowContext.setState(new ProgramState(ProgramStatus.RUNNING, null));
 executeAll(workflowSpec.getNodes().iterator(), program.getApplicationSpecification(),
       new InstantiatorFactory(false), program.getClassLoader(), basicWorkflowToken);
 if (runningThread != null) {
  workflowContext.setState(new ProgramState(ProgramStatus.COMPLETED, null));
 }
 LOG.info("Workflow '{}' with run id '{}' completed", workflowSpec.getName(), workflowRunId.getRun());
}

代码示例来源:origin: cdapio/cdap

private void executeAll(Iterator<WorkflowNode> iterator, ApplicationSpecification appSpec,
            InstantiatorFactory instantiator, ClassLoader classLoader, WorkflowToken token) {
 while (iterator.hasNext() && runningThread != null) {
  try {
   blockIfSuspended();
   WorkflowNode node = iterator.next();
   executeNode(appSpec, node, instantiator, classLoader, token);
  } catch (Throwable t) {
   Throwable rootCause = Throwables.getRootCause(t);
   if (rootCause instanceof InterruptedException) {
    LOG.debug("Workflow '{}' with run id '{}' aborted", workflowSpec.getName(),
         workflowRunId.getRun());
    workflowContext.setState(new ProgramState(ProgramStatus.KILLED, rootCause.getMessage()));
    break;
   }
   workflowContext.setState(new ProgramState(ProgramStatus.FAILED, rootCause.getMessage()));
   throw Throwables.propagate(rootCause);
  }
 }
}

代码示例来源:origin: co.cask.cdap/cdap-app-fabric

@Override
protected void run() throws Exception {
 LOG.info("Starting workflow execution for '{}' with Run id '{}'", workflowSpec.getName(), workflowRunId.getRun());
 LOG.trace("Workflow specification is {}", workflowSpec);
 workflowContext.setState(new ProgramState(ProgramStatus.RUNNING, null));
 executeAll(workflowSpec.getNodes().iterator(), program.getApplicationSpecification(),
       new InstantiatorFactory(false), program.getClassLoader(), basicWorkflowToken);
 if (runningThread != null) {
  workflowContext.setState(new ProgramState(ProgramStatus.COMPLETED, null));
 }
 LOG.info("Workflow '{}' with run id '{}' completed", workflowSpec.getName(), workflowRunId.getRun());
}

代码示例来源:origin: co.cask.cdap/cdap-app-fabric

private void executeAll(Iterator<WorkflowNode> iterator, ApplicationSpecification appSpec,
            InstantiatorFactory instantiator, ClassLoader classLoader, WorkflowToken token) {
 while (iterator.hasNext() && runningThread != null) {
  try {
   blockIfSuspended();
   WorkflowNode node = iterator.next();
   executeNode(appSpec, node, instantiator, classLoader, token);
  } catch (Throwable t) {
   Throwable rootCause = Throwables.getRootCause(t);
   if (rootCause instanceof InterruptedException) {
    LOG.debug("Workflow '{}' with run id '{}' aborted", workflowSpec.getName(),
         workflowRunId.getRun());
    workflowContext.setState(new ProgramState(ProgramStatus.KILLED, rootCause.getMessage()));
    break;
   }
   workflowContext.setState(new ProgramState(ProgramStatus.FAILED, rootCause.getMessage()));
   throw Throwables.propagate(rootCause);
  }
 }
}

代码示例来源:origin: cdapio/cdap

@Override
 public String toString() {
  return "WorkflowSpecification{" +
   "className='" + getClassName() + '\'' +
   ", name='" + getName() + '\'' +
   ", description='" + getDescription() + '\'' +
   ", plugins=" + getPlugins() +
   ", properties=" + properties +
   ", nodes=" + nodes +
   ", nodeIdMap=" + nodeIdMap +
   ", localDatasetSpecs=" + localDatasetSpecs +
   '}';
 }
}

代码示例来源:origin: co.cask.cdap/cdap-app-fabric

/**
 * Delete the specified application version without performing checks that its programs are stopped.
 *
 * @param appId the id of the application to delete
 * @param spec the spec of the application to delete
 */
private void deleteAppVersion(ApplicationId appId, ApplicationSpecification spec) {
 //Delete the schedules
 scheduler.deleteSchedules(appId);
 for (WorkflowSpecification workflowSpec : spec.getWorkflows().values()) {
  scheduler.modifySchedulesTriggeredByDeletedProgram(appId.workflow(workflowSpec.getName()));
 }
 store.removeApplication(appId);
}

代码示例来源:origin: cdapio/cdap

/**
 * Delete the specified application version without performing checks that its programs are stopped.
 *
 * @param appId the id of the application to delete
 * @param spec the spec of the application to delete
 */
private void deleteAppVersion(ApplicationId appId, ApplicationSpecification spec) {
 //Delete the schedules
 scheduler.deleteSchedules(appId);
 for (WorkflowSpecification workflowSpec : spec.getWorkflows().values()) {
  scheduler.modifySchedulesTriggeredByDeletedProgram(appId.workflow(workflowSpec.getName()));
 }
 store.removeApplication(appId);
}

代码示例来源:origin: cdapio/cdap

@SuppressWarnings("unchecked")
private Workflow initializeWorkflow() throws Exception {
 Class<?> clz = Class.forName(workflowSpec.getClassName(), true, program.getClassLoader());
 if (!Workflow.class.isAssignableFrom(clz)) {
  throw new IllegalStateException(String.format("%s is not Workflow.", clz));
 }
 Class<? extends Workflow> workflowClass = (Class<? extends Workflow>) clz;
 final Workflow workflow = new InstantiatorFactory(false).get(TypeToken.of(workflowClass)).create();
 // set metrics
 Reflections.visit(workflow, workflow.getClass(), new MetricsFieldSetter(workflowContext.getMetrics()));
 if (!(workflow instanceof ProgramLifecycle)) {
  return workflow;
 }
 final TransactionControl txControl =
  Transactions.getTransactionControl(workflowContext.getDefaultTxControl(), Workflow.class,
                    workflow, "initialize", WorkflowContext.class);
 basicWorkflowToken.setCurrentNode(workflowSpec.getName());
 workflowContext.setState(new ProgramState(ProgramStatus.INITIALIZING, null));
 workflowContext.initializeProgram((ProgramLifecycle) workflow, txControl, false);
 workflowStateWriter.setWorkflowToken(workflowRunId, basicWorkflowToken);
 return workflow;
}

代码示例来源:origin: co.cask.cdap/cdap-app-fabric

@SuppressWarnings("unchecked")
private Workflow initializeWorkflow() throws Exception {
 Class<?> clz = Class.forName(workflowSpec.getClassName(), true, program.getClassLoader());
 if (!Workflow.class.isAssignableFrom(clz)) {
  throw new IllegalStateException(String.format("%s is not Workflow.", clz));
 }
 Class<? extends Workflow> workflowClass = (Class<? extends Workflow>) clz;
 final Workflow workflow = new InstantiatorFactory(false).get(TypeToken.of(workflowClass)).create();
 // set metrics
 Reflections.visit(workflow, workflow.getClass(), new MetricsFieldSetter(workflowContext.getMetrics()));
 if (!(workflow instanceof ProgramLifecycle)) {
  return workflow;
 }
 final TransactionControl txControl =
  Transactions.getTransactionControl(workflowContext.getDefaultTxControl(), Workflow.class,
                    workflow, "initialize", WorkflowContext.class);
 basicWorkflowToken.setCurrentNode(workflowSpec.getName());
 workflowContext.setState(new ProgramState(ProgramStatus.INITIALIZING, null));
 workflowContext.initializeProgram((ProgramLifecycle) workflow, txControl, false);
 workflowStateWriter.setWorkflowToken(workflowRunId, basicWorkflowToken);
 return workflow;
}

代码示例来源:origin: cdapio/cdap

@SuppressWarnings("unchecked")
private void destroyWorkflow() {
 if (!(workflow instanceof ProgramLifecycle)) {
  return;
 }
 final TransactionControl txControl = Transactions.getTransactionControl(workflowContext.getDefaultTxControl(),
                                     Workflow.class, workflow, "destroy");
 basicWorkflowToken.setCurrentNode(workflowSpec.getName());
 workflowContext.destroyProgram((ProgramLifecycle) workflow, txControl, false);
 try {
  workflowStateWriter.setWorkflowToken(workflowRunId, basicWorkflowToken);
 } catch (Throwable t) {
  LOG.error("Failed to store the final workflow token of Workflow {}", workflowRunId, t);
 }
 if (ProgramStatus.COMPLETED != workflowContext.getState().getStatus()) {
  return;
 }
 try {
  Set<Operation> fieldLineageOperations = workflowContext.getFieldLineageOperations();
  if (!fieldLineageOperations.isEmpty()) {
   FieldLineageInfo info = new FieldLineageInfo(fieldLineageOperations);
   fieldLineageWriter.write(workflowRunId, info);
  }
 } catch (Throwable t) {
  LOG.debug("Failed to emit the field lineage operations for Workflow {}", workflowRunId, t);
 }
}

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