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

Method accept

src/master/master.cpp:3913–4364  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3911
3912
3913void Master::accept(
3914 Framework* framework,
3915 scheduler::Call::Accept&& accept)
3916{
3917 CHECK_NOTNULL(framework);
3918
3919 // Bump metrics.
3920 foreach (const Offer::Operation& operation, accept.operations()) {
3921 if (operation.type() == Offer::Operation::LAUNCH) {
3922 if (operation.launch().task_infos().size() > 0) {
3923 ++metrics->messages_launch_tasks;
3924 } else {
3925 ++metrics->messages_decline_offers;
3926 LOG(WARNING) << "Implicitly declining offers: " << accept.offer_ids()
3927 << " in ACCEPT call for framework " << framework->id()
3928 << " as the launch operation specified no tasks";
3929 }
3930 }
3931
3932 // TODO(mpark): Add metrics for LAUNCH_GROUP operation.
3933 // TODO(jieyu): Add metrics for non launch operations.
3934 }
3935
3936 Option<Error> error = None();
3937
3938 if (accept.offer_ids().size() == 0) {
3939 error = Error("No offers specified");
3940 } else {
3941 // Validate the offers.
3942 error = validation::offer::validate(accept.offer_ids(), this, framework);
3943 }
3944
3945 if (error.isSome()) {
3946 // TODO(jieyu): Consider adding a 'drop' overload for ACCEPT call to
3947 // consistently handle message dropping. It would be ideal if the
3948 // 'drop' overload can handle both resource recovery and lost task
3949 // notifications.
3950
3951 // Discard existing offers.
3952 foreach (const OfferID& offerId, accept.offer_ids()) {
3953 Offer* offer = getOffer(offerId);
3954 if (offer != nullptr) {
3955 discardOffer(offer);
3956 } else {
3957 // If the offer was not in our offer set, then this offer is no
3958 // longer valid.
3959 LOG(WARNING) << "Ignoring accept of offer " << offerId
3960 << " since it is no longer valid";
3961 }
3962 }
3963
3964 LOG(WARNING) << "ACCEPT call used invalid offers '" << accept.offer_ids()
3965 << "': " << error->message;
3966
3967 const TaskState newTaskState =
3968 framework->capabilities.partitionAware ? TASK_DROPPED : TASK_LOST;
3969
3970 foreach (const Offer::Operation& operation, accept.operations()) {

Callers 10

TEST_PFunction · 0.45
foreachvalueFunction · 0.45
foreachFunction · 0.45
acceptLoopMethod · 0.45
sendMethod · 0.45
foreachMethod · 0.45
schedulerMethod · 0.45
foreachvalueFunction · 0.45
frameworksMethod · 0.45
foreachFunction · 0.45

Calls 13

NoneClass · 0.85
getOfferFunction · 0.85
injectAllocationInfoFunction · 0.85
typeMethod · 0.80
executorMethod · 0.80
CopyFromMethod · 0.80
validateFunction · 0.70
foreachFunction · 0.70
ErrorFunction · 0.50
sizeMethod · 0.45
isSomeMethod · 0.45
getMethod · 0.45

Tested by 2

TEST_PFunction · 0.36
foreachMethod · 0.36