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 2012/08/09 20:09:26 UTC

svn commit: r1371350 - in /incubator/mesos/trunk/src/examples: balloon_executor.cpp balloon_framework.cpp

Author: benh
Date: Thu Aug  9 18:09:26 2012
New Revision: 1371350

URL: http://svn.apache.org/viewvc?rev=1371350&view=rev
Log:
Move a constant to ballon executor instead of passing through executor
info (contributed by Jie Yu, https://reviews.apache.org/r/6445).

Modified:
    incubator/mesos/trunk/src/examples/balloon_executor.cpp
    incubator/mesos/trunk/src/examples/balloon_framework.cpp

Modified: incubator/mesos/trunk/src/examples/balloon_executor.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/examples/balloon_executor.cpp?rev=1371350&r1=1371349&r2=1371350&view=diff
==============================================================================
--- incubator/mesos/trunk/src/examples/balloon_executor.cpp (original)
+++ incubator/mesos/trunk/src/examples/balloon_executor.cpp Thu Aug  9 18:09:26 2012
@@ -31,15 +31,19 @@
 using namespace mesos;
 
 
+// The amount of memory in MB each balloon step consumes.
+const static size_t BALLOON_STEP_MB = 64;
+
+
 // This function will increase the memory footprint gradually. The parameter
 // limit specifies the upper limit (in MB) of the memory footprint. The
 // parameter step specifies the step size (in MB).
-static void balloon(size_t limit, size_t step)
+static void balloon(size_t limit)
 {
-  size_t chunk = step * 1024 * 1024;
-  for (size_t i = 0; i < limit / step; i++) {
+  size_t chunk = BALLOON_STEP_MB * 1024 * 1024;
+  for (size_t i = 0; i < limit / BALLOON_STEP_MB; i++) {
     std::cout << "Increasing memory footprint by "
-              << step << " MB" << std::endl;
+              << BALLOON_STEP_MB << " MB" << std::endl;
 
     // Allocate virtual memory.
     char* buffer = (char *)malloc(chunk);
@@ -66,11 +70,6 @@ public:
                           const FrameworkInfo& frameworkInfo,
                           const SlaveInfo& slaveInfo)
   {
-    // Setup balloon step.
-    Try<size_t> step = numify<size_t>(executorInfo.data());
-    assert(step.isSome());
-    balloonStep = step.get();
-
     std::cout << "Registered" << std::endl;
   }
 
@@ -105,7 +104,7 @@ public:
     // of memory allocated to this executor. In that case, the isolation module
     // (e.g. cgroups) should be able to detect that and the task should not be
     // able to reach TASK_FINISHED state.
-    balloon(balloonLimit, balloonStep);
+    balloon(balloonLimit);
 
     std::cout << "Finishing task " << task.task_id().value() << std::endl;
 
@@ -134,10 +133,6 @@ public:
   {
     std::cout << "Error message: " << message << std::endl;
   }
-
-private:
-  // The amount of memory in MB each balloon step consumes.
-  size_t balloonStep;
 };
 
 

Modified: incubator/mesos/trunk/src/examples/balloon_framework.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/examples/balloon_framework.cpp?rev=1371350&r1=1371349&r2=1371350&view=diff
==============================================================================
--- incubator/mesos/trunk/src/examples/balloon_framework.cpp (original)
+++ incubator/mesos/trunk/src/examples/balloon_framework.cpp Thu Aug  9 18:09:26 2012
@@ -39,9 +39,6 @@ using namespace mesos;
 // The amount of memory in MB the executor itself takes.
 const static size_t EXECUTOR_MEMORY_MB = 64;
 
-// The amount of memory in MB each balloon step consumes.
-const static size_t BALLOON_STEP_MB = 64;
-
 
 class BalloonScheduler : public Scheduler
 {
@@ -192,7 +189,6 @@ int main(int argc, char** argv)
   ExecutorInfo executor;
   executor.mutable_executor_id()->set_value("default");
   executor.mutable_command()->set_value(uri);
-  executor.set_data(stringify<size_t>(BALLOON_STEP_MB));
 
   Resource* mem = executor.add_resources();
   mem->set_name("mem");