gpt4 book ai didi

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

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

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

WorkflowToken.getAll介绍

[英]Same key can be added to the WorkflowToken by multiple nodes. This method returns the key to List of NodeValueadded in the Scope#USER scope.
[中]多个节点可以向WorkflowToken添加相同的密钥。此方法返回作用域#用户作用域中添加的nodeValueList的键。

代码示例

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

/**
 * Merge the other WorkflowToken passed to the method as a parameter
 * with the WorkflowToken on which the method is invoked.
 * @param other the other WorkflowToken to be merged
 */
synchronized void mergeToken(WorkflowToken other) {
 for (Scope scope : Scope.values()) {
  Map<String, List<NodeValue>> thisTokenValueMapForScope = this.tokenValueMap.get(scope);
  for (Map.Entry<String, List<NodeValue>> otherTokenValueMapForScopeEntry : other.getAll(scope).entrySet()) {
   String otherKey = otherTokenValueMapForScopeEntry.getKey();
   if (!thisTokenValueMapForScope.containsKey(otherKey)) {
    thisTokenValueMapForScope.put(otherKey, Lists.<NodeValue>newArrayList());
   }
   // Iterate over the list of NodeValue corresponding to the current key.
   // Only add those NodeValue to the merged token which already do not exist.
   for (NodeValue otherNodeValue : otherTokenValueMapForScopeEntry.getValue()) {
    boolean otherNodeValueExist = false;
    for (NodeValue thisNodeValue : thisTokenValueMapForScope.get(otherKey)) {
     if (thisNodeValue.equals(otherNodeValue)) {
      otherNodeValueExist = true;
      break;
     }
    }
    if (!otherNodeValueExist) {
     addOrUpdate(otherKey, otherNodeValue, thisTokenValueMapForScope.get(otherKey), -1);
    }
   }
  }
 }
}

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

@GET
@Path("/apps/{app-id}/workflows/{workflow-id}/runs/{run-id}/token")
public void getWorkflowToken(HttpRequest request, HttpResponder responder,
               @PathParam("namespace-id") String namespaceId,
               @PathParam("app-id") String appId,
               @PathParam("workflow-id") String workflowId,
               @PathParam("run-id") String runId,
               @QueryParam("scope") @DefaultValue("user") String scope,
               @QueryParam("key") @DefaultValue("") String key) throws NotFoundException {
 WorkflowToken workflowToken = getWorkflowToken(namespaceId, appId, workflowId, runId);
 WorkflowToken.Scope tokenScope = WorkflowToken.Scope.valueOf(scope.toUpperCase());
 WorkflowTokenDetail workflowTokenDetail = WorkflowTokenDetail.of(workflowToken.getAll(tokenScope));
 Type workflowTokenDetailType = new TypeToken<WorkflowTokenDetail>() { }.getType();
 if (key.isEmpty()) {
  responder.sendJson(HttpResponseStatus.OK, GSON.toJson(workflowTokenDetail, workflowTokenDetailType));
  return;
 }
 List<NodeValue> nodeValueEntries = workflowToken.getAll(key, tokenScope);
 if (nodeValueEntries.isEmpty()) {
  throw new NotFoundException(key);
 }
 responder.sendJson(HttpResponseStatus.OK,
           GSON.toJson(WorkflowTokenDetail.of(Collections.singletonMap(key, nodeValueEntries)),
                 workflowTokenDetailType));
}

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

/**
 * Merge the other WorkflowToken passed to the method as a parameter
 * with the WorkflowToken on which the method is invoked.
 * @param other the other WorkflowToken to be merged
 */
synchronized void mergeToken(WorkflowToken other) {
 for (Scope scope : Scope.values()) {
  Map<String, List<NodeValue>> thisTokenValueMapForScope = this.tokenValueMap.get(scope);
  for (Map.Entry<String, List<NodeValue>> otherTokenValueMapForScopeEntry : other.getAll(scope).entrySet()) {
   String otherKey = otherTokenValueMapForScopeEntry.getKey();
   if (!thisTokenValueMapForScope.containsKey(otherKey)) {
    thisTokenValueMapForScope.put(otherKey, Lists.<NodeValue>newArrayList());
   }
   // Iterate over the list of NodeValue corresponding to the current key.
   // Only add those NodeValue to the merged token which already do not exist.
   for (NodeValue otherNodeValue : otherTokenValueMapForScopeEntry.getValue()) {
    boolean otherNodeValueExist = false;
    for (NodeValue thisNodeValue : thisTokenValueMapForScope.get(otherKey)) {
     if (thisNodeValue.equals(otherNodeValue)) {
      otherNodeValueExist = true;
      break;
     }
    }
    if (!otherNodeValueExist) {
     addOrUpdate(otherKey, otherNodeValue, thisTokenValueMapForScope.get(otherKey), -1);
    }
   }
  }
 }
}

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

@GET
@Path("/apps/{app-id}/workflows/{workflow-id}/runs/{run-id}/token")
public void getWorkflowToken(HttpRequest request, HttpResponder responder,
               @PathParam("namespace-id") String namespaceId,
               @PathParam("app-id") String appId,
               @PathParam("workflow-id") String workflowId,
               @PathParam("run-id") String runId,
               @QueryParam("scope") @DefaultValue("user") String scope,
               @QueryParam("key") @DefaultValue("") String key) throws NotFoundException {
 WorkflowToken workflowToken = getWorkflowToken(namespaceId, appId, workflowId, runId);
 WorkflowToken.Scope tokenScope = WorkflowToken.Scope.valueOf(scope.toUpperCase());
 WorkflowTokenDetail workflowTokenDetail = WorkflowTokenDetail.of(workflowToken.getAll(tokenScope));
 Type workflowTokenDetailType = new TypeToken<WorkflowTokenDetail>() { }.getType();
 if (key.isEmpty()) {
  responder.sendJson(HttpResponseStatus.OK, GSON.toJson(workflowTokenDetail, workflowTokenDetailType));
  return;
 }
 List<NodeValue> nodeValueEntries = workflowToken.getAll(key, tokenScope);
 if (nodeValueEntries.isEmpty()) {
  throw new NotFoundException(key);
 }
 responder.sendJson(HttpResponseStatus.OK,
           GSON.toJson(WorkflowTokenDetail.of(Collections.singletonMap(key, nodeValueEntries)),
                 workflowTokenDetailType));
}

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

WorkflowToken token = context.getToken();
for (WorkflowToken.Scope scope : Arrays.asList(WorkflowToken.Scope.SYSTEM, WorkflowToken.Scope.USER)) {
 Map<String, List<NodeValue>> all = token.getAll(scope);
 for (Map.Entry<String, List<NodeValue>> entry : all.entrySet()) {
  if (!entry.getKey().startsWith(Constants.StageStatistics.PREFIX + ".")) {

代码示例来源:origin: co.cask.hydrator/core-plugins

WorkflowToken token = context.getToken();
String message = config.includeWorkflowToken ?
 config.message + "\nUSER Workflow Tokens:\n" + token.getAll(WorkflowToken.Scope.USER)
  + "\nSYSTEM Workflow Tokens:\n" + token.getAll(WorkflowToken.Scope.SYSTEM) :
 config.message;
msg.setText(message);

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

List<NodeValue> allNodeValues = token.getAll(Constants.FIELD_OPERATION_KEY_IN_WORKFLOW_TOKEN);

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

if (trueBranchExecuted) {
 List<NodeValue> nodeValueEntries = workflowToken.getAll("action.type");
 Preconditions.checkArgument(5 == nodeValueEntries.size());
 Preconditions.checkArgument(new NodeValue("RecordVerifier",
} else {
 List<NodeValue> nodeValueEntries = workflowToken.getAll("action.type");
 Preconditions.checkArgument(5 == nodeValueEntries.size());
 Preconditions.checkArgument(new NodeValue("RecordVerifier",
 validateMapReduceCounters(workflowToken, "RecordVerifier");
Map<String, List<NodeValue>> allUserKeys = workflowToken.getAll(WorkflowToken.Scope.USER);
Preconditions.checkArgument(5 == allUserKeys.get("action.type").size());

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

@Override
 public boolean apply(@Nullable WorkflowContext input) {
  if (input != null) {
   input.getToken().put("action.type", "Condition");
   List<NodeValue> goodRecords = input.getToken().getAll("MyCustomCounter.GoodRecord", WorkflowToken.Scope.SYSTEM);
   List<NodeValue> badRecords = input.getToken().getAll("MyCustomCounter.BadRecord", WorkflowToken.Scope.SYSTEM);
   // If number of good records are greater than the number of bad records then only
   // return true to execute the true branch associated with this Condition node
   if (goodRecords.get(0).getValue().getAsLong() > badRecords.get(0).getValue().getAsLong()) {
    input.getToken().put("conditionResult", "true");
    return true;
   }
   input.getToken().put("conditionResult", "false");
  }
  return false;
 }
}

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

@Test
 public void testSerDeserScheduleInfo() {
  BasicWorkflowToken token = new BasicWorkflowToken(1);
  token.setCurrentNode("node");
  token.put("tokenKey", "tokenVal");
  List<TriggerInfo> triggerInfos = ImmutableList.of(
    new DefaultProgramStatusTriggerInfo("ns", Specifications.from(new WorkflowAppWithFork()), ProgramType.WORKFLOW,
                      WorkflowAppWithFork.WorkflowWithFork.class.getSimpleName(),
                      RunIds.generate(), ProgramStatus.COMPLETED,
                      token, Collections.emptyMap()),
    new DefaultPartitionTriggerInfo("ns", "ds", 10, 11),
    new DefaultTimeTriggerInfo("1 * * * *", 0L)
  );
  TriggeringScheduleInfo scheduleInfo = new DefaultTriggeringScheduleInfo("schedule", "description", triggerInfos,
                                      ImmutableMap.of("key", "value"));

  String scheduleInfoJson = GSON.toJson(scheduleInfo);
  TriggeringScheduleInfo deserializedScheduleInfo = GSON.fromJson(scheduleInfoJson,
                                  TriggeringScheduleInfo.class);
  Assert.assertEquals(scheduleInfoJson, GSON.toJson(deserializedScheduleInfo));
  DefaultProgramStatusTriggerInfo expectedProgramStatusTriggerInfo =
   (DefaultProgramStatusTriggerInfo) triggerInfos.get(0);
  DefaultProgramStatusTriggerInfo deserializedProgramStatusTriggerInfo =
   (DefaultProgramStatusTriggerInfo) deserializedScheduleInfo.getTriggerInfos().get(0);
  Assert.assertEquals(expectedProgramStatusTriggerInfo.getApplicationSpecification().getName(),
            deserializedProgramStatusTriggerInfo.getApplicationSpecification().getName());
  Assert.assertEquals(expectedProgramStatusTriggerInfo.getWorkflowToken().getAll(),
            deserializedProgramStatusTriggerInfo.getWorkflowToken().getAll());
 }
}

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