-
Notifications
You must be signed in to change notification settings - Fork 2
/
kvs_impl.cpp
102 lines (84 loc) · 3.01 KB
/
kvs_impl.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// This file is auto-generated from kvs.idl with jenerator version 0.9.4-42-g70f7539/develop
// *** DO NOT EDIT ***
#include <map>
#include <string>
#include <vector>
#include <utility>
#include "jubatus/util/lang/shared_ptr.h"
#include <jubatus/server/framework.hpp>
#include "kvs_serv.hpp"
namespace jubatus {
namespace server {
class kvs_impl : public jubatus::server::common::mprpc::rpc_server {
public:
explicit kvs_impl(const jubatus::server::framework::server_argv& a):
rpc_server(a.timeout),
p_(new jubatus::server::framework::server_helper<kvs_serv>(a, true)) {
rpc_server::add<bool(std::string, std::string, std::string)>("put",
jubatus::util::lang::bind(&kvs_impl::put, this, jubatus::util::lang::_2,
jubatus::util::lang::_3));
rpc_server::add<std::string(std::string, std::string)>("get",
jubatus::util::lang::bind(&kvs_impl::get, this,
jubatus::util::lang::_2));
rpc_server::add<bool(std::string, std::string)>("del",
jubatus::util::lang::bind(&kvs_impl::del, this,
jubatus::util::lang::_2));
rpc_server::add<bool(std::string)>("clear", jubatus::util::lang::bind(
&kvs_impl::clear, this));
rpc_server::add<std::string(std::string)>("get_config",
jubatus::util::lang::bind(&kvs_impl::get_config, this));
rpc_server::add<std::map<std::string, std::string>(std::string,
std::string)>("save", jubatus::util::lang::bind(&kvs_impl::save, this,
jubatus::util::lang::_2));
rpc_server::add<bool(std::string, std::string)>("load",
jubatus::util::lang::bind(&kvs_impl::load, this,
jubatus::util::lang::_2));
rpc_server::add<std::map<std::string, std::map<std::string, std::string> >(
std::string)>("get_status", jubatus::util::lang::bind(
&kvs_impl::get_status, this));
}
bool put(const std::string& key, const std::string& value) {
JWLOCK_(p_);
return get_p()->put(key, value);
}
std::string get(const std::string& key) {
JRLOCK_(p_);
return get_p()->get(key);
}
bool del(const std::string& key) {
JWLOCK_(p_);
return get_p()->del(key);
}
bool clear() {
JWLOCK_(p_);
return get_p()->clear();
}
std::string get_config() {
JRLOCK_(p_);
return get_p()->get_config();
}
std::map<std::string, std::string> save(const std::string& id) {
JRLOCK_(p_);
return get_p()->save(id);
}
bool load(const std::string& id) {
JWLOCK_(p_);
return get_p()->load(id);
}
std::map<std::string, std::map<std::string, std::string> > get_status() {
JRLOCK_(p_);
return p_->get_status();
}
int run() { return p_->start(*this); }
jubatus::util::lang::shared_ptr<kvs_serv> get_p() { return p_->server(); }
private:
jubatus::util::lang::shared_ptr<jubatus::server::framework::server_helper<kvs_serv> > p_;
};
} // namespace server
} // namespace jubatus
int main(int argc, char* argv[]) {
return
jubatus::server::framework::run_server<jubatus::server::kvs_impl,
jubatus::server::kvs_serv>
(argc, argv, "kvs");
}