in src/main/java/com/googlesource/gerrit/plugins/quota/RateLimitUploadListener.java [120:149]
public void onBeginNegotiate(
Repository repository,
Project project,
String remoteHost,
UploadPack up,
Collection<? extends ObjectId> wants,
int cntOffered)
throws ValidationException {
RateLimiter limiter = null;
CurrentUser u = user.get();
if (u.isIdentifiedUser()) {
Account.Id accountId = u.asIdentifiedUser().getAccountId();
try {
limiter = limitsPerAccount.get(accountId).get();
} catch (ExecutionException e) {
log.warn("Cannot get rate limits for account ''{}''", accountId, e);
}
} else {
try {
limiter = limitsPerRemoteHost.get(remoteHost).get();
} catch (ExecutionException e) {
log.warn(
"Cannot get rate limits for anonymous access from remote host ''{}''", remoteHost, e);
}
}
if (limiter != null && !limiter.tryAcquire()) {
throw new RateLimitException(
MessageFormat.format(limitExceededMsg, limiter.getRate() * SECONDS_PER_HOUR));
}
}