use of com.google.gerrit.server.index.StalenessCheckResult in project gerrit by GerritCodeReview.
the class AccountIndexerImpl method reindexIfStale.
@Override
public boolean reindexIfStale(Account.Id id) {
try {
StalenessCheckResult stalenessCheckResult = stalenessChecker.check(id);
if (stalenessCheckResult.isStale()) {
logger.atInfo().log("Reindexing stale document %s", stalenessCheckResult);
index(id);
return true;
}
} catch (IOException e) {
throw new StorageException(e);
}
return false;
}
use of com.google.gerrit.server.index.StalenessCheckResult in project gerrit by GerritCodeReview.
the class GroupIndexerImpl method reindexIfStale.
@Override
public boolean reindexIfStale(AccountGroup.UUID uuid) {
try {
StalenessCheckResult stalenessCheckResult = stalenessChecker.check(uuid);
if (stalenessCheckResult.isStale()) {
logger.atInfo().log("Reindexing stale document %s", stalenessCheckResult);
index(uuid);
return true;
}
} catch (IOException e) {
throw new StorageException(e);
}
return false;
}
use of com.google.gerrit.server.index.StalenessCheckResult in project gerrit by GerritCodeReview.
the class StalenessChecker method check.
/**
* Returns a {@link StalenessCheckResult} with structured information about staleness of the
* provided {@link com.google.gerrit.entities.Project.NameKey}.
*/
public StalenessCheckResult check(Project.NameKey project) {
ProjectData projectData = projectCache.get(project).orElseThrow(illegalState(project)).toProjectData();
ProjectIndex i = indexes.getSearchIndex();
if (i == null) {
return StalenessCheckResult.notStale();
}
Optional<FieldBundle> result = i.getRaw(project, QueryOptions.create(indexConfig, 0, 1, FIELDS));
if (!result.isPresent()) {
return StalenessCheckResult.stale("Document %s missing from index", project);
}
SetMultimap<Project.NameKey, RefState> indexedRefStates = RefState.parseStates(result.get().getValue(ProjectField.REF_STATE));
SetMultimap<Project.NameKey, RefState> currentRefStates = MultimapBuilder.hashKeys().hashSetValues().build();
projectData.tree().stream().filter(p -> p.getProject().getConfigRefState() != null).forEach(p -> currentRefStates.put(p.getProject().getNameKey(), RefState.create(RefNames.REFS_CONFIG, p.getProject().getConfigRefState())));
if (currentRefStates.equals(indexedRefStates)) {
return StalenessCheckResult.notStale();
}
return StalenessCheckResult.stale("Document has unexpected ref states (%s != %s)", currentRefStates, indexedRefStates);
}
Aggregations