You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ti...@apache.org on 2015/06/22 16:43:00 UTC

mesos git commit: Updated containerizer to statically initialize isolator factories.

Repository: mesos
Updated Branches:
  refs/heads/master 441dd02cd -> b9b9035c0


Updated containerizer to statically initialize isolator factories.

Replaces dynamic hashmap creation with c++11's static initialization.

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


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

Branch: refs/heads/master
Commit: b9b9035c04468786e017ccf7f33b2fe8cf5a1358
Parents: 441dd02
Author: Jojy Varghese <jo...@mesosphere.io>
Authored: Mon Jun 22 16:18:05 2015 +0200
Committer: Till Toenshoff <to...@me.com>
Committed: Mon Jun 22 16:18:05 2015 +0200

----------------------------------------------------------------------
 src/slave/containerizer/mesos/containerizer.cpp | 24 ++++++++++----------
 1 file changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/b9b9035c/src/slave/containerizer/mesos/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.cpp b/src/slave/containerizer/mesos/containerizer.cpp
index 8c102fb..8dd2cb6 100644
--- a/src/slave/containerizer/mesos/containerizer.cpp
+++ b/src/slave/containerizer/mesos/containerizer.cpp
@@ -111,27 +111,27 @@ Try<MesosContainerizer*> MesosContainerizer::create(
   LOG(INFO) << "Using isolation: " << isolation;
 
   // Create a MesosContainerizerProcess using isolators and a launcher.
-  hashmap<string, Try<Isolator*> (*)(const Flags&)> creators;
-
-  creators["posix/cpu"]   = &PosixCpuIsolatorProcess::create;
-  creators["posix/mem"]   = &PosixMemIsolatorProcess::create;
-  creators["posix/disk"]  = &PosixDiskIsolatorProcess::create;
+  static const hashmap<string, Try<Isolator*> (*)(const Flags&)> creators = {
+    {"posix/cpu", &PosixCpuIsolatorProcess::create},
+    {"posix/mem", &PosixMemIsolatorProcess::create},
+    {"posix/disk", &PosixDiskIsolatorProcess::create},
 #ifdef __linux__
-  creators["cgroups/cpu"] = &CgroupsCpushareIsolatorProcess::create;
-  creators["cgroups/mem"] = &CgroupsMemIsolatorProcess::create;
-  creators["cgroups/perf_event"] = &CgroupsPerfEventIsolatorProcess::create;
-  creators["filesystem/shared"] = &SharedFilesystemIsolatorProcess::create;
-  creators["namespaces/pid"] = &NamespacesPidIsolatorProcess::create;
+    {"cgroups/cpu", &CgroupsCpushareIsolatorProcess::create},
+    {"cgroups/mem", &CgroupsMemIsolatorProcess::create},
+    {"cgroups/perf_event", &CgroupsPerfEventIsolatorProcess::create},
+    {"filesystem/shared", &SharedFilesystemIsolatorProcess::create},
+    {"namespaces/pid", &NamespacesPidIsolatorProcess::create},
 #endif // __linux__
 #ifdef WITH_NETWORK_ISOLATOR
-  creators["network/port_mapping"] = &PortMappingIsolatorProcess::create;
+    {"network/port_mapping", &PortMappingIsolatorProcess::create},
 #endif
+  };
 
   vector<Owned<Isolator>> isolators;
 
   foreach (const string& type, strings::tokenize(isolation, ",")) {
     if (creators.contains(type)) {
-      Try<Isolator*> isolator = creators[type](flags_);
+      Try<Isolator*> isolator = creators.at(type)(flags_);
       if (isolator.isError()) {
         return Error(
             "Could not create isolator " + type + ": " + isolator.error());