/**
     * Restore process to a saved checkpoint.
     */
public CheckpointInfo restoreCheckpoint(ProcessKey processKey, UUID checkpointId) {
        try (TemporaryPath checkpointArchive = IOUtils.tempFile("checkpoint", ".zip")) {
            String checkpointName = export(processKey, checkpointId, checkpointArchive.path());
            if (checkpointName == null) {
                return null;
            }
            try (TemporaryPath extractedDir = IOUtils.tempDir("unzipped-checkpoint")) {
                IOUtils.unzip(checkpointArchive.path(), extractedDir.path());
                // TODO: only for v1 runtime
                String eventName = readCheckpointEventName(extractedDir.path());
                stateManager.tx(tx -> {
                    stateManager.deleteDirectory(tx, processKey, Constants.Files.CONCORD_SYSTEM_DIR_NAME);
                    stateManager.deleteDirectory(tx, processKey, Constants.Files.JOB_ATTACHMENTS_DIR_NAME);
                    stateManager.importPath(tx, processKey, null, extractedDir.path(), (p, attrs) -> true);
                });
                Map<String, Object> out = OutVariablesUtils.read(extractedDir.path().resolve(Constants.Files.JOB_ATTACHMENTS_DIR_NAME));
                if (out.isEmpty()) {
                    queueDao.removeMeta(processKey, "out");
                } else {
                    queueDao.updateMeta(processKey, Collections.singletonMap("out", out));
                }
                return CheckpointInfo.of(checkpointName, eventName);
            }
        } catch (Exception e) {
            throw new RuntimeException("Restore checkpoint '" + checkpointId + "' error", e);
        }
    }
public CheckpointInfo restoreCheckpoint(ProcessKey processKey, UUID checkpointId) {
try (TemporaryPath checkpointArchive = IOUtils.tempFile("checkpoint", ".zip")) {
String checkpointName = export(processKey, checkpointId, checkpointArchive.path());
if (checkpointName == null) {
return null;
}
try (TemporaryPath extractedDir = IOUtils.tempDir("unzipped-checkpoint")) {
IOUtils.unzip(checkpointArchive.path(), extractedDir.path());
// TODO: only for v1 runtime
String eventName = readCheckpointEventName(extractedDir.path());
stateManager.tx(tx -> {
stateManager.deleteDirectory(tx, processKey, Constants.Files.CONCORD_SYSTEM_DIR_NAME);
stateManager.deleteDirectory(tx, processKey, Constants.Files.JOB_ATTACHMENTS_DIR_NAME);
stateManager.importPath(tx, processKey, null, extractedDir.path(), (p, attrs) -> true);
});
Map<String, Object> out = OutVariablesUtils.read(extractedDir.path().resolve(Constants.Files.JOB_ATTACHMENTS_DIR_NAME));
if (out.isEmpty()) {
queueDao.removeMeta(processKey, "out");
} else {
queueDao.updateMeta(processKey, Collections.singletonMap("out", out));
}
return CheckpointInfo.of(checkpointName, eventName);
}
} catch (Exception e) {
throw new RuntimeException("Restore checkpoint '" + checkpointId + "' error", e);
}
}
public CheckpointInfo restoreCheckpoint(ProcessKey processKey, UUID checkpointId) {
try (TemporaryPath checkpointArchive = IOUtils.tempFile("checkpoint", ".zip")) {
String checkpointName = export(processKey, checkpointId, checkpointArchive.path());
if (checkpointName == null) {
return null;
}
try (TemporaryPath extractedDir = IOUtils.tempDir("unzipped-checkpoint")) {
IOUtils.unzip(checkpointArchive.path(), extractedDir.path());
// TODO: only for v1 runtime
String eventName = readCheckpointEventName(extractedDir.path());
stateManager.tx(tx -> {
stateManager.deleteDirectory(tx, processKey, Constants.Files.CONCORD_SYSTEM_DIR_NAME);
stateManager.deleteDirectory(tx, processKey, Constants.Files.JOB_ATTACHMENTS_DIR_NAME);
stateManager.importPath(tx, processKey, null, extractedDir.path(), (p, attrs) -> true);
});
Map<String, Object> out = OutVariablesUtils.read(extractedDir.path().resolve(Constants.Files.JOB_ATTACHMENTS_DIR_NAME));
if (out.isEmpty()) {
queueDao.removeMeta(processKey, "out");
} else {
queueDao.updateMeta(processKey, Collections.singletonMap("out", out));
}
return CheckpointInfo.of(checkpointName, eventName);
}
} catch (Exception e) {
throw new RuntimeException("Restore checkpoint '" + checkpointId + "' error", e);
}
}
public CheckpointInfo restoreCheckpoint(ProcessKey processKey, UUID checkpointId) {
try (TemporaryPath checkpointArchive = IOUtils.tempFile("checkpoint", ".zip")) {
String checkpointName = export(processKey, checkpointId, checkpointArchive.path());
if (checkpointName == null) {
return null;
}
try (TemporaryPath extractedDir = IOUtils.tempDir("unzipped-checkpoint")) {
IOUtils.unzip(checkpointArchive.path(), extractedDir.path());
// TODO: only for v1 runtime
String eventName = readCheckpointEventName(extractedDir.path());
stateManager.tx(tx -> {
stateManager.deleteDirectory(tx, processKey, Constants.Files.CONCORD_SYSTEM_DIR_NAME);
stateManager.deleteDirectory(tx, processKey, Constants.Files.JOB_ATTACHMENTS_DIR_NAME);
stateManager.importPath(tx, processKey, null, extractedDir.path(), (p, attrs) -> true);
});
Map<String, Object> out = OutVariablesUtils.read(extractedDir.path().resolve(Constants.Files.JOB_ATTACHMENTS_DIR_NAME));
if (out.isEmpty()) {
queueDao.removeMeta(processKey, "out");
} else {
queueDao.updateMeta(processKey, Collections.singletonMap("out", out));
}
return CheckpointInfo.of(checkpointName, eventName);
}
} catch (Exception e) {
throw new RuntimeException("Restore checkpoint '" + checkpointId + "' error", e);
}
}