use of edu.snu.mist.client.MISTExecutionEnvironment in project mist by snuspl.
the class MqttFilterApplication method submitQuery.
public static APIQueryControlResult submitQuery(final Configuration configuration) throws IOException, InjectionException, URISyntaxException {
final Injector injector = Tang.Factory.getTang().newInjector(configuration);
final String brokerURI = injector.getNamedInstance(TestMQTTBrokerURI.class);
final String sourceTopic = injector.getNamedInstance(MqttSourceTopic.class);
final String sinkTopic = injector.getNamedInstance(MqttSinkTopic.class);
final String filteredString = injector.getNamedInstance(FilteredString.class);
final String appId = injector.getNamedInstance(ApplicationIdentifier.class);
final SourceConfiguration mqttSourceConf = new MQTTSourceConfiguration.MQTTSourceConfigurationBuilder().setBrokerURI(brokerURI).setTopic(sourceTopic).build();
final MISTQueryBuilder queryBuilder = new MISTQueryBuilder();
queryBuilder.setApplicationId(appId).mqttStream(mqttSourceConf).map(new MqttMessageToStringFunc()).filter(new FilterFunc(filteredString)).map(new MapFunc(filteredString)).mqttOutput(brokerURI, sinkTopic);
final String[] driverSocket = Tang.Factory.getTang().newInjector(configuration).getNamedInstance(MasterAddress.class).split(":");
final String driverHostname = driverSocket[0];
final int driverPort = Integer.parseInt(driverSocket[1]);
try (final MISTExecutionEnvironment executionEnvironment = new MISTDefaultExecutionEnvironmentImpl(driverHostname, driverPort)) {
return executionEnvironment.submitQuery(queryBuilder.build());
} catch (final Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
use of edu.snu.mist.client.MISTExecutionEnvironment in project mist by snuspl.
the class MISTExampleUtils method submit.
/**
* Submit query to MIST driver.
*/
public static APIQueryControlResult submit(final MISTQueryBuilder queryBuilder, final Configuration configuration) throws IOException, URISyntaxException, InjectionException {
final String[] masterSocket = Tang.Factory.getTang().newInjector(configuration).getNamedInstance(MasterAddress.class).split(":");
final String masterHostname = masterSocket[0];
final int masterPort = Integer.parseInt(masterSocket[1]);
try (final MISTExecutionEnvironment executionEnvironment = new MISTDefaultExecutionEnvironmentImpl(masterHostname, masterPort)) {
// Upload jar
final String jarFilePath = getJarFilePath();
final List<String> jarFilePaths = Arrays.asList(jarFilePath);
final JarUploadResult result = executionEnvironment.submitJar(jarFilePaths);
queryBuilder.setApplicationId(result.getIdentifier());
return executionEnvironment.submitQuery(queryBuilder.build());
} catch (final Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
Aggregations