//  Manager.h:
//     The definition of NASD Manager
//

#define MAXSERVERNUM 16
#define MAXCLIENTNUM 64

#define WORKLOADTHREHOLD 4

struct Devicemap
{
  unsigned i_dev;   // comes from trace
  unsigned i_disk;  // the real NASD server

  struct Devicemap * next;
};

class Manager
{
 public:
  unsigned reference[MAXSERVERNUM];  // for load balance use
  double amount[MAXSERVERNUM];     // the amount of data transfered

  unsigned clientact[MAXCLIENTNUM];    // the activity of clients

  struct Devicemap * maplist;

 public:
  Manager();
  ~Manager();

  // return the server id
  int GetCap(unsigned cid, unsigned idev, unsigned inode, unsigned b_begin, unsigned b_count);

  // return the server id who has least workload, if almost same return -1
  int WhoIsIdle(unsigned sid);

  // return the client id who has least workload, if almost same return -1
  int IdleClient(unsigned cid);
};
