(self)
return instance_id_to_task_count
Given a list of mesos tasks, return a count of tasks per agent
Given a list of mesos tasks, return a count of tasks per agent
Given a list of mesos tasks return a count of tasks per agent
def _count_tasks_per_agent(self) -> Mapping[str, TaskCount]:
        """Given a list of mesos tasks, return a count of tasks per agent"""
        instance_id_to_task_count: MutableMapping[str, TaskCount] = defaultdict(
            lambda: TaskCount(all_tasks=0, batch_tasks=0),
        )

        for task in self._tasks:
            if task["state"] == "TASK_RUNNING":
                instance_id_to_task_count[task["slave_id"]]["all_tasks"] += 1
                framework_name = self._frameworks[task["framework_id"]]["name"]
                if self._is_batch_framework(framework_name):
                    instance_id_to_task_count[task["slave_id"]]["batch_tasks"] += 1
        return instance_id_to_task_count
def _count_tasks_per_agent ( self ) -> Mapping [ str , TaskCount ] : instance_id_to_task_count : MutableMapping [ str , TaskCount ] = defaultdict ( lambda : TaskCount ( all_tasks = 0 , batch_tasks = 0 ) , ) for task in self . _tasks : if task [ "state" ] == "TASK_RUNNING" : instance_id_to_task_count [ task [ "slave_id" ] ] [ "all_tasks" ] += 1 framework_name = self . _frameworks [ task [ "framework_id" ] ] [ "name" ] if self . _is_batch_framework ( framework_name ) : instance_id_to_task_count [ task [ "slave_id" ] ] [ "batch_tasks" ] += 1 return instance_id_to_task_count