Skip to content

Commit

Permalink
refactor AdminClient (vesoft-inc#3781)
Browse files Browse the repository at this point in the history
* refactor AdminClient

* fix test case, unify all getAdminAddrFromStoreAddr into AdminClient

* add more test cases

* address @panda-sheep's comment
  • Loading branch information
critical27 authored and liwenhui-soul committed Jan 29, 2022
1 parent 67c2922 commit 1815766
Show file tree
Hide file tree
Showing 40 changed files with 861 additions and 558 deletions.
44 changes: 26 additions & 18 deletions src/interface/storage.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ service GraphStorageService {
//////////////////////////////////////////////////////////
// Common response for admin methods
struct AdminExecResp {
1: required ResponseCommon result,
1: required ResponseCommon result,
2: optional meta.StatsItem stats,
}

Expand Down Expand Up @@ -759,27 +759,36 @@ struct CreateCPRequest {
2: binary name,
}

struct CreateCPResp {
1: common.ErrorCode code,
2: list<common.CheckpointInfo> info,
}

struct DropCPRequest {
1: list<common.GraphSpaceID> space_ids,
2: binary name,
}

struct DropCPResp {
1: common.ErrorCode code,
}

enum EngineSignType {
BLOCK_ON = 1,
BLOCK_OFF = 2,
}


struct BlockingSignRequest {
1: list<common.GraphSpaceID> space_ids,
2: required EngineSignType sign,
}

struct BlockingSignResp {
1: common.ErrorCode code,
}

struct GetLeaderPartsResp {
1: required ResponseCommon result,
1: common.ErrorCode code,
2: map<common.GraphSpaceID, list<common.PartitionID>> (
cpp.template = "std::unordered_map") leader_parts;
}
Expand All @@ -798,11 +807,6 @@ struct RebuildIndexRequest {
3: common.IndexID index_id,
}

struct CreateCPResp {
1: required ResponseCommon result,
2: list<common.CheckpointInfo> info,
}

struct ListClusterInfoResp {
1: required ResponseCommon result,
2: common.DirInfo dir,
Expand All @@ -811,7 +815,7 @@ struct ListClusterInfoResp {
struct ListClusterInfoReq {
}

struct AddAdminTaskRequest {
struct AddTaskRequest {
// rebuild index / flush / compact / statis
1: meta.AdminCmd cmd
2: i32 job_id
Expand All @@ -820,11 +824,19 @@ struct AddAdminTaskRequest {
5: optional i32 concurrency
}

struct StopAdminTaskRequest {
struct AddTaskResp {
1: common.ErrorCode code,
}

struct StopTaskRequest {
1: i32 job_id
2: i32 task_id
}

struct StopTaskResp {
1: common.ErrorCode code,
}

service StorageAdminService {
// Interfaces for admin operations
AdminExecResp transLeader(1: TransLeaderReq req);
Expand All @@ -836,20 +848,16 @@ service StorageAdminService {

// Interfaces for nebula cluster checkpoint
CreateCPResp createCheckpoint(1: CreateCPRequest req);
AdminExecResp dropCheckpoint(1: DropCPRequest req);
AdminExecResp blockingWrites(1: BlockingSignRequest req);

// Interfaces for rebuild index
AdminExecResp rebuildTagIndex(1: RebuildIndexRequest req);
AdminExecResp rebuildEdgeIndex(1: RebuildIndexRequest req);
DropCPResp dropCheckpoint(1: DropCPRequest req);
BlockingSignResp blockingWrites(1: BlockingSignRequest req);

// Return all leader partitions on this host
GetLeaderPartsResp getLeaderParts(1: GetLeaderReq req);
// Return all peers
AdminExecResp checkPeers(1: CheckPeersReq req);

AdminExecResp addAdminTask(1: AddAdminTaskRequest req);
AdminExecResp stopAdminTask(1: StopAdminTaskRequest req);
AddTaskResp addAdminTask(1: AddTaskRequest req);
StopTaskResp stopAdminTask(1: StopTaskRequest req);
}


Expand Down
15 changes: 0 additions & 15 deletions src/meta/ActiveHostsMan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,21 +226,6 @@ ErrorOr<nebula::cpp2::ErrorCode, std::vector<HostAddr>> ActiveHostsMan::getActiv
return activeHosts;
}

ErrorOr<nebula::cpp2::ErrorCode, std::vector<HostAddr>> ActiveHostsMan::getActiveAdminHosts(
kvstore::KVStore* kv, int32_t expiredTTL, cpp2::HostRole role) {
auto hostsRet = getActiveHosts(kv, expiredTTL, role);
if (!nebula::ok(hostsRet)) {
return nebula::error(hostsRet);
}
auto hosts = nebula::value(hostsRet);

std::vector<HostAddr> adminHosts(hosts.size());
std::transform(hosts.begin(), hosts.end(), adminHosts.begin(), [](const auto& h) {
return Utils::getAdminAddrFromStoreAddr(h);
});
return adminHosts;
}

ErrorOr<nebula::cpp2::ErrorCode, bool> ActiveHostsMan::isLived(kvstore::KVStore* kv,
const HostAddr& host) {
auto activeHostsRet = getActiveHosts(kv);
Expand Down
3 changes: 0 additions & 3 deletions src/meta/ActiveHostsMan.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ class ActiveHostsMan final {
static ErrorOr<nebula::cpp2::ErrorCode, std::vector<HostAddr>> getActiveHostsWithZones(
kvstore::KVStore* kv, GraphSpaceID spaceId, int32_t expiredTTL = 0);

static ErrorOr<nebula::cpp2::ErrorCode, std::vector<HostAddr>> getActiveAdminHosts(
kvstore::KVStore* kv, int32_t expiredTTL = 0, cpp2::HostRole role = cpp2::HostRole::STORAGE);

static ErrorOr<nebula::cpp2::ErrorCode, bool> isLived(kvstore::KVStore* kv, const HostAddr& host);

static ErrorOr<nebula::cpp2::ErrorCode, HostInfo> getHostInfo(kvstore::KVStore* kv,
Expand Down
Loading

0 comments on commit 1815766

Please sign in to comment.