mirror of https://gitee.com/bigwinds/arangodb
move-shard slightly changed order of actions
This commit is contained in:
parent
3d475189f1
commit
e053742f45
|
@ -167,7 +167,7 @@ bool MoveShard::start() {
|
||||||
// --- Plan changes
|
// --- Plan changes
|
||||||
pending.add(_agencyPrefix + planPath, VPackValue(VPackValueType::Array));
|
pending.add(_agencyPrefix + planPath, VPackValue(VPackValueType::Array));
|
||||||
if (current[0].copyString() == _from) { // Leader
|
if (current[0].copyString() == _from) { // Leader
|
||||||
pending.add(VPackValue(std::string("_") + current[0].copyString()));
|
pending.add(current[0]);
|
||||||
pending.add(VPackValue(_to));
|
pending.add(VPackValue(_to));
|
||||||
for (size_t i = 1; i < current.length(); ++i) {
|
for (size_t i = 1; i < current.length(); ++i) {
|
||||||
pending.add(current[i]);
|
pending.add(current[i]);
|
||||||
|
@ -252,9 +252,9 @@ JOB_STATUS MoveShard::status () {
|
||||||
|
|
||||||
if (current == plan) {
|
if (current == plan) {
|
||||||
|
|
||||||
if ((current[0].copyString())[0] == '_') { // Leader
|
if ((current[0].copyString())[0] == '_') { // Retired leader
|
||||||
|
|
||||||
Builder cyclic;
|
Builder cyclic; // Cyclic shift _serverId to end
|
||||||
cyclic.openArray();
|
cyclic.openArray();
|
||||||
cyclic.openObject();
|
cyclic.openObject();
|
||||||
// --- Plan changes
|
// --- Plan changes
|
||||||
|
@ -278,36 +278,70 @@ JOB_STATUS MoveShard::status () {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
bool found = false;
|
bool foundFrom = false, foundTo = false;
|
||||||
for (auto const& srv : VPackArrayIterator(current)) {
|
for (auto const& srv : VPackArrayIterator(current)) {
|
||||||
if (srv.copyString() == _from) {
|
std::string srv_str = srv.copyString();
|
||||||
found = true;
|
if (srv_str == _from) {
|
||||||
break;
|
foundFrom = true;
|
||||||
|
}
|
||||||
|
if (srv_str == _to) {
|
||||||
|
foundTo = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found) {
|
if (foundFrom && foundTo) {
|
||||||
|
|
||||||
Builder remove;
|
LOG(WARN) << current[0].copyString() << " " << _from;
|
||||||
remove.openArray();
|
if (current[0].copyString() == _from) { // Leader
|
||||||
remove.openObject();
|
|
||||||
// --- Plan changes
|
Builder underscore; // serverId -> _serverId
|
||||||
remove.add(_agencyPrefix + planPath, VPackValue(VPackValueType::Array));
|
underscore.openArray();
|
||||||
for (auto const& srv : VPackArrayIterator(current)) {
|
underscore.openObject();
|
||||||
if (srv.copyString() != _from) {
|
// --- Plan changes
|
||||||
remove.add(srv);
|
underscore.add(_agencyPrefix + planPath,
|
||||||
|
VPackValue(VPackValueType::Array));
|
||||||
|
underscore.add(
|
||||||
|
VPackValue(std::string("_") + current[0].copyString()));
|
||||||
|
for (size_t i = 1; i < current.length(); ++i) {
|
||||||
|
underscore.add(current[i]);
|
||||||
}
|
}
|
||||||
|
underscore.close();
|
||||||
|
|
||||||
|
// --- Plan version
|
||||||
|
underscore.add(_agencyPrefix + planVersion,
|
||||||
|
VPackValue(VPackValueType::Object));
|
||||||
|
underscore.add("op", VPackValue("increment"));
|
||||||
|
underscore.close();
|
||||||
|
underscore.close(); underscore.close();
|
||||||
|
transact(_agent, underscore);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
Builder remove;
|
||||||
|
remove.openArray();
|
||||||
|
remove.openObject();
|
||||||
|
// --- Plan changes
|
||||||
|
remove.add(_agencyPrefix + planPath, VPackValue(VPackValueType::Array));
|
||||||
|
for (auto const& srv : VPackArrayIterator(current)) {
|
||||||
|
if (srv.copyString() != _from) {
|
||||||
|
remove.add(srv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
remove.close();
|
||||||
|
// --- Plan version
|
||||||
|
remove.add(_agencyPrefix + planVersion,
|
||||||
|
VPackValue(VPackValueType::Object));
|
||||||
|
remove.add("op", VPackValue("increment"));
|
||||||
|
remove.close();
|
||||||
|
remove.close(); remove.close();
|
||||||
|
transact(_agent, remove);
|
||||||
|
|
||||||
}
|
}
|
||||||
remove.close();
|
|
||||||
// --- Plan version
|
|
||||||
remove.add(_agencyPrefix + planVersion,
|
|
||||||
VPackValue(VPackValueType::Object));
|
|
||||||
remove.add("op", VPackValue("increment"));
|
|
||||||
remove.close();
|
|
||||||
remove.close(); remove.close();
|
|
||||||
transact(_agent, remove);
|
|
||||||
|
|
||||||
return PENDING;
|
return PENDING;
|
||||||
|
} else if (foundTo && !foundFrom) {
|
||||||
|
|
||||||
|
return FINISHED;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue