mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jan-Peter Nilsson
08.51.2020 fdb8409e383243c8a3bbf7e8a1d4c852f607c4f2
Blacklist misbehaving servers for a little bit (#144)

Since we only handle client connections once per iteration of trying to
connect to other replication servers we can't spend too much time here
or the clients will time out.

By blacklisting misbehaving servers for a few iterations we should get
a few fast iterations where we can accept clients in between trying the
slow servers.
1 files modified
16 ■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/replication/server/ReplicationServer.java 16 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/replication/server/ReplicationServer.java
@@ -309,6 +309,7 @@
  {
    synchronized (connectThreadLock)
    {
      final Map<HostPort, Long> blacklistedHosts = new HashMap<>();
      while (!shutdown.get())
      {
        HostPort localAddress = HostPort.localAddress(getReplicationPort());
@@ -336,7 +337,16 @@
              continue; // Skip: avoid connecting to self.
            }
            connect(rsAddress, domain.getBaseDN());
            if (blacklistedHosts.getOrDefault(rsAddress, 0L) > domainTicket)
            {
              continue; // Skip: avoid connecting to blacklisted hosts.
            }
            if (!connect(rsAddress, domain.getBaseDN()))
            {
                // Blacklist for a few iterations
                blacklistedHosts.put(rsAddress, domainTicket + 6);
            }
          }
        }
@@ -381,7 +391,7 @@
   * @param baseDN
   *          The baseDN of the connection
   */
  private void connect(HostPort remoteServerAddress, DN baseDN)
  private boolean connect(HostPort remoteServerAddress, DN baseDN)
  {
    boolean sslEncryption = replSessionSecurity.isSslEncryption();
@@ -414,7 +424,9 @@
      logger.traceException(e);
      close(session);
      close(socket);
      return false;
    }
    return true;
  }
  /** Initialization function for the replicationServer. */