You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2013/05/29 19:40:48 UTC

[10/35] git commit: Replaced flags and configurator in Mesos with flags in stout.

Replaced flags and configurator in Mesos with flags in stout.

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


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

Branch: refs/heads/master
Commit: 29183c1b04f9060ba60f59d657c30ff9266b17c8
Parents: 190a3bb
Author: Benjamin Hindman <be...@twitter.com>
Authored: Sun May 26 22:29:26 2013 -0700
Committer: Benjamin Hindman <be...@twitter.com>
Committed: Tue May 28 14:18:39 2013 -0700

----------------------------------------------------------------------
 src/Makefile.am                    |   10 +-
 src/configurator/configuration.cpp |   43 ---
 src/configurator/configuration.hpp |  158 ------------
 src/configurator/configurator.cpp  |  428 -------------------------------
 src/configurator/configurator.hpp  |  385 ---------------------------
 src/configurator/get_conf.cpp      |   52 ----
 src/configurator/option.hpp        |  153 -----------
 src/examples/test_framework.cpp    |    5 +-
 src/flags/flag.hpp                 |   23 --
 src/flags/flags.hpp                |  344 -------------------------
 src/flags/loader.hpp               |  109 --------
 src/flags/parse.hpp                |   55 ----
 src/local/flags.hpp                |    6 +-
 src/local/local.cpp                |   25 +-
 src/local/local.hpp                |    6 +-
 src/local/main.cpp                 |   34 ++--
 src/log/main.cpp                   |   27 +--
 src/logging/flags.hpp              |    3 +-
 src/logging/logging.hpp            |    3 -
 src/master/flags.hpp               |    3 +-
 src/master/main.cpp                |   27 +--
 src/master/master.cpp              |    2 -
 src/master/master.hpp              |    4 -
 src/mesos/main.cpp                 |  105 +--------
 src/sched/sched.cpp                |   46 ++---
 src/slave/flags.hpp                |    3 +-
 src/slave/main.cpp                 |   28 +--
 src/tests/allocator_tests.cpp      |    2 -
 src/tests/configurator_tests.cpp   |  261 -------------------
 src/tests/environment.cpp          |   15 +-
 src/tests/flags.hpp                |    3 +-
 src/tests/flags_tests.cpp          |  223 ----------------
 src/tests/main.cpp                 |   28 +-
 33 files changed, 123 insertions(+), 2496 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 644e1ca..738c18f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -185,7 +185,6 @@ libmesos_no_third_party_la_SOURCES =					\
 	exec/exec.cpp							\
 	common/lock.cpp							\
 	detector/detector.cpp						\
-	configurator/configurator.cpp					\
 	common/date_utils.cpp						\
 	common/resources.cpp						\
 	common/attributes.cpp						\
@@ -218,11 +217,9 @@ libmesos_no_third_party_la_SOURCES += common/attributes.hpp		\
 	common/protobuf_utils.hpp					\
 	common/lock.hpp common/resources.hpp common/process_utils.hpp	\
 	common/type_utils.hpp common/thread.hpp common/units.hpp	\
-	common/values.hpp configurator/configuration.hpp		\
-	configurator/configurator.hpp configurator/option.hpp		\
+	common/values.hpp						\
 	detector/detector.hpp examples/utils.hpp files/files.hpp	\
-	flags/flag.hpp flags/flags.hpp flags/loader.hpp			\
-	flags/parse.hpp launcher/launcher.hpp linux/cgroups.hpp		\
+	launcher/launcher.hpp linux/cgroups.hpp				\
 	linux/fs.hpp local/flags.hpp local/local.hpp			\
 	logging/check_some.hpp logging/flags.hpp logging/logging.hpp	\
 	master/allocator.hpp						\
@@ -804,14 +801,13 @@ mesos_tests_SOURCES = tests/main.cpp tests/utils.cpp			\
 	              tests/gc_tests.cpp				\
 	              tests/resource_offers_tests.cpp			\
 	              tests/fault_tolerance_tests.cpp			\
-	              tests/files_tests.cpp tests/flags_tests.cpp	\
+	              tests/files_tests.cpp				\
 	              tests/isolator_tests.cpp				\
 	              tests/log_tests.cpp				\
 	              tests/monitor_tests.cpp				\
 	              tests/resources_tests.cpp				\
 	              tests/script.cpp					\
 	              tests/examples_tests.cpp				\
-	              tests/configurator_tests.cpp			\
 	              tests/protobuf_io_tests.cpp			\
 	              tests/zookeeper_url_tests.cpp			\
 	              tests/killtree_tests.cpp				\

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/configurator/configuration.cpp
----------------------------------------------------------------------
diff --git a/src/configurator/configuration.cpp b/src/configurator/configuration.cpp
deleted file mode 100644
index fded13c..0000000
--- a/src/configurator/configuration.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <mesos.h>
-
-#include "configuration.hpp"
-
-
-using namespace mesos;
-using namespace mesos::internal;
-
-
-int params_get_int(const char *params, const char *key, int defVal)
-{
-  return Params(params).getInt(key, defVal);
-}
-
-
-int32_t params_get_int32(const char *params, const char *key, int32_t defVal)
-{
-  return Params(params).getInt32(key, defVal);
-}
-
-
-int64_t params_get_int64(const char *params, const char *key, int64_t defVal)
-{
-  return Params(params).getInt64(key, defVal);
-}

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/configurator/configuration.hpp
----------------------------------------------------------------------
diff --git a/src/configurator/configuration.hpp b/src/configurator/configuration.hpp
deleted file mode 100644
index 95effd2..0000000
--- a/src/configurator/configuration.hpp
+++ /dev/null
@@ -1,158 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __CONFIGURATION_HPP__
-#define __CONFIGURATION_HPP__
-
-#include <map>
-#include <sstream>
-#include <string>
-#include <vector>
-
-#include <boost/lexical_cast.hpp>
-
-#include <stout/foreach.hpp>
-#include <stout/none.hpp>
-#include <stout/option.hpp>
-#include <stout/strings.hpp>
-
-
-namespace mesos {
-namespace internal {
-
-struct ParseException : std::exception
-{
-  ParseException(const std::string& _message) : message(_message) {}
-  ~ParseException() throw () {}
-  const char* what() const throw () { return message.c_str(); }
-  const std::string message;
-};
-
-
-/**
- * Stores a set of key-value pairs that can be accessed as strings,
- * ints, etc.
- */
-class Configuration
-{
-private:
-  std::map<std::string, std::string> params;
-
-public:
-  Configuration() {}
-
-  Configuration(const std::map<std::string, std::string>& params_)
-    : params(params_) {}
-
-  Configuration(const std::string& str)
-  {
-    loadString(str);
-  }
-
-  /**
-   * Load key-value pairs from a map into this Configuration object.
-   */
-  void loadMap(const std::map<std::string, std::string>& params_)
-  {
-    foreachpair (const std::string& k, const std::string& v, params_) {
-      params[k] = v;
-    }
-  }
-
-  /**
-   * Load key-value pairs from a string into this Configuration
-   * object.  The string should contain pairs of the form key=value,
-   * one per line.
-   */
-  void loadString(const std::string& str)
-  {
-    std::vector<std::string> lines = strings::tokenize(str, "\n\r");
-    foreach (std::string& line, lines) {
-      std::vector<std::string> parts = strings::tokenize(line, "=");
-      if (parts.size() != 2) {
-        const Try<std::string>& error =
-          strings::format("Failed to parse '%s'", line);
-        throw ParseException(error.isSome() ? error.get() : "Failed to parse");
-      }
-      params[parts[0]] = parts[1];
-    }
-  }
-
-  std::string& operator[] (const std::string& key)
-  {
-    return params[key];
-  }
-
-  template <typename T>
-  Option<T> get(const std::string& key) const
-  {
-    std::map<std::string, std::string>::const_iterator it = params.find(key);
-    if (it != params.end()) {
-      return boost::lexical_cast<T>(it->second);
-    }
-
-    return None();
-  }
-
-  template <typename T>
-  T get(const std::string& key, const T& defaultValue) const
-  {
-    std::map<std::string, std::string>::const_iterator it = params.find(key);
-    if (it != params.end()) {
-      return boost::lexical_cast<T>(it->second);
-    }
-
-    return defaultValue;
-  }
-
-  template <typename T>
-  void set(const std::string& key, T value)
-  {
-    params[key] = boost::lexical_cast<std::string>(value);
-  }
-
-  std::string str() const
-  {
-    std::ostringstream oss;
-    foreachpair (const std::string& key, const std::string& value, params) {
-      oss << key << "=" << value << "\n";
-    }
-    return oss.str();
-  }
-
-  std::map<std::string, std::string>& getMap()
-  {
-    return params;
-  }
-
-  const std::map<std::string, std::string>& getMap() const
-  {
-    return params;
-  }
-
-  bool contains(const std::string& key) const
-  {
-    return params.find(key) != params.end();
-  }
-};
-
-
-} // namespace internal {
-} // namespace mesos {
-
-#endif // __CONFIGURATION_HPP__

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/configurator/configurator.cpp
----------------------------------------------------------------------
diff --git a/src/configurator/configurator.cpp b/src/configurator/configurator.cpp
deleted file mode 100644
index bf45939..0000000
--- a/src/configurator/configurator.cpp
+++ /dev/null
@@ -1,428 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <libgen.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/stat.h>
-
-#include <algorithm>
-#include <fstream>
-#include <iostream>
-
-#include <stout/foreach.hpp>
-#include <stout/os.hpp>
-#include <stout/strings.hpp>
-
-#include "configurator.hpp"
-#include "configuration.hpp"
-
-using namespace mesos::internal;
-
-using std::ifstream;
-using std::map;
-using std::string;
-using std::vector;
-
-
-const char* Configurator::DEFAULT_CONFIG_DIR = "conf";
-const char* Configurator::CONFIG_FILE_NAME = "mesos.conf";
-const char* Configurator::ENV_VAR_PREFIX = "MESOS_";
-
-
-// Define a function for accessing the list of environment variables
-// in a platform-independent way.
-// On Mac OS X, the environ symbol isn't visible to shared libraries,
-// so we must use the _NSGetEnviron() function (see man environ on OS X).
-// On other platforms, it's fine to access environ from shared libraries.
-#ifdef __APPLE__
-#include "crt_externs.h"
-namespace {
-char** getEnviron() { return *_NSGetEnviron(); }
-}
-#else
-extern char** environ;
-namespace {
-char** getEnviron() { return environ; }
-}
-#endif /* __APPLE__ */
-
-
-void Configurator::validate()
-{
-  foreachpair (const string& key, const ConfigOption& opt, options) {
-    if (conf.contains(key) && opt.validator &&
-        !opt.validator->isValid(conf[key])) {
-      string msg = "Invalid value for '" + key + "' option: " + conf[key];
-      throw ConfigurationException(msg.c_str());
-    }
-  }
-}
-
-
-Configuration& Configurator::load(int argc, char** argv)
-{
-  loadEnv();
-  loadCommandLine(argc, argv);
-  loadConfigFileIfGiven();
-  loadDefaults();
-  validate();
-  return conf;
-}
-
-
-Configuration& Configurator::load()
-{
-  loadEnv();
-  loadConfigFileIfGiven();
-  loadDefaults();
-  validate();
-  return conf;
-}
-
-
-Configuration& Configurator::load(const map<string, string>& _params) 
-{
-  loadEnv();
-  conf.loadMap(_params);
-  loadConfigFileIfGiven();
-  loadDefaults();
-  validate();
-  return conf;
-}
-
-
-void Configurator::loadConfigFileIfGiven(bool overwrite) {
-  if (conf.contains("conf")) {
-    // If conf param is given, always look for a config file in that directory.
-    Try<string> path =
-      os::realpath(conf["conf"] + "/" + CONFIG_FILE_NAME);
-
-    if (path.isError()) {
-      LOG(WARNING) << "Cannot load config file: " << path.error();
-    } else {
-      loadConfigFile(path.get(), overwrite);
-    }
-  }
-}
-
-
-void Configurator::loadEnv(bool overwrite)
-{
-  char** environ = getEnviron();
-  int i = 0;
-  while (environ[i] != NULL) {
-    string line = environ[i];
-    if (line.find(ENV_VAR_PREFIX) == 0) {
-      string key, val;
-      size_t eq = line.find_first_of("=");
-      if (eq == string::npos) 
-        continue; // ignore malformed lines (they shouldn't occur in environ!)
-      key = line.substr(strlen(ENV_VAR_PREFIX), eq - strlen(ENV_VAR_PREFIX));
-      std::transform(key.begin(), key.end(), key.begin(), ::tolower);
-      val = line.substr(eq + 1);
-      // Disallow setting home through the environment, because it should
-      // always be resolved from the running Mesos binary (if any)
-      if ((overwrite || !conf.contains(key))) {
-        conf[key] = val;
-      }
-    }
-    i++;
-  }
-}
-
-
-void Configurator::loadCommandLine(int argc,
-                                   char** argv,
-                                   bool overwrite)
-{
-  // Convert args 1 and above to STL strings
-  vector<string> args;
-  for (int i=1; i < argc; i++) {
-    args.push_back(string(argv[i]));
-  }
-
-  // Remember number of times we see each key to warn the user if we see a
-  // key multiple times (since right now we only use the first value)
-  map<string, int> timesSeen;
-
-  for (size_t i = 0; i < args.size(); i++) {
-    string key, val;
-    bool set = false;
-    if (args[i].find("--", 0) == 0) {
-      // handle "--" case
-      size_t eq = args[i].find_first_of("=");
-      if (eq == string::npos &&
-          args[i].find("--no-", 0) == 0) { // handle --no-blah
-        key = args[i].substr(5);
-        val = "0";
-        set = true;
-        checkCommandLineParamFormat(key, true);
-      } else if (eq == string::npos) {     // handle --blah
-        key = args[i].substr(2);
-        val = "1";
-        set = true;
-        checkCommandLineParamFormat(key, true);
-      } else {                             // handle --blah=25
-        key = args[i].substr(2, eq-2); 
-        val = args[i].substr(eq+1);
-        set = true;
-        checkCommandLineParamFormat(key, false);
-      }
-    } else if (args[i].find_first_of("-", 0) == 0 && 
-               args[i].size() > 1) { 
-      // handle "-" case
-      char shortName = '\0';
-      if (args[i].find("-no-",0) == 0 && args[i].size() == 5) {
-        shortName = args[i][4];
-      } else if (args[i].size() == 2) {
-        shortName = args[i][1];
-      }
-      if (shortName == '\0' || getLongName(shortName) == "") {
-        string message = "Short option '" + args[i] + "' unrecognized ";
-        throw ConfigurationException(message.c_str());
-      }
-      key = getLongName(shortName);
-      if (args[i].find("-no-",0) == 0) { // handle -no-b
-        val = "0";
-        set = true;
-        checkCommandLineParamFormat(key, true);
-      } else if (options[key].validator->isBool() ||
-                 i+1 == args.size() ) {  // handle -b
-        val = "1";
-        set = true;
-        checkCommandLineParamFormat(key, true);
-      } else {                           // handle -b 25
-        val = args[i+1];
-        set = true;
-        i++;  // we've consumed next parameter as a "value"-parameter
-      }
-    }
-    std::transform(key.begin(), key.end(), key.begin(), ::tolower);
-    // Check whether the key has already appeared in the command line
-    timesSeen[key]++;
-    if (timesSeen[key] == 2) {
-      LOG(WARNING) << "\"" << key << "\" option appears multiple times in "
-                   << "command line; only the first value will be used";
-    }
-    if (set && (overwrite || !conf.contains(key)) && timesSeen[key] == 1) {
-      conf[key] = val;
-    }
-  }
-}
-
-
-void Configurator::loadConfigFile(const string& fname, bool overwrite) 
-{
-  ifstream cfg(fname.c_str(), std::ios::in);
-  if (!cfg.is_open()) {
-    string message = "Couldn't read Mesos config file: " + fname;
-    throw ConfigurationException(message.c_str());
-  }
-
-  // Remember number of times we see each key to warn the user if we see a
-  // key multiple times (since right now we only use the first value)
-  map<string, int> timesSeen;
-
-  string line, originalLine;
-
-  while (!cfg.eof()) {
-    getline(cfg, line);
-    originalLine = line;
-    // Strip any comment at end of line
-    size_t hash = line.find_first_of("#"); // strip comments
-    if (hash != string::npos) {
-      line = line.substr(0, hash);
-    }
-    // Check for empty line
-    line = strings::trim(line);
-    if (line == "") {
-      continue;
-    }
-    // Split line by = and trim to get key and value
-    vector<string> tokens = strings::tokenize(line, "=");
-    if (tokens.size() != 2) {
-      string message = "Malformed line in config file: '" +
-                       strings::trim(originalLine) + "'";
-      throw ConfigurationException(message.c_str());
-    }
-    string key = strings::trim(tokens[0]);
-    string value = strings::trim(tokens[1]);
-    // Check whether the key has already appeared in this config file
-    timesSeen[key]++;
-    if (timesSeen[key] == 2) {
-      LOG(WARNING) << "\"" << key << "\" option appears multiple times in "
-                   << fname << "; only the first value will be used";
-    }
-    if ((overwrite || !conf.contains(key)) && timesSeen[key] == 1) {
-      conf[key] = value;
-    }
-  }
-  cfg.close();
-}
-
-
-string Configurator::getUsage() const 
-{
-  const int PAD = 5;
-  string usage;
-
-  map<string,string> col1; // key -> col 1 string
-  size_t maxLen = 0;
-
-  // construct string for the first column and get size of column
-  foreachpair (const string& key, const ConfigOption& opt, options) {
-    string val;
-    if (opt.validator->isBool())
-      val = "  --[no-]" + key;
-    else
-      val = "  --" + key + "=VAL";
-
-    if (opt.hasShortName) {
-      if (opt.validator->isBool()) 
-        val += string(" (or -[no-]") + opt.shortName + ")";
-      else
-        val += string(" (or -") + opt.shortName + " VAL)";
-    }
-
-    col1[key] = val;
-    maxLen = val.size() > maxLen ? val.size() : maxLen;
-  }
-
-  foreachpair (const string& key, const ConfigOption& opt, options) {
-    string helpStr = opt.helpString;
-    string line = col1[key];
-
-    if (opt.defaultValue != "") {  // add default value
-      // Place a space between help string and (default: VAL) if the
-      // help string does not end with a newline itself
-      size_t lastNewLine = helpStr.find_last_of("\n\r");
-      if (helpStr.size() > 0 && lastNewLine != helpStr.size() - 1) {
-        helpStr += " ";
-      }
-      string defval = opt.defaultValue;
-      if (opt.validator->isBool())
-        defval = opt.defaultValue == "0" ? "false" : "true";
-
-      helpStr += "(default: " + defval + ")";
-    }
-
-    string pad(PAD + maxLen - line.size(), ' ');
-    line += pad;
-    size_t pos1 = 0, pos2 = 0;
-    pos2 = helpStr.find_first_of("\n\r", pos1);
-    line += helpStr.substr(pos1, pos2 - pos1) + "\n";
-    usage += line;
-
-    while(pos2 != string::npos) {  // handle multi line help strings
-      line = "";
-      pos1 = pos2 + 1;
-      string pad2(PAD + maxLen, ' ');
-      line += pad2;
-      pos2 = helpStr.find_first_of("\n\r", pos1);
-      line += helpStr.substr(pos1, pos2 - pos1) + "\n";
-      usage += line;
-    }
-
-  }
-  return usage;
-}
-
-
-void Configurator::loadDefaults()
-{
-  foreachpair (const string& key, const ConfigOption& option, options) {
-    if (option.hasDefault && !conf.contains(key)) {
-      conf[key] = option.defaultValue;
-    }
-  }
-}
-
-
-vector<string> Configurator::getOptions() const 
-{
-  vector<string> ret;
-  foreachkey (const string& key, options) {
-    ret.push_back(key);
-  }
-  return ret;
-}
-
-
-Configuration& Configurator::getConfiguration()
-{
-  return conf;
-}
-
-string Configurator::getLongName(char shortName) const
-{
-  foreachpair (const string& key, const ConfigOption& opt, options) {
-    if (opt.hasShortName && opt.shortName == shortName)
-      return key;
-  }
-  return "";
-}
-
-
-void Configurator::clearMesosEnvironmentVars()
-{
-  char** environ = getEnviron();
-  int i = 0;
-  vector<string> toRemove;
-  while (environ[i] != NULL) {
-    string line = environ[i];
-    if (line.find(ENV_VAR_PREFIX) == 0) {
-      string key;
-      size_t eq = line.find_first_of("=");
-      if (eq == string::npos) 
-        continue; // ignore malformed lines (they shouldn't occur in environ!)
-      key = line.substr(strlen(ENV_VAR_PREFIX), eq - strlen(ENV_VAR_PREFIX));
-      toRemove.push_back(key);
-    }
-    i++;
-  }
-  foreach (string& str, toRemove) {
-    unsetenv(str.c_str());
-  }
-}
-
-
-void Configurator::checkCommandLineParamFormat(const string& key, bool gotBool) 
-  throw(ConfigurationException)
-{
-  if (options.find(key) != options.end() && 
-      options[key].validator->isBool() != gotBool) {
-    string message = "Option '" + key + "' should ";
-    if (gotBool)
-      message += "not ";
-    message += "be a boolean.";
-
-    throw ConfigurationException(message.c_str());
-  }
-}
-
-
-void Configurator::dumpToGoogleLog()
-{
-  LOG(INFO) << "Dumping configuration options:";
-  const map<string, string>& params = conf.getMap();
-  foreachpair (const string& key, const string& val, params) {
-    LOG(INFO) << "  " << key << " = " << val;
-  }
-  LOG(INFO) << "End configuration dump";
-}

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/configurator/configurator.hpp
----------------------------------------------------------------------
diff --git a/src/configurator/configurator.hpp b/src/configurator/configurator.hpp
deleted file mode 100644
index 8449e05..0000000
--- a/src/configurator/configurator.hpp
+++ /dev/null
@@ -1,385 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __CONFIGURATOR_HPP__
-#define __CONFIGURATOR_HPP__
-
-#include <algorithm>
-#include <map>
-#include <string>
-
-#include <glog/logging.h>
-
-#include "configurator/configuration.hpp"
-#include "configurator/option.hpp"
-
-#include "flags/flag.hpp"
-#include "flags/flags.hpp"
-
-namespace mesos {
-namespace internal {
-
-/**
- * Exception type thrown by Configurator.
- */
-struct ConfigurationException : std::exception
-{
-  ConfigurationException(const std::string& _message) : message(_message) {}
-  ~ConfigurationException() throw () {}
-  const char* what() const throw () { return message.c_str(); }
-  const std::string message;
-};
-
-
-/**
- * This class populates a Configuration object, which can be retrieved
- * with getConfiguration(), by reading variables from the command
- * line, a config file or the environment.
- *
- * It currently supports 3 input types:
- * (i) Environment variables. It adds all variables starting with MESOS_.
- * (ii) Command line variables. Supports "--key=val" "-key val" "-opt" "--opt"
- * (iii) Config file. It ignores comments "#". It finds the file mesos.conf
- * in the directory specified by the "conf" option.
- **/
-class Configurator
-{
-public:
-  static const char* DEFAULT_CONFIG_DIR;
-  static const char* CONFIG_FILE_NAME;
-  static const char* ENV_VAR_PREFIX;
-
-private:
-  Configuration conf;
-  std::map<std::string, ConfigOption> options;
-
-public:
-
-  /**
-   * Initializes a Configurator with no options set and only the "conf"
-   * option registered.
-   **/
-  Configurator()
-  {
-    addOption<std::string>("conf",
-                           "Specifies a config directory from which to\n"
-                           "read Mesos config files.");
-  }
-
-  /**
-   * Initializes a Configurator out of a Flags.
-   **/
-  template <typename Flags>
-  Configurator(const Flags& flags)
-  {
-    addOption<std::string>("conf",
-                           "Specifies a config directory from which to\n"
-                           "read Mesos config files.");
-
-    foreachvalue (const flags::Flag& flag, flags) {
-      if (!flag.boolean) {
-        addOption<std::string>(flag.name, flag.help);
-      } else {
-        addOption<bool>(flag.name, flag.help);
-      }
-    }
-  }
-
-
-  /**
-   * Returns the Configuration object parsed by this Configurator.
-   * @return Configuration populated configuration object
-   **/
-  Configuration& getConfiguration();
-
-
-  /**
-   * Returns a usage string with all registered options
-   * @see addOption()
-   * @return usage string
-   **/
-  std::string getUsage() const;
-
-
-private:
-  /**
-   * Private method for adding an option with, potentially, a default
-   * value and a short name.
-   * @param optName name of the option, e.g. "home"
-   * @param helpString description of the option, may contain line breaks
-   * @param hasShortName whether the option has a short name
-   * @param shortName character representing short name of option, e.g. 'h'
-   * @param hasDefault whether the option has a default value
-   * @param defaultValue default value of the option, as a string.
-   *        The default option is put in the internal conf,
-   *        unless the option already has a value in conf.
-   **/
-  template <class T>
-  void addOption(const std::string& optName,
-                 const std::string& helpString,
-                 bool hasShortName,
-                 char shortName,
-                 bool hasDefault,
-                 const std::string& defaultValue)
-  {
-    std::string name = optName;
-    std::transform(name.begin(), name.end(), name.begin(), ::tolower);
-    if (options.find(name) != options.end()) {
-      std::string message = "Duplicate option registration: " + name;
-      throw ConfigurationException(message.c_str());
-    }
-    options[name] = ConfigOption(helpString,
-                                 Validator<T>(),
-                                 hasShortName,
-                                 shortName,
-                                 hasDefault,
-                                 defaultValue);
-  }
-
-public:
-  /**
-   * Adds a registered option together with a help string.
-   * @param optName name of the option, e.g. "home"
-   * @param helpString description of the option, may contain line breaks
-   **/
-  template <class T>
-  void addOption(const std::string& optName, const std::string& helpString)
-  {
-    addOption<T>(optName, helpString, false, '\0', false, "");
-  }
-
-  /**
-   * Adds a registered option with a short name and help string.
-   * @param optName name of the option, e.g. "home"
-   * @param shortName character representing short name of option, e.g. 'h'
-   * @param helpString description of the option, may contain line breaks
-   **/
-  template <class T>
-  void addOption(const std::string& optName,
-                 char shortName,
-                 const std::string& helpString)
-  {
-    addOption<T>(optName, helpString, true, shortName, false, "");
-  }
-
-  /**
-   * Adds a registered option with a default value and a help string.
-   * @param optName name of the option, e.g. "home"
-   * @param helpString description of the option, may contain line breaks
-   * @param defaultValue default value of option.
-   *        The default option is put in the internal conf,
-   *        unless the option already has a value in conf.
-   *        Its type must support operator<<(ostream,...)
-   **/
-  template <class T>
-  void addOption(const std::string& optName,
-                 const std::string& helpString,
-                 const T& defaultValue)
-  {
-    std::string defaultStr = boost::lexical_cast<std::string>(defaultValue);
-    addOption<T>(optName, helpString, false, '\0', true, defaultStr);
-  }
-
-  /**
-   * Adds a registered option with a default value, short name and help string.
-   * @param optName name of the option, e.g. "home"
-   * @param helpString description of the option, may contain line breaks
-   * @param defaultValue default value of option.
-   *        The default option is put in the internal conf, 
-   *        unless the option already has a value in conf.
-   *        Its type must support operator<<(ostream,...)
-   **/
-  template <class T>
-  void addOption(const std::string& optName,
-                 char shortName,
-                 const std::string& helpString,
-                 const T& defaultValue) 
-  {
-    std::string defaultStr = boost::lexical_cast<std::string>(defaultValue);
-    addOption<T>(optName, helpString, true, shortName, true, defaultStr);
-  }
-
-  /**
-   * Returns the names of all registered options.
-   * @return name of every registered option
-   **/
-  std::vector<std::string> getOptions() const;
-
-
-  /**
-   * Validates the values of all keys that it has a default option for.
-   * @throws ConfigurationError if a key has the wrong type.
-   **/ 
-  void validate();
-
-
-  /**
-   * Populates its internal Configuration with key/value parameters
-   * from environment, command line, and config file.
-   *
-   * <i>Environment:</i><br>
-   * Parses the environment variables and populates a Configuration.
-   * It picks all environment variables that start with MESOS_.
-   * The environment var MESOS_FOO=/dir would lead to key=foo val=/dir<br>
-   *
-   * <i>Command line:</i><br>
-   * It extracts four type of command line parameters:
-   * "--key=val", "-key val", "--key", "-key". The two last cases will
-   * have default value "1" in the Configuration. <br>
-   *
-   * <i>Config file:</i><br>
-   * The config file should contain key=value pairs, one per line.
-   * Comments, which should start with #, are ignored.
-   *
-   * @param argc is the number of parameters in argv
-   * @param argv is an array of c-strings containing parameters
-   * @return the loaded Configuration object
-   **/
-  Configuration& load(int argc, char** argv);
-
-
-  /**
-   * Populates its internal Configuration with key/value parameters
-   * from environment, and config file.
-   *
-   * <i>Environment:</i><br>
-   * Parses the environment variables and populates a Configuration.
-   * It picks all environment variables that start with MESOS_.
-   * The environment var MESOS_FOO=/dir would lead to key=foo val=/dir <br>
-   *
-   * <i>Config file:</i><br>
-   * The config file should contain key=value pairs, one per line.
-   * Comments, which should start with #, are ignored.
-   *
-   * @return the loaded Configuration object
-   **/
-  Configuration& load();
-
-
-  /**
-   * Populates its internal Configuration with key/value parameters
-   * from environment, a provided map, and config file.
-   *
-   * <i>Environment:</i><br>
-   * Parses the environment variables and populates a Configuration.
-   * It picks all environment variables that start with MESOS_.
-   * The environment var MESOS_FOO=/dir would lead to key=foo val=/dir <br>
-   *
-   * <i>Map:</i><br>
-   * Containing a string to string map. <br>
-   *
-   * <i>Config file:</i><br>
-   * The config file should contain key=value pairs, one per line.
-   * Comments, which should start with #, are ignored.
-   *
-   * @param params map containing key value pairs to be loaded
-   * @return the loaded Configuration object
-   **/
-  Configuration& load(const std::map<std::string, std::string>& params);
-
-  /**
-   * Clears all Mesos environment variables (useful for tests).
-   */
-  static void clearMesosEnvironmentVars();
-
-private:
-  /**
-   * Parses the environment variables and populates a Configuration.
-   * It picks all environment variables that start with MESOS_.
-   * The environment variable MESOS_FOO=/dir would lead to key=foo val=/dir
-   * @param overwrite whether to overwrite keys that already have values
-   *         in the internal params (true by default)
-   **/
-  void loadEnv(bool overwrite = true);
-
-  /**
-   * Populates its internal Configuration with key/value parameters
-   * from command line.
-   *
-   * It extracts four type of command line parameters:
-   * "--key=val", "-key val", "--key", "-key". The two last cases will
-   * have default value "1" in the Params.
-   *
-   * @param argc is the number of parameters in argv
-   * @param argv is an array of c-strings containing parameters
-   * @param overwrite whether to overwrite keys that already have values
-   *         in the internal params (true by default)
-   **/
-  void loadCommandLine(int argc,
-                       char** argv,
-                       bool overwrite = true);
-
-  /**
-   * Populates its internal Configuration with key/value parameters
-   * from a config file.
-   *
-   * Values in the config file DO NOT override values already loaded into
-   * conf (i.e. having been defined in the environment or command line), as
-   * is typically expected for programs that allow configuration both ways.
-   *
-   * The config file should contain key=value pairs, one per line.
-   * Comments, which should start with #, are ignored.
-   *
-   * @param fname is the name of the config file to open
-   * @param overwrite whether to overwrite keys that already have values
-   *         in the internal params (false by default)
-   **/
-  void loadConfigFile(const std::string& fname, bool overwrite = false);
-
-  /**
-   * Load the config file set through the command line or environment, if any.
-   * @param overwrite whether to overwrite keys that already have values
-   *         in the internal params (false by default)
-   */
-  void loadConfigFileIfGiven(bool overwrite = false);
-
-  /**
-   * Load default values of options whose values have not already been set.
-   */
-  void loadDefaults();
-
-  /**
-   * Gets the first long name option associated with the provided short name.
-   * @param shortName character representing the short name of the option
-   * @return first long name option matching the short name, "" if none found.
-   */
-  std::string getLongName(char shortName) const;
-
-  /**
-   * Check whether a command-line flag is valid, based on whether it was
-   * passed in boolean form (--flag or --no-flag) versus key-value form
-   * (--flag=value). We test whether this option was actually registered
-   * as a bool (or non-bool), and throw an error if it is passed in
-   * the wrong format.
-   *
-   * @param key the option name parsed from the flag (without --no)
-   * @param gotBool whether the option was passed as a bool
-   */
-  void checkCommandLineParamFormat(const std::string& key, bool gotBool)
-    throw(ConfigurationException);
-
-  /**
-   * Dump the values of all config options to Google Log
-   */
-  void dumpToGoogleLog();
-};
-
-} // namespace internal {
-} // namespace mesos {
-
-#endif // __CONFIGURATOR_HPP__

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/configurator/get_conf.cpp
----------------------------------------------------------------------
diff --git a/src/configurator/get_conf.cpp b/src/configurator/get_conf.cpp
deleted file mode 100644
index aa2bb7b..0000000
--- a/src/configurator/get_conf.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <iostream>
-#include <string>
-
-#include "configurator.hpp"
-
-using namespace mesos::internal;
-
-using std::cout;
-using std::string;
-
-
-int main(int argc, char** argv)
-{
-  if (argc == 1) {
-    cout << "Usage:  mesos-getconf OPTION [arg1 arg2 ... ]\n\n";
-    cout << "OPTION\t\tis the name option whose value is to be extracted\n";
-    cout << "arg1 ...\tOptional arguments passed to mesos, e.g. --quiet\n\n";
-    cout << "This utility gives shell scripts access to Mesos parameters.\n\n";
-    return 1;
-  }
-
-  Configurator configurator;
-  configurator.load(argc, argv, true);
-
-  string param(argv[1]);
-  transform(param.begin(), param.end(), param.begin(), tolower);
-
-  Configuration conf = configurator.getConfiguration();
-  if (conf.contains(param)) {
-    cout << conf[param] << "\n";
-  }
-
-  return 0;
-}

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/configurator/option.hpp
----------------------------------------------------------------------
diff --git a/src/configurator/option.hpp b/src/configurator/option.hpp
deleted file mode 100644
index fc79491..0000000
--- a/src/configurator/option.hpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __CONFIGURATOR_OPTION_HPP__
-#define __CONFIGURATOR_OPTION_HPP__
-
-#include <string>
-
-
-namespace mesos { namespace internal {
-    
-
-/**
- * Interface of a validator
- **/
-class ValidatorBase {
-public:
-  virtual ValidatorBase* clone() const = 0;
-  virtual bool isBool() const = 0;
-  /**
-   * Checks if the provided string can be cast to a T.
-   * @param val value associated with some option
-   * @return true if val can be cast to a T, otherwise false.
-   **/
-  virtual bool isValid(const std::string& val) const = 0;
-
-  virtual ~ValidatorBase() {}
-
-protected:
-  template <class T>
-  bool isValidInternal(const std::string& val) const
-  {
-    try {
-      boost::lexical_cast<T>(val);
-    }
-    catch(const boost::bad_lexical_cast& ex) {
-      return false;
-    }
-    return true;
-  }
-};
-
-
-/**
- * Validator that checks if a string can be cast to its templated type.
- **/
-template <typename T>
-class Validator : public ValidatorBase {
-public:
-  virtual bool isValid(const std::string& val) const { 
-    return isValidInternal<T>(val); 
-  }
-  
-  virtual bool isBool() const { return false; }
-
-  virtual ValidatorBase* clone() const  { 
-    return new Validator<T>(); 
-  }
-};
-
-
-/**
- * Validator for bools that checks if a string can be cast to its templated type.
- **/
-template <>
-class Validator <bool> : public ValidatorBase {
-public:
-  bool isValid(const std::string& val) const { 
-    return isValidInternal<bool>(val); 
-  }
-
-  bool isBool() const { return true; }
-
-  ValidatorBase* clone() const { 
-    return new Validator<bool>(); 
-  }
-};
-
-
-/**
- * Registered option with help string and default value
- **/
-class ConfigOption {
-public:
-  ConfigOption() : hasDefault(false), validator(NULL) {}
-
-  ConfigOption(const std::string& _helpString,
-               const ValidatorBase& _validator,
-               bool _hasShortName,
-               char _shortName,
-               bool _hasDefault,
-               const std::string& _defaultValue)
-    : helpString(_helpString), 
-      hasDefault(_hasDefault),
-      defaultValue(_defaultValue),
-      hasShortName(_hasShortName),
-      shortName(_shortName)
-  {
-    validator = _validator.clone();
-  }
-
-  ConfigOption(const ConfigOption& opt)
-    : helpString(opt.helpString),
-      hasDefault(opt.hasDefault),
-      defaultValue(opt.defaultValue),
-      hasShortName(opt.hasShortName),
-      shortName(opt.shortName)
-  {
-    validator = (opt.validator == NULL) ? NULL : opt.validator->clone();
-  }
-
-  ConfigOption &operator=(const ConfigOption& opt)
-  {
-    helpString = opt.helpString;
-    hasDefault = opt.hasDefault;
-    hasShortName = opt.hasShortName;
-    shortName = opt.shortName;
-    defaultValue = opt.defaultValue;
-    validator = opt.validator == NULL ? NULL : opt.validator->clone();
-    return *this;
-  }
-
-  ~ConfigOption()
-  {
-    if (validator != 0) delete validator;
-  }
-
-  std::string helpString;
-  bool hasDefault;
-  std::string defaultValue;
-  bool hasShortName;
-  char shortName;
-  ValidatorBase *validator;
-};
-
-} }   // end mesos :: internal namespace
-
-#endif // __CONFIGURATOR_OPTION_HPP__

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/examples/test_framework.cpp
----------------------------------------------------------------------
diff --git a/src/examples/test_framework.cpp b/src/examples/test_framework.cpp
index b3608ba..2c46c24 100644
--- a/src/examples/test_framework.cpp
+++ b/src/examples/test_framework.cpp
@@ -154,7 +154,10 @@ public:
                             const SlaveID& slaveID,
                             int status) {}
 
-  virtual void error(SchedulerDriver* driver, const string& message) {}
+  virtual void error(SchedulerDriver* driver, const string& message)
+  {
+    cout << message << endl;
+  }
 
 private:
   const ExecutorInfo executor;

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/flags/flag.hpp
----------------------------------------------------------------------
diff --git a/src/flags/flag.hpp b/src/flags/flag.hpp
deleted file mode 100644
index 46509f7..0000000
--- a/src/flags/flag.hpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef __FLAGS_FLAG_HPP__
-#define __FLAGS_FLAG_HPP__
-
-#include <string>
-
-#include <tr1/functional>
-
-namespace flags {
-
-// Forward declaration.
-class FlagsBase;
-
-struct Flag
-{
-  std::string name;
-  std::string help;
-  bool boolean;
-  std::tr1::function<void(FlagsBase*, const std::string&)> loader;
-};
-
-} // namespace flags {
-
-#endif // __FLAGS_FLAG_HPP__

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/flags/flags.hpp
----------------------------------------------------------------------
diff --git a/src/flags/flags.hpp b/src/flags/flags.hpp
deleted file mode 100644
index 5a9c30c..0000000
--- a/src/flags/flags.hpp
+++ /dev/null
@@ -1,344 +0,0 @@
-#ifndef __FLAGS_FLAGS_HPP__
-#define __FLAGS_FLAGS_HPP__
-
-#include <stdlib.h> // For abort.
-
-#include <map>
-#include <string>
-#include <typeinfo> // For typeid.
-
-#include <tr1/functional>
-
-#include <stout/option.hpp>
-#include <stout/stringify.hpp>
-#include <stout/try.hpp>
-
-#include "flags/flag.hpp"
-#include "flags/loader.hpp"
-#include "flags/parse.hpp"
-
-// An abstraction for application/library "flags". An example is
-// probably best:
-//  -------------------------------------------------------------
-// class MyFlags : public virtual FlagsBase // Use 'virtual' for composition!
-// {
-// public:
-//   Flags()
-//   {
-//     add(&debug,
-//         "debug",
-//         "Help string for debug",
-//         false);
-//
-//     add(&name,
-//         "name",
-//         "Help string for name");
-//   }
-
-//   bool debug;
-//   Option<string> name;
-// };
-//
-// ...
-//
-// map<string, Option<string> > values;
-// values["no-debug"] = None();                       // --no-debug
-// values["debug"] = None();                          // --debug
-// values["debug"] = Option<string>::some("true");    // --debug=true
-// values["debug"] = Option<string>::some("false");   // --debug=false
-// values["name"] = Option<string>::some("frank");    // --name=frank
-//
-// MyFlags flags;
-// flags.load(values);
-// flags.name.isSome() ...
-// flags.debug ...
-//  -------------------------------------------------------------
-//
-// You can also compose flags provided that each has used "virtual
-// inheritance":
-//  -------------------------------------------------------------
-// Flags<MyFlags1, MyFlags2> flags;
-// flags.add(...); // Any other flags you want to throw in there.
-// flags.load(values);
-// flags.flag_from_myflags1 ...
-// flags.flag_from_myflags2 ...
-//  -------------------------------------------------------------
-//
-// "Fail early, fail often":
-//
-// You can not add duplicate flags, this is checked for you at compile
-// time for composite flags (e.g., Flag<MyFlags1, MyFlags2>) and also
-// checked at runtime for any other flags added via inheritance or
-// Flags::add(...).
-//
-// Flags that can not be loaded (e.g., attempting to use the 'no-'
-// prefix for a flag that is not boolean) will print a message to
-// standard error and abort the process.
-
-// TODO(benh): Provide a boolean which specifies whether or not to
-// abort on duplicates or load errors.
-
-// TODO(benh): Make prefix for environment variables configurable
-// (e.g., "MESOS_").
-
-namespace flags {
-
-class FlagsBase
-{
-public:
-  virtual ~FlagsBase() {}
-  virtual void load(const std::map<std::string, Option<std::string> >& values);
-  virtual void load(const std::map<std::string, std::string>& values);
-
-  typedef std::map<std::string, Flag>::const_iterator const_iterator;
-
-  const_iterator begin() const { return flags.begin(); }
-  const_iterator end() const { return flags.end(); }
-
-  template <typename T1, typename T2>
-  void add(T1* t1,
-           const std::string& name,
-           const std::string& help,
-           const T2& t2);
-
-  template <typename T>
-  void add(Option<T>* option,
-           const std::string& name,
-           const std::string& help);
-
-protected:
-  template <typename Flags, typename T1, typename T2>
-  void add(T1 Flags::*t1,
-           const std::string& name,
-           const std::string& help,
-           const T2& t2);
-
-  template <typename Flags, typename T>
-  void add(Option<T> Flags::*option,
-           const std::string& name,
-           const std::string& help);
-
-  void add(const Flag& flag);
-
-private:
-  std::map<std::string, Flag> flags;
-};
-
-
-// Need to declare/define some explicit subclasses of FlagsBase so
-// that we can overload the 'Flags::operator FlagsN () const'
-// functions for each possible type.
-class _Flags1 : public virtual FlagsBase {};
-class _Flags2 : public virtual FlagsBase {};
-class _Flags3 : public virtual FlagsBase {};
-class _Flags4 : public virtual FlagsBase {};
-class _Flags5 : public virtual FlagsBase {};
-
-
-// TODO(benh): Add some "type constraints" for template paramters to
-// make sure they are all of type FlagsBase.
-template <typename Flags1 = _Flags1,
-          typename Flags2 = _Flags2,
-          typename Flags3 = _Flags3,
-          typename Flags4 = _Flags4,
-          typename Flags5 = _Flags5>
-class Flags : public virtual Flags1,
-              public virtual Flags2,
-              public virtual Flags3,
-              public virtual Flags4,
-              public virtual Flags5 {};
-
-
-template <typename T1, typename T2>
-void FlagsBase::add(
-    T1* t1,
-    const std::string& name,
-    const std::string& help,
-    const T2& t2)
-{
-  *t1 = t2; // Set the default.
-
-  Flag flag;
-  flag.name = name;
-  flag.help = help;
-  flag.boolean = typeid(T1) == typeid(bool);
-  flag.loader = std::tr1::bind(
-      &Loader<T1>::load,
-      t1,
-      std::tr1::function<Try<T1>(const std::string&)>(
-          std::tr1::bind(&parse<T1>, std::tr1::placeholders::_1)),
-      name,
-      std::tr1::placeholders::_2); // Use _2 because ignore FlagsBase*.
-
-  // Update the help string to include the default value.
-  flag.help += help.size() > 0 && help.find_last_of("\n\r") != help.size() - 1
-    ? " (default: " // On same line, add space.
-    : "(default: "; // On newline.
-  flag.help += stringify(t2);
-  flag.help += ")";
-
-  FlagsBase::add(flag);
-}
-
-
-template <typename T>
-void FlagsBase::add(
-    Option<T>* option,
-    const std::string& name,
-    const std::string& help)
-{
-  Flag flag;
-  flag.name = name;
-  flag.help = help;
-  flag.boolean = typeid(T) == typeid(bool);
-  flag.loader = std::tr1::bind(
-      &OptionLoader<T>::load,
-      option,
-      std::tr1::function<Try<T>(const std::string&)>(
-          std::tr1::bind(&parse<T>, std::tr1::placeholders::_1)),
-      name,
-      std::tr1::placeholders::_2); // Use _2 because ignore FlagsBase*.
-
-  FlagsBase::add(flag);
-}
-
-
-template <typename Flags, typename T1, typename T2>
-void FlagsBase::add(
-    T1 Flags::*t1,
-    const std::string& name,
-    const std::string& help,
-    const T2& t2)
-{
-  Flags* flags = dynamic_cast<Flags*>(this);
-  if (flags == NULL) {
-    std::cerr << "Attempted to add flag '" << name
-              << "' with incompatible type" << std::endl;
-    abort();
-  } else {
-    flags->*t1 = t2; // Set the default.
-  }
-
-  Flag flag;
-  flag.name = name;
-  flag.help = help;
-  flag.boolean = typeid(T1) == typeid(bool);
-  flag.loader = std::tr1::bind(
-      &MemberLoader<Flags, T1>::load,
-      std::tr1::placeholders::_1,
-      t1,
-      std::tr1::function<Try<T1>(const std::string&)>(
-          std::tr1::bind(&parse<T1>, std::tr1::placeholders::_1)),
-      name,
-      std::tr1::placeholders::_2);
-
-  // Update the help string to include the default value.
-  flag.help += help.size() > 0 && help.find_last_of("\n\r") != help.size() - 1
-    ? " (default: " // On same line, add space.
-    : "(default: "; // On newline.
-  flag.help += stringify(t2);
-  flag.help += ")";
-
-  flag.help += ")";
-
-  add(flag);
-}
-
-
-template <typename Flags, typename T>
-void FlagsBase::add(
-    Option<T> Flags::*option,
-    const std::string& name,
-    const std::string& help)
-{
-  Flags* flags = dynamic_cast<Flags*>(this);
-  if (flags == NULL) {
-    std::cerr << "Attempted to add flag '" << name
-              << "' with incompatible type" << std::endl;
-    abort();
-  }
-
-  Flag flag;
-  flag.name = name;
-  flag.help = help;
-  flag.boolean = typeid(T) == typeid(bool);
-  flag.loader = std::tr1::bind(
-      &OptionMemberLoader<Flags, T>::load,
-      std::tr1::placeholders::_1,
-      option,
-      std::tr1::function<Try<T>(const std::string&)>(
-          std::tr1::bind(&parse<T>, std::tr1::placeholders::_1)),
-      name,
-      std::tr1::placeholders::_2);
-
-  add(flag);
-}
-
-
-inline void FlagsBase::add(const Flag& flag)
-{
-  if (flags.count(flag.name) > 0) {
-    std::cerr << "Attempted to add duplicate flag '"
-              << flag.name << "'" << std::endl;
-    abort();
-  }
-
-  flags[flag.name] = flag;
-}
-
-
-inline void FlagsBase::load(const std::map<std::string, Option<std::string> >& values)
-{
-  std::map<std::string, Option<std::string> >::const_iterator iterator;
-
-  for (iterator = values.begin(); iterator != values.end(); ++iterator) {
-    const std::string& name = iterator->first;
-    const Option<std::string>& value = iterator->second;
-
-    if (flags.count(name) > 0) {
-      if (value.isSome()) {
-        flags[name].loader(this, value.get());                // --name=value
-      } else if (flags[name].boolean) {
-        flags[name].loader(this, "true");                     // --name
-      } else {
-        std::cerr << "Failed to load non-boolean flag via '"
-                  << name << "'" << std::endl;
-        abort();
-      }
-    } else if (name.find("no-") == 0 && flags.count(name.substr(3)) > 0) {
-      if (flags[name.substr(3)].boolean) {
-        if (value.isNone()) {
-          flags[name.substr(3)].loader(this, "false");        // --no-name
-        } else {
-          std::cerr << "Failed to load boolean flag '"
-                    << name.substr(3) << "' via '" << name
-                    << "' with value '" << value.get()
-                    << "'" << std::endl;
-          abort();
-        }
-      } else {
-        std::cerr << "Failed to load non-boolean flag '"
-                  << name.substr(3) << "' via '"
-                  << name << "'" << std::endl;
-        abort();
-      }
-    }
-  }
-}
-
-
-inline void FlagsBase::load(const std::map<std::string, std::string>& _values)
-{
-  std::map<std::string, Option<std::string> > values;
-  std::map<std::string, std::string>::const_iterator iterator;
-  for (iterator = _values.begin(); iterator != _values.end(); ++iterator) {
-    const std::string& name = iterator->first;
-    const std::string& value = iterator->second;
-    values[name] = Option<std::string>::some(value);
-  }
-  load(values);
-}
-
-} // namespace flags {
-
-#endif // __FLAGS_FLAGS_HPP__

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/flags/loader.hpp
----------------------------------------------------------------------
diff --git a/src/flags/loader.hpp b/src/flags/loader.hpp
deleted file mode 100644
index 2226172..0000000
--- a/src/flags/loader.hpp
+++ /dev/null
@@ -1,109 +0,0 @@
-#ifndef __FLAGS_LOADER_HPP__
-#define __FLAGS_LOADER_HPP__
-
-#include <string>
-
-#include <tr1/functional>
-
-#include <stout/option.hpp>
-#include <stout/try.hpp>
-
-namespace flags {
-
-// Forward declaration.
-class FlagsBase;
-
-template <typename T>
-struct Loader
-{
-  static void load(T* flag,
-                   const std::tr1::function<Try<T>(const std::string&)>& parse,
-                   const std::string& name,
-                   const std::string& value)
-  {
-    Try<T> t = parse(value);
-    if (t.isSome()) {
-      *flag = t.get();
-    } else {
-      std::cerr << "Failed to load value '" << value
-                << "' for flag '" << name
-                << "': " << t.error() << std::endl;
-      abort();
-    }
-  }
-};
-
-
-template <typename T>
-struct OptionLoader
-{
-  static void load(Option<T>* flag,
-                   const std::tr1::function<Try<T>(const std::string&)>& parse,
-                   const std::string& name,
-                   const std::string& value)
-  {
-    Try<T> t = parse(value);
-    if (t.isSome()) {
-      *flag = Option<T>::some(t.get());
-    } else {
-      std::cerr << "Failed to load value '" << value
-                << "' for flag '" << name
-                << "': " << t.error() << std::endl;
-      abort();
-    }
-  }
-};
-
-
-template <typename F, typename T>
-struct MemberLoader
-{
-  static void load(FlagsBase* base,
-                   T F::*flag,
-                   const std::tr1::function<Try<T>(const std::string&)>& parse,
-                   const std::string& name,
-                   const std::string& value)
-  {
-    F* f = dynamic_cast<F*>(base);
-    if (f != NULL) {
-      Try<T> t = parse(value);
-      if (t.isSome()) {
-        f->*flag = t.get();
-      } else {
-        std::cerr << "Failed to load value '" << value
-                  << "' for flag '" << name
-                  << "': " << t.error() << std::endl;
-        abort();
-      }
-    }
-  }
-};
-
-
-template <typename F, typename T>
-struct OptionMemberLoader
-{
-  static void load(FlagsBase* base,
-                   Option<T> F::*flag,
-                   const std::tr1::function<Try<T>(const std::string&)>& parse,
-                   const std::string& name,
-                   const std::string& value)
-  {
-    F* f = dynamic_cast<F*>(base);
-    if (f != NULL) {
-      Try<T> t = parse(value);
-      if (t.isSome()) {
-        f->*flag = Option<T>::some(t.get());
-      } else {
-        std::cerr << "Failed to load value '" << value
-                  << "' for flag '" << name
-                  << "': " << t.error() << std::endl;
-        abort();
-      }
-    }
-  }
-};
-
-} // namespace flags {
-
-#endif // __FLAGS_LOADER_HPP__

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/flags/parse.hpp
----------------------------------------------------------------------
diff --git a/src/flags/parse.hpp b/src/flags/parse.hpp
deleted file mode 100644
index 88923fe..0000000
--- a/src/flags/parse.hpp
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef __FLAGS_PARSE_HPP__
-#define __FLAGS_PARSE_HPP__
-
-#include <sstream> // For istringstream.
-#include <string>
-
-#include <tr1/functional>
-
-#include <stout/duration.hpp>
-#include <stout/error.hpp>
-#include <stout/try.hpp>
-
-namespace flags {
-
-template <typename T>
-Try<T> parse(const std::string& value)
-{
-  T t;
-  std::istringstream in(value);
-  in >> t;
-  if (!in.good() && !in.eof()) {
-    return Error("Failed to convert into required type");
-  }
-  return t;
-}
-
-
-template <>
-inline Try<std::string> parse(const std::string& value)
-{
-  return value;
-}
-
-
-template <>
-inline Try<bool> parse(const std::string& value)
-{
-  if (value == "true" || value == "1") {
-    return true;
-  } else if (value == "false" || value == "0") {
-    return false;
-  }
-  return Error("Expecting a boolean (e.g., true or false)");
-}
-
-
-template <>
-inline Try<Duration> parse(const std::string& value)
-{
-  return Duration::parse(value);
-}
-
-} // namespace flags {
-
-#endif // __FLAGS_PARSE_HPP__

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/local/flags.hpp
----------------------------------------------------------------------
diff --git a/src/local/flags.hpp b/src/local/flags.hpp
index 75cd15a..54e8831 100644
--- a/src/local/flags.hpp
+++ b/src/local/flags.hpp
@@ -19,13 +19,15 @@
 #ifndef __LOCAL_FLAGS_HPP__
 #define __LOCAL_FLAGS_HPP__
 
-#include "flags/flags.hpp"
+#include <stout/flags.hpp>
+
+#include "logging/flags.hpp"
 
 namespace mesos {
 namespace internal {
 namespace local {
 
-class Flags : public virtual flags::FlagsBase
+class Flags : public logging::Flags
 {
 public:
   Flags()

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/local/local.cpp
----------------------------------------------------------------------
diff --git a/src/local/local.cpp b/src/local/local.cpp
index eb33e5d..c35c19a 100644
--- a/src/local/local.cpp
+++ b/src/local/local.cpp
@@ -25,9 +25,6 @@
 
 #include "local.hpp"
 
-#include "configurator/configuration.hpp"
-#include "configurator/configurator.hpp"
-
 #include "detector/detector.hpp"
 
 #include "logging/flags.hpp"
@@ -74,10 +71,8 @@ static MasterDetector* detector = NULL;
 static Files* files = NULL;
 
 
-PID<Master> launch(const Configuration& configuration, Allocator* _allocator)
+PID<Master> launch(const Flags& flags, Allocator* _allocator)
 {
-  int numSlaves = configuration.get<int>("num_slaves", 1);
-
   if (master != NULL) {
     LOG(FATAL) << "Can only launch one local cluster at a time (for now)";
   }
@@ -97,7 +92,11 @@ PID<Master> launch(const Configuration& configuration, Allocator* _allocator)
 
   {
     master::Flags flags;
-    flags.load(configuration.getMap());
+    Try<Nothing> load = flags.load("MESOS_", true); // Allow unknown flags.
+    if (load.isError()) {
+      EXIT(1) << "Failed to start a local cluster while loading "
+              << "master flags from the environment: " << load.error();
+    }
     master = new Master(_allocator, files, flags);
   }
 
@@ -105,13 +104,17 @@ PID<Master> launch(const Configuration& configuration, Allocator* _allocator)
 
   vector<UPID> pids;
 
-  slave::Flags flags;
-  flags.load(configuration.getMap());
-
-  for (int i = 0; i < numSlaves; i++) {
+  for (int i = 0; i < flags.num_slaves; i++) {
     // TODO(benh): Create a local isolator?
     ProcessIsolator* isolator = new ProcessIsolator();
 
+    slave::Flags flags;
+    Try<Nothing> load = flags.load("MESOS_", true); // Allow unknown flags.
+    if (load.isError()) {
+      EXIT(1) << "Failed to start a local cluster while loading "
+              << "slave flags from the environment: " << load.error();
+    }
+
     // Use a different work directory for each slave.
     flags.work_dir = path::join(flags.work_dir, stringify(i));
 

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/local/local.hpp
----------------------------------------------------------------------
diff --git a/src/local/local.hpp b/src/local/local.hpp
index 51324e2..a165265 100644
--- a/src/local/local.hpp
+++ b/src/local/local.hpp
@@ -21,6 +21,8 @@
 
 #include <process/process.hpp>
 
+#include "local/flags.hpp"
+
 namespace mesos {
 namespace internal {
 
@@ -36,9 +38,9 @@ class Configuration;
 
 namespace local {
 
-// Launch a local cluster with a given configuration.
+// Launch a local cluster with the given flags.
 process::PID<master::Master> launch(
-    const Configuration& configuration,
+    const Flags& flags,
     master::Allocator* _allocator = NULL);
 
 

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/local/main.cpp
----------------------------------------------------------------------
diff --git a/src/local/main.cpp b/src/local/main.cpp
index d2e632a..5995c53 100644
--- a/src/local/main.cpp
+++ b/src/local/main.cpp
@@ -22,8 +22,6 @@
 #include <stout/os.hpp>
 #include <stout/stringify.hpp>
 
-#include "configurator/configurator.hpp"
-
 #include "detector/detector.hpp"
 
 #include "local/flags.hpp"
@@ -45,14 +43,14 @@ using std::endl;
 using std::string;
 
 
-void usage(const char* argv0, const Configurator& configurator)
+void usage(const char* argv0, const flags::FlagsBase& flags)
 {
   cerr << "Usage: " << os::basename(argv0).get() << " [...]" << endl
        << endl
-       << "Launches a cluster within a single OS process."
+       << "Launches an in-memory cluster within a single process."
        << endl
        << "Supported options:" << endl
-       << configurator.getUsage();
+       << flags.usage();
 }
 
 
@@ -60,7 +58,11 @@ int main(int argc, char **argv)
 {
   GOOGLE_PROTOBUF_VERIFY_VERSION;
 
-  flags::Flags<logging::Flags, local::Flags> flags;
+  // TODO(benh): Inherit from both slave::Flags and master::Flags in
+  // 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;
 
   // The following flags are executable specific (e.g., since we only
   // have one instance of libprocess per execution, we only want to
@@ -77,20 +79,18 @@ int main(int argc, char **argv)
             "Prints this help message",
             false);
 
-  Configurator configurator(flags);
-  Configuration configuration;
-  try {
-    configuration = configurator.load(argc, argv);
-  } catch (ConfigurationException& e) {
-    cerr << "Configuration error: " << e.what() << endl;
-    usage(argv[0], configurator);
+  // Load flags from environment and command line but allow unknown
+  // flags since we might have some master/slave flags as well.
+  Try<Nothing> load = flags.load("MESOS_", argc, argv, true);
+
+  if (load.isError()) {
+    cerr << load.error() << endl;
+    usage(argv[0], flags);
     exit(1);
   }
 
-  flags.load(configuration.getMap());
-
   if (help) {
-    usage(argv[0], configurator);
+    usage(argv[0], flags);
     exit(1);
   }
 
@@ -105,7 +105,7 @@ int main(int argc, char **argv)
 
   logging::initialize(argv[0], flags);
 
-  process::wait(local::launch(configuration));
+  process::wait(local::launch(flags));
 
   return 0;
 }

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/log/main.cpp
----------------------------------------------------------------------
diff --git a/src/log/main.cpp b/src/log/main.cpp
index 24b9d8b..18a1b23 100644
--- a/src/log/main.cpp
+++ b/src/log/main.cpp
@@ -22,15 +22,12 @@
 
 #include <process/process.hpp>
 
+#include <stout/flags.hpp>
 #include <stout/foreach.hpp>
+#include <stout/none.hpp>
 #include <stout/option.hpp>
 #include <stout/os.hpp>
 
-#include "configurator/configurator.hpp"
-#include "configurator/configuration.hpp"
-
-#include "flags/flags.hpp"
-
 #include "log/replica.hpp"
 
 #include "logging/flags.hpp"
@@ -46,12 +43,12 @@ using std::endl;
 using std::string;
 
 
-void usage(const char* argv0, const Configurator& configurator)
+void usage(const char* argv0, const flags::FlagsBase& flags)
 {
   cerr << "Usage: " << os::basename(argv0).get() << " [...] path/to/log"
        << endl
        << "Supported options:" << endl
-       << configurator.getUsage();
+       << flags.usage();
 }
 
 
@@ -75,20 +72,16 @@ int main(int argc, char** argv)
             "Prints this help message",
             false);
 
-  Configurator configurator(flags);
-  Configuration configuration;
-  try {
-    configuration = configurator.load(argc, argv);
-  } catch (ConfigurationException& e) {
-    cerr << "Configuration error: " << e.what() << endl;
-    usage(argv[0], configurator);
+  Try<Nothing> load = flags.load(None(), argc, argv);
+
+  if (load.isError()) {
+    cerr << load.error() << endl;
+    usage(argv[0], flags);
     exit(1);
   }
 
-  flags.load(configuration.getMap());
-
   if (help) {
-    usage(argv[0], configurator);
+    usage(argv[0], flags);
     exit(1);
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/logging/flags.hpp
----------------------------------------------------------------------
diff --git a/src/logging/flags.hpp b/src/logging/flags.hpp
index 4a96316..e2e4afc 100644
--- a/src/logging/flags.hpp
+++ b/src/logging/flags.hpp
@@ -21,10 +21,9 @@
 
 #include <string>
 
+#include <stout/flags.hpp>
 #include <stout/option.hpp>
 
-#include "flags/flags.hpp"
-
 namespace mesos {
 namespace internal {
 namespace logging {

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/logging/logging.hpp
----------------------------------------------------------------------
diff --git a/src/logging/logging.hpp b/src/logging/logging.hpp
index 0e90ef1..56fbbd4 100644
--- a/src/logging/logging.hpp
+++ b/src/logging/logging.hpp
@@ -23,9 +23,6 @@
 
 #include <glog/logging.h> // Includes LOG(*), PLOG(*), CHECK, etc.
 
-#include "configurator/configuration.hpp"
-#include "configurator/configurator.hpp"
-
 #include "logging/check_some.hpp"
 #include "logging/flags.hpp"
 

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/master/flags.hpp
----------------------------------------------------------------------
diff --git a/src/master/flags.hpp b/src/master/flags.hpp
index 23154f3..f4ce8c1 100644
--- a/src/master/flags.hpp
+++ b/src/master/flags.hpp
@@ -22,8 +22,7 @@
 #include <string>
 
 #include <stout/duration.hpp>
-
-#include "flags/flags.hpp"
+#include <stout/flags.hpp>
 
 #include "logging/flags.hpp"
 

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/master/main.cpp
----------------------------------------------------------------------
diff --git a/src/master/main.cpp b/src/master/main.cpp
index 06c265a..79a912c 100644
--- a/src/master/main.cpp
+++ b/src/master/main.cpp
@@ -18,19 +18,16 @@
 
 #include <mesos/mesos.hpp>
 
+#include <stout/flags.hpp>
+#include <stout/nothing.hpp>
 #include <stout/os.hpp>
 #include <stout/stringify.hpp>
 #include <stout/try.hpp>
 
 #include "common/build.hpp"
 
-#include "configurator/configuration.hpp"
-#include "configurator/configurator.hpp"
-
 #include "detector/detector.hpp"
 
-#include "flags/flags.hpp"
-
 #include "logging/flags.hpp"
 #include "logging/logging.hpp"
 
@@ -49,12 +46,12 @@ using std::endl;
 using std::string;
 
 
-void usage(const char* argv0, const Configurator& configurator)
+void usage(const char* argv0, const flags::FlagsBase& flags)
 {
   cerr << "Usage: " << os::basename(argv0).get() << " [...]" << endl
        << endl
        << "Supported options:" << endl
-       << configurator.getUsage();
+       << flags.usage();
 }
 
 
@@ -89,20 +86,16 @@ int main(int argc, char** argv)
             "Prints this help message",
             false);
 
-  Configurator configurator(flags);
-  Configuration configuration;
-  try {
-    configuration = configurator.load(argc, argv);
-  } catch (ConfigurationException& e) {
-    cerr << "Configuration error: " << e.what() << endl;
-    usage(argv[0], configurator);
+  Try<Nothing> load = flags.load("MESOS_", argc, argv);
+
+  if (load.isError()) {
+    cerr << load.error() << endl;
+    usage(argv[0], flags);
     exit(1);
   }
 
-  flags.load(configuration.getMap());
-
   if (help) {
-    usage(argv[0], configurator);
+    usage(argv[0], flags);
     exit(1);
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 5ee7763..cbc40e1 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -36,8 +36,6 @@
 #include "common/date_utils.hpp"
 #include "common/protobuf_utils.hpp"
 
-#include "flags/flags.hpp"
-
 #include "logging/flags.hpp"
 #include "logging/logging.hpp"
 

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index 38d2a51..82e3596 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -41,10 +41,6 @@
 #include "common/type_utils.hpp"
 #include "common/units.hpp"
 
-#include "flags/flags.hpp"
-
-#include "logging/flags.hpp"
-
 #include "files/files.hpp"
 
 #include "master/constants.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/mesos/main.cpp
----------------------------------------------------------------------
diff --git a/src/mesos/main.cpp b/src/mesos/main.cpp
index e7d0837..f633ae1 100644
--- a/src/mesos/main.cpp
+++ b/src/mesos/main.cpp
@@ -1,109 +1,8 @@
-#include <process/process.hpp>
-#include <process/protobuf.hpp>
-
-#include <stout/os.hpp>
-
-#include "configurator/configurator.hpp"
-
-#include "messages/messages.hpp"
-
-using namespace mesos::internal;
-
-using namespace process;
-
-using std::cerr;
-using std::cout;
-using std::endl;
-using std::string;
-
-
-void usage(const char* argv0, const Configurator& configurator)
-{
-  cerr << "Usage: " << os::basename(argv0).get() << " [...]" << endl
-       << endl
-       << "Supported options:" << endl
-       << configurator.getUsage();
-}
+#include <stout/exit.hpp>
 
 
 int main(int argc, char** argv)
 {
-  GOOGLE_PROTOBUF_VERIFY_VERSION;
-
-  Configurator configurator;
-
-  // The following options 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).
-  configurator.addOption<int>("port", 'p', "Port to listen on", 5050);
-  configurator.addOption<string>("ip", "IP address to listen on");
-  configurator.addOption<string>(
-      "master",
-      'm',
-      "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)");
-
-  if (argc == 2 && string("--help") == argv[1]) {
-    usage(argv[0], configurator);
-    exit(1);
-  }
-
-  Configuration conf;
-  try {
-    conf = configurator.load(argc, argv);
-  } catch (const ConfigurationException& e) {
-    cerr << "Configuration error: " << e.what() << endl;
-    exit(1);
-  }
-
-  // Initialize libprocess.
-  process::initialize();
-
-  if (!conf.contains("master")) {
-    cerr << "Missing required option --master (-m)" << endl;
-    usage(argv[0], configurator);
-    exit(1);
-  }
-
-  // TODO(vinod): Parse 'master' when we add ZooKeeper support.
-  UPID master(conf["master"]);
-
-  if (!master) {
-    cerr << "Could not parse --master=" << conf["master"] << endl;
-    usage(argv[0], configurator);
-    exit(1);
-  }
-
-  if (!conf.contains("name")) {
-    // TODO(benh): Need to add '--name' as an option.
-    cerr << "Missing --name (-n)" << endl;
-    usage(argv[0], configurator);
-    exit(1);
-  }
-
-  LOG(INFO) << "Submitting scheduler ...";
-
-  Protocol<SubmitSchedulerRequest, SubmitSchedulerResponse> submit;
-
-  SubmitSchedulerRequest request;
-  request.set_name(conf["name"]);
-
-  Future<SubmitSchedulerResponse> future = submit(master, request);
-
-  future.await(Seconds(5));
-
-  if (future.isReady()) {
-    if (future.get().okay()) {
-      cout << "Scheduler submitted successfully" << endl;
-    } else {
-      cout << "Failed to submit scheduler" << endl;
-    }
-  } else {
-    cout << "Timed out waiting for response from submitting scheduler" << endl;
-  }
-
+  EXIT(1) << "Unimplemented";
   return 0;
 }

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/sched/sched.cpp
----------------------------------------------------------------------
diff --git a/src/sched/sched.cpp b/src/sched/sched.cpp
index e19251b..248e12e 100644
--- a/src/sched/sched.cpp
+++ b/src/sched/sched.cpp
@@ -40,21 +40,16 @@
 
 #include <stout/duration.hpp>
 #include <stout/error.hpp>
-#include <stout/fatal.hpp>
+#include <stout/flags.hpp>
 #include <stout/hashmap.hpp>
 #include <stout/os.hpp>
 #include <stout/uuid.hpp>
 
-#include "configurator/configuration.hpp"
-#include "configurator/configurator.hpp"
-
 #include "common/lock.hpp"
 #include "common/type_utils.hpp"
 
 #include "detector/detector.hpp"
 
-#include "flags/flags.hpp"
-
 #include "local/local.hpp"
 
 #include "logging/flags.hpp"
@@ -676,35 +671,26 @@ MesosSchedulerDriver::MesosSchedulerDriver(
 {
   GOOGLE_PROTOBUF_VERIFY_VERSION;
 
-  // Load the configuration. For now, we just load all key/value pairs
-  // from the environment (and possibly a file if specified) but don't
-  // actually do any validation on them (since we don't register any
-  // options). Any "validation" necessary will be done when we load
-  // the configuration into flags (i.e., below when we initialize
-  // logging or inside of local::launch).
-  Configurator configurator;
-  Configuration configuration;
-  try {
-    configuration = configurator.load();
-  } catch (ConfigurationException& e) {
+  // Load any flags from the environment (we use local::Flags in the
+  // event we run in 'local' mode, since it inherits
+  // logging::Flags). In the future, just as the TODO in
+  // local/main.cpp discusses, we'll probably want a way to load
+  // master::Flags and slave::Flags as well. For now, we need to allow
+  // unknown flags in the event there are flags for the master/slave
+  // in the environment.
+  local::Flags flags;
+
+  Try<Nothing> load = flags.load("MESOS_", true); // Allow unknown flags.
+
+  if (load.isError()) {
     status = DRIVER_ABORTED;
-    string message = string("Configuration error: ") + e.what();
-    scheduler->error(this, message);
+    scheduler->error(this, load.error());
     return;
   }
 
-  flags::Flags<logging::Flags> flags;
-
-  flags.load(configuration.getMap());
-
   // Initialize libprocess.
   process::initialize();
 
-  // TODO(benh): Consider eliminating 'localquiet' so that we don't
-  // have to have weird semantics when the 'quiet' option is set to
-  // false but 'localquiet' is being used.
-  configuration.set("quiet", master == "localquiet");
-
   // TODO(benh): Replace whitespace in framework.name() with '_'?
   logging::initialize(framework.name(), flags);
 
@@ -729,8 +715,8 @@ MesosSchedulerDriver::MesosSchedulerDriver(
 
   // Launch a local cluster if necessary.
   Option<UPID> pid;
-  if (master == "local" || master == "localquiet") {
-    pid = local::launch(configuration);
+  if (master == "local") {
+    pid = local::launch(flags);
   }
 
   CHECK(process == NULL);

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/slave/flags.hpp
----------------------------------------------------------------------
diff --git a/src/slave/flags.hpp b/src/slave/flags.hpp
index f3cbe3d..9612983 100644
--- a/src/slave/flags.hpp
+++ b/src/slave/flags.hpp
@@ -22,10 +22,9 @@
 #include <string>
 
 #include <stout/duration.hpp>
+#include <stout/flags.hpp>
 #include <stout/option.hpp>
 
-#include "flags/flags.hpp"
-
 #include "logging/flags.hpp"
 
 #include "slave/constants.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/slave/main.cpp
----------------------------------------------------------------------
diff --git a/src/slave/main.cpp b/src/slave/main.cpp
index 97c818a..1d3431f 100644
--- a/src/slave/main.cpp
+++ b/src/slave/main.cpp
@@ -18,20 +18,16 @@
 
 #include <mesos/mesos.hpp>
 
+#include <stout/flags.hpp>
+#include <stout/nothing.hpp>
 #include <stout/os.hpp>
 #include <stout/stringify.hpp>
 #include <stout/try.hpp>
 
 #include "common/build.hpp"
 
-#include "configurator/configuration.hpp"
-#include "configurator/configurator.hpp"
-
 #include "detector/detector.hpp"
 
-#include "flags/flags.hpp"
-
-#include "logging/flags.hpp"
 #include "logging/logging.hpp"
 
 #include "slave/slave.hpp"
@@ -46,12 +42,12 @@ using std::endl;
 using std::string;
 
 
-void usage(const char* argv0, const Configurator& configurator)
+void usage(const char* argv0, const flags::FlagsBase& flags)
 {
   cerr << "Usage: " << os::basename(argv0).get() << " [...]" << endl
        << endl
        << "Supported options:" << endl
-       << configurator.getUsage();
+       << flags.usage();
 }
 
 
@@ -90,20 +86,16 @@ int main(int argc, char** argv)
             "Prints this help message",
             false);
 
-  Configurator configurator(flags);
-  Configuration configuration;
-  try {
-    configuration = configurator.load(argc, argv);
-  } catch (ConfigurationException& e) {
-    cerr << "Configuration error: " << e.what() << endl;
-    usage(argv[0], configurator);
+  Try<Nothing> load = flags.load("MESOS_", argc, argv);
+
+  if (load.isError()) {
+    cerr << load.error() << endl;
+    usage(argv[0], flags);
     exit(1);
   }
 
-  flags.load(configuration.getMap());
-
   if (help) {
-    usage(argv[0], configurator);
+    usage(argv[0], flags);
     exit(1);
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/29183c1b/src/tests/allocator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/allocator_tests.cpp b/src/tests/allocator_tests.cpp
index 52e2b03..b153dee 100644
--- a/src/tests/allocator_tests.cpp
+++ b/src/tests/allocator_tests.cpp
@@ -26,8 +26,6 @@
 #include <process/gmock.hpp>
 #include <process/pid.hpp>
 
-#include "configurator/configuration.hpp"
-
 #include "detector/detector.hpp"
 
 #include "master/allocator.hpp"