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

Method recoverFramework

src/master/master.cpp:10054–10155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10052
10053
10054void Master::recoverFramework(const FrameworkInfo& info)
10055{
10056 CHECK(!frameworks.registered.contains(info.id()));
10057
10058 Framework* framework = new Framework(this, flags, info);
10059
10060 // Send a `FRAMEWORK_ADDED` event to subscribers before adding recovered tasks
10061 // so the framework ID referred by any succeeding `TASK_ADDED` event will be
10062 // known to subscribers.
10063 if (!subscribers.subscribed.empty()) {
10064 subscribers.send(protobuf::master::event::createFrameworkAdded(*framework));
10065 }
10066
10067 // Add active operations, tasks, and executors to the framework.
10068 foreachvalue (Slave* slave, slaves.registered) {
10069 if (slave->tasks.contains(framework->id())) {
10070 foreachvalue (Task* task, slave->tasks.at(framework->id())) {
10071 framework->addTask(task);
10072 }
10073 }
10074
10075 if (slave->executors.contains(framework->id())) {
10076 foreachvalue (const ExecutorInfo& executor,
10077 slave->executors.at(framework->id())) {
10078 framework->addExecutor(slave->id, executor);
10079 }
10080 }
10081
10082 // Combine all the operations of the agent into one list
10083 // so they can be processed the same way.
10084 vector<Operation*> allOperations = slave->operations.values();
10085 foreachvalue (const Slave::ResourceProvider& resourceProvider,
10086 slave->resourceProviders) {
10087 foreachvalue (Operation* operation, resourceProvider.operations) {
10088 allOperations.push_back(operation);
10089 }
10090 }
10091
10092 foreach (Operation* operation, allOperations) {
10093 if (operation->has_framework_id() &&
10094 operation->framework_id() == framework->id()) {
10095 framework->addOperation(operation);
10096
10097 // If this is an orphaned operation, the orphan's resources
10098 // must be added back to the agent's total, and the allocator
10099 // will need to be updated with the new total and allocation.
10100 if (slave->orphanedOperations.contains(operation->uuid())) {
10101 LOG(INFO)
10102 << "Recovered orphan operation " << operation->uuid()
10103 << (operation->info().has_id()
10104 ? " (ID: " + operation->info().id().value() + ")"
10105 : "")
10106 << " on agent " << operation->slave_id()
10107 << " belonging to framework " << operation->framework_id()
10108 << " in state " << operation->latest_status().state();
10109
10110 slave->orphanedOperations.erase(operation->uuid());
10111

Callers

nothing calls this directly

Calls 9

createFrameworkAddedFunction · 0.85
atMethod · 0.80
foreachvalueFunction · 0.70
sendMethod · 0.65
containsMethod · 0.45
idMethod · 0.45
emptyMethod · 0.45
addTaskMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected