use of com.ibm.streamsx.rest.Instance in project streamsx.topology by IBMStreams.
the class AppBundleTest method testAppBundles.
@Test
public void testAppBundles() throws Exception {
String namespace = "App.NS_" + (int) (Math.random() * 10000.0);
String name = "AppBundleTest" + System.currentTimeMillis();
final String appName = namespace + "::" + name;
File bundle = createBundle(namespace, name);
Instance instance = getInstance();
Result<Job, JsonObject> result = instance.submitJob(bundle, null);
verifyJob(result, appName, null);
String jobName = "ABJN_" + (int) (Math.random() * 10000.0) + "_" + System.currentTimeMillis();
JobConfig jc = new JobConfig();
jc.setJobName(jobName);
JsonObject overlay = new JsonObject();
overlay.add("jobConfig", new Gson().toJsonTree(jc));
JsonArray a = new JsonArray();
a.add(overlay);
JsonObject jco = new JsonObject();
jco.add("jobConfigOverlays", a);
result = instance.submitJob(bundle, jco);
verifyJob(result, appName, jobName);
final ApplicationBundle appBundle = instance.uploadBundle(bundle);
assertNotNull(appBundle);
verifyJob(appBundle.submitJob(null), appName, null);
jobName = "ABJN2_" + (int) (Math.random() * 10000.0) + "_" + System.currentTimeMillis();
jc.setJobName(jobName);
overlay.add("jobConfig", new Gson().toJsonTree(jc));
verifyJob(appBundle.submitJob(jco), appName, jobName);
}
use of com.ibm.streamsx.rest.Instance 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.Instance in project streamsx.topology by IBMStreams.
the class InstanceTest method testOfEndpoint_standalone.
@Test
public void testOfEndpoint_standalone() throws IOException {
assumeTrue(null == System.getenv("CP4D_URL"));
assumeNotNull(System.getenv("STREAMS_REST_URL"));
Instance instance = Instance.ofEndpoint(null, null, null, null, sslVerify());
check(instance);
}
use of com.ibm.streamsx.rest.Instance in project streamsx.topology by IBMStreams.
the class StreamsConnectionTest method checkResourceAllocation.
private static void checkResourceAllocation(ResourceAllocation ra, boolean app) throws IOException {
if (ra == null)
return;
assertEquals("resourceAllocation", ra.getResourceType());
if (app)
assertTrue(ra.isApplicationResource());
assertNotNull(ra.getSchedulerStatus());
assertNotNull(ra.getStatus());
Instance rai = ra.getInstance();
for (ProcessingElement pe : ra.getPes()) {
assertNotNull(pe);
assertNotNull(pe.getStatus());
}
for (Job job : ra.getJobs()) {
assertNotNull(job);
assertNotNull(job.getStatus());
}
assertSame(rai, ra.getInstance());
Resource r = ra.getResource();
assertNotNull(r.getId());
assertNotNull(r.getDisplayName());
assertNotNull(r.getIpAddress());
assertEquals("resource", r.getResourceType());
for (Metric metric : r.getMetrics()) {
assertTrue((metric.getMetricKind().equals("counter")) || (metric.getMetricKind().equals("gauge")));
assertEquals("system", metric.getMetricType());
assertEquals("metric", metric.getResourceType());
assertNotNull(metric.getName());
assertNotNull(metric.getDescription());
assertTrue(metric.getLastTimeRetrieved() > 0);
}
}
use of com.ibm.streamsx.rest.Instance in project streamsx.topology by IBMStreams.
the class DistributedStreamsContext method createInstance.
private synchronized Instance createInstance(AppEntity entity) throws IOException {
if (!useRestApi())
throw new IllegalStateException();
Instance instance = RemoteDistributedStreamsContext.getConfigInstance(entity);
if (instance == null) {
boolean verify = true;
if (deploy(entity.submission).has(ContextProperties.SSL_VERIFY))
verify = deploy(entity.submission).get(ContextProperties.SSL_VERIFY).getAsBoolean();
instance = Instance.ofEndpoint((String) null, (String) null, (String) null, (String) null, verify);
}
return instance;
}
Aggregations