Search in sources :

Example 11 with Job

use of com.ibm.streamsx.rest.Job in project streamsx.topology by IBMStreams.

the class StreamingAnalyticsConnectionSample method main.

public static void main(String[] args) {
    String credentials = args[0];
    String serviceName = args[1];
    System.out.println(credentials);
    System.out.println(serviceName);
    try {
        StreamingAnalyticsService sClient = StreamingAnalyticsService.of(new JsonPrimitive(credentials), serviceName);
        Instance instance = sClient.getInstance();
        System.out.println("Instance:" + instance.toString());
        if (!instance.getStatus().equals("running")) {
            System.out.println("Instance is not started, please start the instance to retrieve more information");
            System.exit(0);
        }
        /* Retrieve a list of jobs in the instance */
        List<Job> jobs = instance.getJobs();
        for (Job job : jobs) {
            System.out.println("Job: " + job.toString());
            /* Retrieve a list of operators for the current job */
            List<Operator> operators = job.getOperators();
            for (Operator op : operators) {
                System.out.println("Operator: " + op.toString());
                /* Retrieve a list of metrics for the current operator */
                List<Metric> metrics = op.getMetrics();
                for (Metric m : metrics) {
                    System.out.println("Metric: " + m.toString());
                }
                /*
                     * Retrieve a list of output ports for the current operator
                     */
                List<OutputPort> outP = op.getOutputPorts();
                for (OutputPort oport : outP) {
                    System.out.println("Output Port: " + oport.toString());
                    /* Retrieve the metrics for this output port */
                    for (Metric om : oport.getMetrics()) {
                        System.out.println("Output Port Metric: " + om.toString());
                    }
                }
                /*
                     * Retrieve a list of input ports for the current operator
                     */
                List<InputPort> inP = op.getInputPorts();
                for (InputPort ip : inP) {
                    System.out.println("Input Port: " + ip.toString());
                    /* Retrieve the metrics for this input port */
                    for (Metric im : ip.getMetrics()) {
                        System.out.println("Input Port Metric: " + im.toString());
                    }
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Operator(com.ibm.streamsx.rest.Operator) OutputPort(com.ibm.streamsx.rest.OutputPort) StreamingAnalyticsService(com.ibm.streamsx.rest.StreamingAnalyticsService) JsonPrimitive(com.google.gson.JsonPrimitive) Instance(com.ibm.streamsx.rest.Instance) InputPort(com.ibm.streamsx.rest.InputPort) Metric(com.ibm.streamsx.rest.Metric) Job(com.ibm.streamsx.rest.Job)

Aggregations

Job (com.ibm.streamsx.rest.Job)11 JsonObject (com.google.gson.JsonObject)5 Instance (com.ibm.streamsx.rest.Instance)4 JsonElement (com.google.gson.JsonElement)3 Metric (com.ibm.streamsx.rest.Metric)3 Operator (com.ibm.streamsx.rest.Operator)3 ProcessingElement (com.ibm.streamsx.rest.ProcessingElement)3 StreamingAnalyticsService (com.ibm.streamsx.rest.StreamingAnalyticsService)3 JsonArray (com.google.gson.JsonArray)2 JsonPrimitive (com.google.gson.JsonPrimitive)2 ApplicationBundle (com.ibm.streamsx.rest.ApplicationBundle)2 InputPort (com.ibm.streamsx.rest.InputPort)2 OutputPort (com.ibm.streamsx.rest.OutputPort)2 StreamsConnection (com.ibm.streamsx.rest.StreamsConnection)2 File (java.io.File)2 BigInteger (java.math.BigInteger)2 Test (org.junit.Test)2 Gson (com.google.gson.Gson)1 JsonParser (com.google.gson.JsonParser)1 RESTException (com.ibm.streamsx.rest.RESTException)1