List the tasks running in a cluster by checking the /tasks endpoint.
(self, argv)
| 100 | argv["--tty"]) |
| 101 | |
| 102 | def list(self, argv): |
| 103 | """ |
| 104 | List the tasks running in a cluster by checking the /tasks endpoint. |
| 105 | """ |
| 106 | # pylint: disable=unused-argument |
| 107 | try: |
| 108 | master = self.config.master() |
| 109 | except Exception as exception: |
| 110 | raise CLIException("Unable to get leading master address: {error}" |
| 111 | .format(error=exception)) |
| 112 | |
| 113 | try: |
| 114 | tasks = get_tasks(master) |
| 115 | except Exception as exception: |
| 116 | raise CLIException("Unable to get tasks from leading" |
| 117 | " master '{master}': {error}" |
| 118 | .format(master=master, error=exception)) |
| 119 | |
| 120 | if not tasks: |
| 121 | print("There are no tasks running in the cluster.") |
| 122 | return |
| 123 | |
| 124 | try: |
| 125 | table = Table(["ID", "State", "Framework ID", "Executor ID"]) |
| 126 | for task in tasks: |
| 127 | task_state = "UNKNOWN" |
| 128 | if task["statuses"]: |
| 129 | task_state = task["statuses"][-1]["state"] |
| 130 | |
| 131 | if not argv["--all"] and task_state != "TASK_RUNNING": |
| 132 | continue |
| 133 | |
| 134 | table.add_row([task["id"], |
| 135 | task_state, |
| 136 | task["framework_id"], |
| 137 | task["executor_id"]]) |
| 138 | except Exception as exception: |
| 139 | raise CLIException("Unable to build table of tasks: {error}" |
| 140 | .format(error=exception)) |
| 141 | |
| 142 | print(str(table)) |
nothing calls this directly
no test coverage detected