use of com.google.gwtorm.server.OrmRuntimeException in project gerrit by GerritCodeReview.
the class PrimaryStorageMigrator method setReadOnlyInReviewDb.
private Change setReadOnlyInReviewDb(Change.Id id) throws OrmException {
AtomicBoolean alreadyMigrated = new AtomicBoolean(false);
Change result = db().changes().atomicUpdate(id, new AtomicUpdate<Change>() {
@Override
public Change update(Change change) {
NoteDbChangeState state = NoteDbChangeState.parse(change);
if (state == null) {
// really shouldn't happen.
throw new OrmRuntimeException("change " + id + " has no note_db_state; rebuild it first");
}
// If the change is already read-only, then the lease is held by another
// (likely failed) migrator thread. Fail early, as we can't take over
// the lease.
NoteDbChangeState.checkNotReadOnly(change, skewMs);
if (state.getPrimaryStorage() != PrimaryStorage.NOTE_DB) {
Timestamp now = TimeUtil.nowTs();
Timestamp until = new Timestamp(now.getTime() + timeoutMs);
change.setNoteDbState(state.withReadOnlyUntil(until).toString());
} else {
alreadyMigrated.set(true);
}
return change;
}
});
return alreadyMigrated.get() ? null : result;
}
use of com.google.gwtorm.server.OrmRuntimeException in project gerrit by GerritCodeReview.
the class GetRevisionActions method getETag.
@Override
public String getETag(RevisionResource rsrc) {
Hasher h = Hashing.md5().newHasher();
CurrentUser user = rsrc.getControl().getUser();
try {
rsrc.getChangeResource().prepareETag(h, user);
h.putBoolean(Submit.wholeTopicEnabled(config));
ReviewDb db = dbProvider.get();
ChangeSet cs = mergeSuperSet.get().completeChangeSet(db, rsrc.getChange(), user);
for (ChangeData cd : cs.changes()) {
changeResourceFactory.create(cd.changeControl()).prepareETag(h, user);
}
h.putBoolean(cs.furtherHiddenChanges());
} catch (IOException | OrmException e) {
throw new OrmRuntimeException(e);
}
return h.hash().toString();
}
Aggregations