1 #ifndef INCLUDE_UTILS_CLUSTER_RT_H_
2 #define INCLUDE_UTILS_CLUSTER_RT_H_
3 #include <glog/logging.h>
7 #include <zookeeper/zookeeper.h>
21 typedef void (*rt_callback)(
void *contest);
31 virtual bool Init(){
return false;}
36 virtual bool sWatchSGroup(
int gid,
int sid, rt_callback fn,
void *ctx){
return false;}
41 virtual bool wJoinSGroup(
int gid,
int wid,
int s_group){
return false;}
46 virtual bool wLeaveSGroup(
int gid,
int wid,
int s_group){
return false;}
56 bool sWatchSGroup(
int gid,
int sid, rt_callback fn,
void *ctx);
59 static void watcherGlobal(zhandle_t * zh,
int type,
int state,
const char *path,
void *watcherCtx);
62 static void childChanges(zhandle_t *zh,
int type,
int state,
const char *path,
void *watcherCtx);
63 string getSGroupPath(
int gid);
64 string getWorkerPath(
int gid,
int wid);
74 vector<RTCallback *> cb_vec_;
76 const int MAX_BUF_LEN = 50;
77 const int RETRY_NUM = 10;
78 const int SLEEP_SEC = 1;
79 const string ZK_P_SINGA =
"/singa";
80 const string ZK_P_STATUS =
"/status";
85 #endif // INCLUDE_UTILS_CLUSTER_RT_H_
bool wJoinSGroup(int gid, int wid, int s_group)
Worker: join a server group (i.e.
virtual bool wLeaveSGroup(int gid, int wid, int s_group)
Worker: leave a server group (i.e.
Definition: cluster_rt.h:46
Definition: cluster_rt.h:51
bool wLeaveSGroup(int gid, int wid, int s_group)
Worker: leave a server group (i.e.
Definition: cluster_rt.h:23
virtual bool Init()
Initialize the runtime instance.
Definition: cluster_rt.h:31
virtual bool sWatchSGroup(int gid, int sid, rt_callback fn, void *ctx)
Server: watch all workers in a server group, will be notified when all workers have left...
Definition: cluster_rt.h:36
virtual bool wJoinSGroup(int gid, int wid, int s_group)
Worker: join a server group (i.e.
Definition: cluster_rt.h:41
bool sWatchSGroup(int gid, int sid, rt_callback fn, void *ctx)
Server: watch all workers in a server group, will be notified when all workers have left...
bool Init()
Initialize the runtime instance.