Adjust `using` style in a few places. When an identifier is used many times in an implementation file, we typically add a `using` statement for that identifier.
Review: https://reviews.apache.org/r/58084 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/631ed641 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/631ed641 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/631ed641 Branch: refs/heads/master Commit: 631ed6412b3f14f0bf117282be203f6cc71d1d24 Parents: 38dffd7 Author: Neil Conway <[email protected]> Authored: Thu Mar 30 09:40:44 2017 -0700 Committer: Neil Conway <[email protected]> Committed: Mon Apr 3 11:41:26 2017 -0700 ---------------------------------------------------------------------- src/common/build.cpp | 24 +++++++++++--------- src/slave/container_loggers/lib_logrotate.cpp | 21 +++++++++-------- src/tests/cluster.cpp | 14 +++++++----- .../composing_containerizer_tests.cpp | 10 +++++--- 4 files changed, 40 insertions(+), 29 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/631ed641/src/common/build.cpp ---------------------------------------------------------------------- diff --git a/src/common/build.cpp b/src/common/build.cpp index a87d2cf..4192b89 100644 --- a/src/common/build.cpp +++ b/src/common/build.cpp @@ -32,38 +32,40 @@ #include "common/build_config.hpp" #endif // USE_CMAKE_BUILD_CONFIG +using std::string; + namespace mesos { namespace internal { namespace build { -const std::string DATE = BUILD_DATE; +const string DATE = BUILD_DATE; const double TIME = atof(BUILD_TIME); #ifdef BUILD_USER -const std::string USER = BUILD_USER; +const string USER = BUILD_USER; #else -const std::string USER = ""; +const string USER = ""; #endif -const std::string FLAGS = BUILD_FLAGS; -const std::string JAVA_JVM_LIBRARY = BUILD_JAVA_JVM_LIBRARY; +const string FLAGS = BUILD_FLAGS; +const string JAVA_JVM_LIBRARY = BUILD_JAVA_JVM_LIBRARY; #ifdef BUILD_GIT_SHA -const Option<std::string> GIT_SHA = std::string(BUILD_GIT_SHA); +const Option<string> GIT_SHA = string(BUILD_GIT_SHA); #else -const Option<std::string> GIT_SHA = None(); +const Option<string> GIT_SHA = None(); #endif #ifdef BUILD_GIT_BRANCH -const Option<std::string> GIT_BRANCH = std::string(BUILD_GIT_BRANCH); +const Option<string> GIT_BRANCH = string(BUILD_GIT_BRANCH); #else -const Option<std::string> GIT_BRANCH = None(); +const Option<string> GIT_BRANCH = None(); #endif #ifdef BUILD_GIT_TAG -const Option<std::string> GIT_TAG = std::string(BUILD_GIT_TAG); +const Option<string> GIT_TAG = string(BUILD_GIT_TAG); #else -const Option<std::string> GIT_TAG = None(); +const Option<string> GIT_TAG = None(); #endif } // namespace build { } // namespace internal { http://git-wip-us.apache.org/repos/asf/mesos/blob/631ed641/src/slave/container_loggers/lib_logrotate.cpp ---------------------------------------------------------------------- diff --git a/src/slave/container_loggers/lib_logrotate.cpp b/src/slave/container_loggers/lib_logrotate.cpp index ae5d0ac..bc13e6a 100644 --- a/src/slave/container_loggers/lib_logrotate.cpp +++ b/src/slave/container_loggers/lib_logrotate.cpp @@ -55,6 +55,9 @@ using namespace mesos; using namespace process; +using std::map; +using std::string; + using mesos::slave::ContainerLogger; using mesos::slave::ContainerIO; @@ -73,16 +76,16 @@ public: // the files according to the configured maximum size and number of files. Future<ContainerIO> prepare( const ExecutorInfo& executorInfo, - const std::string& sandboxDirectory, - const Option<std::string>& user) + const string& sandboxDirectory, + const Option<string>& user) { // Prepare the environment for the container logger subprocess. // We inherit agent environment variables except for those // LIBPROCESS or MESOS prefixed environment variables. See MESOS-6747. - std::map<std::string, std::string> environment; + map<string, string> environment; foreachpair ( - const std::string& key, const std::string& value, os::environment()) { + const string& key, const string& value, os::environment()) { if (!strings::startsWith(key, "LIBPROCESS_") && !strings::startsWith(key, "MESOS_")) { environment.emplace(key, value); @@ -115,12 +118,12 @@ public: executorInfo.command().has_environment()) { // Search the environment for prefixed environment variables. // We un-prefix those variables before parsing the flag values. - std::map<std::string, std::string> executorEnvironment; + map<string, string> executorEnvironment; foreach (const Environment::Variable variable, executorInfo.command().environment().variables()) { if (strings::startsWith( variable.name(), flags.environment_variable_prefix)) { - std::string unprefixed = strings::lower(strings::remove( + string unprefixed = strings::lower(strings::remove( variable.name(), flags.environment_variable_prefix, strings::PREFIX)); @@ -287,8 +290,8 @@ Try<Nothing> LogrotateContainerLogger::initialize() Future<ContainerIO> LogrotateContainerLogger::prepare( const ExecutorInfo& executorInfo, - const std::string& sandboxDirectory, - const Option<std::string>& user) + const string& sandboxDirectory, + const Option<string>& user) { return dispatch( process.get(), @@ -313,7 +316,7 @@ org_apache_mesos_LogrotateContainerLogger( nullptr, [](const Parameters& parameters) -> ContainerLogger* { // Convert `parameters` into a map. - std::map<std::string, std::string> values; + map<string, string> values; foreach (const Parameter& parameter, parameters.parameter()) { values[parameter.key()] = parameter.value(); } http://git-wip-us.apache.org/repos/asf/mesos/blob/631ed641/src/tests/cluster.cpp ---------------------------------------------------------------------- diff --git a/src/tests/cluster.cpp b/src/tests/cluster.cpp index 7f09a0c..02590a2 100644 --- a/src/tests/cluster.cpp +++ b/src/tests/cluster.cpp @@ -92,6 +92,9 @@ #include "tests/cluster.hpp" #include "tests/mock_registrar.hpp" +using std::string; +using std::vector; + using mesos::master::contender::StandaloneMasterContender; using mesos::master::contender::ZooKeeperMasterContender; @@ -136,8 +139,7 @@ Try<process::Owned<Master>> Master::start( // authorization configuration for this master. bool authorizationSpecified = true; - std::vector<std::string> authorizerNames = - strings::split(flags.authorizers, ","); + vector<string> authorizerNames = strings::split(flags.authorizers, ","); if (authorizerNames.empty()) { return Error("No authorizer specified"); @@ -147,7 +149,7 @@ Try<process::Owned<Master>> Master::start( return Error("Multiple authorizers not supported"); } - std::string authorizerName = authorizerNames[0]; + string authorizerName = authorizerNames[0]; Result<Authorizer*> authorizer((None())); if (authorizerName != master::DEFAULT_AUTHORIZER) { @@ -260,7 +262,7 @@ Try<process::Owned<Master>> Master::start( // Parse the flag value. // TODO(vinod): Move this parsing logic to flags once we have a // 'Rate' abstraction in stout. - std::vector<std::string> tokens = + vector<string> tokens = strings::tokenize(flags.agent_removal_rate_limit.get(), "/"); if (tokens.size() != 2) { @@ -391,7 +393,7 @@ void Master::setAuthorizationCallbacks(Authorizer* authorizer) Try<process::Owned<Slave>> Slave::start( MasterDetector* detector, const slave::Flags& flags, - const Option<std::string>& id, + const Option<string>& id, const Option<slave::Containerizer*>& containerizer, const Option<slave::GarbageCollector*>& gc, const Option<slave::StatusUpdateManager*>& statusUpdateManager, @@ -432,7 +434,7 @@ Try<process::Owned<Slave>> Slave::start( // authorization configuration for this agent. bool authorizationSpecified = true; - std::string authorizerName = flags.authorizer; + string authorizerName = flags.authorizer; Result<Authorizer*> createdAuthorizer((None())); if (authorizerName != slave::DEFAULT_AUTHORIZER) { http://git-wip-us.apache.org/repos/asf/mesos/blob/631ed641/src/tests/containerizer/composing_containerizer_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/containerizer/composing_containerizer_tests.cpp b/src/tests/containerizer/composing_containerizer_tests.cpp index 934824c..d7fd621 100644 --- a/src/tests/containerizer/composing_containerizer_tests.cpp +++ b/src/tests/containerizer/composing_containerizer_tests.cpp @@ -14,6 +14,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include <map> +#include <string> #include <vector> #include <gmock/gmock.h> @@ -39,6 +41,8 @@ using namespace mesos::internal::slave; using namespace process; +using std::map; +using std::string; using std::vector; using testing::_; @@ -77,7 +81,7 @@ TEST_F(ComposingContainerizerTest, DestroyDuringUnsupportedLaunchLoop) TaskInfo taskInfo; ExecutorInfo executorInfo; SlaveID slaveId; - std::map<std::string, std::string> environment; + map<string, string> environment; Promise<bool> launchPromise; @@ -147,7 +151,7 @@ TEST_F(ComposingContainerizerTest, DestroyDuringSupportedLaunchLoop) TaskInfo taskInfo; ExecutorInfo executorInfo; SlaveID slaveId; - std::map<std::string, std::string> environment; + map<string, string> environment; Promise<bool> launchPromise; @@ -213,7 +217,7 @@ TEST_F(ComposingContainerizerTest, DestroyAfterLaunchLoop) TaskInfo taskInfo; ExecutorInfo executorInfo; SlaveID slaveId; - std::map<std::string, std::string> environment; + map<string, string> environment; Promise<bool> launchPromise;
