use of org.platformlayer.PlatformLayerClient in project platformlayer by platformlayer.
the class TailLog method runCommand.
@Override
public Object runCommand() throws PlatformLayerClientException, InterruptedException {
PlatformLayerClient client = getPlatformLayerClient();
// TODO: System.out isn't quite right
JobLogPrinter jobLogPrinter = new JobLogPrinter(new PrintWriter(System.out));
if (Strings.isNullOrEmpty(executionId)) {
JobExecutionList jobExecutions = client.listJobExecutions(jobId);
JobExecutionData last = null;
for (JobExecutionData execution : jobExecutions.getRuns()) {
if (execution.getState() == JobState.PRESTART) {
continue;
}
if (last == null) {
last = execution;
continue;
}
if (last.getStartedAt().before(execution.getStartedAt())) {
last = execution;
continue;
}
}
if (last != null) {
executionId = last.getExecutionId();
}
}
// TODO: What if executionId == null? Also retries..
JobLog previousJobLog = null;
int jobLogOffset = 0;
while (true) {
// TODO: Only fetch tail
JobLog jobLog = client.getJobExecutionLog(jobId, executionId);
if (previousJobLog == null) {
jobLogPrinter.startJobLog(jobLog);
}
List<JobLogLine> lines = jobLog.getLines();
if (jobLogOffset < lines.size()) {
for (JobLogLine line : lines.subList(jobLogOffset, lines.size())) {
jobLogPrinter.write(line);
}
}
jobLogPrinter.flush();
jobLogOffset = lines.size();
previousJobLog = jobLog;
Thread.sleep(1000);
}
}
use of org.platformlayer.PlatformLayerClient in project platformlayer by platformlayer.
the class ListMetrics method runCommand.
@Override
public Object runCommand() throws PlatformLayerClientException {
PlatformLayerClient client = getPlatformLayerClient();
PlatformLayerKey key = getContext().pathToItem(getProject(), path);
MetricInfoCollection items = client.listMetrics(key);
return items;
}
use of org.platformlayer.PlatformLayerClient in project platformlayer by platformlayer.
the class ListTags method runCommand.
@Override
public Object runCommand() throws PlatformLayerClientException {
PlatformLayerClient client = getPlatformLayerClient();
PlatformLayerKey key = path.resolve(getContext());
UntypedItem ret = client.getItemUntyped(key, getFormat());
return ret.getTags();
}
use of org.platformlayer.PlatformLayerClient in project platformlayer by platformlayer.
the class ScriptCommands method activateService.
public static Object activateService(String serviceType, Object properties) throws PlatformLayerClientException, JSONException {
PlatformLayerCliContext context = PlatformLayerCliContext.get();
PlatformLayerClient client = context.getPlatformLayerClient();
String json = properties.toString();
String wrapper = "{ \"data\": \"" + json + "\" }";
String retvalJsonString = client.activateService(serviceType, wrapper, Format.JSON);
JSONObject retvalJsonObject = new JSONObject(retvalJsonString);
return toPython(retvalJsonObject);
}
use of org.platformlayer.PlatformLayerClient in project platformlayer by platformlayer.
the class ScriptCommands method getSchema.
public static Object getSchema(String serviceType) throws PlatformLayerClientException, JSONException {
PlatformLayerCliContext context = PlatformLayerCliContext.get();
PlatformLayerClient client = context.getPlatformLayerClient();
String retval = client.getSchema(serviceType, Format.XML);
return retval;
}
Aggregations