mirror of https://gitee.com/bigwinds/arangodb
replaced all AgencyGeneralTransactions by AgencyWriteTransaction (#3841)
This commit is contained in:
parent
d9f006cb84
commit
7015db790f
|
@ -1277,9 +1277,7 @@ int ClusterInfo::createCollectionCoordinator(std::string const& databaseName,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AgencyGeneralTransaction transaction;
|
AgencyWriteTransaction transaction(opers,precs);
|
||||||
transaction.transactions.push_back(
|
|
||||||
AgencyGeneralTransaction::TransactionType(opers,precs));
|
|
||||||
|
|
||||||
{ // we hold this mutex from now on until we have updated our cache
|
{ // we hold this mutex from now on until we have updated our cache
|
||||||
// using loadPlan, this is necessary for the callback closure to
|
// using loadPlan, this is necessary for the callback closure to
|
||||||
|
|
|
@ -419,12 +419,12 @@ static AgencyCommResult CasWithResult(AgencyComm agency, std::string const& key,
|
||||||
if (oldValue.isNone()) { // for some reason this doesn't work
|
if (oldValue.isNone()) { // for some reason this doesn't work
|
||||||
// precondition: the key must equal old value
|
// precondition: the key must equal old value
|
||||||
AgencyPrecondition pre(key, AgencyPrecondition::Type::EMPTY, true);
|
AgencyPrecondition pre(key, AgencyPrecondition::Type::EMPTY, true);
|
||||||
AgencyGeneralTransaction trx(write, pre);
|
AgencyWriteTransaction trx(write, pre);
|
||||||
return agency.sendTransactionWithFailover(trx, timeout);
|
return agency.sendTransactionWithFailover(trx, timeout);
|
||||||
} else {
|
} else {
|
||||||
// precondition: the key must equal old value
|
// precondition: the key must equal old value
|
||||||
AgencyPrecondition pre(key, AgencyPrecondition::Type::VALUE, oldValue);
|
AgencyPrecondition pre(key, AgencyPrecondition::Type::VALUE, oldValue);
|
||||||
AgencyGeneralTransaction trx(write, pre);
|
AgencyWriteTransaction trx(write, pre);
|
||||||
return agency.sendTransactionWithFailover(trx, timeout);
|
return agency.sendTransactionWithFailover(trx, timeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -516,7 +516,6 @@ bool ServerState::registerAtAgency(AgencyComm& comm,
|
||||||
const ServerState::RoleEnum& role,
|
const ServerState::RoleEnum& role,
|
||||||
std::string const& id) {
|
std::string const& id) {
|
||||||
|
|
||||||
typedef std::pair<AgencyOperation,AgencyPrecondition> operationType;
|
|
||||||
std::string agencyListKey = roleToAgencyListKey(role);
|
std::string agencyListKey = roleToAgencyListKey(role);
|
||||||
std::string idKey = "Latest" + roleToAgencyKey(role) + "Id";
|
std::string idKey = "Latest" + roleToAgencyKey(role) + "Id";
|
||||||
|
|
||||||
|
@ -545,19 +544,16 @@ bool ServerState::registerAtAgency(AgencyComm& comm,
|
||||||
std::string planUrl = "Plan/" + agencyListKey + "/" + id;
|
std::string planUrl = "Plan/" + agencyListKey + "/" + id;
|
||||||
std::string currentUrl = "Current/" + agencyListKey + "/" + id;
|
std::string currentUrl = "Current/" + agencyListKey + "/" + id;
|
||||||
|
|
||||||
AgencyGeneralTransaction reg;
|
AgencyWriteTransaction preg(
|
||||||
reg.push_back( // Plan entry if not exists
|
AgencyOperation(planUrl, AgencyValueOperationType::SET, builder.slice()),
|
||||||
operationType(
|
AgencyPrecondition(planUrl, AgencyPrecondition::Type::EMPTY, true));
|
||||||
AgencyOperation(planUrl, AgencyValueOperationType::SET, builder.slice()),
|
|
||||||
AgencyPrecondition(planUrl, AgencyPrecondition::Type::EMPTY, true)));
|
|
||||||
|
|
||||||
reg.push_back( // Current entry if not exists
|
|
||||||
operationType(
|
|
||||||
AgencyOperation(currentUrl, AgencyValueOperationType::SET, builder.slice()),
|
|
||||||
AgencyPrecondition(currentUrl, AgencyPrecondition::Type::EMPTY, true)));
|
|
||||||
|
|
||||||
// ok to fail..if it failed we are already registered
|
// ok to fail..if it failed we are already registered
|
||||||
comm.sendTransactionWithFailover(reg, 0.0);
|
comm.sendTransactionWithFailover(preg, 0.0);
|
||||||
|
AgencyWriteTransaction creg(
|
||||||
|
AgencyOperation(currentUrl, AgencyValueOperationType::SET, builder.slice()),
|
||||||
|
AgencyPrecondition(currentUrl, AgencyPrecondition::Type::EMPTY, true));
|
||||||
|
// ok to fail..if it failed we are already registered
|
||||||
|
comm.sendTransactionWithFailover(creg, 0.0);
|
||||||
|
|
||||||
std::string targetIdStr = "Target/" + idKey;
|
std::string targetIdStr = "Target/" + idKey;
|
||||||
std::string targetUrl = "Target/MapUniqueToShortID/" + id;
|
std::string targetUrl = "Target/MapUniqueToShortID/" + id;
|
||||||
|
@ -892,4 +888,4 @@ Result ServerState::propagateClusterServerMode(Mode mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result();
|
return Result();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue