Search in sources :

Example 6 with StreamsConnection

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

the class AppBundleTest method getInstance.

protected Instance getInstance() throws IOException {
    assumeNotNull(System.getenv("STREAMS_REST_URL"));
    StreamsConnection sc = StreamsConnection.createInstance(null, null, null);
    sc.allowInsecureHosts(true);
    List<Instance> instances = sc.getInstances();
    if (instances.size() == 1)
        return instances.get(0);
    return sc.getInstance(System.getenv("STREAMS_INSTANCE_ID"));
}
Also used : Instance(com.ibm.streamsx.rest.Instance) StreamsConnection(com.ibm.streamsx.rest.StreamsConnection)

Example 7 with StreamsConnection

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

the class StreamsOnlyConnectionTest method testGetInstances.

@Test
public void testGetInstances() throws Exception {
    assumeNotNull(System.getenv("STREAMS_REST_URL"));
    StreamsConnection connection = StreamsConnection.createInstance(null, null, null);
    connection.allowInsecureHosts(true);
    // get all instances in the domain
    List<Instance> instances = connection.getInstances();
    // there should be at least one instance
    assertTrue(instances.size() > 0);
    Instance i2;
    String instanceName = System.getenv("STREAMS_INSTANCE_ID");
    if (instanceName != null) {
        i2 = connection.getInstance(instanceName);
        assertEquals(instanceName, i2.getId());
        i2.refresh();
        assertEquals(instanceName, i2.getId());
    } else {
        i2 = instances.get(0);
    }
    List<ProcessingElement> instancePes = i2.getPes();
    for (ProcessingElement pe : instancePes) {
        assertNotNull(pe);
    }
    for (Instance instance : instances) StreamsConnectionTest.checkDomainFromInstance(instance);
    try {
        // try a fake instance name
        connection.getInstance("fakeName");
        fail("the connection.getInstance call should have thrown an exception");
    } catch (RESTException r) {
        // not a failure, this is the expected result
        assertEquals(r.toString(), 404, r.getStatusCode());
    }
}
Also used : ProcessingElement(com.ibm.streamsx.rest.ProcessingElement) RESTException(com.ibm.streamsx.rest.RESTException) Instance(com.ibm.streamsx.rest.Instance) StreamsConnection(com.ibm.streamsx.rest.StreamsConnection) Test(org.junit.Test)

Aggregations

StreamsConnection (com.ibm.streamsx.rest.StreamsConnection)7 Instance (com.ibm.streamsx.rest.Instance)5 JsonObject (com.google.gson.JsonObject)3 RESTException (com.ibm.streamsx.rest.RESTException)3 Executor (org.apache.http.client.fluent.Executor)3 JsonParser (com.google.gson.JsonParser)2 Job (com.ibm.streamsx.rest.Job)2 ProcessingElement (com.ibm.streamsx.rest.ProcessingElement)2 ICP4DAuthenticator (com.ibm.streamsx.rest.internal.ICP4DAuthenticator)2 StandaloneAuthenticator (com.ibm.streamsx.rest.internal.StandaloneAuthenticator)2 URL (java.net.URL)2 Test (org.junit.Test)2 JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 ApplicationBundle (com.ibm.streamsx.rest.ApplicationBundle)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 GsonUtilities.jboolean (com.ibm.streamsx.topology.internal.gson.GsonUtilities.jboolean)1