Apache SINGA
A distributed deep learning platform .
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros
server.h
1 #ifndef INCLUDE_TRAINER_SERVER_H_
2 #define INCLUDE_TRAINER_SERVER_H_
3 #include <memory>
4 #include <utils/param.h>
5 #include <utils/updater.h>
6 #include "proto/model.pb.h"
7 #include "communication/socket.h"
8 
9 using std::shared_ptr;
10 namespace singa {
11 /* Repsond to worker's get/put/udpate request, and periodically syncing with
12  * other servers.
13  *
14  * Normally, the Server creates a response message for each request which
15  * will be sent back to the one who issued the request. However, if the request
16  * are not processed successfully, the original message will be returned. The
17  * sever does not know the returned message (response or the original message),
18  * it just sends it to the router. The router will decide to re-send the
19  * request to the server or send it to the worker.
20  */
21 class Server{
22  public:
23  typedef std::map<int, shared_ptr<Param>> ParamShard;
24 
25  Server(int thread_id, int group_id, int server_id);
26  void Setup(const UpdaterProto& proto, shared_ptr<ParamShard> shard);
27  void Run();
28 
29  protected:
30 
36  virtual Msg* HandleGet(shared_ptr<Param> param, Msg** msg);
37 
43  virtual Msg* HandleUpdate(shared_ptr<Param> param, Msg** msg);
44 
51  virtual Msg* HandlePut(shared_ptr<Param> param, Msg **msg);
52 
56  virtual Msg* HandleSyncRequest(shared_ptr<Param> param, Msg** msg);
57 
61  virtual int HandleSyncResponse(shared_ptr<Param> param, Msg** msg);
62 
68  virtual bool SyncNow();
69 
70  protected:
71  int thread_id_,group_id_, server_id_;
72  shared_ptr<Dealer> dealer_;
73  shared_ptr<Updater> updater_;
74  shared_ptr<ParamShard> shard_;
75 };
76 } /* Server */
77 #endif //INCLUDE_TRAINER_SERVER_H_
virtual int HandleSyncResponse(shared_ptr< Param > param, Msg **msg)
TODO Process SYNC response.
virtual bool SyncNow()
Scheduler for synchronizing server groups.
Definition: model.pb.h:3432
Definition: msg.h:59
virtual Msg * HandleUpdate(shared_ptr< Param > param, Msg **msg)
Process Update request.
virtual Msg * HandlePut(shared_ptr< Param > param, Msg **msg)
Process PUT request.
Definition: server.h:21
virtual Msg * HandleGet(shared_ptr< Param > param, Msg **msg)
Process GET request.
virtual Msg * HandleSyncRequest(shared_ptr< Param > param, Msg **msg)
TODO Process SYNC request.