Search in sources :

Example 1 with MISTDefaultExecutionEnvironmentImpl

use of edu.snu.mist.client.MISTDefaultExecutionEnvironmentImpl 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);
    }
}
Also used : MISTQueryBuilder(edu.snu.mist.client.MISTQueryBuilder) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) InjectionException(org.apache.reef.tang.exceptions.InjectionException) Injector(org.apache.reef.tang.Injector) MQTTSourceConfiguration(edu.snu.mist.client.datastreams.configurations.MQTTSourceConfiguration) SourceConfiguration(edu.snu.mist.client.datastreams.configurations.SourceConfiguration) MISTDefaultExecutionEnvironmentImpl(edu.snu.mist.client.MISTDefaultExecutionEnvironmentImpl) MISTExecutionEnvironment(edu.snu.mist.client.MISTExecutionEnvironment) MQTTSourceConfiguration(edu.snu.mist.client.datastreams.configurations.MQTTSourceConfiguration)

Example 2 with MISTDefaultExecutionEnvironmentImpl

use of edu.snu.mist.client.MISTDefaultExecutionEnvironmentImpl 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);
    }
}
Also used : MasterAddress(edu.snu.mist.examples.parameters.MasterAddress) MISTDefaultExecutionEnvironmentImpl(edu.snu.mist.client.MISTDefaultExecutionEnvironmentImpl) MISTExecutionEnvironment(edu.snu.mist.client.MISTExecutionEnvironment) JarUploadResult(edu.snu.mist.formats.avro.JarUploadResult) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) InjectionException(org.apache.reef.tang.exceptions.InjectionException)

Aggregations

MISTDefaultExecutionEnvironmentImpl (edu.snu.mist.client.MISTDefaultExecutionEnvironmentImpl)2 MISTExecutionEnvironment (edu.snu.mist.client.MISTExecutionEnvironment)2 IOException (java.io.IOException)2 URISyntaxException (java.net.URISyntaxException)2 InjectionException (org.apache.reef.tang.exceptions.InjectionException)2 MISTQueryBuilder (edu.snu.mist.client.MISTQueryBuilder)1 MQTTSourceConfiguration (edu.snu.mist.client.datastreams.configurations.MQTTSourceConfiguration)1 SourceConfiguration (edu.snu.mist.client.datastreams.configurations.SourceConfiguration)1 MasterAddress (edu.snu.mist.examples.parameters.MasterAddress)1 JarUploadResult (edu.snu.mist.formats.avro.JarUploadResult)1 Injector (org.apache.reef.tang.Injector)1