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

pgamba
26.49.2009 b12fb6b3c35eca7e872754101ea2d51ac3825ad7
Garanty that release will always be called on domain after lock
1 files modified
107 ■■■■■ changed files
opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java 107 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java
@@ -1142,6 +1142,8 @@
    {
      try
      {
        try
        {
        // Acquire lock on domain (see more details in comment of start()
        // method of ServerHandler)
        lock();
@@ -1155,8 +1157,17 @@
        handler.shutdown();
      }
    }
      catch(Exception e)
      {
        logError(Message.raw(Category.SYNC, Severity.NOTICE,
            stackTraceToSingleLineString(e)));
      }
      finally
      {
    release();
  }
    }
  }
  /**
   * Unregister this handler from the list of handlers registered to this
@@ -2028,7 +2039,8 @@
        "In " + this +
        " Receiving ResetGenerationIdMsg from " + senderHandler.getServerId() +
        " for baseDn " + baseDn + ":\n" + genIdMsg);
    try
    {
    try
    {
      // Acquire lock on domain (see more details in comment of start() method
@@ -2104,8 +2116,17 @@
      Long.toString(newGenId));
    logError(message);
    }
    catch(Exception e)
    {
      logError(Message.raw(Category.SYNC, Severity.NOTICE,
          stackTraceToSingleLineString(e)));
    }
    finally
    {
    release();
  }
  }
  /**
   * Process message of a remote server changing his status.
@@ -2126,6 +2147,8 @@
    try
    {
      try
      {
      // Acquire lock on domain (see more details in comment of start() method
      // of ServerHandler)
      lock();
@@ -2139,7 +2162,6 @@
    {
      // Already logged an error in processNewStatus()
      // just return not to forward a bad status to topology
      release();
      return;
    }
@@ -2153,8 +2175,17 @@
      newStatus.toString());
    logError(message);
    }
    catch(Exception e)
    {
      logError(Message.raw(Category.SYNC, Severity.NOTICE,
          stackTraceToSingleLineString(e)));
    }
    finally
    {
    release();
  }
  }
  /**
   * Change the status of a directory server according to the event generated
@@ -2168,6 +2199,8 @@
  {
    try
    {
    try
    {
      // Acquire lock on domain (see more details in comment of start() method
      // of ServerHandler)
      lock();
@@ -2210,7 +2243,6 @@
      (newStatus == oldStatus) )
    {
      // Change was impossible or already occurred (see StatusAnalyzer comments)
      release();
      return false;
    }
@@ -2218,7 +2250,16 @@
    buildAndSendTopoInfoToDSs(serverHandler);
    buildAndSendTopoInfoToRSs();
    }
    catch(Exception e)
    {
      logError(Message.raw(Category.SYNC, Severity.NOTICE,
          stackTraceToSingleLineString(e)));
    }
    finally
    {
    release();
    }
    return false;
  }
@@ -2338,8 +2379,10 @@
      // Try doing job anyway...
    }
    try
    {
    /*
     * Store DS connected to remote RS and update information about the peer RS
       * Store DS connected to remote RS & update information about the peer RS
     */
    handler.processTopoInfoFromRS(topoMsg);
@@ -2376,8 +2419,17 @@
     */
    buildAndSendTopoInfoToDSs(null);
    }
    catch(Exception e)
    {
      logError(Message.raw(Category.SYNC, Severity.NOTICE,
          stackTraceToSingleLineString(e)));
    }
    finally
    {
    release();
  }
  }
  /* =======================
   * Monitor Data generation
@@ -3048,6 +3100,50 @@
      // Consider this producer (DS/db).
      int sid = db.getServerId();
      // Should it be considered for eligibility ?
      ChangeNumber heartbeatLastDN =
        getChangeTimeHeartbeatState().getMaxChangeNumber(sid);
      // If the most recent UpdateMsg or CLHeartbeatMsg received is very old
      // then the domain is considered down and not considered for eligibility
      /*
      if ((heartbeatLastDN != null) &&
          (TimeThread.getTime()- heartbeatLastDN.getTime() > 5000))
      {
        if (debugEnabled())
          TRACER.debugInfo("In " + this.getName() +
            " Server " + sid
            + " is not considered for eligibility ... potentially down");
        continue;
      }
      */
      boolean sidConnected = false;
      if (directoryServers.containsKey(sid))
      {
        sidConnected = true;
      }
      else
      {
        // not directly connected
        for (ReplicationServerHandler rsh : replicationServers.values())
        {
          if (rsh.isRemoteLDAPServer(sid))
          {
            sidConnected = true;
            break;
          }
        }
      }
      if (!sidConnected)
      {
        if (debugEnabled())
          TRACER.debugInfo("In " + this.getName() +
            " Server " + sid
            + " is not considered for eligibility ... potentially down");
        continue;
      }
      ChangeNumber changelogLastCN = db.getLastChange();
      if (changelogLastCN != null)
      {
@@ -3057,9 +3153,6 @@
        }
      }
      ChangeNumber heartbeatLastDN =
        getChangeTimeHeartbeatState().getMaxChangeNumber(sid);
      if ((heartbeatLastDN != null) &&
       ((eligibleCN == null) || (heartbeatLastDN.newer(eligibleCN))))
      {