Search in sources :

Example 1 with StreamingAnalyticsService

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());
}
Also used : StreamingAnalyticsService(com.ibm.streamsx.rest.StreamingAnalyticsService) Instance(com.ibm.streamsx.rest.Instance) JsonObject(com.google.gson.JsonObject)

Example 2 with StreamingAnalyticsService

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);
}
Also used : StreamingAnalyticsService(com.ibm.streamsx.rest.StreamingAnalyticsService) JsonPrimitive(com.google.gson.JsonPrimitive) JsonElement(com.google.gson.JsonElement) Job(com.ibm.streamsx.rest.Job) JsonParser(com.google.gson.JsonParser)

Example 3 with StreamingAnalyticsService

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);
}
Also used : StreamingAnalyticsService(com.ibm.streamsx.rest.StreamingAnalyticsService) JsonObject(com.google.gson.JsonObject) BigInteger(java.math.BigInteger) Job(com.ibm.streamsx.rest.Job)

Example 4 with StreamingAnalyticsService

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;
}
Also used : StreamingAnalyticsService(com.ibm.streamsx.rest.StreamingAnalyticsService) JsonObject(com.google.gson.JsonObject)

Example 5 with StreamingAnalyticsService

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;
}
Also used : StreamingAnalyticsService(com.ibm.streamsx.rest.StreamingAnalyticsService) Instance(com.ibm.streamsx.rest.Instance) ActiveVersion(com.ibm.streamsx.rest.ActiveVersion) IOException(java.io.IOException)

Aggregations

StreamingAnalyticsService (com.ibm.streamsx.rest.StreamingAnalyticsService)9 JsonObject (com.google.gson.JsonObject)4 Instance (com.ibm.streamsx.rest.Instance)4 JsonPrimitive (com.google.gson.JsonPrimitive)3 Job (com.ibm.streamsx.rest.Job)3 JsonElement (com.google.gson.JsonElement)1 JsonParser (com.google.gson.JsonParser)1 ActiveVersion (com.ibm.streamsx.rest.ActiveVersion)1 InputPort (com.ibm.streamsx.rest.InputPort)1 Metric (com.ibm.streamsx.rest.Metric)1 Operator (com.ibm.streamsx.rest.Operator)1 OutputPort (com.ibm.streamsx.rest.OutputPort)1 File (java.io.File)1 IOException (java.io.IOException)1 BigInteger (java.math.BigInteger)1 Path (java.nio.file.Path)1 Test (org.junit.Test)1