libmantle
 All Classes Files Functions Typedefs Pages
Mantle.h
Go to the documentation of this file.
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
20 #ifndef CEPH_MANTLE_H
21 #define CEPH_MANTLE_H
22 
23 #include <lua.hpp>
24 #include <list>
25 #include <map>
26 #include <string>
27 #include <vector>
28 
29 // TODO: get rid of this
30 using namespace std;
31 
35 typedef double Load;
36 
40 typedef string Policy;
41 
45 typedef int32_t Server;
46 
50 typedef map<std::string, Load> ServerMetrics;
51 
55 typedef vector<ServerMetrics> ClusterMetrics;
56 
60 typedef map<Server,Load> Targets;
61 
62 class Mantle {
63 
64  protected:
65  lua_State *L;
66  Server whoami;
67  ClusterMetrics metrics;
68  Policy when_callback, howmuch_callback, where_callback;
69  int execute(Policy p, Server s, ClusterMetrics m);
70 
71  public:
77  Mantle(Server s) : L(NULL) {
78  whoami = s;
79  };
80 
88  int when(bool &decision);
89 
97  int where(Targets &decision);
98 
106  int howmuch(Load &decision);
107 
116  int configure(Policy when, Policy where, Policy howmuch);
117 
124  int update(ClusterMetrics metrics);
125 };
126 
127 #endif
int32_t Server
server name (e.g., MPI rank, MDS name)
Definition: Mantle.h:45
map< Server, Load > Targets
describes which target server to send load to (see where callback)
Definition: Mantle.h:60
Mantle(Server s)
Definition: Mantle.h:77
vector< ServerMetrics > ClusterMetrics
measurements of every server in the cluster
Definition: Mantle.h:55
Definition: Mantle.h:62
map< std::string, Load > ServerMetrics
measurements used by policies (and populated by the service)
Definition: Mantle.h:50
string Policy
Lua script containing the logic.
Definition: Mantle.h:40
double Load
load metric, calculated using the load callback
Definition: Mantle.h:35