- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中co.cask.cdap.api.workflow.WorkflowToken.put()
方法的一些代码示例,展示了WorkflowToken.put()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WorkflowToken.put()
方法的具体详情如下:
包路径:co.cask.cdap.api.workflow.WorkflowToken
类名称:WorkflowToken
方法名:put
[英]Put the specified key and Value into the WorkflowToken. The token may store additional information about the context in which this key is being set. For example, the context information stored by the token may be the workflow node that is performing the operation, or the name of the workflow if the operation is performed in AbstractWorkflow#initializeor AbstractWorkflow#destroy method.
[中]将指定的键和值放入WorkflowToken。令牌可以存储关于设置该密钥的上下文的附加信息。例如,令牌存储的上下文信息可能是正在执行操作的工作流节点,或者如果在AbstractWorkflow#initializeor AbstractWorkflow#destroy method中执行操作,则可能是工作流的名称。
代码示例来源:origin: co.cask.cdap/hydrator-spark-core2
private void updateWorkflowToken(WorkflowToken token, Map<String, StageStatisticsCollector> collectors) {
for (Map.Entry<String, StageStatisticsCollector> entry : collectors.entrySet()) {
SparkStageStatisticsCollector collector = (SparkStageStatisticsCollector) entry.getValue();
String keyPrefix = Constants.StageStatistics.PREFIX + "." + entry.getKey() + ".";
String inputRecordKey = keyPrefix + Constants.StageStatistics.INPUT_RECORDS;
token.put(inputRecordKey, String.valueOf(collector.getInputRecordCount()));
String outputRecordKey = keyPrefix + Constants.StageStatistics.OUTPUT_RECORDS;
token.put(outputRecordKey, String.valueOf(collector.getOutputRecordCount()));
String errorRecordKey = keyPrefix + Constants.StageStatistics.ERROR_RECORDS;
token.put(errorRecordKey, String.valueOf(collector.getErrorRecordCount()));
}
}
}
代码示例来源:origin: cdapio/cdap
@Override
@SuppressWarnings("ConstantConditions")
public void initialize() throws Exception {
WorkflowToken token = getContext().getWorkflowToken();
Preconditions.checkArgument(token != null, "Workflow actions should always have a workflow token available");
token.put(TOKEN_KEY, TOKEN_VALUE);
}
代码示例来源:origin: cdapio/cdap
@Override
public boolean apply(@Nullable WorkflowContext input) {
input.getToken().put("simple.condition.initialize", "true");
if (input.getRuntimeArguments().containsKey("simple.condition")) {
return true;
}
return false;
}
}
代码示例来源:origin: cdapio/cdap
@Override
public boolean apply(@Nullable WorkflowContext input) {
input.getToken().put("configurable.condition.apply", "true");
if (input.getRuntimeArguments().containsKey("configurable.condition")) {
return true;
}
return false;
}
}
代码示例来源:origin: cdapio/cdap
@Override
public void initialize(WorkflowContext context) throws Exception {
super.initialize(context);
context.getToken().put(ANOTHER_TOKEN_KEY, ANOTHER_TOKEN_VALUE);
}
}
代码示例来源:origin: cdapio/cdap
@Override
public void initialize() throws Exception {
WorkflowToken token = getContext().getWorkflowToken();
token.put("running", Value.of(true));
token.put("finished", Value.of(false));
}
代码示例来源:origin: cdapio/cdap
@Override
public void destroy() {
WorkflowToken token = getContext().getWorkflowToken();
token.put("running", Value.of(false));
token.put("finished", Value.of(true));
}
}
代码示例来源:origin: cdapio/cdap
@Override
public void initialize() throws Exception {
WorkflowToken workflowToken = getContext().getWorkflowToken();
workflowToken.put(TOKEN_KEY, TOKEN_VALUE);
}
代码示例来源:origin: cdapio/cdap
@Override
public void initialize(WorkflowContext context) throws Exception {
super.initialize(context);
context.getToken().put(SampleWorkflow.INITIALIZE_TOKEN_KEY, SampleWorkflow.INITIALIZE_TOKEN_VALUE);
}
代码示例来源:origin: cdapio/cdap
@Override
public void destroy() {
WorkflowToken token = getContext().getToken();
@SuppressWarnings("ConstantConditions")
String initializeValue = token.get(SampleWorkflow.INITIALIZE_TOKEN_KEY, SampleWorkflow.NAME).toString();
if (!initializeValue.equals(SampleWorkflow.INITIALIZE_TOKEN_VALUE)) {
// Should not happen, since we are always putting token in the Workflow.initialize method.
// We can not throw exception here since any exception thrown will be caught in the Workflow driver.
// So in order to test this put some token value which is check in the test case.
token.put(SampleWorkflow.DESTROY_TOKEN_KEY, SampleWorkflow.DESTROY_TOKEN_FAIL_VALUE);
} else {
token.put(SampleWorkflow.DESTROY_TOKEN_KEY, SampleWorkflow.DESTROY_TOKEN_SUCCESS_VALUE);
}
}
代码示例来源:origin: cdapio/cdap
@Override
public void initialize() throws Exception {
MapReduceContext context = getContext();
Map<String, String> args = context.getRuntimeArguments();
String inputPath = args.get("inputPath");
String outputPath = args.get("outputPath");
WordCount.configureJob((Job) context.getHadoopJob(), inputPath, outputPath);
WorkflowToken workflowToken = context.getWorkflowToken();
if (workflowToken == null) {
return;
}
// Put something in the token
workflowToken.put("action_type", "MapReduce");
workflowToken.put("start_time", Value.of(System.currentTimeMillis()));
}
}
代码示例来源:origin: cdapio/cdap
@Override
public void initialize() throws Exception {
MapReduceContext context = getContext();
Job job = context.getHadoopJob();
job.setMapperClass(MyVerifier.class);
String inputPath = context.getRuntimeArguments().get("inputPath");
String outputPath = context.getRuntimeArguments().get("outputPath");
FileInputFormat.addInputPath(job, new Path(inputPath));
FileOutputFormat.setOutputPath(job, new Path(outputPath));
// Put something in the token
WorkflowToken workflowToken = context.getWorkflowToken();
if (workflowToken == null) {
return;
}
workflowToken.put("action.type", "MapReduce");
workflowToken.put("start.time", Value.of(System.currentTimeMillis()));
}
}
代码示例来源:origin: cdapio/cdap
@Override
public void initialize(WorkflowContext context) throws Exception {
super.initialize(context);
TriggeringScheduleInfo scheduleInfo = context.getTriggeringScheduleInfo();
if (scheduleInfo != null) {
// Get values of the runtime args and workflow token from the triggering program
// whose keys are defined as keys in TRIGGERING_PROPERTIES_MAPPING with a special syntax and use their values
// for the corresponding workflow tokens as defined in TRIGGERING_PROPERTIES_MAPPING values
String propertiesMappingString =
scheduleInfo.getProperties().get(TRIGGERING_PROPERTIES_MAPPING);
if (propertiesMappingString != null) {
Map<String, String> propertiesMap = GSON.fromJson(propertiesMappingString, STRING_STRING_MAP);
Map<String, String> newTokenMap =
getNewTokensFromScheduleInfo(scheduleInfo, propertiesMap);
for (Map.Entry<String, String> entry : newTokenMap.entrySet()) {
// Write the workflow token into context
context.getToken().put(entry.getKey(), entry.getValue());
}
}
}
}
}
代码示例来源:origin: cdapio/cdap
@Override
public void initialize() throws Exception {
MapReduceContext context = getContext();
Map<String, String> args = context.getRuntimeArguments();
String inputPath = args.get("inputPath");
String outputPath = args.get("outputPath");
WordCount.configureJob((Job) context.getHadoopJob(), inputPath, outputPath);
WorkflowToken workflowToken = context.getWorkflowToken();
if (workflowToken == null) {
return;
}
// Put something in the token
workflowToken.put("action.type", "MapReduce");
workflowToken.put("start.time", Value.of(System.currentTimeMillis()));
Preconditions.checkNotNull(workflowToken.get("start.time", "RecordVerifier"));
}
}
代码示例来源:origin: cdapio/cdap
@Override
public void destroy() {
super.destroy();
getContext().getToken().put("configurable.condition.destroy", "true");
}
代码示例来源:origin: cdapio/cdap
@Override
public void initialize(WorkflowContext context) throws Exception {
super.initialize(context);
getContext().getToken().put("configurable.condition.initialize", "true");
}
代码示例来源: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
@Override
public void run() {
String actionName = getContext().getSpecification().getName();
LOG.info("Running SimpleAction: {}", actionName);
WorkflowToken token = getContext().getWorkflowToken();
// Put something in the token
token.put("action.type", "CustomAction");
try {
File file = new File(getContext().getRuntimeArguments().get(actionName + ".simple.action.file"));
Preconditions.checkState(file.createNewFile());
File doneFile = new File(getContext().getRuntimeArguments().get(actionName + ".simple.action.donefile"));
while (!doneFile.exists()) {
TimeUnit.MILLISECONDS.sleep(50);
}
} catch (Exception e) {
// no-op
}
}
}
代码示例来源:origin: co.cask.cdap/cdap-etl-batch
@Override
public void run() throws Exception {
CustomActionContext context = getContext();
Map<String, String> properties = context.getSpecification().getProperties();
BatchPhaseSpec phaseSpec = GSON.fromJson(properties.get(Constants.PIPELINEID), BatchPhaseSpec.class);
PipelinePhase phase = phaseSpec.getPhase();
StageSpec stageSpec = phase.iterator().next();
PluginContext pluginContext = new PipelinePluginContext(context, metrics,
phaseSpec.isStageLoggingEnabled(),
phaseSpec.isProcessTimingEnabled());
PipelineRuntime pipelineRuntime = new PipelineRuntime(context, metrics);
Action action =
pluginContext.newPluginInstance(stageSpec.getName(),
new DefaultMacroEvaluator(pipelineRuntime.getArguments(),
context.getLogicalStartTime(),
context,
context.getNamespace()));
ActionContext actionContext = new BasicActionContext(context, pipelineRuntime, stageSpec);
if (!context.getDataTracer(stageSpec.getName()).isEnabled()) {
action.run(actionContext);
}
WorkflowToken token = context.getWorkflowToken();
if (token == null) {
throw new IllegalStateException("WorkflowToken cannot be null when action is executed through Workflow.");
}
for (Map.Entry<String, String> entry : pipelineRuntime.getArguments().getAddedArguments().entrySet()) {
token.put(entry.getKey(), entry.getValue());
}
}
}
代码示例来源:origin: cdapio/cdap
@Override
public void run() throws Exception {
WorkflowToken token = getContext().getWorkflowToken();
token.put("action.name", getContext().getSpecification().getName());
}
}
我想了解 Ruby 方法 methods() 是如何工作的。 我尝试使用“ruby 方法”在 Google 上搜索,但这不是我需要的。 我也看过 ruby-doc.org,但我没有找到这种方法。
Test 方法 对指定的字符串执行一个正则表达式搜索,并返回一个 Boolean 值指示是否找到匹配的模式。 object.Test(string) 参数 object 必选项。总是一个
Replace 方法 替换在正则表达式查找中找到的文本。 object.Replace(string1, string2) 参数 object 必选项。总是一个 RegExp 对象的名称。
Raise 方法 生成运行时错误 object.Raise(number, source, description, helpfile, helpcontext) 参数 object 应为
Execute 方法 对指定的字符串执行正则表达式搜索。 object.Execute(string) 参数 object 必选项。总是一个 RegExp 对象的名称。 string
Clear 方法 清除 Err 对象的所有属性设置。 object.Clear object 应为 Err 对象的名称。 说明 在错误处理后,使用 Clear 显式地清除 Err 对象。此
CopyFile 方法 将一个或多个文件从某位置复制到另一位置。 object.CopyFile source, destination[, overwrite] 参数 object 必选
Copy 方法 将指定的文件或文件夹从某位置复制到另一位置。 object.Copy destination[, overwrite] 参数 object 必选项。应为 File 或 F
Close 方法 关闭打开的 TextStream 文件。 object.Close object 应为 TextStream 对象的名称。 说明 下面例子举例说明如何使用 Close 方
BuildPath 方法 向现有路径后添加名称。 object.BuildPath(path, name) 参数 object 必选项。应为 FileSystemObject 对象的名称
GetFolder 方法 返回与指定的路径中某文件夹相应的 Folder 对象。 object.GetFolder(folderspec) 参数 object 必选项。应为 FileSy
GetFileName 方法 返回指定路径(不是指定驱动器路径部分)的最后一个文件或文件夹。 object.GetFileName(pathspec) 参数 object 必选项。应为
GetFile 方法 返回与指定路径中某文件相应的 File 对象。 object.GetFile(filespec) 参数 object 必选项。应为 FileSystemObject
GetExtensionName 方法 返回字符串,该字符串包含路径最后一个组成部分的扩展名。 object.GetExtensionName(path) 参数 object 必选项。应
GetDriveName 方法 返回包含指定路径中驱动器名的字符串。 object.GetDriveName(path) 参数 object 必选项。应为 FileSystemObjec
GetDrive 方法 返回与指定的路径中驱动器相对应的 Drive 对象。 object.GetDrive drivespec 参数 object 必选项。应为 FileSystemO
GetBaseName 方法 返回字符串,其中包含文件的基本名 (不带扩展名), 或者提供的路径说明中的文件夹。 object.GetBaseName(path) 参数 object 必
GetAbsolutePathName 方法 从提供的指定路径中返回完整且含义明确的路径。 object.GetAbsolutePathName(pathspec) 参数 object
FolderExists 方法 如果指定的文件夹存在,则返回 True;否则返回 False。 object.FolderExists(folderspec) 参数 object 必选项
FileExists 方法 如果指定的文件存在返回 True;否则返回 False。 object.FileExists(filespec) 参数 object 必选项。应为 FileS
我是一名优秀的程序员,十分优秀!