Repository: mesos Updated Branches: refs/heads/master 51c2b523d -> 6b842c27b
Introduced Address and URL protobufs. Review: https://reviews.apache.org/r/36450 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/866147a5 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/866147a5 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/866147a5 Branch: refs/heads/master Commit: 866147a55bedf9338b835621a28d3ef37bd4cc80 Parents: 51c2b52 Author: Benjamin Mahler <[email protected]> Authored: Mon Jul 13 10:29:24 2015 -0700 Committer: Benjamin Mahler <[email protected]> Committed: Fri Jul 17 13:33:15 2015 -0700 ---------------------------------------------------------------------- include/mesos/mesos.proto | 30 ++++++++++++++++++++++++++++++ include/mesos/type_utils.hpp | 1 + src/common/type_utils.cpp | 7 +++++++ src/master/master.cpp | 9 +++++++++ src/tests/master_tests.cpp | 12 ++++++++++++ 5 files changed, 59 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/866147a5/include/mesos/mesos.proto ---------------------------------------------------------------------- diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto index d2f4826..cb24125 100644 --- a/include/mesos/mesos.proto +++ b/include/mesos/mesos.proto @@ -94,6 +94,32 @@ message ContainerID { /** + * A network address. + * + * TODO(bmahler): Use this more widely (e.g. MasterInfo). + */ +message Address { + // May contain a hostname, IP address, or both. + optional string hostname = 1; + optional string ip = 2; + + required int32 port = 3; +} + + +/** + * Represents a URL. + */ +message URL { + required string scheme = 1; + required Address address = 2; + optional string path = 3; + repeated Parameter query = 4; + optional string fragment = 5; +} + + +/** * Describes a framework. */ message FrameworkInfo { @@ -773,6 +799,10 @@ message Offer { required FrameworkID framework_id = 2; required SlaveID slave_id = 3; required string hostname = 4; + + // URL for reaching the slave running on the host. + optional URL url = 8; + repeated Resource resources = 5; repeated Attribute attributes = 7; repeated ExecutorID executor_ids = 6; http://git-wip-us.apache.org/repos/asf/mesos/blob/866147a5/include/mesos/type_utils.hpp ---------------------------------------------------------------------- diff --git a/include/mesos/type_utils.hpp b/include/mesos/type_utils.hpp index eb7fe25..86b37ca 100644 --- a/include/mesos/type_utils.hpp +++ b/include/mesos/type_utils.hpp @@ -60,6 +60,7 @@ bool operator == ( bool operator == (const SlaveInfo& left, const SlaveInfo& right); bool operator == (const Volume& left, const Volume& right); +bool operator == (const URL& left, const URL& right); bool operator == (const TaskStatus& left, const TaskStatus& right); bool operator != (const TaskStatus& left, const TaskStatus& right); http://git-wip-us.apache.org/repos/asf/mesos/blob/866147a5/src/common/type_utils.cpp ---------------------------------------------------------------------- diff --git a/src/common/type_utils.cpp b/src/common/type_utils.cpp index 2ad5b4c..36a2469 100644 --- a/src/common/type_utils.cpp +++ b/src/common/type_utils.cpp @@ -126,6 +126,13 @@ bool operator == (const Volume& left, const Volume& right) } +// TODO(bmahler): Leverage process::http::URL for equality. +bool operator == (const URL& left, const URL& right) +{ + return left.SerializeAsString() == right.SerializeAsString(); +} + + bool operator == ( const ContainerInfo::DockerInfo::PortMapping& left, const ContainerInfo::DockerInfo::PortMapping& right) http://git-wip-us.apache.org/repos/asf/mesos/blob/866147a5/src/master/master.cpp ---------------------------------------------------------------------- diff --git a/src/master/master.cpp b/src/master/master.cpp index 082758e..2f00f24 100644 --- a/src/master/master.cpp +++ b/src/master/master.cpp @@ -4240,11 +4240,20 @@ void Master::offer(const FrameworkID& frameworkId, // separate offers, so that rescinding offers with revocable // resources does not affect offers with regular resources. + // TODO(bmahler): Set "https" if only "https" is supported. + mesos::URL url; + url.set_scheme("http"); + url.mutable_address()->set_hostname(slave->info.hostname()); + url.mutable_address()->set_ip(stringify(slave->pid.address.ip)); + url.mutable_address()->set_port(slave->pid.address.port); + url.set_path("/" + slave->pid.id); + Offer* offer = new Offer(); offer->mutable_id()->MergeFrom(newOfferId()); offer->mutable_framework_id()->MergeFrom(framework->id()); offer->mutable_slave_id()->MergeFrom(slave->id); offer->set_hostname(slave->info.hostname()); + offer->mutable_url()->MergeFrom(url); offer->mutable_resources()->MergeFrom(offered); offer->mutable_attributes()->MergeFrom(slave->info.attributes()); http://git-wip-us.apache.org/repos/asf/mesos/blob/866147a5/src/tests/master_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/master_tests.cpp b/src/tests/master_tests.cpp index 9205ec4..1e934c4 100644 --- a/src/tests/master_tests.cpp +++ b/src/tests/master_tests.cpp @@ -130,6 +130,18 @@ TEST_F(MasterTest, TaskRunning) AWAIT_READY(offers); EXPECT_NE(0u, offers.get().size()); + // Ensure the hostname and url are set correctly. + EXPECT_EQ(slave.get().address.hostname().get(), offers.get()[0].hostname()); + + mesos::URL url; + url.set_scheme("http"); + url.mutable_address()->set_ip(stringify(slave.get().address.ip)); + url.mutable_address()->set_hostname(slave.get().address.hostname().get()); + url.mutable_address()->set_port(slave.get().address.port); + url.set_path("/" + slave.get().id); + + EXPECT_EQ(url, offers.get()[0].url()); + TaskInfo task; task.set_name(""); task.mutable_task_id()->set_value("1");
