|
15 | 15 | #include "io/tablet_writer.h" |
16 | 16 | #include "io/timekey_comparator.h" |
17 | 17 | #include "io/ttlkv_compact_strategy.h" |
| 18 | +#include "io/utils_leveldb.h" |
18 | 19 | #include "leveldb/cache.h" |
19 | 20 | #include "leveldb/compact_strategy.h" |
20 | 21 | #include "leveldb/env.h" |
@@ -66,27 +67,6 @@ extern tera::Counter row_read_delay; |
66 | 67 | namespace tera { |
67 | 68 | namespace io { |
68 | 69 |
|
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 | | - |
90 | 70 | TabletIO::TabletIO() |
91 | 71 | : m_async_writer(NULL), |
92 | 72 | m_compact_status(kTableNotCompact), |
@@ -1258,30 +1238,25 @@ void TabletIO::SetupOptionsForLG() { |
1258 | 1238 |
|
1259 | 1239 | leveldb::LG_info* lg_info = new leveldb::LG_info(lg_schema.id()); |
1260 | 1240 |
|
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); |
1280 | 1250 | } 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(); |
1283 | 1253 | } |
| 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; |
1284 | 1258 | } |
| 1259 | + |
1285 | 1260 | if (compress) { |
1286 | 1261 | lg_info->compression = leveldb::kSnappyCompression; |
1287 | 1262 | } |
|
0 commit comments