Search in sources :

Example 1 with GroupStats

use of edu.snu.mist.formats.avro.GroupStats in project mist by snuspl.

the class DefaultTaskStatsUpdater method updateTaskStatsToMaster.

@Override
public void updateTaskStatsToMaster(final GroupAllocationTable groupAllocationTable) throws AvroRemoteException {
    final List<EventProcessor> epList = new ArrayList<>(groupAllocationTable.getKeys());
    final int numEventProcessors = epList.size();
    final List<Group> groupList = new ArrayList<>();
    // Get the whole group list.
    for (final EventProcessor ep : epList) {
        groupList.addAll(groupAllocationTable.getValue(ep));
    }
    double totalLoad = 0.0;
    final Map<String, GroupStats> groupStatsMap = new HashMap<>();
    for (final Group group : groupList) {
        groupStatsMap.put(group.getGroupId(), GroupStats.newBuilder().setGroupLoad(group.getLoad()).setAppId(group.getApplicationInfo().getApplicationId()).setGroupQueryNum(group.getQueries().size()).setGroupId(group.getGroupId()).build());
        totalLoad += group.getLoad();
    }
    final double taskCpuLoad = totalLoad / numEventProcessors;
    proxyToMaster.updateTaskStats(taskId, TaskStats.newBuilder().setTaskLoad(taskCpuLoad).setGroupStatsMap(groupStatsMap).build());
}
Also used : HashMap(java.util.HashMap) EventProcessor(edu.snu.mist.core.task.groupaware.eventprocessor.EventProcessor) ArrayList(java.util.ArrayList) GroupStats(edu.snu.mist.formats.avro.GroupStats)

Aggregations

EventProcessor (edu.snu.mist.core.task.groupaware.eventprocessor.EventProcessor)1 GroupStats (edu.snu.mist.formats.avro.GroupStats)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1