| 1073 | |
| 1074 | |
| 1075 | void Slave::drain( |
| 1076 | const UPID& from, |
| 1077 | DrainSlaveMessage&& drainSlaveMessage) |
| 1078 | { |
| 1079 | if (operations.empty() && frameworks.empty()) { |
| 1080 | LOG(INFO) |
| 1081 | << "Received DrainConfig " << drainSlaveMessage.config() |
| 1082 | << (drainConfig.isSome() |
| 1083 | ? "; previously stored DrainConfig " + stringify(*drainConfig) |
| 1084 | : "") |
| 1085 | << "; agent has no stored frameworks, tasks, or operations," |
| 1086 | " so draining is already complete"; |
| 1087 | |
| 1088 | return; |
| 1089 | } |
| 1090 | |
| 1091 | hashmap<FrameworkID, hashset<TaskID>> pendingTaskIds; |
| 1092 | foreachvalue (Framework* framework, frameworks) { |
| 1093 | foreachvalue (const auto& taskMap, framework->pendingTasks) { |
| 1094 | pendingTaskIds[framework->id()] = taskMap.keys(); |
| 1095 | } |
| 1096 | } |
| 1097 | |
| 1098 | hashmap<FrameworkID, hashset<TaskID>> queuedTaskIds; |
| 1099 | foreachvalue (Framework* framework, frameworks) { |
| 1100 | foreachvalue (Executor* executor, framework->executors) { |
| 1101 | foreachkey (const TaskID& taskId, executor->queuedTasks) { |
| 1102 | queuedTaskIds[framework->id()].insert(taskId); |
| 1103 | } |
| 1104 | } |
| 1105 | } |
| 1106 | |
| 1107 | hashmap<FrameworkID, hashset<TaskID>> launchedTaskIds; |
| 1108 | foreachvalue (Framework* framework, frameworks) { |
| 1109 | foreachvalue (Executor* executor, framework->executors) { |
| 1110 | foreachkey (const TaskID& taskId, executor->launchedTasks) { |
| 1111 | launchedTaskIds[framework->id()].insert(taskId); |
| 1112 | } |
| 1113 | } |
| 1114 | } |
| 1115 | |
| 1116 | LOG(INFO) |
| 1117 | << "Initiating drain with DrainConfig " << drainSlaveMessage.config() |
| 1118 | << (drainConfig.isSome() |
| 1119 | ? "; overwriting previous DrainConfig " + stringify(*drainConfig) |
| 1120 | : "") |
| 1121 | << "; agent has (pending tasks, queued tasks, launched tasks, operations)" |
| 1122 | << " == (" |
| 1123 | << stringify(pendingTaskIds) << ", " |
| 1124 | << stringify(queuedTaskIds) << ", " |
| 1125 | << stringify(launchedTaskIds) << ", " |
| 1126 | << stringify(operations.keys()) << ")"; |
| 1127 | |
| 1128 | CHECK_SOME(state::checkpoint( |
| 1129 | paths::getDrainConfigPath(metaDir, info.id()), |
| 1130 | drainSlaveMessage.config())) |
| 1131 | << "Failed to checkpoint DrainConfig"; |
| 1132 |
nothing calls this directly
no test coverage detected