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

Method __send

src/scheduler/scheduler.cpp:625–720  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

623 }
624
625 void __send(
626 const id::UUID& _connectionId,
627 const Call& call,
628 const Future<process::http::Response>& response)
629 {
630 // It is possible that we detected a new master before a response could
631 // be received.
632 if (connectionId != _connectionId) {
633 return;
634 }
635
636 CHECK(!response.isDiscarded());
637 CHECK(state == SUBSCRIBING || state == SUBSCRIBED) << state;
638
639 // This can happen during a master failover or a network blip
640 // causing the socket to timeout. Eventually, the scheduler would
641 // detect the disconnection via ZK(disconnect()) or lack of heartbeats.
642 if (response.isFailed()) {
643 LOG(ERROR) << "Request for call type " << call.type() << " failed: "
644 << response.failure();
645 return;
646 }
647
648 if (response->code == process::http::Status::OK) {
649 // Only SUBSCRIBE call should get a "200 OK" response.
650 CHECK_EQ(Call::SUBSCRIBE, call.type());
651 CHECK_EQ(response->type, process::http::Response::PIPE);
652 CHECK_SOME(response->reader);
653
654 state = SUBSCRIBED;
655
656 Pipe::Reader reader = response->reader.get();
657
658 Owned<Reader<Event>> decoder(new Reader<Event>(
659 lambda::bind(deserialize<Event>, contentType, lambda::_1),
660 reader));
661
662 subscribed = SubscribedResponse {reader, decoder};
663
664 // Responses to SUBSCRIBE calls should always include a stream ID.
665 CHECK(response->headers.contains("Mesos-Stream-Id"));
666
667 Try<id::UUID> uuid =
668 id::UUID::fromString(response->headers.at("Mesos-Stream-Id"));
669
670 CHECK_SOME(uuid);
671
672 streamId = uuid.get();
673
674 read();
675
676 return;
677 }
678
679 if (response->code == process::http::Status::ACCEPTED) {
680 // Only non SUBSCRIBE calls should get a "202 Accepted" response.
681 CHECK_NE(Call::SUBSCRIBE, call.type());
682 return;

Callers

nothing calls this directly

Calls 11

errorFunction · 0.85
isDiscardedMethod · 0.80
isFailedMethod · 0.80
typeMethod · 0.80
failureMethod · 0.80
atMethod · 0.80
bindFunction · 0.50
readFunction · 0.50
stringifyFunction · 0.50
getMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected