Issue 1647 Resolution

This commit is contained in:
Stewart Henderson 2020-08-21 06:12:39 -05:00
parent 6077073ac9
commit 6a8da71e80
1 changed files with 0 additions and 87 deletions

View File

@ -53,29 +53,17 @@ bool IReplicationPolicy::validateFull(
if (!solved) {
if (validate(totalSolution, fromServers)) {
if (g_replicationdebug > 2) {
printf("Error: Validate unsolved policy with%3lu also servers and%3lu solution servers\n", alsoServers.size(), solutionSet.size());
}
valid = false;
}
else if (validate(fromServers->getGroupEntries(), fromServers)) {
if (g_replicationdebug > 2) {
printf("Error: Validated unsolved policy with all%5d servers\n", fromServers->size());
}
valid = false;
}
}
else if (!validate(totalSolution, fromServers)) {
if (g_replicationdebug > 2) {
printf("Error: Failed to validate solved policy with%3lu also servers and%3lu solution servers\n", alsoServers.size(), solutionSet.size());
}
valid = false;
}
else if (solutionSet.empty()) {
if (!validate(alsoServers, fromServers)) {
if (g_replicationdebug > 2) {
printf("Error: Failed to validate policy with only%3lu also servers\n", alsoServers.size());
}
valid = false;
}
}
@ -85,14 +73,7 @@ bool IReplicationPolicy::validateFull(
totalSolution[lastSolutionIndex] = totalSolution.back();
totalSolution.pop_back();
for (int index = 0; index < solutionSet.size() && index < totalSolution.size(); index ++) {
if (g_replicationdebug > 3) {
auto fromServer = fromServers->getRecordViaEntry(missingEntry);
printf("Test remove entry: %s test:%3d of%3lu\n", fromServers->getEntryInfo(missingEntry).c_str(), index+1, solutionSet.size());
}
if (validate(totalSolution, fromServers)) {
if (g_replicationdebug > 2) {
printf("Invalid extra entry: %s\n", fromServers->getEntryInfo(missingEntry).c_str());
}
valid = false;
break;
}
@ -119,9 +100,6 @@ bool PolicyOne::selectReplicas(
itemsUsed ++;
totalUsed ++;
}
if (g_replicationdebug > 0) {
printf("PolicyOne used:%5d results:%3d from %3d servers\n", totalUsed, itemsUsed, fromServers->size());
}
return (totalUsed > 0);
}
@ -205,50 +183,16 @@ bool PolicyAcross::validate(
}
}
if (validMap.size() < _count) {
if (g_replicationdebug > 3) {
printf("Across too few values:%3lu <%2d key: %-7s policy: %-10s => %s\n", validMap.size(), _count, _attribKey.c_str(), _policy->name().c_str(), _policy->info().c_str());
}
valid = false;
}
else {
if (g_replicationdebug > 3) {
printf("Across check values:%9lu key: %-7s solutions:%2lu count:%2d policy: %-10s => %s\n", validMap.size(), _attribKey.c_str(), solutionSet.size(), _count, _policy->name().c_str(), _policy->info().c_str());
for (auto& itValue : validMap) {
printf(" value: (%3d) %-10s\n", itValue.first._id, fromServers->valueText(itValue.first).c_str());
}
}
for (auto& itValid : validMap) {
// itValid.second is the vector of LocalityEntries that belong to the same locality
if (_policy->validate(itValid.second, fromServers)) {
if (g_replicationdebug > 4) {
printf("Across valid solution: %6lu key: %-7s count:%3d of%3d value: (%3d) %-10s policy: %-10s => "
"%s\n",
itValid.second.size(), _attribKey.c_str(), count + 1, _count, itValid.first._id,
fromServers->valueText(itValid.first).c_str(), _policy->name().c_str(),
_policy->info().c_str());
if (g_replicationdebug > 5) {
for (auto& entry : itValid.second) {
printf(" entry: %s\n", fromServers->getEntryInfo(entry).c_str());
}
}
}
count ++;
} else if (g_replicationdebug > 4) {
printf("Across invalid solution:%5lu key: %-7s value: (%3d) %-10s policy: %-10s => %s\n", itValid.second.size(), _attribKey.c_str(), itValid.first._id, fromServers->valueText(itValid.first).c_str(), _policy->name().c_str(), _policy->info().c_str());
if (g_replicationdebug > 5) {
for (auto& entry : itValid.second) {
printf(" entry: %s\n", fromServers->getEntryInfo(entry).c_str());
}
}
}
}
if (count < _count) {
if (g_replicationdebug > 3) {
printf("Across failed solution: %3lu key: %-7s values:%3lu count: %d=%d policy: %-10s => %s\n", solutionSet.size(), _attribKey.c_str(), validMap.size(), count, _count, _policy->name().c_str(), _policy->info().c_str());
for (auto& entry : solutionSet) {
printf(" entry: %s\n", fromServers->getEntryInfo(entry).c_str());
}
}
valid = false;
}
}
@ -287,16 +231,6 @@ bool PolicyAcross::selectReplicas(
if ((lowerBound == _usedValues.end()) || (*lowerBound != value.get())) {
//_selected is a set of processes that have the same indexKey and indexValue (value)
_selected = fromServers->restrict(indexKey, value.get());
if (g_replicationdebug > 0) {
if (_selected->size() > 0) {
// entry is the locality entry info (entryValue) from the to-be-selected team member alsoServer
printf("Across !select key: %-7s value: (%3d) %-10s entry: %s\n", _attribKey.c_str(),
value.get()._id, fromServers->valueText(value.get()).c_str(),
fromServers->getEntryInfo(alsoServer).c_str());
} else {
printf("Across !select empty\n");
}
}
if (_selected->size()) {
// Pass only the also array item which are valid for the value
resultsSize = _newResults.size();
@ -321,11 +255,6 @@ bool PolicyAcross::selectReplicas(
if ((count < _count) && (_addedResults.size())) {
// Sort the added results array
std::sort(_addedResults.begin(), _addedResults.end(), PolicyAcross::compareAddedResults);
if (g_replicationdebug > 0) {
printf("Across !add sets key: %-7s sets:%3d results:%3lu count:%3d of%3d\n", _attribKey.c_str(), _addedResults.size(), _newResults.size(), count, _count);
}
if (g_replicationdebug > 0) {
LocalitySet::staticDisplayEntries(fromServers, alsoServers, "also");
LocalitySet::staticDisplayEntries(fromServers, results, "results");
@ -334,9 +263,6 @@ bool PolicyAcross::selectReplicas(
for (auto& addedResult : _addedResults) {
count ++;
if (g_replicationdebug > 0) {
printf("Across !add set key: %-7s count:%3d of%3d results:%3d index:%3d\n", _attribKey.c_str(), count, _count, addedResult.first, addedResult.second);
}
results.reserve(results.size() + addedResult.first);
results.insert(results.end(), _newResults.begin()+addedResult.second, _newResults.begin()+addedResult.second+addedResult.first);
if (count >= _count) break;
@ -349,9 +275,6 @@ bool PolicyAcross::selectReplicas(
// Cannot find replica from the least used alsoServers, now try to find replicas from all servers
// Process the remaining values
if (count < _count) {
if (g_replicationdebug > 0) {
printf("Across items:%4d key: %-7s policy: %-10s => %s count:%3d of%3d\n", fromServers->size(), _attribKey.c_str(), _policy->name().c_str(), _policy->info().c_str(), count, _count);
}
int recordIndex;
// Use mutable array so that swaps does not affect actual element array
auto& mutableArray = fromServers->getMutableEntries();
@ -375,12 +298,6 @@ bool PolicyAcross::selectReplicas(
}
if (_policy->selectReplicas(_selected, emptyEntryArray, results))
{
if (g_replicationdebug > 5) {
printf("Across added:%4d key: %-7s value: (%3d) %-10s policy: %-10s => %s needed:%3d\n",
count + 1, _attribKey.c_str(), value.get()._id,
fromServers->valueText(value.get()).c_str(), _policy->name().c_str(),
_policy->info().c_str(), _count);
}
count ++;
if (count >= _count) break;
_usedValues.insert(lowerBound, value.get());
@ -395,13 +312,9 @@ bool PolicyAcross::selectReplicas(
}
// Clear the return array, if not satified
if (count < _count) {
if (g_replicationdebug > 0) printf("Across result count: %d < %d requested\n", count, _count);
results.resize(resultsInit);
count = 0;
}
if (g_replicationdebug > 0) {
printf("Across used:%5lu results:%3d from %3d items key: %-7s policy: %-10s => %s\n", results.size()-resultsInit, count, fromServers->size(), _attribKey.c_str(), _policy->name().c_str(), _policy->info().c_str());
}
return (count >= _count);
}