Fully qualified addresses of flag members in `add` calls in mesos.

While right now we can technically `add` variables to `Flags` classes
which are not members, the in order to have correct copy semantics for
`Flags` only member variables should be used.

Here we changed all instances to a full pointer-to-member syntax in
the current code.

Review: https://reviews.apache.org/r/46824/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/f441eb9a
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/f441eb9a
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/f441eb9a

Branch: refs/heads/master
Commit: f441eb9adb8c1443e62e10d17ed4019b66391168
Parents: dde5eee
Author: Benjamin Bannier <benjamin.bann...@mesosphere.io>
Authored: Tue Oct 18 04:48:10 2016 -0400
Committer: Michael Park <mp...@apache.org>
Committed: Tue Oct 18 06:09:33 2016 -0400

----------------------------------------------------------------------
 src/cli/execute.cpp                             |  44 +++---
 src/cli/resolve.cpp                             |  33 +++--
 src/docker/executor.hpp                         |  16 +--
 src/examples/balloon_framework.cpp              |  16 +--
 src/examples/disk_full_framework.cpp            |  10 +-
 src/examples/dynamic_reservation_framework.cpp  |   8 +-
 src/examples/load_generator_framework.cpp       |   2 +-
 src/examples/long_lived_framework.cpp           |  14 +-
 src/examples/no_executor_framework.cpp          |  16 +--
 src/examples/persistent_volume_framework.cpp    |  10 +-
 src/examples/test_framework.cpp                 |  37 ++---
 src/examples/test_http_framework.cpp            |  33 +++--
 src/launcher/executor.cpp                       |  14 +-
 src/local/main.cpp                              |  35 +++--
 src/master/main.cpp                             | 139 ++++++++++---------
 src/slave/container_loggers/lib_logrotate.hpp   |  16 +--
 src/slave/container_loggers/logrotate.hpp       |   8 +-
 .../mesos/isolators/network/cni/cni.cpp         |  14 +-
 .../mesos/isolators/network/port_mapping.cpp    |  20 +--
 src/slave/containerizer/mesos/launch.cpp        |  22 +--
 src/slave/containerizer/mesos/mount.cpp         |   4 +-
 src/slave/main.cpp                              | 134 +++++++++---------
 src/tests/active_user_test_helper.cpp           |   2 +-
 .../containerizer/capabilities_test_helper.cpp  |   4 +-
 24 files changed, 344 insertions(+), 307 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/f441eb9a/src/cli/execute.cpp
----------------------------------------------------------------------
diff --git a/src/cli/execute.cpp b/src/cli/execute.cpp
index 94ac463..f308b34 100644
--- a/src/cli/execute.cpp
+++ b/src/cli/execute.cpp
@@ -91,11 +91,11 @@ class Flags : public virtual flags::FlagsBase
 public:
   Flags()
   {
-    add(&master,
+    add(&Flags::master,
         "master",
         "Mesos master (e.g., IP:PORT).");
 
-    add(&task_group,
+    add(&Flags::task_group,
         "task_group",
         "The value could be a JSON-formatted string of `TaskGroupInfo` or a\n"
         "file path containing the JSON-formatted `TaskGroupInfo`. Path must\n"
@@ -135,11 +135,11 @@ public:
         "     ]\n"
         "}");
 
-    add(&name,
+    add(&Flags::name,
         "name",
         "Name for the command.");
 
-    add(&shell,
+    add(&Flags::shell,
         "shell",
         "Determine the command is a shell or not. If not, 'command' will be\n"
         "treated as executable value and arguments (TODO).",
@@ -147,11 +147,11 @@ public:
 
     // TODO(alexr): Once MESOS-4882 lands, elaborate on what `command` can
     // mean: an executable, a shell command, an entrypoint for a container.
-    add(&command,
+    add(&Flags::command,
         "command",
         "Command to launch.");
 
-    add(&environment,
+    add(&Flags::environment,
         "env",
         "Shell command environment variables.\n"
         "The value could be a JSON formatted string of environment variables\n"
@@ -159,80 +159,80 @@ public:
         "formatted environment variables. Path should be of the form\n"
         "'file:///path/to/file'.");
 
-    add(&resources,
+    add(&Flags::resources,
         "resources",
         "Resources for the command.",
         "cpus:1;mem:128");
 
-    add(&hadoop,
+    add(&Flags::hadoop,
         "hadoop",
         "Path to 'hadoop' script (used for copying packages).",
         "hadoop");
 
-    add(&hdfs,
+    add(&Flags::hdfs,
         "hdfs",
         "The ip:port of the NameNode service.",
         "localhost:9000");
 
-    add(&package,
+    add(&Flags::package,
         "package",
         "Package to upload into HDFS and copy into command's\n"
         "working directory (requires 'hadoop', see --hadoop).");
 
-    add(&overwrite,
+    add(&Flags::overwrite,
         "overwrite",
         "Overwrite the package in HDFS if it already exists.",
         false);
 
-    add(&checkpoint,
+    add(&Flags::checkpoint,
         "checkpoint",
         "Enable checkpointing for the framework.",
         false);
 
-    add(&appc_image,
+    add(&Flags::appc_image,
         "appc_image",
         "Appc image name that follows the Appc spec\n"
         "(e.g., ubuntu, example.com/reduce-worker).");
 
-    add(&docker_image,
+    add(&Flags::docker_image,
         "docker_image",
         "Docker image that follows the Docker CLI naming <image>:<tag>\n"
         "(i.e., ubuntu, busybox:latest).");
 
-    add(&framework_capabilities,
+    add(&Flags::framework_capabilities,
         "framework_capabilities",
         "Comma separated list of optional framework capabilities to enable.\n"
         "(the only valid value is currently 'GPU_RESOURCES')");
 
-    add(&containerizer,
+    add(&Flags::containerizer,
         "containerizer",
         "Containerizer to be used (i.e., docker, mesos).",
         "mesos");
 
-    add(&role,
+    add(&Flags::role,
         "role",
         "Role to use when registering.",
         "*");
 
-    add(&kill_after,
+    add(&Flags::kill_after,
         "kill_after",
         "Specifies a delay after which the task is killed\n"
         "(e.g., 10secs, 2mins, etc).");
 
-    add(&networks,
+    add(&Flags::networks,
         "networks",
         "Comma-separated list of networks that the container will join,\n"
         "e.g., `net1,net2`.");
 
-    add(&principal,
+    add(&Flags::principal,
         "principal",
         "The principal to use for framework authentication.");
 
-    add(&secret,
+    add(&Flags::secret,
         "secret",
         "The secret to use for framework authentication.");
 
-    add(&volumes,
+    add(&Flags::volumes,
         "volumes",
         "The value could be a JSON-formatted string of volumes or a\n"
         "file path containing the JSON-formatted volumes. Path must\n"

http://git-wip-us.apache.org/repos/asf/mesos/blob/f441eb9a/src/cli/resolve.cpp
----------------------------------------------------------------------
diff --git a/src/cli/resolve.cpp b/src/cli/resolve.cpp
index 3a12f12..b3cba87 100644
--- a/src/cli/resolve.cpp
+++ b/src/cli/resolve.cpp
@@ -41,23 +41,30 @@ using std::endl;
 using std::string;
 
 
-int main(int argc, char** argv)
+class Flags : public virtual flags::FlagsBase
 {
-  flags::FlagsBase flags;
-  flags.setUsageMessage("Usage: " + Path(argv[0]).basename() + " <master>");
+public:
+  Flags()
+  {
+    add(&Flags::timeout,
+        "timeout",
+        "How long to wait to resolve master",
+        Seconds(5));
+
+    add(&Flags::verbose, "verbose", "Be verbose", false);
+  }
 
   Duration timeout;
-  flags.add(&timeout,
-            "timeout",
-            "How long to wait to resolve master",
-            Seconds(5));
 
   // TODO(marco): `verbose` is also a great candidate for FlagsBase.
   bool verbose;
-  flags.add(&verbose,
-            "verbose",
-            "Be verbose",
-            false);
+};
+
+
+int main(int argc, char** argv)
+{
+  Flags flags;
+  flags.setUsageMessage("Usage: " + Path(argv[0]).basename() + " <master>");
 
   // Load flags from environment and command line, and remove
   // them from argv.
@@ -95,9 +102,9 @@ int main(int argc, char** argv)
 
   Future<Option<MasterInfo>> masterInfo = detector.get()->detect();
 
-  if (!masterInfo.await(timeout)) {
+  if (!masterInfo.await(flags.timeout)) {
     cerr << "Failed to detect master from '" << master
-         << "' within " << timeout << endl;
+         << "' within " << flags.timeout << endl;
     return -1;
   } else {
     CHECK(!masterInfo.isDiscarded());

http://git-wip-us.apache.org/repos/asf/mesos/blob/f441eb9a/src/docker/executor.hpp
----------------------------------------------------------------------
diff --git a/src/docker/executor.hpp b/src/docker/executor.hpp
index 495fad5..8385631 100644
--- a/src/docker/executor.hpp
+++ b/src/docker/executor.hpp
@@ -35,41 +35,41 @@ namespace docker {
 struct Flags : public virtual mesos::internal::logging::Flags
 {
   Flags() {
-    add(&container,
+    add(&Flags::container,
         "container",
         "The name of the docker container to run.");
 
-    add(&docker,
+    add(&Flags::docker,
         "docker",
         "The path to the docker executable.");
 
-    add(&docker_socket,
+    add(&Flags::docker_socket,
         "docker_socket",
         "The UNIX socket path to be used by docker CLI for accessing docker\n"
         "daemon.");
 
-    add(&sandbox_directory,
+    add(&Flags::sandbox_directory,
         "sandbox_directory",
         "The path to the container sandbox holding stdout and stderr files\n"
         "into which docker container logs will be redirected.");
 
-    add(&mapped_directory,
+    add(&Flags::mapped_directory,
         "mapped_directory",
         "The sandbox directory path that is mapped in the docker container.");
 
     // TODO(alexr): Remove this after the deprecation cycle (started in 1.0).
-    add(&stop_timeout,
+    add(&Flags::stop_timeout,
         "stop_timeout",
         "The duration for docker to wait after stopping a running container\n"
         "before it kills that container. This flag is deprecated; use task's\n"
         "kill policy instead.");
 
-    add(&launcher_dir,
+    add(&Flags::launcher_dir,
         "launcher_dir",
         "Directory path of Mesos binaries. Mesos would find fetcher,\n"
         "containerizer and executor binary files under this directory.");
 
-    add(&task_environment,
+    add(&Flags::task_environment,
         "task_environment",
         "A JSON map of environment variables and values that should\n"
         "be passed into the task launched by this executor.");

http://git-wip-us.apache.org/repos/asf/mesos/blob/f441eb9a/src/examples/balloon_framework.cpp
----------------------------------------------------------------------
diff --git a/src/examples/balloon_framework.cpp 
b/src/examples/balloon_framework.cpp
index 50add6a..79495ae 100644
--- a/src/examples/balloon_framework.cpp
+++ b/src/examples/balloon_framework.cpp
@@ -63,11 +63,11 @@ class Flags : public virtual flags::FlagsBase
 public:
   Flags()
   {
-    add(&master,
+    add(&Flags::master,
         "master",
         "Master to connect to.");
 
-    add(&task_memory_usage_limit,
+    add(&Flags::task_memory_usage_limit,
         "task_memory_usage_limit",
         None(),
         "Maximum size, in bytes, of the task's memory usage.\n"
@@ -83,33 +83,33 @@ public:
           return None();
         });
 
-    add(&task_memory,
+    add(&Flags::task_memory,
         "task_memory",
         "How much memory the framework will require per task.\n"
         "If not specified, the task(s) will use all available memory in\n"
         "applicable offers.");
 
-    add(&build_dir,
+    add(&Flags::build_dir,
         "build_dir",
         "The build directory of Mesos. If set, the framework will assume\n"
         "that the executor, framework, and agent(s) all live on the same\n"
         "machine.");
 
-    add(&executor_uri,
+    add(&Flags::executor_uri,
         "executor_uri",
         "URI the fetcher should use to get the executor.");
 
-    add(&executor_command,
+    add(&Flags::executor_command,
         "executor_command",
         "The command that should be used to start the executor.\n"
         "This will override the value set by `--build_dir`.");
 
-    add(&checkpoint,
+    add(&Flags::checkpoint,
         "checkpoint",
         "Whether this framework should be checkpointed.\n",
         false);
 
-    add(&long_running,
+    add(&Flags::long_running,
         "long_running",
         "Whether this framework should launch tasks repeatedly\n"
         "or exit after finishing a single task.",

http://git-wip-us.apache.org/repos/asf/mesos/blob/f441eb9a/src/examples/disk_full_framework.cpp
----------------------------------------------------------------------
diff --git a/src/examples/disk_full_framework.cpp 
b/src/examples/disk_full_framework.cpp
index 78f13d3..e13d4c8 100644
--- a/src/examples/disk_full_framework.cpp
+++ b/src/examples/disk_full_framework.cpp
@@ -62,17 +62,17 @@ class Flags : public virtual flags::FlagsBase
 public:
   Flags()
   {
-    add(&master,
+    add(&Flags::master,
         "master",
         "Master to connect to.");
 
-    add(&run_once,
+    add(&Flags::run_once,
         "run_once",
         "Whether this framework should exit after running a single task.\n"
         "By default framework will keep running tasks forever.\n",
         false);
 
-    add(&pre_sleep_duration,
+    add(&Flags::pre_sleep_duration,
         "pre_sleep_duration",
         "Duration of sleep before the task starts to consume the disk. The\n"
         "purpose of this is to allow an operator to control the frequency at\n"
@@ -81,7 +81,7 @@ public:
         "disk usage.\n",
         Seconds(600));
 
-    add(&post_sleep_duration,
+    add(&Flags::post_sleep_duration,
         "post_sleep_duration",
         "Duration of sleep after the task consumed the disk. The purpose\n"
         "of this is to allow an operator to control how long it takes for\n"
@@ -90,7 +90,7 @@ public:
         "duration.\n",
         Seconds(600));
 
-    add(&disk_use_limit,
+    add(&Flags::disk_use_limit,
         "disk_use_limit",
         "The amount of disk (rounded to the nearest KB) the task should\n"
         "consume. The task requests 5MB of disk, so if the limit is set\n"

http://git-wip-us.apache.org/repos/asf/mesos/blob/f441eb9a/src/examples/dynamic_reservation_framework.cpp
----------------------------------------------------------------------
diff --git a/src/examples/dynamic_reservation_framework.cpp 
b/src/examples/dynamic_reservation_framework.cpp
index c9a6863..4d3db96 100644
--- a/src/examples/dynamic_reservation_framework.cpp
+++ b/src/examples/dynamic_reservation_framework.cpp
@@ -323,7 +323,7 @@ class Flags : public virtual flags::FlagsBase
 public:
   Flags()
   {
-    add(&master,
+    add(&Flags::master,
         "master",
         "The master to connect to. May be one of:\n"
         "  master@addr:port (The PID of the master)\n"
@@ -331,16 +331,16 @@ public:
         "  zk://username:password@host1:port1,host2:port2,.../path\n"
         "  file://path/to/file (where file contains one of the above)");
 
-    add(&role,
+    add(&Flags::role,
         "role",
         "Role to use when registering");
 
-    add(&principal,
+    add(&Flags::principal,
         "principal",
         "The principal used to identify this framework",
         "test");
 
-    add(&command,
+    add(&Flags::command,
         "command",
         "The command to run for each task.",
         "echo hello");

http://git-wip-us.apache.org/repos/asf/mesos/blob/f441eb9a/src/examples/load_generator_framework.cpp
----------------------------------------------------------------------
diff --git a/src/examples/load_generator_framework.cpp 
b/src/examples/load_generator_framework.cpp
index 81c8c23..99fa760 100644
--- a/src/examples/load_generator_framework.cpp
+++ b/src/examples/load_generator_framework.cpp
@@ -229,7 +229,7 @@ class Flags : public virtual mesos::internal::logging::Flags
 public:
   Flags()
   {
-    add(&master,
+    add(&Flags::master,
         "master",
         "Required. The master to connect to. May be one of:\n"
         "  master@addr:port (The PID of the master)\n"

http://git-wip-us.apache.org/repos/asf/mesos/blob/f441eb9a/src/examples/long_lived_framework.cpp
----------------------------------------------------------------------
diff --git a/src/examples/long_lived_framework.cpp 
b/src/examples/long_lived_framework.cpp
index bfb253e..03c26d9 100644
--- a/src/examples/long_lived_framework.cpp
+++ b/src/examples/long_lived_framework.cpp
@@ -465,7 +465,7 @@ class Flags : public virtual flags::FlagsBase
 public:
   Flags()
   {
-    add(&master,
+    add(&Flags::master,
         "master",
         "Master to connect to.",
         [](const Option<string>& value) -> Option<Error> {
@@ -476,31 +476,31 @@ public:
           return None();
         });
 
-    add(&build_dir,
+    add(&Flags::build_dir,
         "build_dir",
         "The build directory of Mesos. If set, the framework will assume\n"
         "that the executor, framework, and agent(s) all live on the same\n"
         "machine.");
 
-    add(&executor_uri,
+    add(&Flags::executor_uri,
         "executor_uri",
         "URI the fetcher should use to get the executor.");
 
-    add(&executor_command,
+    add(&Flags::executor_command,
         "executor_command",
         "The command that should be used to start the executor.\n"
         "This will override the value set by `--build_dir`.");
 
-    add(&checkpoint,
+    add(&Flags::checkpoint,
         "checkpoint",
         "Whether this framework should be checkpointed.",
         false);
 
-    add(&principal,
+    add(&Flags::principal,
         "principal",
         "The principal to use for framework authentication.");
 
-    add(&secret,
+    add(&Flags::secret,
         "secret",
         "The secret to use for framework authentication.");
   }

http://git-wip-us.apache.org/repos/asf/mesos/blob/f441eb9a/src/examples/no_executor_framework.cpp
----------------------------------------------------------------------
diff --git a/src/examples/no_executor_framework.cpp 
b/src/examples/no_executor_framework.cpp
index 4668542..e82ae9a 100644
--- a/src/examples/no_executor_framework.cpp
+++ b/src/examples/no_executor_framework.cpp
@@ -236,7 +236,7 @@ class Flags : public virtual logging::Flags
 public:
   Flags()
   {
-    add(&master,
+    add(&Flags::master,
         "master",
         "The master to connect to. May be one of:\n"
         "  master@addr:port (The PID of the master)\n"
@@ -244,27 +244,27 @@ public:
         "  zk://username:password@host1:port1,host2:port2,.../path\n"
         "  file://path/to/file (where file contains one of the above)");
 
-    add(&checkpoint,
+    add(&Flags::checkpoint,
         "checkpoint",
         "Whether to enable checkpointing (true by default).",
         true);
 
-    add(&principal,
+    add(&Flags::principal,
         "principal",
         "To enable authentication, both --principal and --secret\n"
         "must be supplied.");
 
-    add(&secret,
+    add(&Flags::secret,
         "secret",
         "To enable authentication, both --principal and --secret\n"
         "must be supplied.");
 
-    add(&command,
+    add(&Flags::command,
         "command",
         "The command to run for each task.",
         "echo hello");
 
-    add(&task_resources,
+    add(&Flags::task_resources,
         "task_resources",
         "The resources that the task uses.",
         "cpus:0.1;mem:32;disk:32");
@@ -272,11 +272,11 @@ public:
     // TODO(bmahler): We need to take a separate flag for
     // revocable resources because there is no support yet
     // for specifying revocable resources in a resource string.
-    add(&task_revocable_resources,
+    add(&Flags::task_revocable_resources,
         "task_revocable_resources",
         "The revocable resources that the task uses.");
 
-    add(&num_tasks,
+    add(&Flags::num_tasks,
         "num_tasks",
         "Optionally, the number of tasks to run to completion before 
exiting.\n"
         "If unset, as many tasks as possible will be launched.");

http://git-wip-us.apache.org/repos/asf/mesos/blob/f441eb9a/src/examples/persistent_volume_framework.cpp
----------------------------------------------------------------------
diff --git a/src/examples/persistent_volume_framework.cpp 
b/src/examples/persistent_volume_framework.cpp
index a2a6944..9d45bb4 100644
--- a/src/examples/persistent_volume_framework.cpp
+++ b/src/examples/persistent_volume_framework.cpp
@@ -381,7 +381,7 @@ class Flags : public virtual logging::Flags
 public:
   Flags()
   {
-    add(&master,
+    add(&Flags::master,
         "master",
         "The master to connect to. May be one of:\n"
         "  master@addr:port (The PID of the master)\n"
@@ -389,22 +389,22 @@ public:
         "  zk://username:password@host1:port1,host2:port2,.../path\n"
         "  file://path/to/file (where file contains one of the above)");
 
-    add(&role,
+    add(&Flags::role,
         "role",
         "Role to use when registering",
         "test");
 
-    add(&principal,
+    add(&Flags::principal,
         "principal",
         "The principal used to identify this framework",
         "test");
 
-    add(&num_shards,
+    add(&Flags::num_shards,
         "num_shards",
         "The number of shards the framework will run.",
         3);
 
-    add(&tasks_per_shard,
+    add(&Flags::tasks_per_shard,
         "tasks_per_shard",
         "The number of tasks should be launched per shard.",
         2);

http://git-wip-us.apache.org/repos/asf/mesos/blob/f441eb9a/src/examples/test_framework.cpp
----------------------------------------------------------------------
diff --git a/src/examples/test_framework.cpp b/src/examples/test_framework.cpp
index a910640..753b4de 100644
--- a/src/examples/test_framework.cpp
+++ b/src/examples/test_framework.cpp
@@ -191,6 +191,20 @@ void usage(const char* argv0, const flags::FlagsBase& 
flags)
 }
 
 
+class Flags : public mesos::internal::logging::Flags
+{
+public:
+  Flags()
+  {
+    add(&Flags::role, "role", "Role to use when registering", "*");
+    add(&Flags::master, "master", "ip:port of master to connect");
+  }
+
+  string role;
+  Option<string> master;
+};
+
+
 int main(int argc, char** argv)
 {
   // Find this executable's directory to locate executor.
@@ -204,18 +218,7 @@ int main(int argc, char** argv)
         "test-executor");
   }
 
-  mesos::internal::logging::Flags flags;
-
-  string role;
-  flags.add(&role,
-            "role",
-            "Role to use when registering",
-            "*");
-
-  Option<string> master;
-  flags.add(&master,
-            "master",
-            "ip:port of master to connect");
+  Flags flags;
 
   Try<flags::Warnings> load = flags.load(None(), argc, argv);
 
@@ -223,7 +226,7 @@ int main(int argc, char** argv)
     cerr << load.error() << endl;
     usage(argv[0], flags);
     exit(EXIT_FAILURE);
-  } else if (master.isNone()) {
+  } else if (flags.master.isNone()) {
     cerr << "Missing --master" << endl;
     usage(argv[0], flags);
     exit(EXIT_FAILURE);
@@ -245,7 +248,7 @@ int main(int argc, char** argv)
   FrameworkInfo framework;
   framework.set_user(""); // Have Mesos fill in the current user.
   framework.set_name("Test Framework (C++)");
-  framework.set_role(role);
+  framework.set_role(flags.role);
 
   value = os::getenv("MESOS_CHECKPOINT");
   if (value.isSome()) {
@@ -261,7 +264,7 @@ int main(int argc, char** argv)
   }
 
   MesosSchedulerDriver* driver;
-  TestScheduler scheduler(implicitAcknowledgements, executor, role);
+  TestScheduler scheduler(implicitAcknowledgements, executor, flags.role);
 
   if (os::getenv("MESOS_AUTHENTICATE_FRAMEWORKS").isSome()) {
     cout << "Enabling authentication for the framework" << endl;
@@ -288,7 +291,7 @@ int main(int argc, char** argv)
     driver = new MesosSchedulerDriver(
         &scheduler,
         framework,
-        master.get(),
+        flags.master.get(),
         implicitAcknowledgements,
         credential);
   } else {
@@ -297,7 +300,7 @@ int main(int argc, char** argv)
     driver = new MesosSchedulerDriver(
         &scheduler,
         framework,
-        master.get(),
+        flags.master.get(),
         implicitAcknowledgements);
   }
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/f441eb9a/src/examples/test_http_framework.cpp
----------------------------------------------------------------------
diff --git a/src/examples/test_http_framework.cpp 
b/src/examples/test_http_framework.cpp
index d6e248c..579a0c5 100644
--- a/src/examples/test_http_framework.cpp
+++ b/src/examples/test_http_framework.cpp
@@ -377,6 +377,20 @@ void usage(const char* argv0, const flags::FlagsBase& 
flags)
 }
 
 
+class Flags : public mesos::internal::logging::Flags
+{
+public:
+  Flags()
+  {
+    add(&Flags::role, "role", "Role to use when registering", "*");
+    add(&Flags::master, "master", "ip:port of master to connect");
+  }
+
+  string role;
+  Option<string> master;
+};
+
+
 int main(int argc, char** argv)
 {
   // Find this executable's directory to locate executor.
@@ -390,18 +404,7 @@ int main(int argc, char** argv)
         "test-http-executor");
   }
 
-  mesos::internal::logging::Flags flags;
-
-  string role;
-  flags.add(&role,
-            "role",
-            "Role to use when registering",
-            "*");
-
-  Option<string> master;
-  flags.add(&master,
-            "master",
-            "ip:port of master to connect");
+  Flags flags;
 
   Try<flags::Warnings> load = flags.load(None(), argc, argv);
 
@@ -409,7 +412,7 @@ int main(int argc, char** argv)
     cerr << load.error() << endl;
     usage(argv[0], flags);
     EXIT(EXIT_FAILURE);
-  } else if (master.isNone()) {
+  } else if (flags.master.isNone()) {
     cerr << "Missing --master" << endl;
     usage(argv[0], flags);
     EXIT(EXIT_FAILURE);
@@ -425,7 +428,7 @@ int main(int argc, char** argv)
 
   FrameworkInfo framework;
   framework.set_name("Event Call Scheduler using libprocess (C++)");
-  framework.set_role(role);
+  framework.set_role(flags.role);
 
   const Result<string> user = os::user();
 
@@ -453,7 +456,7 @@ int main(int argc, char** argv)
   framework.set_principal(value.get());
 
   process::Owned<HTTPScheduler> scheduler(
-      new HTTPScheduler(framework, executor, master.get()));
+      new HTTPScheduler(framework, executor, flags.master.get()));
 
   process::spawn(scheduler.get());
   process::wait(scheduler.get());

http://git-wip-us.apache.org/repos/asf/mesos/blob/f441eb9a/src/launcher/executor.cpp
----------------------------------------------------------------------
diff --git a/src/launcher/executor.cpp b/src/launcher/executor.cpp
index dec1e07..0544121 100644
--- a/src/launcher/executor.cpp
+++ b/src/launcher/executor.cpp
@@ -821,35 +821,35 @@ class Flags : public virtual flags::FlagsBase
 public:
   Flags()
   {
-    add(&rootfs,
+    add(&Flags::rootfs,
         "rootfs",
         "The path to the root filesystem for the task");
 
     // The following flags are only applicable when a rootfs is
     // provisioned for this command.
-    add(&sandbox_directory,
+    add(&Flags::sandbox_directory,
         "sandbox_directory",
         "The absolute path for the directory in the container where the\n"
         "sandbox is mapped to");
 
-    add(&working_directory,
+    add(&Flags::working_directory,
         "working_directory",
         "The working directory for the task in the container.");
 
-    add(&user,
+    add(&Flags::user,
         "user",
         "The user that the task should be running as.");
 
-    add(&task_command,
+    add(&Flags::task_command,
         "task_command",
         "If specified, this is the overrided command for launching the\n"
         "task (instead of the command from TaskInfo).");
 
-    add(&capabilities,
+    add(&Flags::capabilities,
         "capabilities",
         "Capabilities the command can use.");
 
-    add(&launcher_dir,
+    add(&Flags::launcher_dir,
         "launcher_dir",
         "Directory path of Mesos binaries.",
         PKGLIBEXECDIR);

http://git-wip-us.apache.org/repos/asf/mesos/blob/f441eb9a/src/local/main.cpp
----------------------------------------------------------------------
diff --git a/src/local/main.cpp b/src/local/main.cpp
index 578b65e..f0d7e8c 100644
--- a/src/local/main.cpp
+++ b/src/local/main.cpp
@@ -45,6 +45,24 @@ using std::endl;
 using std::string;
 
 
+class Flags : public virtual local::Flags
+{
+public:
+  Flags()
+  {
+    add(&Flags::port, "port", "Port to listen on", 5050);
+    add(&Flags::ip, "ip", "IP address to listen on");
+  }
+
+  // The following flags are executable specific (e.g., since we only
+  // have one instance of libprocess per execution, we only want to
+  // advertise the port and ip option once, here).
+
+  uint16_t port;
+  Option<string> ip;
+};
+
+
 int main(int argc, char **argv)
 {
   GOOGLE_PROTOBUF_VERIFY_VERSION;
@@ -53,21 +71,12 @@ int main(int argc, char **argv)
   // order to pass those flags on to the master. Alternatively, add a
   // way to load flags and ignore unknowns in order to load
   // master::flags, then slave::Flags, then local::Flags.
-  local::Flags flags;
+  Flags flags;
 
   flags.setUsageMessage(
       "Usage: " + Path(argv[0]).basename() + " [...]\n\n" +
       "Launches an in-memory cluster within a single process.");
 
-  // The following flags are executable specific (e.g., since we only
-  // have one instance of libprocess per execution, we only want to
-  // advertise the port and ip option once, here).
-  uint16_t port;
-  flags.add(&port, "port", "Port to listen on", 5050);
-
-  Option<string> ip;
-  flags.add(&ip, "ip", "IP address to listen on");
-
   // Load flags from environment and command line but allow unknown
   // flags since we might have some master/slave flags as well.
   Try<flags::Warnings> load = flags.load("MESOS_", argc, argv, true);
@@ -83,10 +92,10 @@ int main(int argc, char **argv)
   }
 
   // Initialize libprocess.
-  os::setenv("LIBPROCESS_PORT", stringify(port));
+  os::setenv("LIBPROCESS_PORT", stringify(flags.port));
 
-  if (ip.isSome()) {
-    os::setenv("LIBPROCESS_IP", ip.get());
+  if (flags.ip.isSome()) {
+    os::setenv("LIBPROCESS_IP", flags.ip.get());
   }
 
   process::initialize("master");

http://git-wip-us.apache.org/repos/asf/mesos/blob/f441eb9a/src/master/main.cpp
----------------------------------------------------------------------
diff --git a/src/master/main.cpp b/src/master/main.cpp
index 9d2fd92..2d2dfb7 100644
--- a/src/master/main.cpp
+++ b/src/master/main.cpp
@@ -120,6 +120,62 @@ using std::string;
 using std::vector;
 
 
+class Flags : public virtual master::Flags
+{
+public:
+  Flags()
+  {
+    add(&Flags::ip,
+        "ip",
+        "IP address to listen on. This cannot be used in conjunction\n"
+        "with `--ip_discovery_command`.");
+
+    add(&Flags::port, "port", "Port to listen on.", MasterInfo().port());
+
+    add(&Flags::advertise_ip,
+        "advertise_ip",
+        "IP address advertised to reach this Mesos master.\n"
+        "The master does not bind using this IP address.\n"
+        "However, this IP address may be used to access this master.");
+
+    add(&Flags::advertise_port,
+        "advertise_port",
+        "Port advertised to reach Mesos master (along with\n"
+        "`advertise_ip`). The master does not bind to this port.\n"
+        "However, this port (along with `advertise_ip`) may be used to\n"
+        "access this master.");
+
+    add(&Flags::zk,
+        "zk",
+        "ZooKeeper URL (used for leader election amongst masters)\n"
+        "May be one of:\n"
+        "  `zk://host1:port1,host2:port2,.../path`\n"
+        "  `zk://username:password@host1:port1,host2:port2,.../path`\n"
+        "  `file:///path/to/file` (where file contains one of the above)\n"
+        "NOTE: Not required if master is run in standalone mode (non-HA).");
+
+    add(&Flags::ip_discovery_command,
+        "ip_discovery_command",
+        "Optional IP discovery binary: if set, it is expected to emit\n"
+        "the IP address which the master will try to bind to.\n"
+        "Cannot be used in conjunction with `--ip`.");
+    }
+
+    // The following flags are executable specific (e.g., since we only
+    // have one instance of libprocess per execution, we only want to
+    // advertise the IP and port option once, here).
+
+    Option<string> ip;
+    uint16_t port;
+    Option<string> advertise_ip;
+    Option<string> advertise_port;
+    Option<string> zk;
+
+    // Optional IP discover script that will set the Master IP.
+    // If set, its output is expected to be a valid parseable IP string.
+    Option<string> ip_discovery_command;
+};
+
 
 int main(int argc, char** argv)
 {
@@ -149,56 +205,7 @@ int main(int argc, char** argv)
 
   GOOGLE_PROTOBUF_VERIFY_VERSION;
 
-  master::Flags flags;
-
-  // The following flags are executable specific (e.g., since we only
-  // have one instance of libprocess per execution, we only want to
-  // advertise the IP and port option once, here).
-  Option<string> ip;
-  flags.add(&ip,
-            "ip",
-            "IP address to listen on. This cannot be used in conjunction\n"
-            "with `--ip_discovery_command`.");
-
-  uint16_t port;
-  flags.add(&port,
-            "port",
-            "Port to listen on.",
-            MasterInfo().port());
-
-  Option<string> advertise_ip;
-  flags.add(&advertise_ip,
-            "advertise_ip",
-            "IP address advertised to reach this Mesos master.\n"
-            "The master does not bind using this IP address.\n"
-            "However, this IP address may be used to access this master.");
-
-  Option<string> advertise_port;
-  flags.add(&advertise_port,
-            "advertise_port",
-            "Port advertised to reach Mesos master (along with\n"
-            "`advertise_ip`). The master does not bind to this port.\n"
-            "However, this port (along with `advertise_ip`) may be used to\n"
-            "access this master.");
-
-  Option<string> zk;
-  flags.add(&zk,
-            "zk",
-            "ZooKeeper URL (used for leader election amongst masters)\n"
-            "May be one of:\n"
-            "  `zk://host1:port1,host2:port2,.../path`\n"
-            "  `zk://username:password@host1:port1,host2:port2,.../path`\n"
-            "  `file:///path/to/file` (where file contains one of the above)\n"
-            "NOTE: Not required if master is run in standalone mode 
(non-HA).");
-
-  // Optional IP discover script that will set the Master IP.
-  // If set, its output is expected to be a valid parseable IP string.
-  Option<string> ip_discovery_command;
-  flags.add(&ip_discovery_command,
-            "ip_discovery_command",
-            "Optional IP discovery binary: if set, it is expected to emit\n"
-            "the IP address which the master will try to bind to.\n"
-            "Cannot be used in conjunction with `--ip`.");
+  ::Flags flags;
 
   Try<flags::Warnings> load = flags.load("MESOS_", argc, argv);
 
@@ -217,34 +224,34 @@ int main(int argc, char** argv)
     return EXIT_FAILURE;
   }
 
-  if (ip_discovery_command.isSome() && ip.isSome()) {
+  if (flags.ip_discovery_command.isSome() && flags.ip.isSome()) {
     EXIT(EXIT_FAILURE) << flags.usage(
         "Only one of `--ip` or `--ip_discovery_command` should be specified");
   }
 
-  if (ip_discovery_command.isSome()) {
-    Try<string> ipAddress = os::shell(ip_discovery_command.get());
+  if (flags.ip_discovery_command.isSome()) {
+    Try<string> ipAddress = os::shell(flags.ip_discovery_command.get());
 
     if (ipAddress.isError()) {
       EXIT(EXIT_FAILURE) << ipAddress.error();
     }
 
     os::setenv("LIBPROCESS_IP", strings::trim(ipAddress.get()));
-  } else if (ip.isSome()) {
-    os::setenv("LIBPROCESS_IP", ip.get());
+  } else if (flags.ip.isSome()) {
+    os::setenv("LIBPROCESS_IP", flags.ip.get());
   }
 
-  os::setenv("LIBPROCESS_PORT", stringify(port));
+  os::setenv("LIBPROCESS_PORT", stringify(flags.port));
 
-  if (advertise_ip.isSome()) {
-    os::setenv("LIBPROCESS_ADVERTISE_IP", advertise_ip.get());
+  if (flags.advertise_ip.isSome()) {
+    os::setenv("LIBPROCESS_ADVERTISE_IP", flags.advertise_ip.get());
   }
 
-  if (advertise_port.isSome()) {
-    os::setenv("LIBPROCESS_ADVERTISE_PORT", advertise_port.get());
+  if (flags.advertise_port.isSome()) {
+    os::setenv("LIBPROCESS_ADVERTISE_PORT", flags.advertise_port.get());
   }
 
-  if (zk.isNone()) {
+  if (flags.zk.isNone()) {
     if (flags.master_contender.isSome() ^ flags.master_detector.isSome()) {
       EXIT(EXIT_FAILURE)
         << flags.usage("Both --master_contender and --master_detector should "
@@ -390,7 +397,7 @@ int main(int argc, char** argv)
         << "': " << mkdir.error();
     }
 
-    if (zk.isSome()) {
+    if (flags.zk.isSome()) {
       // Use replicated log with ZooKeeper.
       if (flags.quorum.isNone()) {
         EXIT(EXIT_FAILURE)
@@ -398,7 +405,7 @@ int main(int argc, char** argv)
           << " registry when using ZooKeeper";
       }
 
-      Try<zookeeper::URL> url = zookeeper::URL::parse(zk.get());
+      Try<zookeeper::URL> url = zookeeper::URL::parse(flags.zk.get());
       if (url.isError()) {
         EXIT(EXIT_FAILURE) << "Error parsing ZooKeeper URL: " << url.error();
       }
@@ -439,7 +446,7 @@ int main(int argc, char** argv)
   MasterDetector* detector;
 
   Try<MasterContender*> contender_ = MasterContender::create(
-      zk, flags.master_contender);
+      flags.zk, flags.master_contender);
 
   if (contender_.isError()) {
     EXIT(EXIT_FAILURE)
@@ -449,7 +456,7 @@ int main(int argc, char** argv)
   contender = contender_.get();
 
   Try<MasterDetector*> detector_ = MasterDetector::create(
-      zk, flags.master_detector);
+      flags.zk, flags.master_detector);
 
   if (detector_.isError()) {
     EXIT(EXIT_FAILURE)
@@ -551,7 +558,7 @@ int main(int argc, char** argv)
       slaveRemovalLimiter,
       flags);
 
-  if (zk.isNone() && flags.master_detector.isNone()) {
+  if (flags.zk.isNone() && flags.master_detector.isNone()) {
     // It means we are using the standalone detector so we need to
     // appoint this Master as the leader.
     dynamic_cast<StandaloneMasterDetector*>(detector)->appoint(master->info());

http://git-wip-us.apache.org/repos/asf/mesos/blob/f441eb9a/src/slave/container_loggers/lib_logrotate.hpp
----------------------------------------------------------------------
diff --git a/src/slave/container_loggers/lib_logrotate.hpp 
b/src/slave/container_loggers/lib_logrotate.hpp
index f91db3e..28fdf3b 100644
--- a/src/slave/container_loggers/lib_logrotate.hpp
+++ b/src/slave/container_loggers/lib_logrotate.hpp
@@ -47,14 +47,14 @@ struct LoggerFlags : public virtual flags::FlagsBase
 {
   LoggerFlags()
   {
-    add(&max_stdout_size,
+    add(&LoggerFlags::max_stdout_size,
         "max_stdout_size",
         "Maximum size, in bytes, of a single stdout log file.\n"
         "Defaults to 10 MB.  Must be at least 1 (memory) page.",
         Megabytes(10),
         &LoggerFlags::validateSize);
 
-    add(&logrotate_stdout_options,
+    add(&LoggerFlags::logrotate_stdout_options,
         "logrotate_stdout_options",
         "Additional config options to pass into 'logrotate' for stdout.\n"
         "This string will be inserted into a 'logrotate' configuration file.\n"
@@ -65,14 +65,14 @@ struct LoggerFlags : public virtual flags::FlagsBase
         "  }\n"
         "NOTE: The 'size' option will be overriden by this module.");
 
-    add(&max_stderr_size,
+    add(&LoggerFlags::max_stderr_size,
         "max_stderr_size",
         "Maximum size, in bytes, of a single stderr log file.\n"
         "Defaults to 10 MB.  Must be at least 1 (memory) page.",
         Megabytes(10),
         &LoggerFlags::validateSize);
 
-    add(&logrotate_stderr_options,
+    add(&LoggerFlags::logrotate_stderr_options,
         "logrotate_stderr_options",
         "Additional config options to pass into 'logrotate' for stderr.\n"
         "This string will be inserted into a 'logrotate' configuration file.\n"
@@ -107,7 +107,7 @@ struct Flags : public virtual LoggerFlags
 {
   Flags()
   {
-    add(&environment_variable_prefix,
+    add(&Flags::environment_variable_prefix,
         "environment_variable_prefix",
         "Prefix for environment variables meant to modify the behavior of\n"
         "the logrotate logger for the specific executor being launched.\n"
@@ -121,7 +121,7 @@ struct Flags : public virtual LoggerFlags
         "via module parameters.",
         "CONTAINER_LOGGER_");
 
-    add(&launcher_dir,
+    add(&Flags::launcher_dir,
         "launcher_dir",
         "Directory path of Mesos binaries.  The logrotate container logger\n"
         "will find the '" + mesos::internal::logger::rotate::NAME + "'\n"
@@ -138,7 +138,7 @@ struct Flags : public virtual LoggerFlags
           return None();
         });
 
-    add(&logrotate_path,
+    add(&Flags::logrotate_path,
         "logrotate_path",
         "If specified, the logrotate container logger will use the specified\n"
         "'logrotate' instead of the system's 'logrotate'.",
@@ -157,7 +157,7 @@ struct Flags : public virtual LoggerFlags
           return None();
         });
 
-    add(&libprocess_num_worker_threads,
+    add(&Flags::libprocess_num_worker_threads,
         "libprocess_num_worker_threads",
         "Number of Libprocess worker threads.\n"
         "Defaults to 8.  Must be at least 1.",

http://git-wip-us.apache.org/repos/asf/mesos/blob/f441eb9a/src/slave/container_loggers/logrotate.hpp
----------------------------------------------------------------------
diff --git a/src/slave/container_loggers/logrotate.hpp 
b/src/slave/container_loggers/logrotate.hpp
index f906a16..d1db692 100644
--- a/src/slave/container_loggers/logrotate.hpp
+++ b/src/slave/container_loggers/logrotate.hpp
@@ -51,7 +51,7 @@ struct Flags : public virtual flags::FlagsBase
       "are supported.  See '--logrotate_options'.\n"
       "\n");
 
-    add(&max_size,
+    add(&Flags::max_size,
         "max_size",
         "Maximum size, in bytes, of a single log file.\n"
         "Defaults to 10 MB.  Must be at least 1 (memory) page.",
@@ -65,7 +65,7 @@ struct Flags : public virtual flags::FlagsBase
           return None();
         });
 
-    add(&logrotate_options,
+    add(&Flags::logrotate_options,
         "logrotate_options",
         "Additional config options to pass into 'logrotate'.\n"
         "This string will be inserted into a 'logrotate' configuration file.\n"
@@ -76,7 +76,7 @@ struct Flags : public virtual flags::FlagsBase
         "  }\n"
         "NOTE: The 'size' option will be overriden by this command.");
 
-    add(&log_filename,
+    add(&Flags::log_filename,
         "log_filename",
         "Absolute path to the leading log file.\n"
         "NOTE: This command will also create two files by appending\n"
@@ -94,7 +94,7 @@ struct Flags : public virtual flags::FlagsBase
           return None();
         });
 
-    add(&logrotate_path,
+    add(&Flags::logrotate_path,
         "logrotate_path",
         "If specified, this command will use the specified\n"
         "'logrotate' instead of the system's 'logrotate'.",

http://git-wip-us.apache.org/repos/asf/mesos/blob/f441eb9a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp 
b/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
index c87e671..939142e 100644
--- a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
+++ b/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
@@ -1578,27 +1578,27 @@ const char* NetworkCniIsolatorSetup::NAME = 
"network-cni-setup";
 
 NetworkCniIsolatorSetup::Flags::Flags()
 {
-  add(&pid, "pid", "PID of the container");
+  add(&Flags::pid, "pid", "PID of the container");
 
-  add(&hostname, "hostname", "Hostname of the container");
+  add(&Flags::hostname, "hostname", "Hostname of the container");
 
-  add(&rootfs,
+  add(&Flags::rootfs,
       "rootfs",
       "Path to rootfs for the container on the host-file system");
 
-  add(&etc_hosts_path,
+  add(&Flags::etc_hosts_path,
       "etc_hosts_path",
       "Path in the host file system for 'hosts' file");
 
-  add(&etc_hostname_path,
+  add(&Flags::etc_hostname_path,
       "etc_hostname_path",
       "Path in the host file system for 'hostname' file");
 
-  add(&etc_resolv_conf,
+  add(&Flags::etc_resolv_conf,
       "etc_resolv_conf",
       "Path in the host file system for 'resolv.conf'");
 
-  add(&bind_host_files,
+  add(&Flags::bind_host_files,
       "bind_host_files",
       "Bind mount the container's network files to the network files "
       "present on host filesystem",

http://git-wip-us.apache.org/repos/asf/mesos/blob/f441eb9a/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp 
b/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp
index 20fb6ab..48202fb 100644
--- a/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp
+++ b/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp
@@ -394,25 +394,25 @@ const char* PortMappingUpdate::NAME = "update";
 
 PortMappingUpdate::Flags::Flags()
 {
-  add(&eth0_name,
+  add(&Flags::eth0_name,
       "eth0_name",
       "The name of the public network interface (e.g., eth0)");
 
-  add(&lo_name,
+  add(&Flags::lo_name,
       "lo_name",
       "The name of the loopback network interface (e.g., lo)");
 
-  add(&pid,
+  add(&Flags::pid,
       "pid",
       "The pid of the process whose namespaces we will enter");
 
-  add(&ports_to_add,
+  add(&Flags::ports_to_add,
       "ports_to_add",
       "A collection of port ranges (formatted as a JSON object)\n"
       "for which to add IP filters. E.g.,\n"
       "--ports_to_add={\"range\":[{\"begin\":4,\"end\":8}]}");
 
-  add(&ports_to_remove,
+  add(&Flags::ports_to_remove,
       "ports_to_remove",
       "A collection of port ranges (formatted as a JSON object)\n"
       "for which to remove IP filters. E.g.,\n"
@@ -658,26 +658,26 @@ const char* PortMappingStatistics::NAME = "statistics";
 
 PortMappingStatistics::Flags::Flags()
 {
-  add(&eth0_name,
+  add(&Flags::eth0_name,
       "eth0_name",
       "The name of the public network interface (e.g., eth0)");
 
-  add(&pid,
+  add(&Flags::pid,
       "pid",
       "The pid of the process whose namespaces we will enter");
 
-  add(&enable_socket_statistics_summary,
+  add(&Flags::enable_socket_statistics_summary,
       "enable_socket_statistics_summary",
       "Whether to collect socket statistics summary for this container\n",
       false);
 
-  add(&enable_socket_statistics_details,
+  add(&Flags::enable_socket_statistics_details,
       "enable_socket_statistics_details",
       "Whether to collect socket statistics details (e.g., TCP RTT)\n"
       "for this container.",
       false);
 
-  add(&enable_snmp_statistics,
+  add(&Flags::enable_snmp_statistics,
       "enable_snmp_statistics",
       "Whether to collect SNMP statistics details (e.g., TCPRetransSegs)\n"
       "for this container.",

http://git-wip-us.apache.org/repos/asf/mesos/blob/f441eb9a/src/slave/containerizer/mesos/launch.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/launch.cpp 
b/src/slave/containerizer/mesos/launch.cpp
index 8a30ff8..4a41aaf 100644
--- a/src/slave/containerizer/mesos/launch.cpp
+++ b/src/slave/containerizer/mesos/launch.cpp
@@ -67,35 +67,35 @@ const string MesosContainerizerLaunch::NAME = "launch";
 
 MesosContainerizerLaunch::Flags::Flags()
 {
-  add(&command,
+  add(&Flags::command,
       "command",
       "The command to execute.");
 
-  add(&environment,
+  add(&Flags::environment,
       "environment",
       "The environment variables for the command.");
 
-  add(&working_directory,
+  add(&Flags::working_directory,
       "working_directory",
       "The working directory for the command. It has to be an absolute path \n"
       "w.r.t. the root filesystem used for the command.");
 
 #ifndef __WINDOWS__
-  add(&runtime_directory,
+  add(&Flags::runtime_directory,
       "runtime_directory",
       "The runtime directory for the container (used for checkpointing)");
 
-  add(&rootfs,
+  add(&Flags::rootfs,
       "rootfs",
       "Absolute path to the container root filesystem. The command will be \n"
       "interpreted relative to this path");
 
-  add(&user,
+  add(&Flags::user,
       "user",
       "The user to change to.");
 #endif // __WINDOWS__
 
-  add(&pipe_read,
+  add(&Flags::pipe_read,
       "pipe_read",
       "The read end of the control pipe. This is a file descriptor \n"
       "on Posix, or a handle on Windows. It's caller's responsibility \n"
@@ -103,7 +103,7 @@ MesosContainerizerLaunch::Flags::Flags()
       "properly in the subprocess. It's used to synchronize with the \n"
       "parent process. If not specified, no synchronization will happen.");
 
-  add(&pipe_write,
+  add(&Flags::pipe_write,
       "pipe_write",
       "The write end of the control pipe. This is a file descriptor \n"
       "on Posix, or a handle on Windows. It's caller's responsibility \n"
@@ -111,17 +111,17 @@ MesosContainerizerLaunch::Flags::Flags()
       "properly in the subprocess. It's used to synchronize with the \n"
       "parent process. If not specified, no synchronization will happen.");
 
-  add(&pre_exec_commands,
+  add(&Flags::pre_exec_commands,
       "pre_exec_commands",
       "The additional preparation commands to execute before\n"
       "executing the command.");
 
 #ifdef __linux__
-  add(&capabilities,
+  add(&Flags::capabilities,
       "capabilities",
       "Capabilities the command can use.");
 
-  add(&unshare_namespace_mnt,
+  add(&Flags::unshare_namespace_mnt,
       "unshare_namespace_mnt",
       "Whether to launch the command in a new mount namespace.",
       false);

http://git-wip-us.apache.org/repos/asf/mesos/blob/f441eb9a/src/slave/containerizer/mesos/mount.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/mount.cpp 
b/src/slave/containerizer/mesos/mount.cpp
index 4b90666..73a4861 100644
--- a/src/slave/containerizer/mesos/mount.cpp
+++ b/src/slave/containerizer/mesos/mount.cpp
@@ -40,11 +40,11 @@ const string MesosContainerizerMount::MAKE_RSLAVE = 
"make-rslave";
 
 MesosContainerizerMount::Flags::Flags()
 {
-  add(&operation,
+  add(&Flags::operation,
       "operation",
       "The mount operation to apply.");
 
-  add(&path,
+  add(&Flags::path,
       "path",
       "The path to apply mount operation to.");
 }

http://git-wip-us.apache.org/repos/asf/mesos/blob/f441eb9a/src/slave/main.cpp
----------------------------------------------------------------------
diff --git a/src/slave/main.cpp b/src/slave/main.cpp
index 219914d..8010f8e 100644
--- a/src/slave/main.cpp
+++ b/src/slave/main.cpp
@@ -94,6 +94,63 @@ using std::string;
 using std::vector;
 
 
+class Flags : public slave::Flags
+{
+public:
+  Flags()
+  {
+    add(&Flags::ip,
+        "ip",
+        "IP address to listen on. This cannot be used in conjunction\n"
+        "with `--ip_discovery_command`.");
+
+    add(&Flags::port, "port", "Port to listen on.", SlaveInfo().port());
+
+    add(&Flags::advertise_ip,
+        "advertise_ip",
+        "IP address advertised to reach this Mesos slave.\n"
+        "The slave does not bind to this IP address.\n"
+        "However, this IP address may be used to access this slave.");
+
+    add(&Flags::advertise_port,
+        "advertise_port",
+        "Port advertised to reach this Mesos slave (along with\n"
+        "`advertise_ip`). The slave does not bind to this port.\n"
+        "However, this port (along with `advertise_ip`) may be used to\n"
+        "access this slave.");
+
+    add(&Flags::master,
+        "master",
+        "May be one of:\n"
+        "  `host:port`\n"
+        "  `zk://host1:port1,host2:port2,.../path`\n"
+        "  `zk://username:password@host1:port1,host2:port2,.../path`\n"
+        "  `file:///path/to/file` (where file contains one of the above)");
+
+
+    add(&Flags::ip_discovery_command,
+        "ip_discovery_command",
+        "Optional IP discovery binary: if set, it is expected to emit\n"
+        "the IP address which the slave will try to bind to.\n"
+        "Cannot be used in conjunction with `--ip`.");
+  }
+
+  // The following flags are executable specific (e.g., since we only
+  // have one instance of libprocess per execution, we only want to
+  // advertise the IP and port option once, here).
+
+  Option<string> ip;
+  uint16_t port;
+  Option<string> advertise_ip;
+  Option<string> advertise_port;
+  Option<string> master;
+
+  // Optional IP discover script that will set the slave's IP.
+  // If set, its output is expected to be a valid parseable IP string.
+  Option<string> ip_discovery_command;
+};
+
+
 int main(int argc, char** argv)
 {
   // The order of initialization is as follows:
@@ -129,56 +186,7 @@ int main(int argc, char** argv)
 
   GOOGLE_PROTOBUF_VERIFY_VERSION;
 
-  slave::Flags flags;
-
-  // The following flags are executable specific (e.g., since we only
-  // have one instance of libprocess per execution, we only want to
-  // advertise the IP and port option once, here).
-  Option<string> ip;
-  flags.add(&ip,
-            "ip",
-            "IP address to listen on. This cannot be used in conjunction\n"
-            "with `--ip_discovery_command`.");
-
-  uint16_t port;
-  flags.add(&port,
-            "port",
-            "Port to listen on.",
-            SlaveInfo().port());
-
-  Option<string> advertise_ip;
-  flags.add(&advertise_ip,
-            "advertise_ip",
-            "IP address advertised to reach this Mesos agent.\n"
-            "The agent does not bind to this IP address.\n"
-            "However, this IP address may be used to access this agent.");
-
-  Option<string> advertise_port;
-  flags.add(&advertise_port,
-            "advertise_port",
-            "Port advertised to reach this Mesos agent (along with\n"
-            "`advertise_ip`). The agent does not bind to this port.\n"
-            "However, this port (along with `advertise_ip`) may be used to\n"
-            "access this agent.");
-
-  Option<string> master;
-  flags.add(&master,
-            "master",
-            "May be one of:\n"
-            "  `host:port`\n"
-            "  `zk://host1:port1,host2:port2,.../path`\n"
-            "  `zk://username:password@host1:port1,host2:port2,.../path`\n"
-            "  `file:///path/to/file` (where file contains one of the above)");
-
-
-  // Optional IP discover script that will set the slave's IP.
-  // If set, its output is expected to be a valid parseable IP string.
-  Option<string> ip_discovery_command;
-  flags.add(&ip_discovery_command,
-            "ip_discovery_command",
-            "Optional IP discovery binary: if set, it is expected to emit\n"
-            "the IP address which the agent will try to bind to.\n"
-            "Cannot be used in conjunction with `--ip`.");
+  ::Flags flags;
 
   Try<flags::Warnings> load = flags.load("MESOS_", argc, argv);
 
@@ -199,44 +207,44 @@ int main(int argc, char** argv)
     return EXIT_FAILURE;
   }
 
-  if (master.isNone() && flags.master_detector.isNone()) {
+  if (flags.master.isNone() && flags.master_detector.isNone()) {
     cerr << flags.usage("Missing required option `--master` or "
                         "`--master_detector`.") << endl;
     return EXIT_FAILURE;
   }
 
-  if (master.isSome() && flags.master_detector.isSome()) {
+  if (flags.master.isSome() && flags.master_detector.isSome()) {
     cerr << flags.usage("Only one of --master or --master_detector options "
                         "should be specified.");
     return EXIT_FAILURE;
   }
 
   // Initialize libprocess.
-  if (ip_discovery_command.isSome() && ip.isSome()) {
+  if (flags.ip_discovery_command.isSome() && flags.ip.isSome()) {
     EXIT(EXIT_FAILURE) << flags.usage(
         "Only one of `--ip` or `--ip_discovery_command` should be specified");
   }
 
-  if (ip_discovery_command.isSome()) {
-    Try<string> ipAddress = os::shell(ip_discovery_command.get());
+  if (flags.ip_discovery_command.isSome()) {
+    Try<string> ipAddress = os::shell(flags.ip_discovery_command.get());
 
     if (ipAddress.isError()) {
       EXIT(EXIT_FAILURE) << ipAddress.error();
     }
 
     os::setenv("LIBPROCESS_IP", strings::trim(ipAddress.get()));
-  } else if (ip.isSome()) {
-    os::setenv("LIBPROCESS_IP", ip.get());
+  } else if (flags.ip.isSome()) {
+    os::setenv("LIBPROCESS_IP", flags.ip.get());
   }
 
-  os::setenv("LIBPROCESS_PORT", stringify(port));
+  os::setenv("LIBPROCESS_PORT", stringify(flags.port));
 
-  if (advertise_ip.isSome()) {
-    os::setenv("LIBPROCESS_ADVERTISE_IP", advertise_ip.get());
+  if (flags.advertise_ip.isSome()) {
+    os::setenv("LIBPROCESS_ADVERTISE_IP", flags.advertise_ip.get());
   }
 
-  if (advertise_port.isSome()) {
-    os::setenv("LIBPROCESS_ADVERTISE_PORT", advertise_port.get());
+  if (flags.advertise_port.isSome()) {
+    os::setenv("LIBPROCESS_ADVERTISE_PORT", flags.advertise_port.get());
   }
 
   // Log build information.
@@ -365,7 +373,7 @@ int main(int argc, char** argv)
   }
 
   Try<MasterDetector*> detector_ = MasterDetector::create(
-      master, flags.master_detector);
+      flags.master, flags.master_detector);
 
   if (detector_.isError()) {
     EXIT(EXIT_FAILURE)

http://git-wip-us.apache.org/repos/asf/mesos/blob/f441eb9a/src/tests/active_user_test_helper.cpp
----------------------------------------------------------------------
diff --git a/src/tests/active_user_test_helper.cpp 
b/src/tests/active_user_test_helper.cpp
index 80bd0ac..f056d9d 100644
--- a/src/tests/active_user_test_helper.cpp
+++ b/src/tests/active_user_test_helper.cpp
@@ -31,7 +31,7 @@ const char ActiveUserTestHelper::NAME[] = "ActiveUser";
 
 ActiveUserTestHelper::Flags::Flags()
 {
-  add(&user,
+  add(&Flags::user,
       "user",
       "The expected user name.");
 }

http://git-wip-us.apache.org/repos/asf/mesos/blob/f441eb9a/src/tests/containerizer/capabilities_test_helper.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/capabilities_test_helper.cpp 
b/src/tests/containerizer/capabilities_test_helper.cpp
index 2d7be6d..17f00b00 100644
--- a/src/tests/containerizer/capabilities_test_helper.cpp
+++ b/src/tests/containerizer/capabilities_test_helper.cpp
@@ -56,11 +56,11 @@ const char CapabilitiesTestHelper::NAME[] = "Capabilities";
 
 CapabilitiesTestHelper::Flags::Flags()
 {
-  add(&user,
+  add(&Flags::user,
       "user",
       "User to be used for the test.");
 
-  add(&capabilities,
+  add(&Flags::capabilities,
       "capabilities",
       "Capabilities to be set for the process.");
 }

Reply via email to