| 2879 | |
| 2880 | |
| 2881 | Future<JSON::Array> Http::__containers( |
| 2882 | const Owned<ObjectApprovers>& approvers, |
| 2883 | Option<IDAcceptor<ContainerID>> selectContainerId, |
| 2884 | bool showNestedContainers, |
| 2885 | bool showStandaloneContainers) const |
| 2886 | { |
| 2887 | return slave->containerizer->containers() |
| 2888 | .then(defer(slave->self(), [=](const hashset<ContainerID> containerIds) { |
| 2889 | Owned<vector<JSON::Object>> metadata(new vector<JSON::Object>()); |
| 2890 | vector<Future<ContainerStatus>> statusFutures; |
| 2891 | vector<Future<ResourceStatistics>> statsFutures; |
| 2892 | |
| 2893 | hashset<ContainerID> executorContainerIds; |
| 2894 | hashset<ContainerID> authorizedExecutorContainerIds; |
| 2895 | |
| 2896 | foreachvalue (const Framework* framework, slave->frameworks) { |
| 2897 | foreachvalue (const Executor* executor, framework->executors) { |
| 2898 | // No need to get statistics and status if we know that the |
| 2899 | // executor has already terminated. |
| 2900 | if (executor->state == Executor::TERMINATED) { |
| 2901 | continue; |
| 2902 | } |
| 2903 | |
| 2904 | const ExecutorInfo& info = executor->info; |
| 2905 | const ContainerID& containerId = executor->containerId; |
| 2906 | |
| 2907 | executorContainerIds.insert(containerId); |
| 2908 | |
| 2909 | if ((selectContainerId.isSome() && |
| 2910 | !selectContainerId->accept(containerId)) || |
| 2911 | !approvers->approved<VIEW_CONTAINER>(info, framework->info)) { |
| 2912 | continue; |
| 2913 | } |
| 2914 | |
| 2915 | authorizedExecutorContainerIds.insert(containerId); |
| 2916 | |
| 2917 | JSON::Object entry; |
| 2918 | entry.values["framework_id"] = info.framework_id().value(); |
| 2919 | entry.values["executor_id"] = info.executor_id().value(); |
| 2920 | entry.values["executor_name"] = info.name(); |
| 2921 | entry.values["source"] = info.source(); |
| 2922 | entry.values["container_id"] = containerId.value(); |
| 2923 | |
| 2924 | metadata->push_back(entry); |
| 2925 | statusFutures.push_back(slave->containerizer->status(containerId)); |
| 2926 | statsFutures.push_back(slave->containerizer->usage(containerId)); |
| 2927 | } |
| 2928 | } |
| 2929 | |
| 2930 | foreach (const ContainerID& containerId, containerIds) { |
| 2931 | if (executorContainerIds.contains(containerId)) { |
| 2932 | continue; |
| 2933 | } |
| 2934 | |
| 2935 | if (selectContainerId.isSome() && |
| 2936 | !selectContainerId->accept(containerId)) { |
| 2937 | continue; |
| 2938 | } |
nothing calls this directly
no test coverage detected