mirror of https://gitee.com/bigwinds/arangodb
getting rid of locks in cluster comm
This commit is contained in:
parent
39e3923094
commit
11a36db83c
|
@ -1220,16 +1220,8 @@ int ClusterInfo::setCollectionPropertiesCoordinator(
|
|||
AgencyComm ac;
|
||||
AgencyCommResult res;
|
||||
|
||||
{
|
||||
AgencyCommLocker locker("Plan", "WRITE");
|
||||
|
||||
if (!locker.successful()) {
|
||||
return TRI_ERROR_CLUSTER_COULD_NOT_LOCK_PLAN;
|
||||
}
|
||||
|
||||
if (!ac.exists("Plan/Databases/" + databaseName)) {
|
||||
return TRI_ERROR_ARANGO_DATABASE_NOT_FOUND;
|
||||
}
|
||||
AgencyPrecondition databaseExists(
|
||||
"Plan/Databases/" + databaseName, AgencyPrecondition::EMPTY, false);
|
||||
|
||||
res = ac.getValues("Plan/Collections/" + databaseName+"/" + collectionID);
|
||||
|
||||
|
@ -1267,13 +1259,20 @@ int ClusterInfo::setCollectionPropertiesCoordinator(
|
|||
}
|
||||
|
||||
res.clear();
|
||||
res = ac.setValue("Plan/Collections/" + databaseName + "/" + collectionID,
|
||||
copy.slice(), 0.0);
|
||||
}
|
||||
|
||||
AgencyOperation setColl (
|
||||
"Plan/Collections/" + databaseName + "/" + collectionID,
|
||||
AgencyValueOperationType::SET, copy.slice());
|
||||
|
||||
AgencyWriteTransaction trans (setColl, databaseExists);
|
||||
|
||||
res = ac.sendTransactionWithFailover(trans);
|
||||
|
||||
if (res.successful()) {
|
||||
loadPlan();
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
} else {
|
||||
return TRI_ERROR_ARANGO_DATABASE_NOT_FOUND;
|
||||
}
|
||||
|
||||
return TRI_ERROR_INTERNAL;
|
||||
|
@ -1290,16 +1289,8 @@ int ClusterInfo::setCollectionStatusCoordinator(
|
|||
AgencyComm ac;
|
||||
AgencyCommResult res;
|
||||
|
||||
{
|
||||
AgencyCommLocker locker("Plan", "WRITE");
|
||||
|
||||
if (!locker.successful()) {
|
||||
return TRI_ERROR_CLUSTER_COULD_NOT_LOCK_PLAN;
|
||||
}
|
||||
|
||||
if (!ac.exists("Plan/Databases/" + databaseName)) {
|
||||
return TRI_ERROR_ARANGO_DATABASE_NOT_FOUND;
|
||||
}
|
||||
AgencyPrecondition databaseExists(
|
||||
"Plan/Databases/" + databaseName, AgencyPrecondition::EMPTY, false);
|
||||
|
||||
res = ac.getValues("Plan/Collections/" + databaseName +"/" + collectionID);
|
||||
|
||||
|
@ -1338,13 +1329,20 @@ int ClusterInfo::setCollectionStatusCoordinator(
|
|||
return TRI_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
res.clear();
|
||||
res = ac.setValue("Plan/Collections/" + databaseName + "/" + collectionID,
|
||||
builder.slice(), 0.0);
|
||||
}
|
||||
|
||||
AgencyOperation setColl (
|
||||
"Plan/Collections/" + databaseName + "/" + collectionID,
|
||||
AgencyValueOperationType::SET, builder.slice());
|
||||
|
||||
AgencyWriteTransaction trans (setColl, databaseExists);
|
||||
|
||||
res = ac.sendTransactionWithFailover(trans);
|
||||
|
||||
if (res.successful()) {
|
||||
loadPlan();
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
} else {
|
||||
return TRI_ERROR_ARANGO_DATABASE_NOT_FOUND;
|
||||
}
|
||||
|
||||
return TRI_ERROR_INTERNAL;
|
||||
|
@ -1880,14 +1878,7 @@ void ClusterInfo::loadServers() {
|
|||
}
|
||||
|
||||
// Now contact the agency:
|
||||
AgencyCommResult result;
|
||||
{
|
||||
AgencyCommLocker locker("Current", "READ");
|
||||
|
||||
if (locker.successful()) {
|
||||
result = _agency.getValues(prefixServers);
|
||||
}
|
||||
}
|
||||
AgencyCommResult result = _agency.getValues(prefixServers);
|
||||
|
||||
if (result.successful()) {
|
||||
|
||||
|
@ -2012,14 +2003,7 @@ void ClusterInfo::loadCurrentCoordinators() {
|
|||
}
|
||||
|
||||
// Now contact the agency:
|
||||
AgencyCommResult result;
|
||||
{
|
||||
AgencyCommLocker locker("Current", "READ");
|
||||
|
||||
if (locker.successful()) {
|
||||
result = _agency.getValues(prefixCurrentCoordinators);
|
||||
}
|
||||
}
|
||||
AgencyCommResult result = _agency.getValues(prefixCurrentCoordinators);
|
||||
|
||||
if (result.successful()) {
|
||||
|
||||
|
@ -2069,14 +2053,7 @@ void ClusterInfo::loadCurrentDBServers() {
|
|||
}
|
||||
|
||||
// Now contact the agency:
|
||||
AgencyCommResult result;
|
||||
{
|
||||
AgencyCommLocker locker("Current", "READ");
|
||||
|
||||
if (locker.successful()) {
|
||||
result = _agency.getValues(prefixCurrentDBServers);
|
||||
}
|
||||
}
|
||||
AgencyCommResult result = _agency.getValues(prefixCurrentDBServers);
|
||||
|
||||
if (result.successful()) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue