Skip to content

Commit

Permalink
curvefs tools space-status
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyber-SiKu authored and ilixiaocui committed Nov 9, 2021
1 parent 43b4df1 commit d39a3a3
Show file tree
Hide file tree
Showing 47 changed files with 2,714 additions and 136 deletions.
4 changes: 4 additions & 0 deletions curvefs/conf/tools.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ mdsAddr=127.0.0.1:6700 # __ANSIBLE_TEMPLATE__ {{ groups.mds | join_peer(hostvar
rpcTimeoutMs=500
# topo file path
topoFilePath=curvefs/test/tools/topo_example.json # __ANSIBLE_TEMPLATE__ {{ project_root_dest }}/conf/topology.json __ANSIBLE_TEMPLATE__
# metaserver
metaserverAddr=127.0.0.1:6701 # __ANSIBLE_TEMPLATE__ {{ groups.metaserver | join_peer(hostvars, "metaserver_listen_port") }} __ANSIBLE_TEMPLATE__
# etcd
etcdAddr=127.0.0.1:12379 # __ANSIBLE_TEMPLATE__ {{ groups.etcd | join_peer(hostvars, "etcd_listen_client_port") }} __ANSIBLE_TEMPLATE__
9 changes: 9 additions & 0 deletions curvefs/proto/copyset.proto
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,16 @@ message CopysetStatusResponse {
optional CopysetStatus copysetStatus = 2;
};

message CopysetsStatusRequest {
repeated CopysetStatusRequest copysets = 1;
}

message CopysetsStatusResponse {
repeated CopysetStatusResponse status = 1;
}

service CopysetService {
rpc CreateCopysetNode(CreateCopysetRequest) returns (CreateCopysetResponse);
rpc GetCopysetStatus(CopysetStatusRequest) returns (CopysetStatusResponse);
rpc GetCopysetsStatus(CopysetsStatusRequest) returns (CopysetsStatusResponse);
}
18 changes: 9 additions & 9 deletions curvefs/proto/mds.proto
Original file line number Diff line number Diff line change
Expand Up @@ -146,22 +146,22 @@ message AllocateS3ChunkResponse {
}


message StatClusterMetadataSpaceRequest{
message StatMetadataUsageRequest{
}

message StatClusterMetadataSpaceResponse{
required FSStatusCode status = 1;
required uint32 total = 2;
required uint32 used = 3;
required uint32 left = 4;
message StatMetadataUsageResponse{
required FSStatusCode statusCode = 1;
// KB
required uint64 total = 2;
required uint64 used = 3;
required uint64 left = 4;
}

message ListClusterFsInfoRequest {
}

message ListClusterFsInfoResponse {
required FSStatusCode statusCode = 1;
repeated FsInfo fsInfo = 2;
repeated FsInfo fsInfo = 1;
}

service MdsService {
Expand All @@ -173,6 +173,6 @@ service MdsService {
// rpc UpdateFsInfo(UpdateFsInfoRequest) returns (UpdateFsInfoResponse);
rpc DeleteFs(DeleteFsRequest) returns (DeleteFsResponse);
rpc AllocateS3Chunk(AllocateS3ChunkRequest) returns (AllocateS3ChunkResponse);
rpc StatClusterMetadataSpace(StatClusterMetadataSpaceRequest) returns (StatClusterMetadataSpaceResponse);
rpc StatMetadataUsage(StatMetadataUsageRequest) returns (StatMetadataUsageResponse);
rpc ListClusterFsInfo (ListClusterFsInfoRequest) returns (ListClusterFsInfoResponse);
}
13 changes: 12 additions & 1 deletion curvefs/proto/metaserver.proto
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,15 @@ message MetaServerMetadata {
required uint32 id = 2;
required string token = 3;
// required uint32 checksum = 4;
};
}

message GetAllCopysetsIdRequest {
}

message GetAllCopysetsIdResponse {
required MetaStatusCode statusCode = 1;
repeated uint32 copysetsId = 2;
}

service MetaServerService {
// dentry interface
Expand All @@ -313,4 +321,7 @@ service MetaServerService {
// partition interface
rpc CreatePartition(CreatePartitionRequest) returns (CreatePartitionResponse);
rpc DeletePartition(DeletePartitionRequest) returns (DeletePartitionResponse);

// get all copysets id
rpc GetAllCopysetId(GetAllCopysetsIdRequest) returns (GetAllCopysetsIdResponse);
}
34 changes: 32 additions & 2 deletions curvefs/proto/topology.proto
Original file line number Diff line number Diff line change
Expand Up @@ -380,13 +380,41 @@ message CommitTxResponse {
required TopoStatusCode statusCode = 1;
}

message ListPartitionsRequest {
repeated uint32 fsId = 1;
}

message PartitionInfoList {
repeated common.PartitionInfo partitionInfoList = 1;
}

message ListPartitionsResponse {
required TopoStatusCode statusCode = 1;
map<uint32, PartitionInfoList> fsId2partitionList = 2;
}

message GetCopysetInfoRequest {
required uint32 copysetId = 1;
required uint32 poolId = 1;
required uint32 copysetId = 2;
}

message CopysetInfo {
required uint32 poolId = 1;
required uint32 copysetId = 2;
repeated common.Peer peers = 3;
}

message GetCopysetInfoResponse {
required TopoStatusCode statusCode = 1;
required curvefs.mds.heartbeat.CopySetInfo copysetInfo = 2;
optional CopysetInfo copysetInfo = 2;
}

message GetCopysetsInfoRequest {
repeated GetCopysetInfoRequest copysets= 1;
}

message GetCopysetsInfoResponse {
repeated GetCopysetInfoResponse copysetsInfo = 1;
}

service TopologyService {
Expand Down Expand Up @@ -416,5 +444,7 @@ service TopologyService {
rpc ListPartition(ListPartitionRequest) returns (ListPartitionResponse);
rpc GetCopysetOfPartition(GetCopysetOfPartitionRequest) returns (GetCopysetOfPartitionResponse);
rpc CommitTx(CommitTxRequest) returns (CommitTxResponse);
rpc ListPartitions(ListPartitionsRequest) returns (ListPartitionsResponse);
rpc GetCopysetInfo (GetCopysetInfoRequest) returns (GetCopysetInfoResponse);
rpc GetCopysetsInfo (GetCopysetsInfoRequest) returns (GetCopysetsInfoResponse);
}
10 changes: 10 additions & 0 deletions curvefs/src/mds/topology/deal_peerid.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ inline bool SplitPeerId(const std::string &peerId, std::string *ip,
return false;
}

inline bool SplitPeerId(const std::string& peerId, std::string* addr) {
std::vector<std::string> items;
curve::common::SplitString(peerId, ":", &items);
if (3 == items.size()) {
*addr = items[0] + ":" + items[1];
return true;
}
return false;
}

} // namespace topology
} // namespace mds
} // namespace curvefs
Expand Down
41 changes: 35 additions & 6 deletions curvefs/src/tools/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,54 @@ cc_binary(
],
)


# tools lib
cc_library(
name = "curvefs_tools_lib",
srcs = glob([
"curvefs_tool.cpp",
"curvefs_tool_factory.cpp",
"version/curvefs_version_tool.cpp",
"umountfs/curvefs_umountfs_tool.cpp",
"curvefs_tool_define.cpp",
"topology/curvefs_build_topology_tool.cpp",
"curvefs_tool_metric.cpp",
"build/curvefs_build_topology_tool.cpp",
"version/curvefs_version_tool.cpp",
"space/curvefs_metadata_usage_tool.cpp",
"space/curvefs_space_base_tool.cpp",
"status/curvefs_status_base_tool.cpp",
"status/curvefs_mds_status.cpp",
"status/curvefs_metaserver_status.cpp",
"status/curvefs_etcd_status.cpp",
"status/curvefs_copyset_status.cpp",
"query/curvefs_copyset_query.cpp",
"list/curvefs_fs_partition_list.cpp",
"list/curvefs_fsinfo_list.cpp",
"status/curvefs_metaserver_status.cpp",
"list/curvefs_copysetid_list.cpp",

]),
hdrs = glob([
"curvefs_tool.h",
"curvefs_tool_factory.h",
"curvefs_tool_define.h",
"curvefs_tool_metric.h",
"version/curvefs_version_tool.h",
"curvefs_tool_abstract_creator.h",
"umountfs/curvefs_umountfs_tool.h",
"topology/curvefs_build_topology_tool.h",
"build/curvefs_build_topology_tool.h",
"space/curvefs_metadata_usage_tool.h",
"space/curvefs_space_base_tool.h",
"status/curvefs_status_base_tool.h",
"status/curvefs_mds_status.h",
"status/curvefs_copyset_status.h",
"query/curvefs_copyset_query.h",
"list/curvefs_fs_partition_list.h",
"list/curvefs_fsinfo_list.h",
"status/curvefs_metaserver_status.h",
"status/curvefs_etcd_status.h",
"list/curvefs_copysetid_list.h",
]),
copts = COPTS,
linkopts = [
"-lpthread"
],
visibility = ["//visibility:public"],
deps = [
Expand All @@ -77,8 +102,12 @@ cc_library(
"//external:glog",
"//external:json",
"//curvefs/src/mds/common:fs_mds_common",
"//src/common:curve_common",
"//curvefs/src/mds/topology:curvefs_deal_peerid",
"//src/mds/topology:topology",
"//curvefs/proto:mds_cc_proto",
"//curvefs/proto:curvefs_topology_cc_proto",
"//curvefs/proto:space_cc_proto",
"//curvefs/proto:copyset_cc_proto",
"//curvefs/proto:metaserver_cc_proto",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
* Author: wanghai01
*/

#include "curvefs/src/tools/topology/curvefs_build_topology_tool.h"
#include "curvefs/src/tools/build/curvefs_build_topology_tool.h"

DECLARE_string(mds_addr);
DECLARE_string(cluster_map);
DECLARE_uint32(rpcTimeOutMs);
DECLARE_string(confPath);
DECLARE_string(op);

Expand All @@ -42,8 +41,8 @@ void UpdateFlagsFromConf(curve::common::Configuration* conf) {
LOG(INFO) << "conf: " << FLAGS_mds_addr;
}

if (GetCommandLineFlagInfo("rpcTimeOutMs", &info) && info.is_default) {
conf->GetUInt32Value("rpcTimeoutMs", &FLAGS_rpcTimeOutMs);
if (GetCommandLineFlagInfo("rpcTimeoutMs", &info) && info.is_default) {
conf->GetUInt32Value("rpcTimeoutMs", &FLAGS_rpcTimeoutMs);
}

if (GetCommandLineFlagInfo("cluster_map", &info) && info.is_default) {
Expand Down Expand Up @@ -323,7 +322,7 @@ int CurvefsBuildTopologyTool::ListPool(std::list<PoolInfo>* poolInfos) {
ListPoolRequest request;
ListPoolResponse response;
brpc::Controller cntl;
cntl.set_timeout_ms(FLAGS_rpcTimeOutMs);
cntl.set_timeout_ms(FLAGS_rpcTimeoutMs);
cntl.set_log_id(1);

LOG(INFO) << "ListPool send request: " << request.DebugString();
Expand Down Expand Up @@ -355,7 +354,7 @@ int CurvefsBuildTopologyTool::GetZonesInPool(PoolIdType poolid,
request.set_poolid(poolid);

brpc::Controller cntl;
cntl.set_timeout_ms(FLAGS_rpcTimeOutMs);
cntl.set_timeout_ms(FLAGS_rpcTimeoutMs);
cntl.set_log_id(1);

LOG(INFO) << "ListZoneInPool, send request: " << request.DebugString();
Expand Down Expand Up @@ -388,7 +387,7 @@ int CurvefsBuildTopologyTool::GetServersInZone(
ListZoneServerResponse response;
request.set_zoneid(zoneid);
brpc::Controller cntl;
cntl.set_timeout_ms(FLAGS_rpcTimeOutMs);
cntl.set_timeout_ms(FLAGS_rpcTimeoutMs);
cntl.set_log_id(1);

LOG(INFO) << "ListZoneServer, send request: " << request.DebugString();
Expand Down Expand Up @@ -429,7 +428,7 @@ int CurvefsBuildTopologyTool::CreatePool() {
request.set_redundanceandplacementpolicy(rapString);

brpc::Controller cntl;
cntl.set_timeout_ms(FLAGS_rpcTimeOutMs);
cntl.set_timeout_ms(FLAGS_rpcTimeoutMs);
cntl.set_log_id(1);

LOG(INFO) << "CreatePool, send request: " << request.DebugString();
Expand Down Expand Up @@ -468,7 +467,7 @@ int CurvefsBuildTopologyTool::CreateZone() {
request.set_poolname(it.poolName);

brpc::Controller cntl;
cntl.set_timeout_ms(FLAGS_rpcTimeOutMs);
cntl.set_timeout_ms(FLAGS_rpcTimeoutMs);
cntl.set_log_id(1);

LOG(INFO) << "CreateZone, send request: " << request.DebugString();
Expand Down Expand Up @@ -511,7 +510,7 @@ int CurvefsBuildTopologyTool::CreateServer() {
request.set_poolname(it.poolName);

brpc::Controller cntl;
cntl.set_timeout_ms(FLAGS_rpcTimeOutMs);
cntl.set_timeout_ms(FLAGS_rpcTimeoutMs);
cntl.set_log_id(1);

LOG(INFO) << "CreateServer, send request: " << request.DebugString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
* Author: chengyi01
*/

#ifndef CURVEFS_SRC_TOOLS_TOPOLOGY_CURVEFS_BUILD_TOPOLOGY_TOOL_H_
#define CURVEFS_SRC_TOOLS_TOPOLOGY_CURVEFS_BUILD_TOPOLOGY_TOOL_H_
#ifndef CURVEFS_SRC_TOOLS_BUILD_CURVEFS_BUILD_TOPOLOGY_TOOL_H_
#define CURVEFS_SRC_TOOLS_BUILD_CURVEFS_BUILD_TOPOLOGY_TOOL_H_

#include <brpc/channel.h>
#include <brpc/server.h>
Expand Down Expand Up @@ -160,4 +160,4 @@ class CurvefsBuildTopologyTool : public curvefs::tools::CurvefsTool {
} // namespace mds
} // namespace curvefs

#endif // CURVEFS_SRC_TOOLS_TOPOLOGY_CURVEFS_BUILD_TOPOLOGY_TOOL_H_
#endif // CURVEFS_SRC_TOOLS_BUILD_CURVEFS_BUILD_TOPOLOGY_TOOL_H_
Loading

0 comments on commit d39a3a3

Please sign in to comment.