55#ifndef TERA_CLIENT_H_
66#define TERA_CLIENT_H_
77
8+ #include < stdint.h>
9+ #include < list>
10+ #include < map>
11+ #include < set>
812#include < string>
913#include < vector>
1014
@@ -17,88 +21,81 @@ namespace tera {
1721
1822class Client {
1923public:
20- // Create a new client
21- // User should delete Client* if it is no longer needed.
22- // A Client can only be deleted if ALL the tables it opened have been deleted.
24+ // / 使用glog的用户必须调用此接口,避免glog被重复初始化
25+ static void SetGlogIsInitialized ();
26+
2327 static Client* NewClient (const std::string& confpath,
2428 const std::string& log_prefix,
2529 ErrorCode* err = NULL );
30+
2631 static Client* NewClient (const std::string& confpath,
2732 ErrorCode* err = NULL );
28- static Client* NewClient ();
2933
30- // Open a table by name.
31- // This operation could fail due to zookeeper down, meta not avaliable, table not exists, etc.
32- virtual Table* OpenTable (const std::string& table_name, ErrorCode* err) = 0;
34+ static Client* NewClient ();
3335
34- // Create a new table with specified descriptor.
36+ // / 创建表格
3537 virtual bool CreateTable (const TableDescriptor& desc, ErrorCode* err) = 0;
36- // Create a new table with multiple tablets pre-assigned by tablet_delim.
3738 virtual bool CreateTable (const TableDescriptor& desc,
3839 const std::vector<std::string>& tablet_delim,
3940 ErrorCode* err) = 0;
40-
41- // Update table schema. User should call UpdateCheck to check if the update operation is complete.
42- virtual bool UpdateTableSchema (const TableDescriptor& desc, ErrorCode* err) = 0;
41+ // / 更新表格Schema
42+ virtual bool UpdateTable (const TableDescriptor& desc, ErrorCode* err) = 0;
4343 virtual bool UpdateCheck (const std::string& table_name, bool * done, ErrorCode* err) = 0;
44- // Disable a table by name. A disabled table will not provide any service.
44+ // / 删除表格
45+ virtual bool DeleteTable (const std::string& name, ErrorCode* err) = 0;
46+ // / 停止表格服务
4547 virtual bool DisableTable (const std::string& name, ErrorCode* err) = 0;
46- // Drop a table by name. Only a disabled table can be dropped.
47- virtual bool DropTable (const std::string& name, ErrorCode* err) = 0;
48- // Revive a disabled table.
48+ // / 恢复表格服务
4949 virtual bool EnableTable (const std::string& name, ErrorCode* err) = 0;
5050
51- // Get the descriptor of the table
52- virtual TableDescriptor* GetTableDescriptor (const std::string& table_name, ErrorCode* err) = 0;
53- // List all tables.
54- virtual bool List (std::vector<TableInfo>* table_list, ErrorCode* err) = 0;
55- // Get table & tablet(s) info for a specified table.
56- virtual bool List (const std::string& table_name, TableInfo* table_info,
57- std::vector<TabletInfo>* tablet_list, ErrorCode* err) = 0;
58-
59- // Check the table status by name.
60- virtual bool IsTableExist (const std::string& table_name, ErrorCode* err) = 0;
61- virtual bool IsTableEnabled (const std::string& table_name, ErrorCode* err) = 0;
62- virtual bool IsTableEmpty (const std::string& table_name, ErrorCode* err) = 0;
63-
64- // Send command to to server, like meta, tablet, etc.
65- virtual bool CmdCtrl (const std::string& command, const std::vector<std::string>& arg_list,
66- bool * bool_result, std::string* str_result, ErrorCode* err) = 0;
67- // User who use glog besides tera should call this method to prevent conflict.
68- static void SetGlogIsInitialized ();
69-
70- // User management.
71- virtual bool CreateUser (const std::string& user, const std::string& password, ErrorCode* err) = 0;
51+ // / acl
52+ virtual bool CreateUser (const std::string& user,
53+ const std::string& password, ErrorCode* err) = 0;
7254 virtual bool DeleteUser (const std::string& user, ErrorCode* err) = 0;
73- virtual bool ChangePwd (const std::string& user, const std::string& password, ErrorCode* err) = 0;
55+ virtual bool ChangePwd (const std::string& user,
56+ const std::string& password, ErrorCode* err) = 0;
7457 virtual bool ShowUser (const std::string& user, std::vector<std::string>& user_groups,
7558 ErrorCode* err) = 0;
76- virtual bool AddUserToGroup (const std::string& user, const std::string& group, ErrorCode* err) = 0;
59+ virtual bool AddUserToGroup (const std::string& user,
60+ const std::string& group, ErrorCode* err) = 0;
7761 virtual bool DeleteUserFromGroup (const std::string& user,
7862 const std::string& group, ErrorCode* err) = 0;
63+ // / 打开表格, 失败返回NULL
64+ virtual Table* OpenTable (const std::string& table_name, ErrorCode* err) = 0;
65+ // / 获取表格分布信息
66+ virtual bool GetTabletLocation (const std::string& table_name,
67+ std::vector<TabletInfo>* tablets,
68+ ErrorCode* err) = 0;
69+ // / 获取表格Schema
70+ virtual TableDescriptor* GetTableDescriptor (const std::string& table_name,
71+ ErrorCode* err) = 0;
72+
73+ virtual bool List (std::vector<TableInfo>* table_list,
74+ ErrorCode* err) = 0;
7975
80- // EXPERIMENTAL
76+ virtual bool List (const std::string& table_name,
77+ TableInfo* table_info,
78+ std::vector<TabletInfo>* tablet_list,
79+ ErrorCode* err) = 0;
80+
81+ virtual bool IsTableExist (const std::string& table_name, ErrorCode* err) = 0;
82+
83+ virtual bool IsTableEnabled (const std::string& table_name, ErrorCode* err) = 0;
84+
85+ virtual bool IsTableEmpty (const std::string& table_name, ErrorCode* err) = 0;
8186
82- // Create a snapshot for the table.
8387 virtual bool GetSnapshot (const std::string& name, uint64_t * snapshot, ErrorCode* err) = 0;
84- // Delete a specified snapshot.
85- virtual bool DelSnapshot (const std::string& name, uint64_t snapshot, ErrorCode* err) = 0;
86- // Perform a rollback operation to a specified snapshot
88+ virtual bool DelSnapshot (const std::string& name, uint64_t snapshot,ErrorCode* err) = 0;
8789 virtual bool Rollback (const std::string& name, uint64_t snapshot,
8890 const std::string& rollback_name, ErrorCode* err) = 0;
8991
90- // DEPRECATED
91-
92- // Use DropTable instead.
93- virtual bool DeleteTable (const std::string& name, ErrorCode* err) = 0;
94- // Use UpdateTableSchema instead.
95- virtual bool UpdateTable (const TableDescriptor& desc, ErrorCode* err) = 0;
96- // Use List instead.
97- virtual bool GetTabletLocation (const std::string& table_name, std::vector<TabletInfo>* tablets,
98- ErrorCode* err) = 0;
99-
100- // Rename a table.
101- virtual bool Rename (const std::string& old_table_name, const std::string& new_table_name,
92+ virtual bool CmdCtrl (const std::string& command,
93+ const std::vector<std::string>& arg_list,
94+ bool * bool_result,
95+ std::string* str_result,
96+ ErrorCode* err) = 0;
97+ virtual bool Rename (const std::string& old_table_name,
98+ const std::string& new_table_name,
10299 ErrorCode* err) = 0 ;
103100 Client () {}
104101 virtual ~Client () {}
0 commit comments