| 365 | |
| 366 | |
| 367 | void Framework::removeExecutor( |
| 368 | const SlaveID& slaveId, |
| 369 | const ExecutorID& executorId) |
| 370 | { |
| 371 | CHECK(hasExecutor(slaveId, executorId)) |
| 372 | << "Unknown executor '" << executorId |
| 373 | << "' of framework " << id() |
| 374 | << " of agent " << slaveId; |
| 375 | |
| 376 | const ExecutorInfo& executorInfo = executors[slaveId][executorId]; |
| 377 | |
| 378 | totalUsedResources -= executorInfo.resources(); |
| 379 | usedResources[slaveId] -= executorInfo.resources(); |
| 380 | if (usedResources[slaveId].empty()) { |
| 381 | usedResources.erase(slaveId); |
| 382 | } |
| 383 | |
| 384 | // If we are no longer subscribed to the role to which these resources are |
| 385 | // being returned to, and we have no more resources allocated to us for that |
| 386 | // role, stop tracking the framework under the role. |
| 387 | if (!executorInfo.resources().empty()) { |
| 388 | const std::string& role = |
| 389 | executorInfo.resources().begin()->allocation_info().role(); |
| 390 | |
| 391 | auto allocatedToRole = [&role](const Resource& resource) { |
| 392 | return resource.allocation_info().role() == role; |
| 393 | }; |
| 394 | |
| 395 | if (roles.count(role) == 0 && |
| 396 | totalUsedResources.filter(allocatedToRole).empty()) { |
| 397 | CHECK(totalOfferedResources.filter(allocatedToRole).empty()); |
| 398 | untrackUnderRole(role); |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | executors[slaveId].erase(executorId); |
| 403 | if (executors[slaveId].empty()) { |
| 404 | executors.erase(slaveId); |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | |
| 409 | void Framework::addOperation(Operation* operation) |