-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
0b45406
to
eb911d0
Compare
Jenkins go |
Unit testing passed. |
namespace nebula { | ||
namespace meta { | ||
|
||
TEST(BalanceIntegrationTest, SimpleTest) { |
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.
more tests on going?
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.
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; |
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.
clear to 0 every time?
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 code here is to find the index of leader in hosts.
}); | ||
} | ||
|
||
nebula::cpp2::HostAddr AdminClient::to(const HostAddr& addr) { |
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.
better naming than to()
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.
How about toThriftHost ?
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.
sounds better
} | ||
case kvstore::ResultCode::ERR_KEY_NOT_FOUND: | ||
return Status::Error("Key Not Found"); | ||
default: |
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.
need a log?
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.
Good point.
|
||
StatusOr<std::vector<HostAddr>> AdminClient::getPeers(GraphSpaceID spaceId, PartitionID partId) { | ||
CHECK_NOTNULL(kv_); | ||
auto partKey = MetaServiceUtils::partKey(spaceId, partId); |
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.
copy?
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.
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) { |
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.
line 36: ms or s ?
BTW, do more logs in this function: a lot of cases for state change tracking
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.
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]); | ||
} |
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.
let's try more than 3 hosts.
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.
Yes. We have more situations to test. Let's open another issue to track it.
baton.post(); | ||
}); | ||
baton.wait(); | ||
} |
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.
what about add part again?
or let's loop the test a few times
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.
AddPart again will be tested on server side. The UT is just to test client interface.
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.
Yep. It's simple for the client, but a valued corned case.
eb911d0
to
f92944b
Compare
Unit testing failed. |
Jenkins go |
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) { |
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 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?
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.
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) { |
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.
and here why not move(req)?
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.
A HA. Good catch! We should use move.
79d84d6
to
f00dc93
Compare
Unit testing passed. |
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.
LGTM
Unit testing failed. |
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.
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] |
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.
leader
}); | ||
} | ||
|
||
nebula::cpp2::HostAddr AdminClient::to(const HostAddr& addr) { |
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.
sounds better
} | ||
} | ||
|
||
TEST(AdminClientTest, RetryTest) { |
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.
Great!
baton.post(); | ||
}); | ||
baton.wait(); | ||
} |
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.
Yep. It's simple for the client, but a valued corned case.
41e4253
to
4684f43
Compare
Unit testing passed. |
Yes, all interfaces here reentrant functions. When we implement them on server-side, we should keep the principle |
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.
LGTM
Unit testing passed. |
* Implement AdminClient * Address whitewum's comments * Address wadeliuyi's comments * Fix failed compile
* Implement AdminClient * Address whitewum's comments * Address wadeliuyi's comments * Fix failed compile
The PR is based on #516 .
Subtask of #515