Search in sources :

Example 1 with UpdateLocalsCommand

use of com.walmartlabs.concord.runtime.v2.runner.vm.UpdateLocalsCommand in project concord by walmartlabs.

the class Runner method resume.

public ProcessSnapshot resume(ProcessSnapshot snapshot, Map<String, Object> input) throws Exception {
    statusCallback.onRunning(instanceId.getValue());
    log.debug("resume -> running...");
    State state = snapshot.vmState();
    VM vm = createVM(snapshot.processDefinition());
    // update the global variables using the input map by running a special command
    vm.run(state, new UpdateLocalsCommand(input));
    // continue as usual
    vm.start(state);
    log.debug("resume -> done");
    return ProcessSnapshot.builder().from(snapshot).vmState(state).build();
}
Also used : UpdateLocalsCommand(com.walmartlabs.concord.runtime.v2.runner.vm.UpdateLocalsCommand)

Example 2 with UpdateLocalsCommand

use of com.walmartlabs.concord.runtime.v2.runner.vm.UpdateLocalsCommand in project concord by walmartlabs.

the class Runner method start.

public ProcessSnapshot start(ProcessConfiguration processConfiguration, ProcessDefinition processDefinition, Map<String, Object> input) throws Exception {
    statusCallback.onRunning(instanceId.getValue());
    log.debug("start ['{}'] -> running...", processConfiguration.entryPoint());
    Command cmd = CompilerUtils.compile(compiler, processConfiguration, processDefinition, processConfiguration.entryPoint());
    State state = new InMemoryState(cmd);
    // install the exception handler into the root frame
    // takes care of all unhandled errors bubbling up
    VMUtils.assertNearestRoot(state, state.getRootThreadId()).setExceptionHandler(new SaveLastErrorCommand());
    VM vm = createVM(processDefinition);
    // update the global variables using the input map by running a special command
    // TODO merge with the cfg's arguments
    vm.run(state, new UpdateLocalsCommand(input));
    // start the normal execution
    vm.start(state);
    log.debug("start ['{}'] -> done", processConfiguration.entryPoint());
    return ProcessSnapshot.builder().vmState(state).processDefinition(processDefinition).build();
}
Also used : SaveLastErrorCommand(com.walmartlabs.concord.runtime.v2.runner.vm.SaveLastErrorCommand) UpdateLocalsCommand(com.walmartlabs.concord.runtime.v2.runner.vm.UpdateLocalsCommand) SaveLastErrorCommand(com.walmartlabs.concord.runtime.v2.runner.vm.SaveLastErrorCommand) UpdateLocalsCommand(com.walmartlabs.concord.runtime.v2.runner.vm.UpdateLocalsCommand)

Example 3 with UpdateLocalsCommand

use of com.walmartlabs.concord.runtime.v2.runner.vm.UpdateLocalsCommand in project concord by walmartlabs.

the class Runner method resume.

public ProcessSnapshot resume(ProcessSnapshot snapshot, Set<String> eventRefs, Map<String, Object> input) throws Exception {
    statusCallback.onRunning(instanceId.getValue());
    log.debug("resume ['{}'] -> running...", eventRefs);
    State state = snapshot.vmState();
    VM vm = createVM(snapshot.processDefinition());
    // update the global variables using the input map by running a special command
    // only the threads with the specified eventRef will receive the input
    Collection<ThreadId> resumingThreads = state.getEventRefs().entrySet().stream().filter(kv -> eventRefs.contains(kv.getValue())).map(Map.Entry::getKey).collect(Collectors.toList());
    vm.run(state, new UpdateLocalsCommand(input, resumingThreads));
    // resume normally
    vm.resume(state, eventRefs);
    log.debug("resume ['{}'] -> done", eventRefs);
    return ProcessSnapshot.builder().from(snapshot).vmState(state).build();
}
Also used : Map(java.util.Map) UpdateLocalsCommand(com.walmartlabs.concord.runtime.v2.runner.vm.UpdateLocalsCommand)

Aggregations

UpdateLocalsCommand (com.walmartlabs.concord.runtime.v2.runner.vm.UpdateLocalsCommand)3 SaveLastErrorCommand (com.walmartlabs.concord.runtime.v2.runner.vm.SaveLastErrorCommand)1 Map (java.util.Map)1