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

Implement admin client for balancer #553

Merged
merged 5 commits into from
Jul 15, 2019

Conversation

dangleptr
Copy link
Contributor

@dangleptr dangleptr commented Jun 28, 2019

The PR is based on #516 .

Subtask of #515

@dangleptr dangleptr added the do not review PR: not ready for the code review yet label Jun 28, 2019
@dangleptr dangleptr added this to the v1_beta_release milestone Jun 28, 2019
@dangleptr dangleptr requested review from critical27 and whitewum July 4, 2019 11:08
@dangleptr dangleptr added ready-for-testing PR: ready for the CI test and removed do not review PR: not ready for the code review yet labels Jul 4, 2019
@dangleptr
Copy link
Contributor Author

Jenkins go

@nebula-community-bot
Copy link
Member

Unit testing passed.

namespace nebula {
namespace meta {

TEST(BalanceIntegrationTest, SimpleTest) {
Copy link
Contributor

Choose a reason for hiding this comment

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

more tests on going?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. The BalanceIntegrationTest will go on when server-side is ready.

case storage::cpp2::ErrorCode::E_LEADER_CHANGED: {
if (retry < retryLimit) {
HostAddr leader(resp.get_leader().get_ip(), resp.get_leader().get_port());
int32_t leaderIndex = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

clear to 0 every time?

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 code here is to find the index of leader in hosts.

});
}

nebula::cpp2::HostAddr AdminClient::to(const HostAddr& addr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

better naming than to()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about toThriftHost ?

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds better

}
case kvstore::ResultCode::ERR_KEY_NOT_FOUND:
return Status::Error("Key Not Found");
default:
Copy link
Contributor

Choose a reason for hiding this comment

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

need a log?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point.


StatusOr<std::vector<HostAddr>> AdminClient::getPeers(GraphSpaceID spaceId, PartitionID partId) {
CHECK_NOTNULL(kv_);
auto partKey = MetaServiceUtils::partKey(spaceId, partId);
Copy link
Contributor

Choose a reason for hiding this comment

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

copy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Compiler will optimize it. The partKey will reuse the returned string's allocation.

@@ -38,7 +38,7 @@ void BalanceTask::invoke() {
case Status::CHANGE_LEADER: {
LOG(INFO) << taskIdStr_ << "Ask the src to give up the leadership.";
SAVE_STATE();
client_->transLeader(spaceId_, partId_, src_, dst_).thenValue([this](auto&& resp) {
client_->transLeader(spaceId_, partId_, src_).thenValue([this](auto&& resp) {
Copy link
Contributor

Choose a reason for hiding this comment

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

line 36: ms or s ?
BTW, do more logs in this function: a lot of cases for state change tracking

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. We should use MS here.

ASSERT_EQ(HostAddr(localIp, sc2->port_), hosts[0]);
ASSERT_EQ(HostAddr(localIp, sc1->port_), hosts[1]);
ASSERT_EQ(HostAddr(1, 1), hosts[2]);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

let's try more than 3 hosts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. We have more situations to test. Let's open another issue to track it.

baton.post();
});
baton.wait();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

what about add part again?
or let's loop the test a few times

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AddPart again will be tested on server side. The UT is just to test client interface.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep. It's simple for the client, but a valued corned case.

@nebula-community-bot
Copy link
Member

Unit testing failed.

@dangleptr
Copy link
Contributor Author

Jenkins go

@nebula-community-bot
Copy link
Member

Unit testing passed.

req.set_space_id(spaceId);
req.set_part_id(partId);
req.set_as_learner(asLearner);
return getResponse(host, std::move(req), [] (auto client, auto request) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I can not understand why need move(req) here, the req’s memory is in caller stack, and the parameter req of getResponse passed by value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe req will be changed in the future. So use move here.

}
folly::Promise<Status> pro;
auto f = pro.getFuture();
getResponse(ret.value(), 0, req, [] (auto client, auto request) {
Copy link
Contributor

Choose a reason for hiding this comment

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

and here why not move(req)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A HA. Good catch! We should use move.

@nebula-community-bot
Copy link
Member

Unit testing passed.

wadeliuyi
wadeliuyi previously approved these changes Jul 15, 2019
Copy link
Contributor

@wadeliuyi wadeliuyi left a comment

Choose a reason for hiding this comment

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

LGTM

@nebula-community-bot
Copy link
Member

Unit testing failed.

whitewum
whitewum previously approved these changes Jul 15, 2019
Copy link
Contributor

@whitewum whitewum left a comment

Choose a reason for hiding this comment

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

Please consider some corner cases: 1.operations failed at the server side, or 2. client crashed and resume to do some job (what should client do).

}
leaderIndex++;
}
LOG(INFO) << "Return leder change from " << hosts[index]
Copy link
Contributor

Choose a reason for hiding this comment

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

leader

});
}

nebula::cpp2::HostAddr AdminClient::to(const HostAddr& addr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

sounds better

}
}

TEST(AdminClientTest, RetryTest) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Great!

baton.post();
});
baton.wait();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Yep. It's simple for the client, but a valued corned case.

@dangleptr dangleptr dismissed stale reviews from whitewum and wadeliuyi via 4684f43 July 15, 2019 09:10
@nebula-community-bot
Copy link
Member

Unit testing passed.

@dangleptr
Copy link
Contributor Author

Please consider some corner cases: 1.operations failed at the server side, or 2. client crashed and resume to do some job (what should client do).

Yes, all interfaces here reentrant functions. When we implement them on server-side, we should keep the principle

Copy link
Contributor

@wadeliuyi wadeliuyi left a comment

Choose a reason for hiding this comment

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

LGTM

@nebula-community-bot
Copy link
Member

Unit testing passed.

@dangleptr dangleptr merged commit 0a3fbc4 into vesoft-inc:master Jul 15, 2019
@dangleptr dangleptr deleted the balancer-client branch July 15, 2019 10:52
yixinglu pushed a commit to yixinglu/nebula that referenced this pull request Feb 16, 2020
* Implement AdminClient

* Address whitewum's comments

* Address wadeliuyi's comments

* Fix failed compile
tong-hao pushed a commit to tong-hao/nebula that referenced this pull request Jun 1, 2021
* Implement AdminClient

* Address whitewum's comments

* Address wadeliuyi's comments

* Fix failed compile
yixinglu pushed a commit to yixinglu/nebula that referenced this pull request Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-testing PR: ready for the CI test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants