use of com.ibm.streamsx.topology.context.StreamsContext in project streamsx.topology by IBMStreams.
the class PlaceableTest method produceADL.
public static Document produceADL(TopologyElement te) throws Exception {
@SuppressWarnings("unchecked") StreamsContext<File> ctx = (StreamsContext<File>) StreamsContextFactory.getStreamsContext(StreamsContext.Type.TOOLKIT);
File tkDir = ctx.submit(te.topology()).get();
System.out.println("TKDIR:" + tkDir);
String topoTkDir = System.getProperty("topology.toolkit.release");
List<String> cmd = new ArrayList<>();
cmd.add(System.getenv("STREAMS_INSTALL") + "/bin/sc");
cmd.add("--suppress-all-but-the-application-model");
cmd.add("--spl-path");
cmd.add(topoTkDir);
cmd.add("--main-composite");
cmd.add(te.topology().getNamespace() + "::" + te.topology().getName());
ProcessBuilder pb = new ProcessBuilder(cmd);
pb.directory(tkDir);
pb.redirectInput(Redirect.INHERIT);
pb.redirectOutput(Redirect.INHERIT);
pb.redirectError(Redirect.INHERIT);
Process p = pb.start();
int rc = p.waitFor();
System.out.println("RC:" + rc);
assertEquals(0, rc);
File adl = new File(tkDir, "output/" + te.topology().getNamespace() + "." + te.topology().getName() + ".adl");
assertTrue(adl.exists());
assertTrue(adl.isFile());
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
try (InputStream adlIn = new FileInputStream(adl)) {
return db.parse(new InputSource(adlIn));
}
}
use of com.ibm.streamsx.topology.context.StreamsContext in project streamsx.topology by IBMStreams.
the class ToolkitTest method testParallel.
@Test
public void testParallel() throws Exception {
final Topology topology = newTopology("TKParallel");
TStream<Number> s1 = topology.numbers(1, 2, 3, 94, 5, 6).parallel(6).filter(new AllowAll<Number>()).endParallel();
@SuppressWarnings("unused") TStream<String> sp = StringStreams.toString(s1);
@SuppressWarnings("unchecked") StreamsContext<File> tkContext = (StreamsContext<File>) StreamsContextFactory.getStreamsContext(Type.TOOLKIT);
File tkRoot = tkContext.submit(topology).get();
assertNotNull(tkRoot);
assertTrue(tkRoot.exists());
}
use of com.ibm.streamsx.topology.context.StreamsContext in project streamsx.topology by IBMStreams.
the class ServiceSubmissionAPITest method submitFromBundle.
private void submitFromBundle(Topology topology) throws Exception {
@SuppressWarnings("unchecked") StreamsContext<BigInteger> ctx = (StreamsContext<BigInteger>) StreamsContextFactory.getStreamsContext("STREAMING_ANALYTICS_SERVICE");
BigInteger jobId = ctx.submit(topology, getConfig()).get();
assertNotNull(jobId);
cancel(jobId);
}
use of com.ibm.streamsx.topology.context.StreamsContext in project streamsx.topology by IBMStreams.
the class ServiceSubmissionAPITest method testNoResults.
@Test
public void testNoResults() throws Exception {
TStream<String> stream = createTopology("testNoResults");
@SuppressWarnings("unchecked") StreamsContext<BigInteger> ctx = (StreamsContext<BigInteger>) StreamsContextFactory.getStreamsContext("STREAMING_ANALYTICS_SERVICE");
Map<String, Object> config = new HashMap<>();
BigInteger jobId = ctx.submit(stream.topology(), config).get();
cancel(jobId);
assertFalse(config.containsKey(ResultProperties.JOB_SUBMISSION));
}
use of com.ibm.streamsx.topology.context.StreamsContext in project streamsx.topology by IBMStreams.
the class ServiceSubmissionAPITest method testResults.
@Test
public void testResults() throws Exception {
TStream<String> stream = createTopology("testResults");
@SuppressWarnings("unchecked") StreamsContext<BigInteger> ctx = (StreamsContext<BigInteger>) StreamsContextFactory.getStreamsContext("STREAMING_ANALYTICS_SERVICE");
Map<String, Object> config = new HashMap<>();
config.put(ResultProperties.JOB_SUBMISSION, false);
BigInteger jobId = ctx.submit(stream.topology(), config).get();
cancel(jobId);
assertTrue(config.containsKey(ResultProperties.JOB_SUBMISSION));
Object r = config.get(ResultProperties.JOB_SUBMISSION);
assertTrue(r.getClass().getName(), r instanceof JsonObject);
JsonObject sr = (JsonObject) r;
assertTrue(sr.has(SubmissionResultsKeys.CONSOLE_APPLICATION_URL));
assertTrue(sr.has(SubmissionResultsKeys.CONSOLE_APPLICATION_JOB_URL));
}
Aggregations