-
Notifications
You must be signed in to change notification settings - Fork 436
Upgrade split #253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Upgrade split #253
Changes from 2 commits
139dfa5
174d8fa
2bd76e5
8877b16
508d87c
8aae5c1
e90a853
9f045f5
865ad1c
c3e9248
770f055
228bb44
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -134,6 +134,11 @@ bool TabletIO::Load(const TableSchema& schema, | |
| StatusCode* status) { | ||
| { | ||
| MutexLock lock(&m_mutex); | ||
| LOG(INFO) << __func__ << ", path " << path << ", status " | ||
| << StatusCodeToString(m_status) << ", m_start_key " | ||
| << m_start_key << ", m_end_key " << m_end_key | ||
| << ", key_start " << key_start << ", key_end " << key_end; | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 加上DebugString吧,防止乱码 |
||
| if (m_status == kReady && m_start_key == key_start | ||
| && m_end_key == key_end) { | ||
| return true; | ||
|
|
@@ -314,12 +319,13 @@ bool TabletIO::Unload(StatusCode* status) { | |
|
|
||
| { | ||
| MutexLock lock(&m_mutex); | ||
| m_status = kNotInit; | ||
| m_status = kFrozen; | ||
| m_db_ref_count--; | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| // discard it, never use it | ||
| bool TabletIO::Split(std::string* split_key, StatusCode* status) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 删掉 |
||
| { | ||
| MutexLock lock(&m_mutex); | ||
|
|
@@ -396,6 +402,64 @@ bool TabletIO::Split(std::string* split_key, StatusCode* status) { | |
| return true; | ||
| } | ||
|
|
||
| bool TabletIO::GetMidKey(std::string* mid_key, StatusCode* status) | ||
| { | ||
| { | ||
| MutexLock lock(&m_mutex); | ||
| if (m_status != kReady && | ||
| m_status != kOnSplit && | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OnSplit和Splited不是作废了吗 |
||
| m_status != kSplited && | ||
| m_status != kUnLoading) { | ||
| SetStatusCode(m_status, status); | ||
| return false; | ||
| } | ||
| m_db_ref_count++; | ||
| } | ||
|
|
||
| // find mid key | ||
| std::string raw_split_key; | ||
| if (!m_db->FindSplitKey(m_raw_start_key, m_raw_end_key, 0.5, | ||
| &raw_split_key)) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 缩进。。 |
||
| MutexLock lock(&m_mutex); | ||
| SetStatusCode(kTableNotSupport, status); | ||
| m_db_ref_count--; | ||
| return false; | ||
| } | ||
|
|
||
| // parse key | ||
| leveldb::Slice key_split; | ||
| if (m_kv_only && m_table_schema.raw_key() == Readable) { | ||
| key_split = raw_split_key; | ||
| } else { | ||
| leveldb::Slice cf_split; | ||
| leveldb::Slice qu_split; | ||
| if (!m_key_operator->ExtractTeraKey(raw_split_key, &key_split, | ||
| &cf_split, &qu_split, NULL, NULL)) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 缩进。。 |
||
| SetStatusCode(kTableNotSupport, status); | ||
| MutexLock lock(&m_mutex); | ||
| m_db_ref_count--; | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| // sanity check key | ||
| if (key_split.empty() || key_split.ToString() <= m_start_key || | ||
| (!m_end_key.empty() && key_split.ToString() >= m_end_key)) { | ||
| SetStatusCode(kTableNotSupport, status); | ||
| MutexLock lock(&m_mutex); | ||
| m_db_ref_count--; | ||
| return false; | ||
| } | ||
|
|
||
| *mid_key = key_split.ToString(); | ||
| { | ||
| MutexLock lock(&m_mutex); | ||
| SetStatusCode(kTabletNodeOk, status); | ||
| m_db_ref_count--; | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| bool TabletIO::Compact(StatusCode* status) { | ||
| { | ||
| MutexLock lock(&m_mutex); | ||
|
|
@@ -1720,6 +1784,12 @@ const leveldb::RawKeyOperator* TabletIO::GetRawKeyOperator() { | |
| } | ||
|
|
||
| void TabletIO::GetAndClearCounter(TabletCounter* counter, int64_t interval) { | ||
| std::string mid_key; | ||
| StatusCode status = kTabletNodeOk; | ||
| if (!GetMidKey(&mid_key, &status)) { | ||
| mid_key.clear(); | ||
| } | ||
|
|
||
| counter->set_low_read_cell(m_counter.low_read_cell.Clear() * 1000000 / interval); | ||
| counter->set_scan_rows(m_counter.scan_rows.Clear() * 1000000 / interval); | ||
| counter->set_scan_kvs(m_counter.scan_kvs.Clear() * 1000000 / interval); | ||
|
|
@@ -1731,6 +1801,8 @@ void TabletIO::GetAndClearCounter(TabletCounter* counter, int64_t interval) { | |
| counter->set_write_kvs(m_counter.write_kvs.Clear() * 1000000 / interval); | ||
| counter->set_write_size(m_counter.write_size.Clear() * 1000000 / interval); | ||
| counter->set_is_on_busy(IsBusy()); | ||
|
|
||
| counter->set_mid_key(mid_key); | ||
| } | ||
|
|
||
| int32_t TabletIO::AddRef() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,10 +38,11 @@ class TabletIO { | |
| kNotInit = kTabletNotInit, | ||
| kReady = kTabletReady, | ||
| kOnLoad = kTabletOnLoad, | ||
| kOnSplit = kTabletOnSplit, | ||
| kSplited = kTabletSplited, | ||
| kUnLoading = kTabletUnLoading, | ||
| kUnLoading2 = kTabletUnLoading2 | ||
| kUnLoading2 = kTabletUnLoading2, | ||
| kOnSplit = kTabletOnSplit,// discard | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 果断滴删掉 |
||
| kSplited = kTabletSplited,// discard | ||
| kFrozen = kTabletFrozen, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. kunloading2是原代码的状态,tablietio进行该卸载第二阶段,需要阻塞读写;kfrozen状态是卸载结束后tabletio进入的状态,表示该区间目前不操作; |
||
| }; | ||
| typedef std::map< std::string, std::set<std::string> > ColumnFamilyMap; | ||
| struct ScanOptions { | ||
|
|
@@ -96,7 +97,10 @@ class TabletIO { | |
| leveldb::TableCache* table_cache = NULL, | ||
| StatusCode* status = NULL); | ||
| virtual bool Unload(StatusCode* status = NULL); | ||
|
|
||
| virtual bool Split(std::string* split_key, StatusCode* status = NULL); | ||
| virtual bool GetMidKey(std::string* mid_key, StatusCode* status); | ||
|
|
||
| virtual bool Compact(StatusCode* status = NULL); | ||
| bool CompactMinor(StatusCode* status = NULL); | ||
| bool Destroy(StatusCode* status = NULL); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这些日志是必须的么?