mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ji...@apache.org
Subject mesos git commit: Moved NoopResourceEstimator to a separate file.
Date Wed, 03 Jun 2015 17:05:59 GMT
Repository: mesos
Updated Branches:
  refs/heads/master ffbdc78ed -> d983bc6a5


Moved NoopResourceEstimator to a separate file.

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


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

Branch: refs/heads/master
Commit: d983bc6a5ff2ea5c287c4a2d307b13f9f3765885
Parents: ffbdc78
Author: Jie Yu <yujie.jay@gmail.com>
Authored: Tue Jun 2 16:09:35 2015 -0700
Committer: Jie Yu <yujie.jay@gmail.com>
Committed: Wed Jun 3 10:05:33 2015 -0700

----------------------------------------------------------------------
 src/Makefile.am                                 |  7 +-
 src/examples/test_resource_estimator_module.cpp |  3 +-
 src/local/local.cpp                             |  3 +-
 src/slave/main.cpp                              |  3 +-
 src/slave/resource_estimator.cpp                | 70 +---------------
 src/slave/resource_estimator.hpp                | 54 ------------
 src/slave/resource_estimators/noop.cpp          | 88 ++++++++++++++++++++
 src/slave/resource_estimators/noop.hpp          | 54 ++++++++++++
 src/tests/cluster.hpp                           |  3 +-
 9 files changed, 155 insertions(+), 130 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/d983bc6a/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index f045b89..66030c4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -389,8 +389,9 @@ libmesos_no_3rdparty_la_SOURCES =					\
 	slave/monitor.cpp						\
 	slave/paths.cpp							\
 	slave/resource_estimator.cpp					\
-	slave/state.cpp							\
 	slave/slave.cpp							\
+	slave/state.cpp							\
+	slave/status_update_manager.cpp					\
 	slave/containerizer/containerizer.cpp				\
 	slave/containerizer/composing.cpp				\
 	slave/containerizer/composing.hpp				\
@@ -403,7 +404,7 @@ libmesos_no_3rdparty_la_SOURCES =					\
 	slave/containerizer/launcher.cpp				\
 	slave/containerizer/mesos/containerizer.cpp			\
 	slave/containerizer/mesos/launch.cpp				\
-	slave/status_update_manager.cpp					\
+	slave/resource_estimators/noop.cpp				\
 	usage/usage.cpp							\
 	watcher/whitelist_watcher.cpp					\
 	zookeeper/contender.cpp						\
@@ -610,7 +611,6 @@ libmesos_no_3rdparty_la_SOURCES +=					\
 	slave/metrics.hpp						\
 	slave/monitor.hpp						\
 	slave/paths.hpp							\
-	slave/resource_estimator.hpp					\
 	slave/slave.hpp							\
 	slave/state.hpp							\
 	slave/status_update_manager.hpp					\
@@ -629,6 +629,7 @@ libmesos_no_3rdparty_la_SOURCES +=					\
 	slave/containerizer/isolators/cgroups/perf_event.hpp		\
 	slave/containerizer/isolators/namespaces/pid.hpp		\
 	slave/containerizer/isolators/filesystem/shared.hpp		\
+	slave/resource_estimators/noop.hpp				\
 	tests/cluster.hpp						\
 	tests/containerizer.hpp						\
 	tests/environment.hpp						\

http://git-wip-us.apache.org/repos/asf/mesos/blob/d983bc6a/src/examples/test_resource_estimator_module.cpp
----------------------------------------------------------------------
diff --git a/src/examples/test_resource_estimator_module.cpp b/src/examples/test_resource_estimator_module.cpp
index df85978..86375c9 100644
--- a/src/examples/test_resource_estimator_module.cpp
+++ b/src/examples/test_resource_estimator_module.cpp
@@ -26,7 +26,8 @@
 #include <mesos/slave/resource_estimator.hpp>
 
 #include <stout/try.hpp>
-#include <slave/resource_estimator.hpp>
+
+#include "slave/resource_estimators/noop.hpp"
 
 using namespace mesos;
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/d983bc6a/src/local/local.cpp
----------------------------------------------------------------------
diff --git a/src/local/local.cpp b/src/local/local.cpp
index 84f73e2..6bf4b77 100644
--- a/src/local/local.cpp
+++ b/src/local/local.cpp
@@ -27,6 +27,8 @@
 
 #include <mesos/module/anonymous.hpp>
 
+#include <mesos/slave/resource_estimator.hpp>
+
 #include <process/limiter.hpp>
 #include <process/owned.hpp>
 #include <process/pid.hpp>
@@ -60,7 +62,6 @@
 #include "module/manager.hpp"
 
 #include "slave/gc.hpp"
-#include "slave/resource_estimator.hpp"
 #include "slave/slave.hpp"
 #include "slave/status_update_manager.hpp"
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/d983bc6a/src/slave/main.cpp
----------------------------------------------------------------------
diff --git a/src/slave/main.cpp b/src/slave/main.cpp
index e3a45f4..c4d8940 100644
--- a/src/slave/main.cpp
+++ b/src/slave/main.cpp
@@ -22,6 +22,8 @@
 
 #include <mesos/module/anonymous.hpp>
 
+#include <mesos/slave/resource_estimator.hpp>
+
 #include <stout/check.hpp>
 #include <stout/flags.hpp>
 #include <stout/nothing.hpp>
@@ -42,7 +44,6 @@
 #include "module/manager.hpp"
 
 #include "slave/gc.hpp"
-#include "slave/resource_estimator.hpp"
 #include "slave/slave.hpp"
 #include "slave/status_update_manager.hpp"
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/d983bc6a/src/slave/resource_estimator.cpp
----------------------------------------------------------------------
diff --git a/src/slave/resource_estimator.cpp b/src/slave/resource_estimator.cpp
index a67640c..5aaf305 100644
--- a/src/slave/resource_estimator.cpp
+++ b/src/slave/resource_estimator.cpp
@@ -16,14 +16,9 @@
  * limitations under the License.
  */
 
-#include <process/dispatch.hpp>
-#include <process/process.hpp>
-
 #include <stout/error.hpp>
 
-#include "slave/resource_estimator.hpp"
-
-using namespace process;
+#include "slave/resource_estimators/noop.hpp"
 
 using std::string;
 
@@ -42,66 +37,3 @@ Try<ResourceEstimator*> ResourceEstimator::create(const Option<string>&
type)
 
 } // namespace slave {
 } // namespace mesos {
-
-
-namespace mesos {
-namespace internal {
-namespace slave {
-
-class NoopResourceEstimatorProcess :
-  public Process<NoopResourceEstimatorProcess>
-{
-public:
-  NoopResourceEstimatorProcess() : sent(false) {}
-
-  Future<Resources> oversubscribable()
-  {
-    if (!sent) {
-      sent = true;
-      return Resources();
-    }
-
-    return Future<Resources>();
-  }
-
-private:
-  bool sent;
-};
-
-
-NoopResourceEstimator::~NoopResourceEstimator()
-{
-  if (process.get() != NULL) {
-    terminate(process.get());
-    wait(process.get());
-  }
-}
-
-
-Try<Nothing> NoopResourceEstimator::initialize()
-{
-  if (process.get() != NULL) {
-    return Error("Noop resource estimator has already been initialized");
-  }
-
-  process.reset(new NoopResourceEstimatorProcess());
-  spawn(process.get());
-
-  return Nothing();
-}
-
-
-Future<Resources> NoopResourceEstimator::oversubscribable()
-{
-  if (process.get() == NULL) {
-    return Failure("Noop resource estimator is not initialized");
-  }
-
-  return dispatch(
-      process.get(),
-      &NoopResourceEstimatorProcess::oversubscribable);
-}
-
-} // namespace slave {
-} // namespace internal {
-} // namespace mesos {

http://git-wip-us.apache.org/repos/asf/mesos/blob/d983bc6a/src/slave/resource_estimator.hpp
----------------------------------------------------------------------
diff --git a/src/slave/resource_estimator.hpp b/src/slave/resource_estimator.hpp
deleted file mode 100644
index 717804d..0000000
--- a/src/slave/resource_estimator.hpp
+++ /dev/null
@@ -1,54 +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 __SLAVE_RESOURCE_ESTIMATOR_HPP__
-#define __SLAVE_RESOURCE_ESTIMATOR_HPP__
-
-#include <mesos/slave/resource_estimator.hpp>
-
-#include <process/owned.hpp>
-
-namespace mesos {
-namespace internal {
-namespace slave {
-
-// Forward declaration.
-class NoopResourceEstimatorProcess;
-
-
-// A noop resource estimator which tells the master that no resource
-// on the slave can be oversubscribed. Using this resource estimator
-// will effectively turn off the oversubscription on the slave.
-class NoopResourceEstimator : public mesos::slave::ResourceEstimator
-{
-public:
-  virtual ~NoopResourceEstimator();
-
-  virtual Try<Nothing> initialize();
-  virtual process::Future<Resources> oversubscribable();
-
-protected:
-  process::Owned<NoopResourceEstimatorProcess> process;
-};
-
-
-} // namespace slave {
-} // namespace internal {
-} // namespace mesos {
-
-#endif // __SLAVE_RESOURCE_ESTIMATOR_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/d983bc6a/src/slave/resource_estimators/noop.cpp
----------------------------------------------------------------------
diff --git a/src/slave/resource_estimators/noop.cpp b/src/slave/resource_estimators/noop.cpp
new file mode 100644
index 0000000..3fb44d6
--- /dev/null
+++ b/src/slave/resource_estimators/noop.cpp
@@ -0,0 +1,88 @@
+/**
+ * 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 <process/dispatch.hpp>
+#include <process/process.hpp>
+
+#include <stout/error.hpp>
+
+#include "slave/resource_estimators/noop.hpp"
+
+using namespace process;
+
+namespace mesos {
+namespace internal {
+namespace slave {
+
+class NoopResourceEstimatorProcess :
+  public Process<NoopResourceEstimatorProcess>
+{
+public:
+  NoopResourceEstimatorProcess() : sent(false) {}
+
+  Future<Resources> oversubscribable()
+  {
+    if (!sent) {
+      sent = true;
+      return Resources();
+    }
+
+    return Future<Resources>();
+  }
+
+private:
+  bool sent;
+};
+
+
+NoopResourceEstimator::~NoopResourceEstimator()
+{
+  if (process.get() != NULL) {
+    terminate(process.get());
+    wait(process.get());
+  }
+}
+
+
+Try<Nothing> NoopResourceEstimator::initialize()
+{
+  if (process.get() != NULL) {
+    return Error("Noop resource estimator has already been initialized");
+  }
+
+  process.reset(new NoopResourceEstimatorProcess());
+  spawn(process.get());
+
+  return Nothing();
+}
+
+
+Future<Resources> NoopResourceEstimator::oversubscribable()
+{
+  if (process.get() == NULL) {
+    return Failure("Noop resource estimator is not initialized");
+  }
+
+  return dispatch(
+      process.get(),
+      &NoopResourceEstimatorProcess::oversubscribable);
+}
+
+} // namespace slave {
+} // namespace internal {
+} // namespace mesos {

http://git-wip-us.apache.org/repos/asf/mesos/blob/d983bc6a/src/slave/resource_estimators/noop.hpp
----------------------------------------------------------------------
diff --git a/src/slave/resource_estimators/noop.hpp b/src/slave/resource_estimators/noop.hpp
new file mode 100644
index 0000000..2234ed6
--- /dev/null
+++ b/src/slave/resource_estimators/noop.hpp
@@ -0,0 +1,54 @@
+/**
+ * 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 __SLAVE_RESOURCE_ESTIMATORS_NOOP_HPP__
+#define __SLAVE_RESOURCE_ESTIMATORS_NOOP_HPP__
+
+#include <mesos/slave/resource_estimator.hpp>
+
+#include <process/owned.hpp>
+
+namespace mesos {
+namespace internal {
+namespace slave {
+
+// Forward declaration.
+class NoopResourceEstimatorProcess;
+
+
+// A noop resource estimator which tells the master that no resource
+// on the slave can be oversubscribed. Using this resource estimator
+// will effectively turn off the oversubscription on the slave.
+class NoopResourceEstimator : public mesos::slave::ResourceEstimator
+{
+public:
+  virtual ~NoopResourceEstimator();
+
+  virtual Try<Nothing> initialize();
+  virtual process::Future<Resources> oversubscribable();
+
+protected:
+  process::Owned<NoopResourceEstimatorProcess> process;
+};
+
+
+} // namespace slave {
+} // namespace internal {
+} // namespace mesos {
+
+#endif // __SLAVE_RESOURCE_ESTIMATORS_NOOP_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/d983bc6a/src/tests/cluster.hpp
----------------------------------------------------------------------
diff --git a/src/tests/cluster.hpp b/src/tests/cluster.hpp
index 7370c77..f5a7c54 100644
--- a/src/tests/cluster.hpp
+++ b/src/tests/cluster.hpp
@@ -28,6 +28,8 @@
 
 #include <mesos/master/allocator.hpp>
 
+#include <mesos/slave/resource_estimator.hpp>
+
 #include <process/clock.hpp>
 #include <process/future.hpp>
 #include <process/gmock.hpp>
@@ -70,7 +72,6 @@
 
 #include "slave/flags.hpp"
 #include "slave/gc.hpp"
-#include "slave/resource_estimator.hpp"
 #include "slave/slave.hpp"
 #include "slave/status_update_manager.hpp"
 


Mime
View raw message