-
Notifications
You must be signed in to change notification settings - Fork 390
/
thrift_if.cc
116 lines (94 loc) · 3.27 KB
/
thrift_if.cc
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//
// Copyright (c) 2015 Juniper Networks, Inc. All rights reserved.
//
#include <database/gendb_if.h>
#include <database/cassandra/thrift/thrift_if.h>
#include <database/cassandra/thrift/thrift_if_impl.h>
ThriftIf::ThriftIf(GenDb::GenDbIf::DbErrorHandler errhandler,
const std::vector<std::string> &cassandra_ips,
const std::vector<int> &cassandra_ports,
std::string name, bool only_sync, const std::string& cassandra_user,
const std::string& cassandra_password) {
impl_ = new ThriftIfImpl(errhandler, cassandra_ips, cassandra_ports,
name, only_sync, cassandra_user, cassandra_password);
}
ThriftIf::ThriftIf() : impl_(NULL) {
}
ThriftIf::~ThriftIf() {
if (impl_) {
delete impl_;
}
}
// Init/Uninit
bool ThriftIf::Db_Init(const std::string& task_id, int task_instance) {
return impl_->Db_Init(task_id, task_instance);
}
void ThriftIf::Db_Uninit(const std::string& task_id, int task_instance) {
impl_->Db_Uninit(task_id, task_instance);
}
void ThriftIf::Db_UninitUnlocked(const std::string& task_id,
int task_instance) {
impl_->Db_UninitUnlocked(task_id, task_instance);
}
void ThriftIf::Db_SetInitDone(bool init_done) {
impl_->Db_SetInitDone(init_done);
}
// Tablespace
bool ThriftIf::Db_SetTablespace(const std::string& tablespace) {
return impl_->Db_SetTablespace(tablespace);
}
bool ThriftIf::Db_AddSetTablespace(const std::string& tablespace,
const std::string& replication_factor) {
return impl_->Db_AddSetTablespace(tablespace, replication_factor);
}
// Column family
bool ThriftIf::Db_AddColumnfamily(const GenDb::NewCf& cf) {
return impl_->Db_AddColumnfamily(cf);
}
bool ThriftIf::Db_UseColumnfamily(const GenDb::NewCf& cf) {
return impl_->Db_UseColumnfamily(cf);
}
// Column
bool ThriftIf::Db_AddColumn(std::auto_ptr<GenDb::ColList> cl) {
return impl_->Db_AddColumn(cl);
}
bool ThriftIf::Db_AddColumnSync(std::auto_ptr<GenDb::ColList> cl) {
return impl_->Db_AddColumnSync(cl);
}
// Read
bool ThriftIf::Db_GetRow(GenDb::ColList *ret, const std::string& cfname,
const GenDb::DbDataValueVec& rowkey) {
return impl_->Db_GetRow(ret, cfname, rowkey);
}
bool ThriftIf::Db_GetMultiRow(GenDb::ColListVec *ret,
const std::string& cfname,
const std::vector<GenDb::DbDataValueVec>& key,
const GenDb::ColumnNameRange& crange) {
return impl_->Db_GetMultiRow(ret, cfname, key, crange);
}
bool ThriftIf::Db_GetMultiRow(GenDb::ColListVec *ret,
const std::string& cfname,
const std::vector<GenDb::DbDataValueVec>& key) {
return impl_->Db_GetMultiRow(ret, cfname, key);
}
// Queue
bool ThriftIf::Db_GetQueueStats(uint64_t *queue_count,
uint64_t *enqueues) const {
return impl_->Db_GetQueueStats(queue_count, enqueues);
}
void ThriftIf::Db_SetQueueWaterMark(bool high, size_t queue_count,
GenDb::GenDbIf::DbQueueWaterMarkCb cb) {
impl_->Db_SetQueueWaterMark(high, queue_count, cb);
}
void ThriftIf::Db_ResetQueueWaterMarks() {
impl_->Db_ResetQueueWaterMarks();
}
// Stats
bool ThriftIf::Db_GetStats(std::vector<GenDb::DbTableInfo> *vdbti,
GenDb::DbErrors *dbe) {
return impl_->Db_GetStats(vdbti, dbe);
}
// Connection
std::vector<GenDb::Endpoint> ThriftIf::Db_GetEndpoints() const {
return impl_->Db_GetEndpoints();
}