incubator-mesos-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Zhao (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MESOS-29) Where should the class SharesPrinter reside
Date Wed, 20 Jul 2011 01:03:59 GMT

    [ https://issues.apache.org/jira/browse/MESOS-29?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13068113#comment-13068113
] 

Bill Zhao commented on MESOS-29:
--------------------------------

here the code:


// A process that periodically prints frameworks' shares to a file
class SharesPrinter : public MesosProcess {
public:
  SharesPrinter(const PID &_master) : master(_master) {}
  ~SharesPrinter() {}

protected:
  virtual void operator () ()
  {
    int tick = 0;

    std::ofstream file ("/tmp/shares");
    if (!file.is_open())
      LOG(FATAL) << "Could not open /tmp/shares";

    while (true) {
      pause(1);

      send(master, M2M_GET_STATE);
      receive();
      CHECK(msgid() == M2M_GET_STATE_REPLY);

      const MSG<M2M_GET_STATE_REPLY>& msg = message();

      state::MasterState *state =
        *(state::MasterState **) msg.pointer().data();

      uint32_t total_cpus = 0;
      uint32_t total_mem = 0;

      foreach (state::Slave *s, state->slaves) {
        total_cpus += s->cpus;
        total_mem += s->mem;
      }
      
      if (state->frameworks.empty()) {
        file << "--------------------------------" << endl;
      } else {
        foreach (state::Framework *f, state->frameworks) {
          double cpu_share = f->cpus / (double) total_cpus;
          double mem_share = f->mem / (double) total_mem;
          double max_share = max(cpu_share, mem_share);
          file << tick << "#" << f->id << "#" << f->name
<< "#" 
               << f->cpus << "#" << f->mem << "#"
               << cpu_share << "#" << mem_share << "#" << max_share
<< endl;
        }
      }
      delete state;
      tick++;
    }
    file.close();
  }

private:
  const PID master;
};


> Where should the class SharesPrinter reside 
> --------------------------------------------
>
>                 Key: MESOS-29
>                 URL: https://issues.apache.org/jira/browse/MESOS-29
>             Project: Mesos
>          Issue Type: Task
>          Components: master
>         Environment: Unix, Linux, Mac OS X
>            Reporter: Bill Zhao
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> I need to collect some performance data.  I was wondering which part of the master.cpp
that I can paste in.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message