use of com.google.gerrit.server.logging.TraceContext.TraceTimer in project gerrit by GerritCodeReview.
the class ExternalIdCacheLoader method reloadAllExternalIds.
private AllExternalIds reloadAllExternalIds(ObjectId notesRev) throws IOException, ConfigInvalidException {
try (TraceTimer ignored = TraceContext.newTimer("Loading external IDs from scratch", Metadata.builder().revision(notesRev.name()).build())) {
ImmutableSet<ExternalId> externalIds = externalIdReader.all(notesRev);
externalIds.forEach(ExternalId::checkThatBlobIdIsSet);
AllExternalIds allExternalIds = AllExternalIds.create(externalIds.stream());
reloadCounter.increment(false);
return allExternalIds;
}
}
use of com.google.gerrit.server.logging.TraceContext.TraceTimer in project gerrit by GerritCodeReview.
the class StarredChangesUtil method deleteRef.
private void deleteRef(Repository repo, String refName, ObjectId oldObjectId) throws IOException {
if (ObjectId.zeroId().equals(oldObjectId)) {
// ref doesn't exist
return;
}
try (TraceTimer traceTimer = TraceContext.newTimer("Delete star labels", Metadata.builder().noteDbRefName(refName).build())) {
RefUpdate u = repo.updateRef(refName);
u.setForceUpdate(true);
u.setExpectedOldObjectId(oldObjectId);
u.setRefLogIdent(serverIdent.get());
u.setRefLogMessage("Unstar change", true);
RefUpdate.Result result = u.delete();
switch(result) {
case FORCED:
gitRefUpdated.fire(allUsers, u, null);
return;
case LOCK_FAILURE:
throw new LockFailureException(String.format("Delete star ref %s failed", refName), u);
case NEW:
case NO_CHANGE:
case FAST_FORWARD:
case IO_FAILURE:
case NOT_ATTEMPTED:
case REJECTED:
case REJECTED_CURRENT_BRANCH:
case RENAMED:
case REJECTED_MISSING_OBJECT:
case REJECTED_OTHER_REASON:
default:
throw new StorageException(String.format("Delete star ref %s failed: %s", refName, result.name()));
}
}
}
use of com.google.gerrit.server.logging.TraceContext.TraceTimer in project gerrit by GerritCodeReview.
the class ChangeResource method getETag.
@Override
public String getETag() {
try (TraceTimer ignored = TraceContext.newTimer("Compute change ETag", Metadata.builder().changeId(changeData.getId().get()).projectName(changeData.project().get()).build())) {
Hasher h = Hashing.murmur3_128().newHasher();
if (user.isIdentifiedUser()) {
h.putString(starredChangesUtil.getObjectId(user.getAccountId(), getId()).name(), UTF_8);
}
prepareETag(h, user);
return h.hash().toString();
}
}
use of com.google.gerrit.server.logging.TraceContext.TraceTimer in project gerrit by GerritCodeReview.
the class GroupsUpdate method updateGroup.
/**
* Updates the specified group.
*
* @param groupUuid the UUID of the group to update
* @param groupDelta a {@link GroupDelta} which indicates the desired updates on the group
* @throws DuplicateKeyException if the new name of the group is used by another group
* @throws IOException if indexing fails, or an error occurs while reading/writing from/to NoteDb
* @throws NoSuchGroupException if the specified group doesn't exist
*/
public void updateGroup(AccountGroup.UUID groupUuid, GroupDelta groupDelta) throws DuplicateKeyException, IOException, NoSuchGroupException, ConfigInvalidException {
try (TraceTimer ignored = TraceContext.newTimer("Updating group", Metadata.builder().groupUuid(groupUuid.get()).build())) {
Optional<Instant> updatedOn = groupDelta.getUpdatedOn();
if (!updatedOn.isPresent()) {
updatedOn = Optional.of(TimeUtil.now());
groupDelta = groupDelta.toBuilder().setUpdatedOn(updatedOn.get()).build();
}
UpdateResult result = updateGroupInNoteDbWithRetry(groupUuid, groupDelta);
updateNameInProjectConfigsIfNecessary(result);
evictCachesOnGroupUpdate(result);
dispatchAuditEventsOnGroupUpdate(result, updatedOn.get());
}
}
use of com.google.gerrit.server.logging.TraceContext.TraceTimer in project gerrit by GerritCodeReview.
the class ChangeIndexer method indexImpl.
private void indexImpl(ChangeData cd) {
logger.atFine().log("Reindex change %d in index.", cd.getId().get());
for (Index<?, ChangeData> i : getWriteIndexes()) {
try (TraceTimer traceTimer = TraceContext.newTimer("Reindexing change in index", Metadata.builder().changeId(cd.getId().get()).patchSetId(cd.currentPatchSet().number()).indexVersion(i.getSchema().getVersion()).build())) {
if (isFirstInsertForEntry.equals(IsFirstInsertForEntry.YES)) {
i.insert(cd);
} else {
i.replace(cd);
}
} catch (RuntimeException e) {
throw new StorageException(String.format("Failed to reindex change %d in index version %d (current patch set = %d)", cd.getId().get(), i.getSchema().getVersion(), cd.currentPatchSet().number()), e);
}
}
fireChangeIndexedEvent(cd.project().get(), cd.getId().get());
}
Aggregations