use of com.walmartlabs.concord.ApiClient in project concord by walmartlabs.
the class NodeRosterTask method findDeployedArtifacts.
/**
* Find artifacts deployed on a given host
*/
public void findDeployedArtifacts(Context ctx, Map<String, Object> paramsCfg) throws Exception {
ApiClient clientConfig = clientConfig(ctx, paramsCfg);
NodeRosterArtifactsApi api = new NodeRosterArtifactsApi(clientConfig);
List<ArtifactEntry> deployedArtifacts = NodeRosterTaskUtils.findDeployedArtifacts(api, paramsCfg);
ctx.setVariable("result", createResponse(deployedArtifacts));
}
use of com.walmartlabs.concord.ApiClient in project concord by walmartlabs.
the class NodeRosterTask method findHostsWithArtifacts.
/**
* Find hosts with a deployed artifact
*/
public void findHostsWithArtifacts(Context ctx, Map<String, Object> paramsCfg) throws Exception {
ApiClient clientConfig = clientConfig(ctx, paramsCfg);
NodeRosterHostsApi api = new NodeRosterHostsApi(clientConfig);
List<HostEntry> hosts = NodeRosterTaskUtils.findHostsWithArtifacts(api, paramsCfg);
ctx.setVariable("result", createResponse(hosts));
}
use of com.walmartlabs.concord.ApiClient in project concord by walmartlabs.
the class LockTask method unlock.
public void unlock(@InjectVariable("txId") String instanceId, String lockName, String scope) throws Exception {
ApiClient apiClient = apiClientFactory.create(context);
new LockTaskCommon(apiClient, UUID.fromString(instanceId)).unlock(lockName, scope);
}
use of com.walmartlabs.concord.ApiClient in project concord by walmartlabs.
the class LockTask method lock.
public void lock(@InjectVariable("txId") String instanceId, String lockName, String scope) throws Exception {
ApiClient apiClient = apiClientFactory.create(context);
TaskResult taskResult = new LockTaskCommon(apiClient, UUID.fromString(instanceId)).lock(lockName, scope);
if (taskResult instanceof TaskResult.SuspendResult) {
context.suspend(((TaskResult.SuspendResult) taskResult).eventName());
}
}
use of com.walmartlabs.concord.ApiClient in project concord by walmartlabs.
the class Main method run.
public void run(RunnerConfiguration runnerCfg, Path baseDir) throws Exception {
log.debug("run -> working directory: {}", baseDir.toAbsolutePath());
long t1 = System.currentTimeMillis();
Path idPath = baseDir.resolve(Constants.Files.INSTANCE_ID_FILE_NAME);
UUID instanceId = readInstanceId(idPath);
long t2 = System.currentTimeMillis();
if (runnerCfg.debug()) {
log.info("Spent {}ms waiting for the payload", (t2 - t1));
}
Map<String, Object> policy = readPolicyRules(baseDir);
if (policy.isEmpty()) {
PolicyEngineHolder.INSTANCE.setEngine(null);
} else {
PolicyEngineHolder.INSTANCE.setEngine(new PolicyEngine(objectMapper.convertValue(policy, PolicyEngineRules.class)));
}
// read the process configuration
Map<String, Object> processCfg = readRequest(baseDir);
processCfg = variablesConverter.convert(baseDir, processCfg);
String sessionToken = getSessionToken(processCfg);
ApiClient apiClient = apiClientFactory.create(ApiClientConfiguration.builder().sessionToken(sessionToken).txId(instanceId).build());
ProcessHeartbeat heartbeat = new ProcessHeartbeat(apiClient, instanceId, runnerCfg.api().maxNoHeartbeatInterval());
heartbeat.start();
ProcessApiClient processApiClient = new ProcessApiClient(runnerCfg, apiClient);
processApiClient.updateStatus(instanceId, runnerCfg.agentId(), ProcessEntry.StatusEnum.RUNNING);
CheckpointManager checkpointManager = new CheckpointManager(instanceId, processApiClient);
long t3 = System.currentTimeMillis();
if (runnerCfg.debug()) {
log.info("Ready to start in {}ms", (t3 - t2));
}
executeProcess(instanceId.toString(), checkpointManager, baseDir, processCfg);
}
Aggregations