Java Code Examples for org.springframework.statemachine.StateContext#getMessageHeader()
The following examples show how to use
org.springframework.statemachine.StateContext#getMessageHeader() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TaskLauncherStateMachine.java From spring-cloud-deployer-yarn with Apache License 2.0 | 5 votes |
@Override public void execute(StateContext<String, String> context) { String appVersion = (String) context.getMessageHeader(HEADER_APP_VERSION); // we control type so casting is safe @SuppressWarnings("unchecked") List<String> contextRunArgs = (List<String>) context.getMessageHeader(HEADER_CONTEXT_RUN_ARGS); String applicationId = getYarnCloudAppService().submitApplication(appVersion, CloudAppType.TASK, contextRunArgs); logger.info("New application id is {}", applicationId); context.getExtendedState().getVariables().put(VAR_APPLICATION_ID, applicationId); }
Example 2
Source File: AbstractDeployerStateMachine.java From spring-cloud-deployer-yarn with Apache License 2.0 | 5 votes |
@Override public void execute(StateContext<String, String> context) { String appVersion = (String) context.getMessageHeader(HEADER_APP_VERSION); if (!StringUtils.hasText(appVersion)) { context.getExtendedState().getVariables().put(VAR_ERROR, new RuntimeException("appVersion not defined")); } else { Collection<CloudAppInfo> appInfos = yarnCloudAppService.getApplications(cloudAppType); for (CloudAppInfo appInfo : appInfos) { if (appInfo.getName().equals(appVersion)) { context.getExtendedState().getVariables().put(VAR_APP_VERSION, appVersion); } } } }
Example 3
Source File: AbstractDeployerStateMachine.java From spring-cloud-deployer-yarn with Apache License 2.0 | 5 votes |
@Override public void execute(StateContext<String, String> context) { Resource artifact = (Resource) context.getMessageHeader(HEADER_ARTIFACT); String artifactDir = (String) context.getMessageHeader(HEADER_ARTIFACT_DIR); if (!isHdfsResource(artifact)) { yarnCloudAppService.pushArtifact(artifact, artifactDir); } else { if (!artifact.exists()) { context.getExtendedState().getVariables().put(VAR_ERROR, new RuntimeException("hdfs artifact missing")); } } }
Example 4
Source File: AppDeployerStateMachine.java From spring-cloud-deployer-yarn with Apache License 2.0 | 5 votes |
@Override public void execute(StateContext<String, String> context) { String appVersion = (String) context.getMessageHeader(HEADER_APP_VERSION); String groupId = (String) context.getMessageHeader(HEADER_GROUP_ID); String appName = "scdstream:" + appVersion + ":" + groupId; CloudAppInstanceInfo appInstanceInfo = findRunningInstance(appName); if (appInstanceInfo != null) { context.getExtendedState().getVariables().put(VAR_APPLICATION_ID, appInstanceInfo.getApplicationId()); } }
Example 5
Source File: AppDeployerStateMachine.java From spring-cloud-deployer-yarn with Apache License 2.0 | 5 votes |
@Override public void execute(StateContext<String, String> context) { String appVersion = (String) context.getMessageHeader(HEADER_APP_VERSION); // we control type so casting is safe @SuppressWarnings("unchecked") List<String> contextRunArgs = (List<String>) context.getMessageHeader(HEADER_CONTEXT_RUN_ARGS); String applicationId = getYarnCloudAppService().submitApplication(appVersion, CloudAppType.STREAM, contextRunArgs); context.getExtendedState().getVariables().put(VAR_APPLICATION_ID, applicationId); }
Example 6
Source File: AppDeployerStateMachine.java From spring-cloud-deployer-yarn with Apache License 2.0 | 5 votes |
@Override public void execute(StateContext<String, String> context) { String appVersion = (String) context.getMessageHeader(HEADER_APP_VERSION); String groupId = (String) context.getMessageHeader(HEADER_GROUP_ID); if (StringUtils.hasText(appVersion) && StringUtils.hasText(groupId)) { String appName = "scdstream:" + appVersion + ":" + groupId; context.getExtendedState().getVariables().put(VAR_APPNAME, appName); } }
Example 7
Source File: AbstractAction.java From cloudbreak with Apache License 2.0 | 5 votes |
@Override public void execute(StateContext<S, E> context) { FlowParameters flowParameters = (FlowParameters) context.getMessageHeader(MessageFactory.HEADERS.FLOW_PARAMETERS.name()); ThreadBasedUserCrnProvider.doAs(flowParameters.getFlowTriggerUserCrn(), () -> { MDCBuilder.addFlowId(flowParameters.getFlowId()); P payload = convertPayload(context.getMessageHeader(MessageFactory.HEADERS.DATA.name())); C flowContext = null; try { Map<Object, Object> variables = context.getExtendedState().getVariables(); prepareExecution(payload, variables); String flowStateName = String.valueOf(variables.get(FLOW_STATE_NAME)); Span activeSpan = tracer.activeSpan(); String operationName = context.getEvent().name(); SpanContext spanContext = flowParameters.getSpanContext(); if (TracingUtil.isActiveSpanReusable(activeSpan, spanContext, operationName)) { LOGGER.debug("Reusing existing span. {}", activeSpan.context()); flowContext = createFlowContext(flowParameters, context, payload); executeAction(context, payload, flowContext, variables, flowStateName); } else { Span span = TracingUtil.getSpan(tracer, operationName, spanContext, flowParameters.getFlowId(), null, flowParameters.getFlowTriggerUserCrn()); spanContext = TracingUtil.useOrCreateSpanContext(spanContext, span); flowParameters.setSpanContext(spanContext); try (Scope ignored = tracer.activateSpan(span)) { flowContext = createFlowContext(flowParameters, context, payload); executeAction(context, payload, flowContext, variables, flowStateName); } finally { span.finish(); } } } catch (Exception ex) { LOGGER.error("Error during execution of " + getClass().getName(), ex); if (failureEvent != null) { sendEvent(flowParameters, failureEvent.event(), getFailurePayload(payload, Optional.ofNullable(flowContext), ex), Map.of()); } else { LOGGER.error("Missing error handling for " + getClass().getName()); } } }); }
Example 8
Source File: TaskLauncherStateMachine.java From spring-cloud-deployer-yarn with Apache License 2.0 | 4 votes |
@Override public void execute(StateContext<String, String> context) { String applicationId = (String) context.getMessageHeader(HEADER_APPLICATION_ID); logger.info("Killing application {}", applicationId); getYarnCloudAppService().killApplication(applicationId, CloudAppType.TASK); }
Example 9
Source File: AbstractDeployerStateMachine.java From spring-cloud-deployer-yarn with Apache License 2.0 | 4 votes |
@Override public void execute(StateContext<String, String> context) { String appVersion = (String) context.getMessageHeader(HEADER_APP_VERSION); yarnCloudAppService.pushApplication(appVersion, cloudAppType); }
Example 10
Source File: AppDeployerStateMachine.java From spring-cloud-deployer-yarn with Apache License 2.0 | 4 votes |
@Override public void execute(StateContext<String, String> context) { String clusterId = context.getMessageHeaders().get(HEADER_CLUSTER_ID, String.class); String applicationId = (String) context.getMessageHeader(HEADER_APPLICATION_ID); getYarnCloudAppService().stopCluster(applicationId, clusterId); }
Example 11
Source File: AppDeployerStateMachine.java From spring-cloud-deployer-yarn with Apache License 2.0 | 4 votes |
@Override public void execute(StateContext<String, String> context) { String clusterId = context.getMessageHeaders().get(HEADER_CLUSTER_ID, String.class); String applicationId = (String) context.getMessageHeader(HEADER_APPLICATION_ID); getYarnCloudAppService().destroyCluster(applicationId, clusterId); }