1
0
Fork 0

replaced all AgencyGeneralTransactions by AgencyWriteTransaction (#3841)

This commit is contained in:
Kaveh Vahedipour 2017-11-29 17:33:24 +01:00 committed by Jan
parent d9f006cb84
commit 7015db790f
3 changed files with 13 additions and 19 deletions

View File

@ -1277,9 +1277,7 @@ int ClusterInfo::createCollectionCoordinator(std::string const& databaseName,
}
}
AgencyGeneralTransaction transaction;
transaction.transactions.push_back(
AgencyGeneralTransaction::TransactionType(opers,precs));
AgencyWriteTransaction transaction(opers,precs);
{ // we hold this mutex from now on until we have updated our cache
// using loadPlan, this is necessary for the callback closure to

View File

@ -419,12 +419,12 @@ static AgencyCommResult CasWithResult(AgencyComm agency, std::string const& key,
if (oldValue.isNone()) { // for some reason this doesn't work
// precondition: the key must equal old value
AgencyPrecondition pre(key, AgencyPrecondition::Type::EMPTY, true);
AgencyGeneralTransaction trx(write, pre);
AgencyWriteTransaction trx(write, pre);
return agency.sendTransactionWithFailover(trx, timeout);
} else {
// precondition: the key must equal old value
AgencyPrecondition pre(key, AgencyPrecondition::Type::VALUE, oldValue);
AgencyGeneralTransaction trx(write, pre);
AgencyWriteTransaction trx(write, pre);
return agency.sendTransactionWithFailover(trx, timeout);
}
}

View File

@ -516,7 +516,6 @@ bool ServerState::registerAtAgency(AgencyComm& comm,
const ServerState::RoleEnum& role,
std::string const& id) {
typedef std::pair<AgencyOperation,AgencyPrecondition> operationType;
std::string agencyListKey = roleToAgencyListKey(role);
std::string idKey = "Latest" + roleToAgencyKey(role) + "Id";
@ -545,19 +544,16 @@ bool ServerState::registerAtAgency(AgencyComm& comm,
std::string planUrl = "Plan/" + agencyListKey + "/" + id;
std::string currentUrl = "Current/" + agencyListKey + "/" + id;
AgencyGeneralTransaction reg;
reg.push_back( // Plan entry if not exists
operationType(
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)));
AgencyWriteTransaction preg(
AgencyOperation(planUrl, AgencyValueOperationType::SET, builder.slice()),
AgencyPrecondition(planUrl, AgencyPrecondition::Type::EMPTY, true));
// 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 targetUrl = "Target/MapUniqueToShortID/" + id;
@ -892,4 +888,4 @@ Result ServerState::propagateClusterServerMode(Mode mode) {
}
return Result();
}
}