use of com.google.gerrit.server.notedb.IntBlob in project gerrit by GerritCodeReview.
the class NoteDbSchemaVersionManager method increment.
public void increment(int expectedOldVersion) throws IOException {
try (Repository repo = repoManager.openRepository(allProjectsName);
RevWalk rw = new RevWalk(repo)) {
Optional<IntBlob> old = IntBlob.parse(repo, REFS_VERSION, rw);
if (old.isPresent() && old.get().value() != expectedOldVersion) {
throw new StorageException(String.format("Expected old version %d for %s, found %d", expectedOldVersion, REFS_VERSION, old.get().value()));
}
IntBlob.store(repo, rw, allProjectsName, REFS_VERSION, old.map(IntBlob::id).orElse(ObjectId.zeroId()), expectedOldVersion + 1, GitReferenceUpdated.DISABLED);
}
}
use of com.google.gerrit.server.notedb.IntBlob in project gerrit by GerritCodeReview.
the class NoteDbSchemaVersionManager method init.
public void init() throws IOException {
try (Repository repo = repoManager.openRepository(allProjectsName);
RevWalk rw = new RevWalk(repo)) {
Optional<IntBlob> old = IntBlob.parse(repo, REFS_VERSION, rw);
if (old.isPresent()) {
throw new StorageException(String.format("Expected no old version for %s, found %s", REFS_VERSION, old.get().value()));
}
IntBlob.store(repo, rw, allProjectsName, REFS_VERSION, old.map(IntBlob::id).orElse(ObjectId.zeroId()), NoteDbSchemaVersions.LATEST, GitReferenceUpdated.DISABLED);
}
}
Aggregations