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);
}
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);
}
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();
}
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);
}
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);
}
}
Aggregations