Skip to content

Commit

Permalink
issue #934: multithread compactiong support
Browse files Browse the repository at this point in the history
  • Loading branch information
caijieming committed Aug 29, 2016
1 parent b66c065 commit 4ee16ed
Show file tree
Hide file tree
Showing 101 changed files with 4,426 additions and 4,429 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ map<RowKey, map<ColummnFamily:Qualifier, map<Timestamp, Value> > >
![架构图](resources/images/arch.png)

#系统依赖
* 使用分布式文件系统([BFS](https://github.com/baidu/bfs)、HDFS等)持久化数据与元信息
* 使用分布式协调服务([Nexus](https://github.com/baidu/ins/)或者Zookeeper)选主与协调
* 使用分布式文件系统(HDFS、NFS等)持久化数据与元信息
* 使用分布式协调服务([Nexus](https://github.com/baidu/ins/)或者[zookeeper](http://zookeeper.apache.org/))选主与协调
* 使用[Sofa-pbrpc](https://github.com/baidu/sofa-pbrpc/)实现跨进程通信

#系统构建
Expand Down
6 changes: 3 additions & 3 deletions doc/new_sdk_dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* 按接口使用频率重新排序
* 接口分类
* 默认为已发布接口
* DEVELOPING 开发中接口,鼓励完善
* EXPERIMENTAL 正在测试中,鼓励试用
* DEPRECATED 未实现或不建议用户使用,保证兼容性
* pre-release 待发布,正在测试中,鼓励试用
* developing 开发中接口,鼓励完善
* do-not-use 未实现或不建议用户使用,保证兼容性
* 重写接口注释
2 changes: 1 addition & 1 deletion doc/sdk_dev_guide_for_python.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 使用tera的Python Sdk

1. 下载[TeraSdk.py](https://github.com/baidu/tera/blob/master/src/sdk/python/TeraSdk.py)
2. 编译(或从其它途径获取)得到libtera_c.so;将.so与TeraSdk.py置于同一目录下,或者通过`LD_LIBRARY_PATH`环境变量等方法指定libtera_c.so的查找路径
2. 编译(或从其它途径获取)得到libtera_c.so,与TeraSdk.py置于同一目录下
3. 编写应用程序
1. 示例[sample](https://github.com/baidu/tera/blob/master/src/sdk/python/sample.py)

Expand Down
108 changes: 0 additions & 108 deletions doc/sdk_reference/mutation.md

This file was deleted.

1 change: 0 additions & 1 deletion include/tera.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@
#include "tera/table.h"
#include "tera/table_descriptor.h"
#include "tera/transaction.h"
#include "tera/utils.h"

#endif // TERA_TERA_H_
109 changes: 53 additions & 56 deletions include/tera/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#ifndef TERA_CLIENT_H_
#define TERA_CLIENT_H_

#include <stdint.h>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

Expand All @@ -17,88 +21,81 @@ namespace tera {

class Client {
public:
// Create a new client
// User should delete Client* if it is no longer needed.
// A Client can only be deleted if ALL the tables it opened have been deleted.
/// 使用glog的用户必须调用此接口,避免glog被重复初始化
static void SetGlogIsInitialized();

static Client* NewClient(const std::string& confpath,
const std::string& log_prefix,
ErrorCode* err = NULL);

static Client* NewClient(const std::string& confpath,
ErrorCode* err = NULL);
static Client* NewClient();

// Open a table by name.
// This operation could fail due to zookeeper down, meta not avaliable, table not exists, etc.
virtual Table* OpenTable(const std::string& table_name, ErrorCode* err) = 0;
static Client* NewClient();

// Create a new table with specified descriptor.
/// 创建表格
virtual bool CreateTable(const TableDescriptor& desc, ErrorCode* err) = 0;
// Create a new table with multiple tablets pre-assigned by tablet_delim.
virtual bool CreateTable(const TableDescriptor& desc,
const std::vector<std::string>& tablet_delim,
ErrorCode* err) = 0;

// Update table schema. User should call UpdateCheck to check if the update operation is complete.
virtual bool UpdateTableSchema(const TableDescriptor& desc, ErrorCode* err) = 0;
/// 更新表格Schema
virtual bool UpdateTable(const TableDescriptor& desc, ErrorCode* err) = 0;
virtual bool UpdateCheck(const std::string& table_name, bool* done, ErrorCode* err) = 0;
// Disable a table by name. A disabled table will not provide any service.
/// 删除表格
virtual bool DeleteTable(const std::string& name, ErrorCode* err) = 0;
/// 停止表格服务
virtual bool DisableTable(const std::string& name, ErrorCode* err) = 0;
// Drop a table by name. Only a disabled table can be dropped.
virtual bool DropTable(const std::string& name, ErrorCode* err) = 0;
// Revive a disabled table.
/// 恢复表格服务
virtual bool EnableTable(const std::string& name, ErrorCode* err) = 0;

// Get the descriptor of the table
virtual TableDescriptor* GetTableDescriptor(const std::string& table_name, ErrorCode* err) = 0;
// List all tables.
virtual bool List(std::vector<TableInfo>* table_list, ErrorCode* err) = 0;
// Get table & tablet(s) info for a specified table.
virtual bool List(const std::string& table_name, TableInfo* table_info,
std::vector<TabletInfo>* tablet_list, ErrorCode* err) = 0;

// Check the table status by name.
virtual bool IsTableExist(const std::string& table_name, ErrorCode* err) = 0;
virtual bool IsTableEnabled(const std::string& table_name, ErrorCode* err) = 0;
virtual bool IsTableEmpty(const std::string& table_name, ErrorCode* err) = 0;

// Send command to to server, like meta, tablet, etc.
virtual bool CmdCtrl(const std::string& command, const std::vector<std::string>& arg_list,
bool* bool_result, std::string* str_result, ErrorCode* err) = 0;
// User who use glog besides tera should call this method to prevent conflict.
static void SetGlogIsInitialized();

// User management.
virtual bool CreateUser(const std::string& user, const std::string& password, ErrorCode* err) = 0;
/// acl
virtual bool CreateUser(const std::string& user,
const std::string& password, ErrorCode* err) = 0;
virtual bool DeleteUser(const std::string& user, ErrorCode* err) = 0;
virtual bool ChangePwd(const std::string& user, const std::string& password, ErrorCode* err) = 0;
virtual bool ChangePwd(const std::string& user,
const std::string& password, ErrorCode* err) = 0;
virtual bool ShowUser(const std::string& user, std::vector<std::string>& user_groups,
ErrorCode* err) = 0;
virtual bool AddUserToGroup(const std::string& user, const std::string& group, ErrorCode* err) = 0;
virtual bool AddUserToGroup(const std::string& user,
const std::string& group, ErrorCode* err) = 0;
virtual bool DeleteUserFromGroup(const std::string& user,
const std::string& group, ErrorCode* err) = 0;
/// 打开表格, 失败返回NULL
virtual Table* OpenTable(const std::string& table_name, ErrorCode* err) = 0;
/// 获取表格分布信息
virtual bool GetTabletLocation(const std::string& table_name,
std::vector<TabletInfo>* tablets,
ErrorCode* err) = 0;
/// 获取表格Schema
virtual TableDescriptor* GetTableDescriptor(const std::string& table_name,
ErrorCode* err) = 0;

virtual bool List(std::vector<TableInfo>* table_list,
ErrorCode* err) = 0;

// EXPERIMENTAL
virtual bool List(const std::string& table_name,
TableInfo* table_info,
std::vector<TabletInfo>* tablet_list,
ErrorCode* err) = 0;

virtual bool IsTableExist(const std::string& table_name, ErrorCode* err) = 0;

virtual bool IsTableEnabled(const std::string& table_name, ErrorCode* err) = 0;

virtual bool IsTableEmpty(const std::string& table_name, ErrorCode* err) = 0;

// Create a snapshot for the table.
virtual bool GetSnapshot(const std::string& name, uint64_t* snapshot, ErrorCode* err) = 0;
// Delete a specified snapshot.
virtual bool DelSnapshot(const std::string& name, uint64_t snapshot, ErrorCode* err) = 0;
// Perform a rollback operation to a specified snapshot
virtual bool DelSnapshot(const std::string& name, uint64_t snapshot,ErrorCode* err) = 0;
virtual bool Rollback(const std::string& name, uint64_t snapshot,
const std::string& rollback_name, ErrorCode* err) = 0;

// DEPRECATED

// Use DropTable instead.
virtual bool DeleteTable(const std::string& name, ErrorCode* err) = 0;
// Use UpdateTableSchema instead.
virtual bool UpdateTable(const TableDescriptor& desc, ErrorCode* err) = 0;
// Use List instead.
virtual bool GetTabletLocation(const std::string& table_name, std::vector<TabletInfo>* tablets,
ErrorCode* err) = 0;

// Rename a table.
virtual bool Rename(const std::string& old_table_name, const std::string& new_table_name,
virtual bool CmdCtrl(const std::string& command,
const std::vector<std::string>& arg_list,
bool* bool_result,
std::string* str_result,
ErrorCode* err) = 0;
virtual bool Rename(const std::string& old_table_name,
const std::string& new_table_name,
ErrorCode* err) = 0 ;
Client() {}
virtual ~Client() {}
Expand Down
48 changes: 22 additions & 26 deletions include/tera/error_code.h
Original file line number Diff line number Diff line change
@@ -1,54 +1,50 @@
// Copyright (c) 2015, Baidu.com, Inc. All Rights Reserved
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// A ErrorCode encapsulates the result of an operation.

#ifndef TERA_ERROR_CODE_H_
#define TERA_ERROR_CODE_H_
#ifndef TERA_ERROR_CODE_
#define TERA_ERROR_CODE_

#include <stdint.h>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

#pragma GCC visibility push(default)

namespace tera {

class ErrorCode {
public:
enum ErrorCodeType {
kOK = 0,
kNotFound = 1,
kBadParam = 2,
kSystem = 3,
kTimeout = 4,
kBusy = 5,
kNoQuota = 6,
kNoAuth = 7,
kUnknown = 8,
kNotImpl = 9,
kTxnFail = 10
kOK = 0,
kNotFound,
kBadParam,
kSystem,
kTimeout,
kBusy,
kNoQuota,
kNoAuth,
kUnknown,
kNotImpl,
kTxnFail
};

public:
// Returns a string includes type&reason
// Format: "type [kOK], reason [success]"
ErrorCode();
std::string ToString() const;

ErrorCodeType GetType() const;
std::string GetReason() const;

// Internal funcion, do not use
ErrorCode();
ErrorCodeType GetType() const;
void SetFailed(ErrorCodeType err, const std::string& reason = "");

private:
ErrorCodeType _err;
std::string _reason;
};

// DEPRECATED. Use error_code.ToString() instead.
const char* strerr(ErrorCode error_code);

} // namespace tera
#pragma GCC visibility pop
#endif // TERA_ERROR_CODE_H_

#endif // TERA_ERROR_CODE_
Loading

0 comments on commit 4ee16ed

Please sign in to comment.