in src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java [399:453]
public Future<?> schedule(
Project.NameKey project,
String ref,
URIish uri,
ReplicationState state,
ReplicationType replicationType) {
repLog.info("scheduling replication {}:{} => {}", uri, ref, project);
if (!shouldReplicate(project, ref, state)) {
return CompletableFuture.completedFuture(null);
}
if (!config.replicatePermissions()) {
FetchOne e;
synchronized (stateLock) {
e = pending.get(uri);
}
if (e == null) {
try (Repository git = gitManager.openRepository(project)) {
try {
Ref head = git.exactRef(Constants.HEAD);
if (head != null
&& head.isSymbolic()
&& RefNames.REFS_CONFIG.equals(head.getLeaf().getName())) {
return CompletableFuture.completedFuture(null);
}
} catch (IOException err) {
stateLog.error(String.format("cannot check type of project %s", project), err, state);
return CompletableFuture.completedFuture(null);
}
} catch (IOException err) {
stateLog.error(String.format("source project %s not available", project), err, state);
return CompletableFuture.completedFuture(null);
}
}
}
synchronized (stateLock) {
FetchOne e = pending.get(uri);
Future<?> f = CompletableFuture.completedFuture(null);
if (e == null) {
e = opFactory.create(project, uri);
addRef(e, ref);
e.addState(ref, state);
pending.put(uri, e);
f = pool.schedule(e, isSyncCall(replicationType) ? 0 : config.getDelay(), TimeUnit.SECONDS);
} else if (!e.getRefs().contains(ref)) {
addRef(e, ref);
e.addState(ref, state);
}
state.increaseFetchTaskCount(project.get(), ref);
repLog.info("scheduled {}:{} => {} to run after {}s", e, ref, project, config.getDelay());
return f;
}
}