Search in sources :

Example 16 with EventProcessor

use of edu.snu.mist.core.task.groupaware.eventprocessor.EventProcessor in project mist by snuspl.

the class DefaultGroupMergerImpl method logging.

private void logging(final List<EventProcessor> eventProcessors, final Map<EventProcessor, Double> loadTable) {
    final StringBuilder sb = new StringBuilder();
    sb.append("-------------- TABLE ----------------\n");
    for (final EventProcessor ep : eventProcessors) {
        final Collection<Group> groups = groupAllocationTable.getValue(ep);
        sb.append(ep);
        sb.append(" -> [");
        sb.append(loadTable.get(ep));
        sb.append("], [");
        sb.append(groups.size());
        sb.append("], ");
        sb.append(groups);
        sb.append("\n");
    }
    LOG.info(sb.toString());
}
Also used : Group(edu.snu.mist.core.task.groupaware.Group) EventProcessor(edu.snu.mist.core.task.groupaware.eventprocessor.EventProcessor)

Example 17 with EventProcessor

use of edu.snu.mist.core.task.groupaware.eventprocessor.EventProcessor in project mist by snuspl.

the class UtilizationLoadUpdater method update.

@Override
public void update() {
    startTime = System.currentTimeMillis();
    final List<EventProcessor> eventProcessors = groupAllocationTable.getKeys();
    for (final EventProcessor eventProcessor : eventProcessors) {
        updateGroupAndThreadLoad(eventProcessor, groupAllocationTable.getValue(eventProcessor));
    }
    previousUpdateTime = startTime;
    LOG.info(groupAllocationTable.toString());
}
Also used : EventProcessor(edu.snu.mist.core.task.groupaware.eventprocessor.EventProcessor)

Example 18 with EventProcessor

use of edu.snu.mist.core.task.groupaware.eventprocessor.EventProcessor in project mist by snuspl.

the class GroupMergerTest method defaultGroupMergerTest1.

/**
 * t1: [0.4, 0.2, 0.3, 0.1, 0.05] (1.05) overloaded.
 * t2: [0.1, 0.1, 0.05, 0.05] (0.3) underloaded.
 *
 * After merging.
 * t1: [0.4, 0.2, 0.3] (0.9)
 * t2: [0.1, 0.1, 0.15, 0.1] (0.45)
 */
@Test
public void defaultGroupMergerTest1() 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 GroupMerger groupMerger = injector.getInstance(GroupMerger.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 < 2; i++) {
        eventProcessors.add(epFactory.newEventProcessor());
        groupAllocationTable.put(eventProcessors.get(i));
    }
    final EventProcessor ep1 = eventProcessors.get(0);
    final EventProcessor ep2 = eventProcessors.get(1);
    final ApplicationInfo mg1 = createMetaGroup();
    final Group g1 = createGroup("g1");
    mg1.addGroup(g1);
    g1.setLoad(0.4);
    g1.setEventProcessor(ep1);
    final ApplicationInfo mg2 = createMetaGroup();
    final Group g2 = createGroup("g2");
    mg2.addGroup(g2);
    g2.setLoad(0.2);
    g2.setEventProcessor(ep1);
    final ApplicationInfo mg3 = createMetaGroup();
    final Group g3 = createGroup("g3");
    mg3.addGroup(g3);
    g3.setLoad(0.3);
    g3.setEventProcessor(ep1);
    final ApplicationInfo mg4 = createMetaGroup();
    final Group g4 = createGroup("g4");
    mg4.addGroup(g4);
    g4.setLoad(0.1);
    g4.setEventProcessor(ep1);
    final Query sg1 = createQuery("sg1");
    sg1.setLoad(0.02);
    g4.addQuery(sg1);
    final Query sg2 = createQuery("sg2");
    sg2.setLoad(0.04);
    g4.addQuery(sg2);
    final Query sg3 = createQuery("sg3");
    sg3.setLoad(0.04);
    g4.addQuery(sg3);
    final ApplicationInfo mg5 = createMetaGroup();
    final Group g5 = createGroup("g5");
    mg5.addGroup(g5);
    g5.setLoad(0.05);
    g5.setEventProcessor(ep1);
    final Query sg4 = createQuery("sg4");
    sg4.setLoad(0.02);
    g5.addQuery(sg4);
    final Query sg5 = createQuery("sg5");
    sg5.setLoad(0.03);
    g5.addQuery(sg5);
    final ApplicationInfo mg6 = createMetaGroup();
    final Group g6 = createGroup("g6");
    mg6.addGroup(g6);
    g6.setLoad(0.1);
    g6.setEventProcessor(ep2);
    final ApplicationInfo mg7 = createMetaGroup();
    final Group g7 = createGroup("g7");
    mg7.addGroup(g7);
    g7.setLoad(0.1);
    g7.setEventProcessor(ep2);
    final Group g44 = createGroup("g4");
    g44.setLoad(0.05);
    mg4.addGroup(g44);
    g44.setEventProcessor(ep2);
    final Query sg6 = createQuery("sg6");
    sg6.setLoad(0.05);
    g44.addQuery(sg6);
    final Group g55 = createGroup("g5");
    mg5.addGroup(g55);
    g55.setLoad(0.05);
    g55.setEventProcessor(ep2);
    final Query sg7 = createQuery("sg7");
    sg7.setLoad(0.05);
    g55.addQuery(sg7);
    groupAllocationTable.getValue(ep1).add(g1);
    groupAllocationTable.getValue(ep1).add(g2);
    groupAllocationTable.getValue(ep1).add(g3);
    groupAllocationTable.getValue(ep1).add(g4);
    groupAllocationTable.getValue(ep1).add(g5);
    groupAllocationTable.getValue(ep2).add(g6);
    groupAllocationTable.getValue(ep2).add(g7);
    groupAllocationTable.getValue(ep2).add(g44);
    groupAllocationTable.getValue(ep2).add(g55);
    loadUpdater.update();
    groupMerger.groupMerging();
    Assert.assertEquals(1, mg4.getGroups().size());
    Assert.assertEquals(1, mg5.getGroups().size());
    Assert.assertEquals(4, g44.size());
    Assert.assertEquals(3, g55.size());
    Assert.assertEquals(g44, sg1.getGroup());
    Assert.assertEquals(g44, sg2.getGroup());
    Assert.assertEquals(g44, sg3.getGroup());
    Assert.assertEquals(g55, sg4.getGroup());
    Assert.assertEquals(g55, sg5.getGroup());
    Assert.assertEquals(0.9, calculateLoadOfGroups(groupAllocationTable.getValue(eventProcessors.get(0))), 0.0001);
    Assert.assertEquals(0.45, calculateLoadOfGroups(groupAllocationTable.getValue(eventProcessors.get(1))), 0.0001);
}
Also used : GroupMerger(edu.snu.mist.core.task.groupaware.rebalancer.GroupMerger) 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) Injector(org.apache.reef.tang.Injector) EventProcessor(edu.snu.mist.core.task.groupaware.eventprocessor.EventProcessor) JavaConfigurationBuilder(org.apache.reef.tang.JavaConfigurationBuilder) Test(org.junit.Test)

Example 19 with EventProcessor

use of edu.snu.mist.core.task.groupaware.eventprocessor.EventProcessor in project mist by snuspl.

the class GroupRebalancerTest method firstFitRebalancerTest1.

// ep1: [1.0, 2.0, 3.0, 4.0, 0.5, 0.5, 1.0] (total 12)
// ep2: [1.0, 1.0, 1.0, 1.0, 0.5, 0.5] (total 5)
// ep3: [0.5, 5.0, 0.5, 0.5, 0.5, 0.5] (total 7.5)
// ep4: [2.0, 0.3, 0.2, 0.5, 0.5] (total 3.5)
// ==> total_load: 28
// ==> desirable load: 7
// Items: [1.0, 2.0, 3.0, 0.5]
// ep1: [4.0, 0.5, 0.5, 1.0] (total 6)
// ep2: [1.0, 1.0, 1.0, 1.0, 0.5, 0.5] (total 5)
// ep3: [5.0, 0.5, 0.5, 0.5, 0.5] (total 7)
// ep4: [2.0, 0.3, 0.2, 0.5, 0.5] (total 3.5)
// First-fit algorithm:
// ep1: [4.0, 0.5, 0.5, 1.0, 1.0] (total 7)
// ep2: [1.0, 1.0, 1.0, 1.0, 0.5, 0.5, 2] (total 7)
// ep3: [5.0, 0.5, 0.5, 0.5, 0.5] (total 7)
// ep4: [2.0, 0.3, 0.2, 0.5, 0.5, 3.0, 0.5] (total 7)
@Test
public void firstFitRebalancerTest1() 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(FirstFitRebalancerImpl.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 < 4; i++) {
        eventProcessors.add(epFactory.newEventProcessor());
        groupAllocationTable.put(eventProcessors.get(i));
    }
    final List<Double> loadsForEp1 = Arrays.asList(1.0, 2.0, 3.0, 4.0, 0.5, 0.5, 1.0);
    final List<Double> loadsForEp2 = Arrays.asList(1.0, 1.0, 1.0, 1.0, 0.5, 0.5);
    final List<Double> loadsForEp3 = Arrays.asList(0.5, 5.0, 0.5, 0.5, 0.5, 0.5);
    final List<Double> loadsForEp4 = Arrays.asList(2.0, 0.3, 0.2, 0.5, 0.5);
    final List<List<Double>> loads = Arrays.asList(loadsForEp1, loadsForEp2, loadsForEp3, loadsForEp4);
    for (int i = 0; i < 4; 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.isSplited()).thenReturn(false);
            when(group.toString()).thenReturn(Double.toString(load));
            groupAllocationTable.getValue(eventProcessor).add(group);
        }
    }
    loadUpdater.update();
    rebalancer.triggerRebalancing();
    Assert.assertEquals(7.0, calculateLoadOfGroups(groupAllocationTable.getValue(eventProcessors.get(0))));
    Assert.assertEquals(7.0, calculateLoadOfGroups(groupAllocationTable.getValue(eventProcessors.get(1))));
    Assert.assertEquals(7.0, calculateLoadOfGroups(groupAllocationTable.getValue(eventProcessors.get(2))));
    Assert.assertEquals(7.0, calculateLoadOfGroups(groupAllocationTable.getValue(eventProcessors.get(3))));
}
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)

Aggregations

EventProcessor (edu.snu.mist.core.task.groupaware.eventprocessor.EventProcessor)19 Group (edu.snu.mist.core.task.groupaware.Group)9 Injector (org.apache.reef.tang.Injector)5 JavaConfigurationBuilder (org.apache.reef.tang.JavaConfigurationBuilder)5 Test (org.junit.Test)5 DefaultEventProcessorFactory (edu.snu.mist.core.task.groupaware.eventprocessor.DefaultEventProcessorFactory)4 EventProcessorFactory (edu.snu.mist.core.task.groupaware.eventprocessor.EventProcessorFactory)4 LoadUpdater (edu.snu.mist.core.task.groupaware.rebalancer.LoadUpdater)4 LinkedList (java.util.LinkedList)4 Query (edu.snu.mist.core.task.Query)2 GroupRebalancer (edu.snu.mist.core.task.groupaware.rebalancer.GroupRebalancer)2 List (java.util.List)2 DefaultQueryImpl (edu.snu.mist.core.task.DefaultQueryImpl)1 SourceOutputEmitter (edu.snu.mist.core.task.SourceOutputEmitter)1 DefaultEventProcessor (edu.snu.mist.core.task.groupaware.eventprocessor.DefaultEventProcessor)1 NextGroupSelector (edu.snu.mist.core.task.groupaware.eventprocessor.NextGroupSelector)1 GroupMerger (edu.snu.mist.core.task.groupaware.rebalancer.GroupMerger)1 GroupSplitter (edu.snu.mist.core.task.groupaware.rebalancer.GroupSplitter)1 GroupCheckpoint (edu.snu.mist.formats.avro.GroupCheckpoint)1 GroupStats (edu.snu.mist.formats.avro.GroupStats)1