MCPcopy Create free account
hub / github.com/apache/mesos / finalize

Method finalize

src/master/master.cpp:1149–1260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1147
1148
1149void Master::finalize()
1150{
1151 LOG(INFO) << "Master terminating";
1152
1153 // NOTE: Even though we remove the slave and framework from the
1154 // allocator, it is possible that offers are already dispatched to
1155 // this master. In tests, if a new master (with the same PID) is
1156 // started, it might process the offers from the old master's
1157 // allocator.
1158 // TODO(vinod): Fix the above race by changing the allocator
1159 // interface to return a stream of offer events.
1160
1161 // Remove the slaves.
1162 foreachvalue (Slave* slave, slaves.registered) {
1163 // We first remove the slave from the allocator so that any
1164 // recovered resources below are not reoffered.
1165 allocator->removeSlave(slave->id);
1166
1167 foreachkey (const FrameworkID& frameworkId, utils::copy(slave->tasks)) {
1168 foreachvalue (Task* task, utils::copy(slave->tasks[frameworkId])) {
1169 removeTask(task);
1170 }
1171 }
1172
1173 // Remove executors.
1174 foreachkey (const FrameworkID& frameworkId, utils::copy(slave->executors)) {
1175 foreachkey (const ExecutorID& executorId,
1176 utils::copy(slave->executors[frameworkId])) {
1177 removeExecutor(slave, frameworkId, executorId);
1178 }
1179 }
1180
1181 foreach (Offer* offer, utils::copy(slave->offers)) {
1182 discardOffer(offer);
1183 }
1184
1185 // Remove inverse offers.
1186 foreach (InverseOffer* inverseOffer, utils::copy(slave->inverseOffers)) {
1187 // We don't need to update the allocator because the slave has already
1188 // been removed.
1189 removeInverseOffer(inverseOffer);
1190 }
1191
1192 // Terminate the slave observer.
1193 terminate(slave->observer);
1194 wait(slave->observer);
1195
1196 delete slave->observer;
1197 delete slave;
1198 }
1199 slaves.registered.clear();
1200
1201 // Remove the frameworks.
1202 // Note we are not deleting the pointers to the frameworks from the
1203 // roles because it is unnecessary bookkeeping at this point since
1204 // we are shutting down.
1205 foreachvalue (Framework* framework, frameworks.registered) {
1206 allocator->removeFramework(framework->id());

Callers

nothing calls this directly

Calls 12

copyFunction · 0.85
foreachvalueFunction · 0.70
foreachFunction · 0.70
terminateFunction · 0.50
waitFunction · 0.50
removeSlaveMethod · 0.45
clearMethod · 0.45
removeFrameworkMethod · 0.45
idMethod · 0.45
emptyMethod · 0.45
isSomeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected