Search in sources :

Example 11 with JavaConfigurationBuilder

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

the class EventProcessorManagerTest method setUp.

@Before
public void setUp() throws InjectionException {
    final JavaConfigurationBuilder jcb = Tang.Factory.getTang().newConfigurationBuilder();
    jcb.bindNamedParameter(DefaultNumEventProcessors.class, Integer.toString(DEFAULT_NUM_THREADS));
    jcb.bindNamedParameter(EventProcessorUpperBound.class, Integer.toString(MAX_NUM_THREADS));
    jcb.bindNamedParameter(EventProcessorLowerBound.class, Integer.toString(MIN_NUM_THREADS));
    jcb.bindNamedParameter(GracePeriod.class, Integer.toString(0));
    jcb.bindImplementation(EventProcessorFactory.class, TestEventProcessorFactory.class);
    groupRebalancer = mock(GroupRebalancer.class);
    groupBalancer = new TestGroupAssigner();
    groupIdRequestor = mock(GroupIdRequestor.class);
    taskStatsUpdater = mock(TaskStatsUpdater.class);
    final Injector injector = Tang.Factory.getTang().newInjector(jcb.build());
    injector.bindVolatileInstance(GroupRebalancer.class, groupRebalancer);
    injector.bindVolatileInstance(GroupAssigner.class, groupBalancer);
    injector.bindVolatileInstance(GroupIdRequestor.class, groupIdRequestor);
    injector.bindVolatileInstance(TaskStatsUpdater.class, taskStatsUpdater);
    eventProcessorManager = injector.getInstance(DefaultEventProcessorManager.class);
    groupAllocationTableModifier = injector.getInstance(GroupAllocationTableModifier.class);
}
Also used : GroupRebalancer(edu.snu.mist.core.task.groupaware.rebalancer.GroupRebalancer) Injector(org.apache.reef.tang.Injector) JavaConfigurationBuilder(org.apache.reef.tang.JavaConfigurationBuilder) Before(org.junit.Before)

Example 12 with JavaConfigurationBuilder

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

the class GroupMergerTest method createGroup.

private Group createGroup(final String id) throws InjectionException {
    final JavaConfigurationBuilder jcb = Tang.Factory.getTang().newConfigurationBuilder();
    jcb.bindNamedParameter(GroupId.class, id);
    final Injector injector = Tang.Factory.getTang().newInjector(jcb.build());
    return injector.getInstance(Group.class);
}
Also used : Injector(org.apache.reef.tang.Injector) JavaConfigurationBuilder(org.apache.reef.tang.JavaConfigurationBuilder)

Example 13 with JavaConfigurationBuilder

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

the class GroupRebalancerTest method defaultRebalancerTest1.

/**
 * Reassignment.
 * (alpha: 0.85, beta: 0.9, targetload = 0.875)
 * t1: [0.1, 0.05, 0.1, 0.2, 0.1, 0.05, 0.1, 0.2, 0.05] (0.95) overloaded
 * t2: [0.05, 0.05, 0.05, 0.1, 0.2, 0.1, 0.05, 0.1, 0.2, 0.05] (0.95) overloaded
 * t3: [0.1, 0.2, 0.3, 0.2, 0.05] (0.85) normal
 * t4: [0.1, 0.1] (0.2) underloaded
 * t5: [0.1, 0.1, 0.1, 0.1] (0.4) underloaded
 *
 * After rebalancing
 * t1: [0.1,  0.1, 0.2, 0.1, 0.05, 0.1, 0.2, 0.05] (0.9) overloaded
 * t2: [0.05, 0.05, 0.1, 0.2, 0.1, 0.05, 0.1, 0.2, 0.05] (0.9) overloaded
 * t3: [0.1, 0.2, 0.3, 0.2, 0.05] (0.85) normal
 * t4: [0.1, 0.1, 0.05, 0.05] (0.3) underloaded
 * t5: [0.1, 0.1, 0.1, 0.1] (0.4) underloaded
 */
@Test
public void defaultRebalancerTest1() throws InjectionException {
    final JavaConfigurationBuilder jcb = Tang.Factory.getTang().newConfigurationBuilder();
    jcb.bindNamedParameter(DefaultNumEventProcessors.class, "0");
    jcb.bindImplementation(LoadUpdater.class, TestLoadUpdater.class);
    final Injector injector = Tang.Factory.getTang().newInjector(jcb.build());
    final GroupAllocationTable groupAllocationTable = injector.getInstance(GroupAllocationTable.class);
    final GroupRebalancer rebalancer = injector.getInstance(DefaultGroupRebalancerImpl.class);
    final LoadUpdater loadUpdater = injector.getInstance(LoadUpdater.class);
    final EventProcessorFactory epFactory = injector.getInstance(DefaultEventProcessorFactory.class);
    final List<EventProcessor> eventProcessors = new LinkedList<>();
    for (int i = 0; i < 5; i++) {
        eventProcessors.add(epFactory.newEventProcessor());
        groupAllocationTable.put(eventProcessors.get(i));
    }
    final List<Double> loadsForEp1 = Arrays.asList(0.1, 0.05, 0.1, 0.2, 0.1, 0.05, 0.1, 0.2, 0.05);
    final List<Double> loadsForEp2 = Arrays.asList(0.05, 0.05, 0.05, 0.1, 0.2, 0.1, 0.05, 0.1, 0.2, 0.05);
    final List<Double> loadsForEp3 = Arrays.asList(0.1, 0.2, 0.3, 0.2, 0.05);
    final List<Double> loadsForEp4 = Arrays.asList(0.1, 0.1);
    final List<Double> loadsForEp5 = Arrays.asList(0.1, 0.1, 0.1, 0.1);
    final List<List<Double>> loads = Arrays.asList(loadsForEp1, loadsForEp2, loadsForEp3, loadsForEp4, loadsForEp5);
    for (int i = 0; i < 5; i++) {
        final EventProcessor eventProcessor = eventProcessors.get(i);
        final List<Double> loadList = loads.get(i);
        for (final Double load : loadList) {
            final Group group = mock(Group.class);
            when(group.getLoad()).thenReturn(load);
            when(group.toString()).thenReturn(Double.toString(load));
            when(group.isSplited()).thenReturn(false);
            groupAllocationTable.getValue(eventProcessor).add(group);
        }
    }
    loadUpdater.update();
    rebalancer.triggerRebalancing();
    Assert.assertEquals(0.9, calculateLoadOfGroups(groupAllocationTable.getValue(eventProcessors.get(0))), 0.0001);
    Assert.assertEquals(0.9, calculateLoadOfGroups(groupAllocationTable.getValue(eventProcessors.get(1))), 0.0001);
    Assert.assertEquals(0.85, calculateLoadOfGroups(groupAllocationTable.getValue(eventProcessors.get(2))), 0.0001);
    Assert.assertEquals(0.3, calculateLoadOfGroups(groupAllocationTable.getValue(eventProcessors.get(3))), 0.0001);
    Assert.assertEquals(0.4, calculateLoadOfGroups(groupAllocationTable.getValue(eventProcessors.get(4))), 0.0001);
}
Also used : LoadUpdater(edu.snu.mist.core.task.groupaware.rebalancer.LoadUpdater) DefaultEventProcessorFactory(edu.snu.mist.core.task.groupaware.eventprocessor.DefaultEventProcessorFactory) EventProcessorFactory(edu.snu.mist.core.task.groupaware.eventprocessor.EventProcessorFactory) LinkedList(java.util.LinkedList) GroupRebalancer(edu.snu.mist.core.task.groupaware.rebalancer.GroupRebalancer) Injector(org.apache.reef.tang.Injector) EventProcessor(edu.snu.mist.core.task.groupaware.eventprocessor.EventProcessor) List(java.util.List) LinkedList(java.util.LinkedList) JavaConfigurationBuilder(org.apache.reef.tang.JavaConfigurationBuilder) Test(org.junit.Test)

Example 14 with JavaConfigurationBuilder

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

the class MergeAwareQueryRemoverTest method setUp.

@Before
public void setUp() throws InjectionException, IOException {
    final JavaConfigurationBuilder jcb = Tang.Factory.getTang().newConfigurationBuilder();
    jcb.bindImplementation(ExecutionDags.class, MergingExecutionDags.class);
    final Injector injector = Tang.Factory.getTang().newInjector(jcb.build());
    queryRemover = injector.getInstance(MergeAwareQueryRemover.class);
    srcAndDagMap = injector.getInstance(SrcAndDagMap.class);
    executionVertexCountMap = injector.getInstance(ExecutionVertexCountMap.class);
    executionDags = injector.getInstance(ExecutionDags.class);
    executionVertexDagMap = injector.getInstance(ExecutionVertexDagMap.class);
    configExecutionVertexMap = injector.getInstance(ConfigExecutionVertexMap.class);
    queryIdConfigDagMap = injector.getInstance(QueryIdConfigDagMap.class);
    idAndConfGenerator = new IdAndConfGenerator();
    configVertexId = new AtomicLong();
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) Injector(org.apache.reef.tang.Injector) JavaConfigurationBuilder(org.apache.reef.tang.JavaConfigurationBuilder) IdAndConfGenerator(edu.snu.mist.core.task.utils.IdAndConfGenerator) Before(org.junit.Before)

Example 15 with JavaConfigurationBuilder

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

the class RuleBasedWeatherInfo 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