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());
}
Aggregations