Skip to content

Commit d3d63d4

Browse files
committed
Merge remote-tracking branch 'baidu_tera/master'
2 parents 6416256 + 2f7e1db commit d3d63d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1188
-169
lines changed

.travis.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: cpp
22
compiler: gcc
33
install:
4-
- sudo apt-get install libboost-dev
4+
- sudo apt-get install libboost-dev uuid-dev
55

66
- wget https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz
77
- tar xf protobuf-2.6.1.tar.gz
@@ -32,6 +32,9 @@ install:
3232
- tar zxvf gperftools-2.2.1.tar.gz
3333
- ( cd gperftools-2.2.1 && ./configure --with-pic && make -j4 && sudo make install )
3434

35+
- git clone https://github.com/fxsjy/ins
36+
- (cd ins && PBRPC_PATH=../sofa-pbrpc/output/ make sdk )
37+
3538
before_script:
3639
- sed -i 's/^SOFA_PBRPC_PREFIX=.*/SOFA_PBRPC_PREFIX=.\/sofa-pbrpc\/output/' depends.mk
3740
- sed -i 's/^PROTOBUF_PREFIX=.*/PROTOBUF_PREFIX=\/usr\/local/' depends.mk
@@ -41,6 +44,7 @@ before_script:
4144
- sed -i 's/^GLOG_PREFIX=.*/GLOG_PREFIX=\/usr\/local/' depends.mk
4245
- sed -i 's/^GPERFTOOLS_PREFIX=.*/GPERFTOOLS_PREFIX=\/usr\/local/' depends.mk
4346
- sed -i 's/^BOOST_INCDIR=.*/BOOST_INCDIR=\/usr\/local\/include/' depends.mk
47+
- sed -i 's/^INS_PREFIX=.*/INS_PREFIX=.\/ins\/output/' depends.mk
4448

4549
script:
4650
- make -j4

build.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,21 @@ make -j4
118118
make install
119119
cd -
120120

121+
wget --no-check-certificate https://raw.githubusercontent.com/fxsjy/thirdparty/master/uuid-1.6.2.tar.gz
122+
tar -xzvf uuid-1.6.2.tar.gz
123+
cd uuid-1.6.2
124+
./configure ${DEPS_CONFIG}
125+
make -j4
126+
make install
127+
cd -
128+
129+
git clone https://github.com/fxsjy/ins
130+
cd ins
131+
sed -i "s|^PREFIX=.*|PREFIX=${DEPS_PREFIX}|" Makefile
132+
sed -i "s|^PROTOC=.*|PROTOC=${DEPS_PREFIX}/bin/protoc|" Makefile
133+
make install_sdk
134+
cd -
135+
121136
cd ${WORK_DIR}
122137

123138
########################################
@@ -132,6 +147,7 @@ sed -i 's/^GFLAGS_PREFIX=.*/GFLAGS_PREFIX=.\/thirdparty/' depends.mk
132147
sed -i 's/^GLOG_PREFIX=.*/GLOG_PREFIX=.\/thirdparty/' depends.mk
133148
sed -i 's/^GPERFTOOLS_PREFIX=.*/GPERFTOOLS_PREFIX=.\/thirdparty/' depends.mk
134149
sed -i 's/^BOOST_INCDIR=.*/BOOST_INCDIR=.\/thirdparty\/boost_1_57_0/' depends.mk
150+
sed -i 's/^INS_PREFIX=.*/INS_PREFIX=.\/thirdparty/' depends.mk
135151

136152
########################################
137153
# build tera

depends.mk

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ ZOOKEEPER_PREFIX=
1212
GFLAGS_PREFIX=
1313
GLOG_PREFIX=
1414
GPERFTOOLS_PREFIX=
15+
INS_PREFIX=
1516
BOOST_INCDIR=
1617

1718
SOFA_PBRPC_INCDIR = $(SOFA_PBRPC_PREFIX)/include
@@ -21,6 +22,7 @@ ZOOKEEPER_INCDIR = $(ZOOKEEPER_PREFIX)/include
2122
GFLAGS_INCDIR = $(GFLAGS_PREFIX)/include
2223
GLOG_INCDIR = $(GLOG_PREFIX)/include
2324
GPERFTOOLS_INCDIR = $(GPERFTOOLS_PREFIX)/include
25+
INS_INCDIR = $(INS_PREFIX)/include
2426

2527
SOFA_PBRPC_LIBDIR = $(SOFA_PBRPC_PREFIX)/lib
2628
PROTOBUF_LIBDIR = $(PROTOBUF_PREFIX)/lib
@@ -29,6 +31,7 @@ ZOOKEEPER_LIBDIR = $(ZOOKEEPER_PREFIX)/lib
2931
GFLAGS_LIBDIR = $(GFLAGS_PREFIX)/lib
3032
GLOG_LIBDIR = $(GLOG_PREFIX)/lib
3133
GPERFTOOLS_LIBDIR = $(GPERFTOOLS_PREFIX)/lib
34+
INS_LIBDIR = $(INS_PREFIX)/lib
3235

3336
PROTOC = $(PROTOBUF_PREFIX)/bin/protoc
3437

@@ -39,10 +42,10 @@ PROTOC = $(PROTOBUF_PREFIX)/bin/protoc
3942
DEPS_INCPATH = -I$(SOFA_PBRPC_INCDIR) -I$(PROTOBUF_INCDIR) \
4043
-I$(SNAPPY_INCDIR) -I$(ZOOKEEPER_INCDIR) \
4144
-I$(GFLAGS_INCDIR) -I$(GLOG_INCDIR) \
42-
-I$(GPERFTOOLS_INCDIR) -I$(BOOST_INCDIR)
45+
-I$(GPERFTOOLS_INCDIR) -I$(BOOST_INCDIR) -I$(INS_INCDIR)
4346
DEPS_LDPATH = -L$(SOFA_PBRPC_LIBDIR) -L$(PROTOBUF_LIBDIR) \
4447
-L$(SNAPPY_LIBDIR) -L$(ZOOKEEPER_LIBDIR) \
4548
-L$(GFLAGS_LIBDIR) -L$(GLOG_LIBDIR) \
46-
-L$(GPERFTOOLS_LIBDIR)
47-
DEPS_LDFLAGS = -lsofa-pbrpc -lprotobuf -lsnappy -lzookeeper_mt \
48-
-lgflags -lglog -ltcmalloc_minimal
49+
-L$(GPERFTOOLS_LIBDIR) -L$(INS_LIBDIR)
50+
DEPS_LDFLAGS = -lins_sdk -lsofa-pbrpc -lprotobuf -lsnappy -lzookeeper_mt \
51+
-lgflags -lglog -ltcmalloc_minimal -luuid

internal_build.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ make -j4
101101
make install
102102
cd -
103103

104+
git clone [email protected]:fxsjy/ins.git
105+
cd ins
106+
sed -i "s|^PREFIX=.*|PREFIX=${DEPS_PREFIX}|" Makefile
107+
sed -i "s|^PROTOC=.*|PROTOC=${DEPS_PREFIX}/bin/protoc|" Makefile
108+
make install_sdk
109+
cd -
110+
104111
cd ${WORK_DIR}
105112

106113
########################################
@@ -115,6 +122,7 @@ sed -i 's/^GFLAGS_PREFIX=.*/GFLAGS_PREFIX=.\/thirdparty/' depends.mk
115122
sed -i 's/^GLOG_PREFIX=.*/GLOG_PREFIX=.\/thirdparty/' depends.mk
116123
sed -i 's/^GPERFTOOLS_PREFIX=.*/GPERFTOOLS_PREFIX=.\/thirdparty/' depends.mk
117124
sed -i 's/^BOOST_INCDIR=.*/BOOST_INCDIR=.\/thirdparty\/boost_1_57_0/' depends.mk
125+
sed -i 's/^INS_PREFIX=.*/INS_PREFIX=.\/thirdparty/' depends.mk
118126

119127
########################################
120128
# build tera

src/benchmark/mark_main.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
#include <sys/time.h>
1313
#include <time.h>
1414

15-
#include <openssl/md5.h>
16-
1715
#include "benchmark/mark.h"
1816

1917
DECLARE_string(flagfile);
@@ -32,6 +30,7 @@ DEFINE_int64(max_outflow, -1, "max_outflow");
3230
DEFINE_int64(max_rate, -1, "max_rate");
3331
DEFINE_bool(scan_streaming, false, "enable streaming scan");
3432
DEFINE_int64(batch_count, 1, "batch_count(sync)");
33+
DEFINE_bool(seq_write, false, "enable sequential write");
3534

3635
int mode = 0;
3736
int type = 0;
@@ -472,13 +471,15 @@ int main(int argc, char** argv) {
472471
::google::ParseCommandLineFlags(&argc, &argv, true);
473472

474473
tera::ErrorCode err;
475-
tera::Client* client = tera::Client::NewClient("./tera.flag", "sample");
474+
tera::Client* client = tera::Client::NewClient("./tera.flag", "tera_mark");
476475
if (NULL == client) {
477476
std::cerr << "fail to create client: " << tera::strerr(err) << std::endl;
478477
return -1;
479478
}
480479

481-
tera::Table* table = client->OpenTable(FLAGS_tablename, &err);
480+
tera::TableOptions options;
481+
options.sequential_write = FLAGS_seq_write;
482+
tera::Table* table = client->OpenTable(FLAGS_tablename, options, &err);
482483
if (NULL == table) {
483484
std::cerr << "fail to open table: " << tera::strerr(err) << std::endl;
484485
return -1;

src/common/thread_pool.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@ class ThreadPool {
9797
work_cv_.Signal();
9898
return bg_item.id;
9999
}
100-
/// Cancel a delayed task ,if running, wait
101-
bool CancelTask(int64_t task_id) {
100+
/// Cancel a delayed task
101+
/// if running, wait if non_block==false; return immediately if non_block==true
102+
bool CancelTask(int64_t task_id, bool non_block = false, bool* is_running = NULL) {
102103
if (task_id == 0) {
103104
return false;
104105
}
@@ -108,10 +109,18 @@ class ThreadPool {
108109
if (running_task_id_ != task_id) {
109110
BGMap::iterator it = latest_.find(task_id);
110111
if (it == latest_.end()) {
112+
if (is_running != NULL) {
113+
*is_running = false;
114+
}
111115
return false;
112116
}
113117
latest_.erase(it);
114118
return true;
119+
} else if (non_block) {
120+
if (is_running != NULL) {
121+
*is_running = true;
122+
}
123+
return false;
115124
}
116125
}
117126
timespec ts = {0, 100000};

src/io/tablet_io.cc

Lines changed: 17 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "io/tablet_writer.h"
1616
#include "io/timekey_comparator.h"
1717
#include "io/ttlkv_compact_strategy.h"
18+
#include "io/utils_leveldb.h"
1819
#include "leveldb/cache.h"
1920
#include "leveldb/compact_strategy.h"
2021
#include "leveldb/env.h"
@@ -66,27 +67,6 @@ extern tera::Counter row_read_delay;
6667
namespace tera {
6768
namespace io {
6869

69-
#define OPERATE_WITH_RETRY(func, tips, sleep_time, max_retry) \
70-
do { \
71-
int32_t retry = 0; \
72-
bool ret = false; \
73-
while ( !(ret = func) && retry < max_retry ) { \
74-
ThisThread::Sleep(sleep_time); \
75-
if (max_retry < 10 || retry % (max_retry / 10 + 1) == 0) { \
76-
LOG(WARNING) << "try again to " << tips << ": " << retry; \
77-
} \
78-
retry++; \
79-
} \
80-
if (!ret) { \
81-
LOG(ERROR) << "can not " << tips << " status: " << db_status.ToString(); \
82-
} \
83-
} while (0)
84-
85-
#define OPERATE_FILE_WITH_RETRY(func, tips) \
86-
OPERATE_WITH_RETRY(func, tips, \
87-
FLAGS_tera_io_retry_period, \
88-
0 /*FLAGS_tera_io_retry_max_times*/);
89-
9070
TabletIO::TabletIO()
9171
: m_async_writer(NULL),
9272
m_compact_status(kTableNotCompact),
@@ -1258,30 +1238,25 @@ void TabletIO::SetupOptionsForLG() {
12581238

12591239
leveldb::LG_info* lg_info = new leveldb::LG_info(lg_schema.id());
12601240

1261-
if (FLAGS_tera_leveldb_env_type == "local") {
1262-
m_ldb_options.env = lg_info->env = leveldb::NewPosixEnv();
1263-
m_ldb_options.seek_latency = FLAGS_tera_leveldb_env_local_seek_latency;
1264-
} else {
1265-
if (store == MemoryStore) {
1266-
m_ldb_options.env = lg_info->env = leveldb::EnvInMemory();
1267-
m_ldb_options.seek_latency = 0;
1268-
m_ldb_options.block_cache =
1269-
leveldb::NewLRUCache(FLAGS_tera_memenv_block_cache_size * 1024 * 1024);
1270-
m_mem_store_activated = true;
1271-
} else if (store == FlashStore) {
1272-
if (!FLAGS_tera_tabletnode_cache_enabled) {
1273-
m_ldb_options.env = lg_info->env =
1274-
leveldb::EnvFlash(m_ldb_options.info_log);
1275-
} else {
1276-
LOG(INFO) << "activate block-level Cache store";
1277-
m_ldb_options.env = lg_info->env = leveldb::EnvThreeLevelCache();
1278-
}
1279-
m_ldb_options.seek_latency = FLAGS_tera_leveldb_env_local_seek_latency;
1241+
if (store == MemoryStore) {
1242+
m_ldb_options.env = lg_info->env = LeveldbMemEnv();
1243+
m_ldb_options.seek_latency = 0;
1244+
m_ldb_options.block_cache =
1245+
leveldb::NewLRUCache(FLAGS_tera_memenv_block_cache_size * 1024 * 1024);
1246+
m_mem_store_activated = true;
1247+
} else if (store == FlashStore) {
1248+
if (!FLAGS_tera_tabletnode_cache_enabled) {
1249+
m_ldb_options.env = lg_info->env = LeveldbFlashEnv(m_ldb_options.info_log);
12801250
} else {
1281-
m_ldb_options.env = lg_info->env = leveldb::EnvDfs();
1282-
m_ldb_options.seek_latency = FLAGS_tera_leveldb_env_dfs_seek_latency;
1251+
LOG(INFO) << "activate block-level Cache store";
1252+
m_ldb_options.env = lg_info->env = leveldb::EnvThreeLevelCache();
12831253
}
1254+
m_ldb_options.seek_latency = FLAGS_tera_leveldb_env_local_seek_latency;
1255+
} else {
1256+
m_ldb_options.env = lg_info->env = LeveldbBaseEnv();
1257+
m_ldb_options.seek_latency = FLAGS_tera_leveldb_env_dfs_seek_latency;
12841258
}
1259+
12851260
if (compress) {
12861261
lg_info->compression = leveldb::kSnappyCompression;
12871262
}

0 commit comments

Comments
 (0)