in src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/ApplyObjectCommand.java [77:125]
public void applyObject(
Project.NameKey name, String refName, RevisionData revisionData, String sourceLabel)
throws IOException, RefUpdateException, MissingParentObjectException {
repLog.info("Apply object from {} for project {}, ref name {}", sourceLabel, name, refName);
Timer1.Context<String> context = metrics.start(sourceLabel);
RefUpdateState refUpdateState = applyObject.apply(name, new RefSpec(refName), revisionData);
long elapsed = NANOSECONDS.toMillis(context.stop());
try {
Context.setLocalEvent(true);
Source source =
sourcesCollection
.getByRemoteName(sourceLabel)
.orElseThrow(
() ->
new IllegalStateException(
String.format("Could not find URI for %s remote", sourceLabel)));
eventDispatcher
.get()
.postEvent(
new FetchRefReplicatedEvent(
name.get(),
refName,
source.getURI(name),
getStatus(refUpdateState),
refUpdateState.getResult()));
} catch (PermissionBackendException | IllegalStateException e) {
logger.atSevere().withCause(e).log(
"Cannot post event for ref '%s', project %s", refName, name);
} finally {
Context.unsetLocalEvent();
}
if (!isSuccessful(refUpdateState.getResult())) {
String message =
String.format(
"RefUpdate failed with result %s for: sourceLcabel=%s, project=%s, refName=%s",
refUpdateState.getResult().name(), sourceLabel, name, refName);
fetchStateLog.error(message);
throw new RefUpdateException(message);
}
repLog.info(
"Apply object from {} for project {}, ref name {} completed in {}ms",
sourceLabel,
name,
refName,
elapsed);
}