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

x33g5p2x  于2022-02-03 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(135)

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

WorkflowContext.getRecord介绍

暂无

代码示例

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

/**
 * Update context of the Workflow
 */
public void updateWorkflowContext(String resourceName, WorkflowContext workflowContext) {
 updateContext(resourceName, workflowContext.getRecord());
}

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

/**
 * Update context of the Workflow
 */
public void updateWorkflowContext(String resourceName, WorkflowContext workflowContext,
  HelixDataAccessor accessor) {
 updateContext(resourceName, workflowContext.getRecord(), accessor);
}

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

/**
 * Set the runtime context of a single workflow
 * @param manager a connection to Helix
 * @param workflow the name of the workflow
 * @param workflowContext the up-to-date {@link WorkflowContext} for the workflow
 */
protected static void setWorkflowContext(HelixManager manager, String workflow,
  WorkflowContext workflowContext) {
 manager.getHelixPropertyStore().set(
   Joiner.on("/").join(TaskConstants.REBALANCER_CONTEXT_ROOT, workflow, CONTEXT_NODE),
   workflowContext.getRecord(), AccessOption.PERSISTENT);
}

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

/**
 * Set the runtime context of a single workflow
 * @param manager a connection to Helix
 * @param workflow the name of the workflow
 * @param workflowContext the up-to-date {@link WorkflowContext} for the workflow
 */
protected static void setWorkflowContext(HelixManager manager, String workflow,
  WorkflowContext workflowContext) {
 manager.getHelixPropertyStore().set(
   Joiner.on("/").join(TaskConstants.REBALANCER_CONTEXT_ROOT, workflow, CONTEXT_NODE),
   workflowContext.getRecord(), AccessOption.PERSISTENT);
}

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

@GET
@Path("{workflowId}/context")
public Response getWorkflowContext(@PathParam("clusterId") String clusterId,
  @PathParam("workflowId") String workflowId) {
 TaskDriver taskDriver = getTaskDriver(clusterId);
 WorkflowContext workflowContext = taskDriver.getWorkflowContext(workflowId);
 ObjectNode workflowContextNode = JsonNodeFactory.instance.objectNode();
 if (workflowContext != null) {
  getWorkflowContextNode(workflowContextNode, workflowContext.getRecord());
 }
 return JSONRepresentation(workflowContextNode);
}

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

@Override
 public ZNRecord update(ZNRecord currentData) {
  if (currentData != null) {
   WorkflowContext workflowContext = new WorkflowContext(currentData);
   workflowContext.removeJobStates(jobs);
   workflowContext.removeJobStartTime(jobs);
   currentData = workflowContext.getRecord();
  }
  return currentData;
 }
};

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

@Override
 public ZNRecord update(ZNRecord currentData) {
  if (currentData != null) {
   WorkflowContext workflowContext = new WorkflowContext(currentData);
   workflowContext.removeJobStates(jobs);
   workflowContext.removeJobStartTime(jobs);
   currentData = workflowContext.getRecord();
  }
  return currentData;
 }
};

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

/**
 * This test method tests whether PropertyKey.Builder successfully creates a path for
 * WorkflowContext instances.
 * TODO: KeyBuilder must handle the case for future versions of Task Framework with a different
 * path structure
 */
@Test
public void testGetWorkflowContext() {
 // Manually create a WorkflowContext instance
 ZNRecord znRecord = new ZNRecord(WORKFLOW_NAME);
 WorkflowContext workflowContext = new WorkflowContext(znRecord);
 _manager.getHelixPropertyStore().set(
   Joiner.on("/").join(TaskConstants.REBALANCER_CONTEXT_ROOT, WORKFLOW_NAME, CONTEXT_NODE),
   workflowContext.getRecord(), AccessOption.PERSISTENT);
 // Test retrieving this WorkflowContext using PropertyKey.Builder.getPath()
 String path = KEY_BUILDER.workflowContext(WORKFLOW_NAME).getPath();
 WorkflowContext workflowCtx =
   new WorkflowContext(_baseAccessor.get(path, null, AccessOption.PERSISTENT));
 Assert.assertEquals(workflowContext, workflowCtx);
}

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

@GET
@Path("{workflowId}")
public Response getWorkflow(@PathParam("clusterId") String clusterId,
  @PathParam("workflowId") String workflowId) {
 TaskDriver taskDriver = getTaskDriver(clusterId);
 WorkflowConfig workflowConfig = taskDriver.getWorkflowConfig(workflowId);
 WorkflowContext workflowContext = taskDriver.getWorkflowContext(workflowId);
 ObjectNode root = JsonNodeFactory.instance.objectNode();
 TextNode id = JsonNodeFactory.instance.textNode(workflowId);
 root.put(Properties.id.name(), id);
 ObjectNode workflowConfigNode = JsonNodeFactory.instance.objectNode();
 ObjectNode workflowContextNode = JsonNodeFactory.instance.objectNode();
 if (workflowConfig != null) {
  getWorkflowConfigNode(workflowConfigNode, workflowConfig.getRecord());
 }
 if (workflowContext != null) {
  getWorkflowContextNode(workflowContextNode, workflowContext.getRecord());
 }
 root.put(WorkflowProperties.WorkflowConfig.name(), workflowConfigNode);
 root.put(WorkflowProperties.WorkflowContext.name(), workflowContextNode);
 JobDag jobDag = workflowConfig.getJobDag();
 ArrayNode jobs = OBJECT_MAPPER.valueToTree(jobDag.getAllNodes());
 ObjectNode parentJobs = OBJECT_MAPPER.valueToTree(jobDag.getChildrenToParents());
 root.put(WorkflowProperties.Jobs.name(), jobs);
 root.put(WorkflowProperties.ParentJobs.name(), parentJobs);
 root.put(WorkflowProperties.LastScheduledTask.name(), OBJECT_MAPPER.valueToTree(taskDriver.getLastScheduledTaskExecutionInfo(workflowId)));
 return JSONRepresentation(root);
}

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

StringRepresentation getHostedEntitiesRepresentation(String clusterName, String jobQueueName)
  throws Exception {
 ZkClient zkClient =
   ResourceUtil.getAttributeFromCtx(getContext(), ResourceUtil.ContextKey.ZKCLIENT);
 HelixDataAccessor accessor =
   ClusterRepresentationUtil.getClusterDataAccessor(zkClient, clusterName);
 PropertyKey.Builder keyBuilder = accessor.keyBuilder();
 TaskDriver taskDriver = new TaskDriver(zkClient, clusterName);
 // Get job queue config
 // TODO: fix this to use workflowConfig.
 ResourceConfig jobQueueConfig = accessor.getProperty(keyBuilder.resourceConfig(jobQueueName));
 // Get job queue context
 WorkflowContext ctx = taskDriver.getWorkflowContext(jobQueueName);
 // Create the result
 ZNRecord hostedEntitiesRecord = new ZNRecord(jobQueueName);
 if (jobQueueConfig != null) {
  hostedEntitiesRecord.merge(jobQueueConfig.getRecord());
 }
 if (ctx != null) {
  hostedEntitiesRecord.merge(ctx.getRecord());
 }
 StringRepresentation representation =
   new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(hostedEntitiesRecord),
     MediaType.APPLICATION_JSON);
 return representation;
}

相关文章