Search in sources :

Example 26 with JavaConfigurationBuilder

use of org.apache.reef.tang.JavaConfigurationBuilder in project mist by snuspl.

the class MistDriverTest method launchDriverTestHelper.

/**
 * Test whether MistDriver runs MistTaks successfully.
 * @throws InjectionException
 */
public void launchDriverTestHelper(final int clientToTaskPort) throws InjectionException {
    final JavaConfigurationBuilder jcb = Tang.Factory.getTang().newConfigurationBuilder();
    jcb.bindNamedParameter(DriverRuntimeType.class, "LOCAL");
    jcb.bindNamedParameter(NumTaskCores.class, "1");
    jcb.bindNamedParameter(DefaultNumEventProcessors.class, "1");
    jcb.bindNamedParameter(TaskMemorySize.class, "256");
    jcb.bindNamedParameter(NumMasterCores.class, "1");
    jcb.bindNamedParameter(MasterMemorySize.class, "256");
    jcb.bindNamedParameter(ClientToTaskPort.class, Integer.toString(clientToTaskPort));
    final Configuration runtimeConf = LocalRuntimeConfiguration.CONF.build();
    final Configuration driverConf = MistLauncher.getDriverConfiguration(jcb.build());
    final LauncherStatus state = TestLauncher.run(runtimeConf, driverConf, 5000);
    final Optional<Throwable> err = state.getError();
    System.out.println("Job state after execution: " + state);
    System.out.println("Error: " + err.get());
    Assert.assertFalse(err.isPresent());
}
Also used : Configuration(org.apache.reef.tang.Configuration) LocalRuntimeConfiguration(org.apache.reef.runtime.local.client.LocalRuntimeConfiguration) LauncherStatus(org.apache.reef.client.LauncherStatus) JavaConfigurationBuilder(org.apache.reef.tang.JavaConfigurationBuilder)

Example 27 with JavaConfigurationBuilder

use of org.apache.reef.tang.JavaConfigurationBuilder in project mist by snuspl.

the class GroupAwareQueryManagerImpl method createApplication.

@Override
public ApplicationInfo createApplication(final String appId, final List<String> paths) throws InjectionException {
    final JavaConfigurationBuilder jcb = Tang.Factory.getTang().newConfigurationBuilder();
    jcb.bindNamedParameter(ApplicationIdentifier.class, appId);
    // TODO: Submit a single jar instead of list of jars
    jcb.bindNamedParameter(JarFilePath.class, paths.get(0));
    jcb.bindNamedParameter(PeriodicCheckpointPeriod.class, String.valueOf(checkpointPeriod));
    final Injector injector = Tang.Factory.getTang().newInjector(jcb.build());
    injector.bindVolatileInstance(MQTTResource.class, mqttSharedResource);
    injector.bindVolatileInstance(KafkaSharedResource.class, kafkaSharedResource);
    injector.bindVolatileInstance(NettySharedResource.class, nettySharedResource);
    injector.bindVolatileInstance(QueryInfoStore.class, planStore);
    final ApplicationInfo applicationInfo = injector.getInstance(ApplicationInfo.class);
    applicationMap.putIfAbsent(appId, applicationInfo);
    return applicationMap.get(appId);
}
Also used : Injector(org.apache.reef.tang.Injector) JavaConfigurationBuilder(org.apache.reef.tang.JavaConfigurationBuilder)

Example 28 with JavaConfigurationBuilder

use of org.apache.reef.tang.JavaConfigurationBuilder in project mist by snuspl.

the class GroupAwareQueryManagerImpl method createGroup.

@Override
public Group createGroup(final ApplicationInfo applicationInfo) throws InjectionException {
    final JavaConfigurationBuilder jcb = Tang.Factory.getTang().newConfigurationBuilder();
    final String groupId = groupIdRequestor.requestGroupId(applicationInfo.getApplicationId());
    if (groupId == null) {
        throw new RuntimeException("An error occured while getting a groupId!");
    }
    jcb.bindNamedParameter(GroupId.class, groupId);
    final Injector injector = Tang.Factory.getTang().newInjector(jcb.build());
    injector.bindVolatileInstance(ExecutionDags.class, applicationInfo.getExecutionDags());
    injector.bindVolatileInstance(QueryIdConfigDagMap.class, applicationInfo.getQueryIdConfigDagMap());
    injector.bindVolatileInstance(ConfigExecutionVertexMap.class, applicationInfo.getConfigExecutionVertexMap());
    final Group group = injector.getInstance(Group.class);
    groupAllocationTableModifier.addEvent(new WritingEvent(WritingEvent.EventType.GROUP_ADD, new Tuple<>(applicationInfo, group)));
    return group;
}
Also used : Injector(org.apache.reef.tang.Injector) JavaConfigurationBuilder(org.apache.reef.tang.JavaConfigurationBuilder) Tuple(org.apache.reef.io.Tuple)

Example 29 with JavaConfigurationBuilder

use of org.apache.reef.tang.JavaConfigurationBuilder in project mist by snuspl.

the class HelloMist method main.

/**
 * Set the environment(Hostname and port of driver, source, and sink) and submit a query.
 * @param args command line parameters
 * @throws Exception
 */
public static void main(final String[] args) throws Exception {
    final JavaConfigurationBuilder jcb = Tang.Factory.getTang().newConfigurationBuilder();
    final CommandLine commandLine = MISTExampleUtils.getDefaultCommandLine(jcb).registerShortNameOfClass(// Additional parameter
    NettySourceAddress.class).processCommandLine(args);
    if (commandLine == null) {
        // Option '?' was entered and processCommandLine printed the help.
        return;
    }
    Thread sinkServer = new Thread(MISTExampleUtils.getSinkServer());
    sinkServer.start();
    final APIQueryControlResult result = submitQuery(jcb.build());
    System.out.println("Query submission result: " + result.getQueryId());
}
Also used : APIQueryControlResult(edu.snu.mist.client.APIQueryControlResult) CommandLine(org.apache.reef.tang.formats.CommandLine) JavaConfigurationBuilder(org.apache.reef.tang.JavaConfigurationBuilder) NettySourceAddress(edu.snu.mist.examples.parameters.NettySourceAddress)

Example 30 with JavaConfigurationBuilder

use of org.apache.reef.tang.JavaConfigurationBuilder in project mist by snuspl.

the class KMeansClustering method main.

/**
 * Set the environment(Hostname and port of driver, source, and sink) and submit a query.
 * @param args command line parameters
 * @throws Exception
 */
public static void main(final String[] args) throws Exception {
    final JavaConfigurationBuilder jcb = Tang.Factory.getTang().newConfigurationBuilder();
    final CommandLine commandLine = MISTExampleUtils.getDefaultCommandLine(jcb).registerShortNameOfClass(// Additional parameter
    NettySourceAddress.class).processCommandLine(args);
    if (commandLine == null) {
        // Option '?' was entered and processCommandLine printed the help.
        return;
    }
    Thread sinkServer = new Thread(MISTExampleUtils.getSinkServer());
    sinkServer.start();
    final APIQueryControlResult result = submitQuery(jcb.build());
    System.out.println("Query submission result: " + result.getQueryId());
}
Also used : APIQueryControlResult(edu.snu.mist.client.APIQueryControlResult) CommandLine(org.apache.reef.tang.formats.CommandLine) JavaConfigurationBuilder(org.apache.reef.tang.JavaConfigurationBuilder) NettySourceAddress(edu.snu.mist.examples.parameters.NettySourceAddress)

Aggregations

JavaConfigurationBuilder (org.apache.reef.tang.JavaConfigurationBuilder)51 Injector (org.apache.reef.tang.Injector)24 CommandLine (org.apache.reef.tang.formats.CommandLine)18 APIQueryControlResult (edu.snu.mist.client.APIQueryControlResult)17 NettySourceAddress (edu.snu.mist.examples.parameters.NettySourceAddress)12 Before (org.junit.Before)9 Test (org.junit.Test)8 DefaultEventProcessorFactory (edu.snu.mist.core.task.groupaware.eventprocessor.DefaultEventProcessorFactory)5 EventProcessor (edu.snu.mist.core.task.groupaware.eventprocessor.EventProcessor)5 EventProcessorFactory (edu.snu.mist.core.task.groupaware.eventprocessor.EventProcessorFactory)5 LinkedList (java.util.LinkedList)5 LoadUpdater (edu.snu.mist.core.task.groupaware.rebalancer.LoadUpdater)4 MISTQuery (edu.snu.mist.client.MISTQuery)3 GroupRebalancer (edu.snu.mist.core.task.groupaware.rebalancer.GroupRebalancer)3 AvroDag (edu.snu.mist.formats.avro.AvroDag)3 MISTQueryBuilder (edu.snu.mist.client.MISTQueryBuilder)2 Tuple2 (edu.snu.mist.common.types.Tuple2)2 MQTTSharedResource (edu.snu.mist.core.shared.MQTTSharedResource)2 ApplicationInfo (edu.snu.mist.core.task.groupaware.ApplicationInfo)2 IdAndConfGenerator (edu.snu.mist.core.task.utils.IdAndConfGenerator)2