use of com.ibm.streamsx.rest.StreamingAnalyticsService in project streamsx.topology by IBMStreams.
the class StreamingAnalyticsServiceTest method use_it.
private void use_it(StreamingAnalyticsService service) throws Exception {
assertNotNull(service);
Result<StreamingAnalyticsService, JsonObject> cs = service.checkStatus(false);
assertNotNull(cs);
assertSame(service, cs.getElement());
assertNull(cs.getId());
assertTrue(cs.isOk());
assertNotNull(cs.getRawResult());
cs = service.checkStatus(true);
assertNotNull(cs);
assertSame(service, cs.getElement());
assertNull(cs.getId());
assertTrue(cs.isOk());
assertNotNull(cs.getRawResult());
Instance instance = service.getInstance();
assertNotNull(instance);
assertNotNull(instance.getJobs());
}
use of com.ibm.streamsx.rest.StreamingAnalyticsService in project streamsx.topology by IBMStreams.
the class ServiceSubmissionAPITest method cancel.
private void cancel(BigInteger jobId) throws Exception {
JsonElement vse;
if (vcapServices.startsWith(File.separator))
vse = new JsonPrimitive(vcapServices);
else
vse = new JsonParser().parse(vcapServices);
StreamingAnalyticsService sas = StreamingAnalyticsService.of(vse, serviceName);
Job job = sas.getInstance().getJob(jobId.toString());
assertNotNull(job);
boolean canceled = job.cancel();
assertTrue(canceled);
}
use of com.ibm.streamsx.rest.StreamingAnalyticsService in project streamsx.topology by IBMStreams.
the class AnalyticsServiceStreamsContext method submitJobToService.
private BigInteger submitJobToService(File bundle, AppEntity entity) throws IOException {
final JsonObject submission = entity.submission;
JsonObject deploy = deploy(submission);
JsonObject jco = DeployKeys.copyJobConfigOverlays(deploy);
final StreamingAnalyticsService sas = sas(entity);
Result<Job, JsonObject> submitResult = sas.submitJob(bundle, jco);
final JsonObject submissionResult = GsonUtilities.objectCreate(submission, RemoteContext.SUBMISSION_RESULTS);
GsonUtilities.addAll(submissionResult, submitResult.getRawResult());
// Ensure job id is in a known place regardless of version
final String jobId = submitResult.getId();
GsonUtilities.addToObject(submissionResult, SubmissionResultsKeys.JOB_ID, jobId);
return new BigInteger(jobId);
}
use of com.ibm.streamsx.rest.StreamingAnalyticsService in project streamsx.topology by IBMStreams.
the class AnalyticsServiceStreamsContext method sas.
/**
* Get the connection to the service and check it is running.
*/
private static StreamingAnalyticsService sas(AppEntity entity) throws IOException {
StreamingAnalyticsService sas = (StreamingAnalyticsService) entity.getSavedObject(StreamingAnalyticsService.class);
if (sas == null) {
JsonObject deploy = deploy(entity.submission);
sas = entity.saveObject(StreamingAnalyticsService.class, streamingAnalyticServiceFromDeploy(deploy));
RemoteContexts.checkServiceRunning(sas);
}
return sas;
}
use of com.ibm.streamsx.rest.StreamingAnalyticsService in project streamsx.topology by IBMStreams.
the class AnalyticsServiceStreamsContext method getSasServiceBase.
/**
* Get the SAS OS version base.
*/
private static int getSasServiceBase(AppEntity entity) {
// Need to interrogate the service to figure out
// the os version of the service.
StreamingAnalyticsService sas;
try {
sas = sas(entity);
Instance instance = sas.getInstance();
ActiveVersion ver = instance.getActiveVersion();
// service force remote build.
return Integer.valueOf(ver.getMinimumOSBaseVersion());
} catch (IOException e) {
;
}
return -1;
}
Aggregations