Skip to content
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

Conversation

Cyber-SiKu
Copy link
Contributor

  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

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

  • Relevant documentation/comments is changed or added
  • I acknowledge that all my contributions will be made under the project's license

@Cyber-SiKu Cyber-SiKu force-pushed the curvefs/mds_add_memchache_in_topology branch from f6e0e81 to a9d7a6f Compare November 29, 2022 08:06
@Cyber-SiKu
Copy link
Contributor Author

recheck

@Cyber-SiKu Cyber-SiKu force-pushed the curvefs/mds_add_memchache_in_topology branch from a9d7a6f to 7dd30cc Compare November 29, 2022 09:13
@Cyber-SiKu
Copy link
Contributor Author

recheck

@Cyber-SiKu Cyber-SiKu force-pushed the curvefs/mds_add_memchache_in_topology branch from 7dd30cc to bc28a61 Compare November 29, 2022 11:43
@Cyber-SiKu
Copy link
Contributor Author

recheck

@Cyber-SiKu Cyber-SiKu force-pushed the curvefs/mds_add_memchache_in_topology branch 2 times, most recently from 09f70af to 27aa16b Compare December 1, 2022 07:03
@Cyber-SiKu
Copy link
Contributor Author

recheck

@Cyber-SiKu Cyber-SiKu force-pushed the curvefs/mds_add_memchache_in_topology branch from 27aa16b to 2963e9d Compare December 5, 2022 02:53
@Cyber-SiKu
Copy link
Contributor Author

recheck

2 similar comments
@Cyber-SiKu
Copy link
Contributor Author

recheck

@Cyber-SiKu
Copy link
Contributor Author

recheck

@Cyber-SiKu Cyber-SiKu force-pushed the curvefs/mds_add_memchache_in_topology branch 2 times, most recently from 266d12e to c334fdd Compare December 7, 2022 03:11
@Cyber-SiKu
Copy link
Contributor Author

recheck

@Cyber-SiKu Cyber-SiKu force-pushed the curvefs/mds_add_memchache_in_topology branch from c334fdd to 11dcba6 Compare December 7, 2022 05:10
message ListMemcacheClusterRequest {
}

message MemcacheClusterInfo {
Copy link
Contributor

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

Copy link
Contributor Author

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

#2096 Merge first, fix when merge.

@@ -458,6 +459,33 @@ message ListTopologyResponse {
required ListMetaServerResponse metaservers = 5;
}

message MemcacheServerInfo {
Copy link
Contributor

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add metric for this

Copy link
Contributor Author

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why +1 here

Copy link
Contributor Author

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)
Copy link
Contributor

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.

Copy link
Contributor Author

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

@ilixiaocui ilixiaocui mentioned this pull request Dec 7, 2022
2 tasks
@Cyber-SiKu Cyber-SiKu force-pushed the curvefs/mds_add_memchache_in_topology branch 2 times, most recently from 081cc60 to 2a3aa95 Compare December 8, 2022 02:23
@Cyber-SiKu
Copy link
Contributor Author

recheck

return ret;
}

*cluster = response.cluster();
Copy link
Contributor

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()) ?

Copy link
Contributor Author

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()) ?

image

Copy link
Contributor

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());
Copy link
Contributor

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.

Copy link
Contributor Author

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();
Copy link
Contributor

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?

Copy link
Contributor Author

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()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (!clusterList.empty())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (!clusterList.empty())

fix

@Cyber-SiKu Cyber-SiKu force-pushed the curvefs/mds_add_memchache_in_topology branch 2 times, most recently from 79affe4 to bd311cd Compare December 8, 2022 09:22

bool StorageFs2MemCluster(FsIdType fsId,
MemcacheClusterIdType memClusterId) override;
bool LoadFs2MemCluster(std::unordered_map<FsIdType, MemcacheClusterIdType>*
Copy link
Contributor

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

Copy link
Contributor Author

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add readlock registMemcacheClusterMutex_

Copy link
Contributor Author

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add readlock registMemcacheClusterMutex_

Copy link
Contributor Author

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.

Comment on lines 1710 to 1711
memClusterMap_[data.GetId()] = data;
memClusterMap_.insert(std::make_pair(data.GetId(), std::move(data)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two line is dup

Copy link
Contributor Author

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for condition is wrong

Copy link
Contributor Author

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

@Cyber-SiKu Cyber-SiKu force-pushed the curvefs/mds_add_memchache_in_topology branch 3 times, most recently from c3682be to b4ce25f Compare December 9, 2022 02:22
@YunhuiChen
Copy link
Contributor

recheck

@Cyber-SiKu Cyber-SiKu force-pushed the curvefs/mds_add_memchache_in_topology branch from b4ce25f to 706dd2a Compare December 9, 2022 03:05
@SeanHai
Copy link
Contributor

SeanHai commented Dec 9, 2022

create a new issue related this pr about add unit tests of this pr.

@Cyber-SiKu
Copy link
Contributor Author

create a new issue related this pr about add unit tests of this pr.

add #2147

@Cyber-SiKu
Copy link
Contributor Author

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>
@Cyber-SiKu Cyber-SiKu force-pushed the curvefs/mds_add_memchache_in_topology branch from 706dd2a to 63f4d15 Compare December 9, 2022 08:09
@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu Cyber-SiKu merged commit 982b864 into opencurve:master Dec 9, 2022
@Cyber-SiKu Cyber-SiKu deleted the curvefs/mds_add_memchache_in_topology branch December 9, 2022 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants