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

Method doReliableRegistration

src/sched/sched.cpp:823–878  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

821 }
822
823 void doReliableRegistration(Duration maxBackoff)
824 {
825 if (!running.load()) {
826 return;
827 }
828
829 if (connected || master.isNone()) {
830 return;
831 }
832
833 if (credential.isSome() && !authenticated) {
834 return;
835 }
836
837 VLOG(1) << "Sending SUBSCRIBE call to " << master->pid();
838
839 Call call;
840 call.set_type(Call::SUBSCRIBE);
841
842 Call::Subscribe* subscribe = call.mutable_subscribe();
843 subscribe->mutable_framework_info()->CopyFrom(framework);
844 *subscribe->mutable_offer_constraints() = offerConstraints;
845 *subscribe->mutable_suppressed_roles() = RepeatedPtrField<string>(
846 suppressedRoles.begin(), suppressedRoles.end());
847
848 if (framework.has_id() && !framework.id().value().empty()) {
849 subscribe->set_force(failover);
850 call.mutable_framework_id()->CopyFrom(framework.id());
851 }
852
853 send(master->pid(), call);
854
855 // Bound the maximum backoff by 'REGISTRATION_RETRY_INTERVAL_MAX'.
856 maxBackoff =
857 std::min(maxBackoff, scheduler::REGISTRATION_RETRY_INTERVAL_MAX);
858
859 // If failover timeout is present, bound the maximum backoff
860 // by 1/10th of the failover timeout.
861 if (framework.has_failover_timeout()) {
862 Try<Duration> duration = Duration::create(framework.failover_timeout());
863 if (duration.isSome() && duration.get() > Duration::zero()) {
864 maxBackoff = std::min(maxBackoff, duration.get() / 10);
865 }
866 }
867
868 // Determine the delay for next attempt by picking a random
869 // duration between 0 and 'maxBackoff'.
870 // TODO(vinod): Use random numbers from <random> header.
871 Duration delay = maxBackoff * ((double) os::random() / RAND_MAX);
872
873 VLOG(1) << "Will retry registration in " << delay << " if necessary";
874
875 // Backoff.
876 frameworkRegistrationTimer = process::delay(
877 delay, self(), &Self::doReliableRegistration, maxBackoff * 2);
878 }
879
880 void resourceOffers(

Callers

nothing calls this directly

Calls 15

minFunction · 0.85
randomFunction · 0.85
CopyFromMethod · 0.80
sendFunction · 0.50
createFunction · 0.50
delayFunction · 0.50
loadMethod · 0.45
isNoneMethod · 0.45
isSomeMethod · 0.45
pidMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected