-
Notifications
You must be signed in to change notification settings - Fork 487
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
curvefs: support memcache cluster #2108
curvefs: support memcache cluster #2108
Conversation
f6e0e81
to
a9d7a6f
Compare
recheck |
a9d7a6f
to
7dd30cc
Compare
recheck |
7dd30cc
to
bc28a61
Compare
recheck |
09f70af
to
27aa16b
Compare
recheck |
27aa16b
to
2963e9d
Compare
recheck |
2 similar comments
recheck |
recheck |
266d12e
to
c334fdd
Compare
recheck |
c334fdd
to
11dcba6
Compare
message ListMemcacheClusterRequest { | ||
} | ||
|
||
message MemcacheClusterInfo { |
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.
the message is not same with #2096
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.
@@ -458,6 +459,33 @@ message ListTopologyResponse { | |||
required ListMetaServerResponse metaservers = 5; | |||
} | |||
|
|||
message MemcacheServerInfo { |
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.
the message is not same with #2096
@@ -413,6 +413,40 @@ bool MdsClientImpl::ListPartition(uint32_t fsID, | |||
return 0 == rpcexcutor_.DoRPCTask(task, mdsOpt_.mdsMaxRetryMS); | |||
} | |||
|
|||
bool MdsClientImpl::AllocOrGetMemcacheCluster(MemcacheClusterInfo* cluster) { | |||
auto task = RPCTask { |
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.
add metric for this
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.
add metric for this
fix
response.memclusters(); | ||
if (!clusters.empty()) { | ||
int randId = | ||
(static_cast<int>(butil::fast_rand()) % clusters.size()) + 1; |
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.
why +1 here
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.
why +1 here
fix
@@ -57,7 +58,7 @@ struct ClusterInformation { | |||
std::map<uint32_t, uint32_t> partitionIndexs; | |||
|
|||
ClusterInformation() = default; | |||
explicit ClusterInformation(const std::string &clusterId) | |||
explicit ClusterInformation(const std::string& clusterId) |
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.
这个文件有大量的格式修改,没有办法review,这种仅仅是格式的修改,而且旧的格式问题不大,最好不要去动他,建议格式恢复回去再review。
This file has a lot of format changes, and there is no way to review it. This is only a format modification, and the old format is not a big problem. It is best not to touch it. It is recommended to restore the format and review it.
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.
这个文件有大量的格式修改,没有办法review,这种仅仅是格式的修改,而且旧的格式问题不大,最好不要去动他,建议格式恢复回去再review。
This file has a lot of format changes, and there is no way to review it. This is only a format modification, and the old format is not a big problem. It is best not to touch it. It is recommended to restore the format and review it.
fix
081cc60
to
2a3aa95
Compare
recheck |
return ret; | ||
} | ||
|
||
*cluster = response.cluster(); |
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.
*cluster = std::move(*response.mutable_cluster()) ?
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.
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.
don't use response.cluster() instead with *response.mutable_cluster()
response->set_statuscode(TopoStatusCode::TOPO_OK); | ||
// register memcacheCluster as server | ||
curve::common::NameLockGuard lock(registMemcacheClusterMutex_, | ||
request->ShortDebugString()); |
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.
I'm not sure the ShortDebugString are the same when the different order of servers added in request.
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.
I'm not sure the ShortDebugString are the same when the different order of servers added in request.
fix
request->ShortDebugString()); | ||
|
||
// Guarantee the uniqueness of memcacheServer | ||
std::list<MemcacheServer> serverRegisted = topology_->ListMemcacheServers(); |
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.
Can one machine serve two clusters?
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.
Can one machine serve two clusters?
yep
void TopologyManager::ListMemcacheCluster( | ||
ListMemcacheClusterResponse* response) { | ||
std::list<MemcacheCluster> clusterList = topology_->ListMemcacheClusters(); | ||
if (clusterList.empty()) { |
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.
if (!clusterList.empty())
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.
if (!clusterList.empty())
fix
79affe4
to
bd311cd
Compare
|
||
bool StorageFs2MemCluster(FsIdType fsId, | ||
MemcacheClusterIdType memClusterId) override; | ||
bool LoadFs2MemCluster(std::unordered_map<FsIdType, MemcacheClusterIdType>* |
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.
MemCluster is MemcacheCluster
memCluster may be mistaken for memoryCluster
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.
MemCluster is MemcacheCluster
memCluster may be mistaken for memoryCluster
fix
} | ||
|
||
void TopologyManager::ListMemcacheCluster( | ||
ListMemcacheClusterResponse* response) { |
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.
add readlock registMemcacheClusterMutex_
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.
add readlock registMemcacheClusterMutex_
In topology_->ListMemcacheClusters();
there is ReadLockGuard rlockMemcacheCluster(memcacheClusterMutex_);
which can already guarantee the validity of the data?
|
||
void TopologyManager::AllocOrGetMemcacheCluster( | ||
const AllocOrGetMemcacheClusterRequest* request, | ||
AllocOrGetMemcacheClusterResponse* response) { |
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.
add readlock registMemcacheClusterMutex_
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.
add readlock registMemcacheClusterMutex_
ditto
topology_->AllocOrGetMemcacheCluster
to ensure data consistency.
memClusterMap_[data.GetId()] = data; | ||
memClusterMap_.insert(std::make_pair(data.GetId(), std::move(data))); |
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.
two line is dup
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.
two line is dup
fix
int randId = | ||
static_cast<int>(butil::fast_rand()) % memClusterMap_.size(); | ||
auto iter = memClusterMap_.cbegin(); | ||
for (int i = 0; i <= randId; ++i, ++iter) continue; |
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.
for condition is wrong
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.
for condition is wrong
fix
c3682be
to
b4ce25f
Compare
recheck |
b4ce25f
to
706dd2a
Compare
create a new issue related this pr about add unit tests of this pr. |
add #2147 |
cicheck |
1. add define in topology.proto 2. add RegistMemcacheCluster in topology service 3. add define in topology_item 4. add AllocOrGetMemcacheCluster in client/mdsclinet 5. add ListMemcacheCluster in topology service Signed-off-by: Cyber-SiKu <Cyber-SiKu@outlook.com>
706dd2a
to
63f4d15
Compare
cicheck |
Signed-off-by: Cyber-SiKu Cyber-SiKu@outlook.com
What problem does this PR solve?
Issue Number: #xxx
Problem Summary:
What is changed and how it works?
What's Changed:
How it Works:
Side effects(Breaking backward compatibility? Performance regression?):
Check List