Search in sources :

Example 1 with State

use of com.walmartlabs.concord.svm.State in project concord by walmartlabs.

the class ContextVariables method get.

@Override
public Object get(String key) {
    State state = ctx.execution().state();
    ThreadId threadId = ctx.execution().currentThreadId();
    return VMUtils.getCombinedLocal(state, threadId, key);
}
Also used : ThreadId(com.walmartlabs.concord.svm.ThreadId) State(com.walmartlabs.concord.svm.State)

Example 2 with State

use of com.walmartlabs.concord.svm.State in project concord by walmartlabs.

the class ContextVariables method has.

@Override
public boolean has(String key) {
    State state = ctx.execution().state();
    ThreadId threadId = ctx.execution().currentThreadId();
    return VMUtils.hasCombinedLocal(state, threadId, key);
}
Also used : ThreadId(com.walmartlabs.concord.svm.ThreadId) State(com.walmartlabs.concord.svm.State)

Example 3 with State

use of com.walmartlabs.concord.svm.State in project concord by walmartlabs.

the class Main method getTopLevelVariables.

private static Map<String, Serializable> getTopLevelVariables(ProcessSnapshot snapshot) {
    State state = snapshot.vmState();
    List<Frame> frames = state.getFrames(state.getRootThreadId());
    Frame rootFrame = frames.get(frames.size() - 1);
    return rootFrame.getLocals();
}
Also used : Frame(com.walmartlabs.concord.svm.Frame) State(com.walmartlabs.concord.svm.State)

Example 4 with State

use of com.walmartlabs.concord.svm.State in project concord by walmartlabs.

the class DefaultCheckpointService method create.

@Override
public void create(ThreadId threadId, UUID correlationId, String name, Runtime runtime, ProcessSnapshot snapshot) {
    validate(threadId, snapshot);
    UUID checkpointId = UUID.randomUUID();
    try (StateArchive archive = new StateArchive()) {
        // the goal here is to create a process state snapshot with
        // a "synthetic" event that can be used to continue the process
        // after the checkpoint step
        String resumeEventRef = checkpointId.toString();
        State state = clone(snapshot.vmState(), classLoader);
        state.setEventRef(threadId, resumeEventRef);
        state.setStatus(threadId, ThreadStatus.SUSPENDED);
        archive.withResumeEvent(resumeEventRef).withProcessState(ProcessSnapshot.builder().from(snapshot).vmState(state).build()).withSystemDirectory(workingDirectory.getValue());
        try (TemporaryPath zip = archive.zip()) {
            checkpointUploader.upload(checkpointId, correlationId, name, zip.path());
        }
    } catch (Exception e) {
        throw new RuntimeException("Checkpoint upload error", e);
    }
    log.info("Checkpoint '{}' created", name);
}
Also used : State(com.walmartlabs.concord.svm.State) UUID(java.util.UUID) TemporaryPath(com.walmartlabs.concord.common.TemporaryPath)

Example 5 with State

use of com.walmartlabs.concord.svm.State in project concord by walmartlabs.

the class DefaultCheckpointService method validate.

private static void validate(ThreadId threadId, ProcessSnapshot snapshot) {
    State state = snapshot.vmState();
    String eventRef = state.getEventRefs().get(threadId);
    if (eventRef != null) {
        throw new IllegalStateException("Can't create a checkpoint, the current thread has an unprocessed eventRef: " + eventRef);
    }
}
Also used : State(com.walmartlabs.concord.svm.State)

Aggregations

State (com.walmartlabs.concord.svm.State)10 ThreadId (com.walmartlabs.concord.svm.ThreadId)6 Frame (com.walmartlabs.concord.svm.Frame)3 TemporaryPath (com.walmartlabs.concord.common.TemporaryPath)2 UUID (java.util.UUID)2 TaskProviders (com.walmartlabs.concord.runtime.v2.runner.tasks.TaskProviders)1 InMemoryState (com.walmartlabs.concord.svm.InMemoryState)1 Serializable (java.io.Serializable)1 Test (org.junit.jupiter.api.Test)1