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

jvergara
22.29.2009 284cc30fd544917e405f1a10b922afeb5a9625db
The code in ReplicationCliMain assumed that when the first server where replication was enabled always had the server itself registered in the ADS.  This is not true when all the suffixes had already been disabled in that server.  With this fix the user can enable and disable replication for all suffixes without problems on a given server.
2 files modified
53 ■■■■■ changed files
opends/src/ads/org/opends/admin/ads/ADSContext.java 23 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java 30 ●●●●● patch | view | raw | blame | history
opends/src/ads/org/opends/admin/ads/ADSContext.java
@@ -2290,6 +2290,29 @@
   return "cn=secret keys," + getAdministrationSuffixDN();
 }
  /**
   * Tells whether the provided server is registered in the registry.
   * @param server the server.
   * @param registry the registry.
   * @return <CODE>true</CODE> if the server is registered in the registry
   * and <CODE>false</CODE> otherwise.
   */
  public static boolean isRegistered(
      ServerDescriptor server,
      Set<Map<ADSContext.ServerProperty, Object>> registry)
  {
    boolean isRegistered = false;
    for (Map<ADSContext.ServerProperty, Object> s : registry)
    {
      ServerDescriptor servInRegistry = ServerDescriptor.createStandalone(s);
      if (servInRegistry.getId().equals(server.getId()))
      {
        isRegistered = true;
        break;
      }
    }
    return isRegistered;
  }
  /**
   Register instance key-pair public-key certificate provided in
opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java
@@ -4603,7 +4603,7 @@
          {
            adsCtx1.createAdministrator(getAdministratorProperties(uData));
          }
          if (registry2.size() == 0)
          if (!ADSContext.isRegistered(server2, registry2))
          {
            server2.updateAdsPropertiesWithServerProperties();
            registerServer(adsCtx1, server2.getAdsProperties());
@@ -4612,6 +4612,11 @@
          {
            registerServer(adsCtx1, registry2.iterator().next());
          }
          if (!ADSContext.isRegistered(server1, registry1))
          {
            server1.updateAdsPropertiesWithServerProperties();
            registerServer(adsCtx1, server1.getAdsProperties());
          }
          ctxSource = ctx1;
          ctxDestination = ctx2;
@@ -4624,7 +4629,7 @@
          {
            adsCtx2.createAdministrator(getAdministratorProperties(uData));
          }
          if (registry1.size() == 0)
          if (!ADSContext.isRegistered(server1, registry1))
          {
            server1.updateAdsPropertiesWithServerProperties();
            registerServer(adsCtx2, server1.getAdsProperties());
@@ -4633,6 +4638,11 @@
          {
            registerServer(adsCtx2, registry1.iterator().next());
          }
          if (!ADSContext.isRegistered(server2, registry2))
          {
            server2.updateAdsPropertiesWithServerProperties();
            registerServer(adsCtx2, server2.getAdsProperties());
          }
          ctxSource = ctx2;
          ctxDestination = ctx1;
@@ -4664,6 +4674,13 @@
        }
        server1.updateAdsPropertiesWithServerProperties();
        registerServer(adsCtx2, server1.getAdsProperties());
        Set<Map<ADSContext.ServerProperty, Object>> registry2 =
          adsCtx2.readServerRegistry();
        if (!ADSContext.isRegistered(server2, registry2))
        {
          server2.updateAdsPropertiesWithServerProperties();
          registerServer(adsCtx2, server2.getAdsProperties());
        }
        ctxSource = ctx2;
        ctxDestination = ctx1;
@@ -4678,6 +4695,13 @@
        }
        server2.updateAdsPropertiesWithServerProperties();
        registerServer(adsCtx1, server2.getAdsProperties());
        Set<Map<ADSContext.ServerProperty, Object>> registry1 =
          adsCtx1.readServerRegistry();
        if (!ADSContext.isRegistered(server1, registry1))
        {
          server1.updateAdsPropertiesWithServerProperties();
          registerServer(adsCtx1, server1.getAdsProperties());
        }
        ctxSource = ctx1;
        ctxDestination = ctx2;
@@ -5247,7 +5271,7 @@
        // contents of the ADS.
        try
        {
          Thread.sleep(2000);
          Thread.sleep(5000);
        }
        catch (Throwable t)
        {