protected DestinationConfiguration()

in src/main/java/com/googlesource/gerrit/plugins/replication/DestinationConfiguration.java [54:117]


  protected DestinationConfiguration(RemoteConfig remoteConfig, Config cfg) {
    this.remoteConfig = remoteConfig;
    String name = remoteConfig.getName();
    urls = ImmutableList.copyOf(cfg.getStringList("remote", name, "url"));
    delay = Math.max(0, getInt(remoteConfig, cfg, "replicationdelay", DEFAULT_REPLICATION_DELAY));
    rescheduleDelay =
        Math.max(3, getInt(remoteConfig, cfg, "rescheduledelay", DEFAULT_RESCHEDULE_DELAY));
    projects = ImmutableList.copyOf(cfg.getStringList("remote", name, "projects"));
    adminUrls = ImmutableList.copyOf(cfg.getStringList("remote", name, "adminUrl"));
    retryDelay = Math.max(0, getInt(remoteConfig, cfg, "replicationretry", 1));
    drainQueueAttempts =
        Math.max(0, getInt(remoteConfig, cfg, "drainQueueAttempts", DEFAULT_DRAIN_QUEUE_ATTEMPTS));
    poolThreads = Math.max(0, getInt(remoteConfig, cfg, "threads", 1));
    authGroupNames = ImmutableList.copyOf(cfg.getStringList("remote", name, "authGroup"));
    updateRefErrorMaxRetries =
        cfg.getInt(
            "replication",
            "updateRefErrorMaxRetries",
            cfg.getInt("replication", "lockErrorMaxRetries", 0));
    createMissingRepos = cfg.getBoolean("remote", name, "createMissingRepositories", true);
    replicatePermissions = cfg.getBoolean("remote", name, "replicatePermissions", true);
    replicateProjectDeletions = cfg.getBoolean("remote", name, "replicateProjectDeletions", false);
    replicateHiddenProjects = cfg.getBoolean("remote", name, "replicateHiddenProjects", false);
    remoteNameStyle =
        MoreObjects.firstNonNull(cfg.getString("remote", name, "remoteNameStyle"), "slash");
    maxRetries =
        getInt(
            remoteConfig, cfg, "replicationMaxRetries", cfg.getInt("replication", "maxRetries", 0));

    slowLatencyThreshold =
        (int)
            ConfigUtil.getTimeUnit(
                cfg,
                "remote",
                remoteConfig.getName(),
                "slowLatencyThreshold",
                DEFAULT_SLOW_LATENCY_THRESHOLD_SECS,
                TimeUnit.SECONDS);

    pushBatchSize =
        memoize(
            () -> {
              int configuredBatchSize =
                  Math.max(
                      0,
                      getInt(
                          remoteConfig,
                          cfg,
                          "pushBatchSize",
                          cfg.getInt("gerrit", "pushBatchSize", 0)));
              if (configuredBatchSize > 0) {
                int distributionInterval = cfg.getInt("replication", "distributionInterval", 0);
                if (distributionInterval > 0) {
                  repLog.atWarning().log(
                      "Push in batches cannot be turned on for remote (%s) when 'Cluster"
                          + " Replication' (replication.distributionInterval) is configured",
                      name);
                  return 0;
                }
                return configuredBatchSize;
              }
              return 0;
            });
  }