From 83e17e3a3f12fca9aff4de972b38ba3bd17388e3 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Wed, 16 Apr 2008 08:53:37 +0000
Subject: [PATCH] Fix for issue  3139 (dsreplication tool inefficient in relation to number of backends)

---
 opendj-sdk/opends/src/ads/org/opends/admin/ads/TopologyCacheFilter.java                   |  126 ++++++++++++
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java           |   28 ++
 opendj-sdk/opends/src/ads/org/opends/admin/ads/TopologyCache.java                         |   12 +
 opendj-sdk/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java                      |  285 ++++++++++++++++------------
 opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java           |    1 
 opendj-sdk/opends/src/ads/org/opends/admin/ads/util/ServerLoader.java                     |   10 
 opendj-sdk/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliMain.java |   90 +++++++-
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Application.java                   |    6 
 opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java    |    1 
 9 files changed, 417 insertions(+), 142 deletions(-)

diff --git a/opendj-sdk/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java b/opendj-sdk/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java
index 9100d85..c954372 100644
--- a/opendj-sdk/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java
+++ b/opendj-sdk/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java
@@ -629,23 +629,26 @@
    * using the provided InitialLdapContext.
    * @param ctx the InitialLdapContext that will be used to read the
    * configuration of the server.
+   * @param filter the topology cache filter describing the information that
+   * must be retrieved.
    * @return a ServerDescriptor object that corresponds to the read
    * configuration.
    * @throws NamingException if a problem occurred reading the server
    * configuration.
    */
-  public static ServerDescriptor createStandalone(InitialLdapContext ctx)
+  public static ServerDescriptor createStandalone(InitialLdapContext ctx,
+      TopologyCacheFilter filter)
   throws NamingException
   {
     ServerDescriptor desc = new ServerDescriptor();
 
 
-    updateLdapConfiguration(desc, ctx);
-    updateJmxConfiguration(desc, ctx);
-    updateReplicas(desc, ctx);
-    updateReplication(desc, ctx);
-    updatePublicKeyCertificate(desc, ctx);
-    updateMiscellaneous(desc, ctx);
+    updateLdapConfiguration(desc, ctx, filter);
+    updateJmxConfiguration(desc, ctx, filter);
+    updateReplicas(desc, ctx, filter);
+    updateReplication(desc, ctx, filter);
+    updatePublicKeyCertificate(desc, ctx, filter);
+    updateMiscellaneous(desc, ctx, filter);
 
     desc.serverProperties.put(ServerProperty.HOST_NAME,
         ConnectionUtils.getHostName(ctx));
@@ -654,7 +657,8 @@
   }
 
   private static void updateLdapConfiguration(ServerDescriptor desc,
-      InitialLdapContext ctx) throws NamingException
+      InitialLdapContext ctx, TopologyCacheFilter cacheFilter)
+  throws NamingException
   {
     SearchControls ctls = new SearchControls();
     ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
@@ -712,7 +716,8 @@
   }
 
   private static void updateJmxConfiguration(ServerDescriptor desc,
-      InitialLdapContext ctx) throws NamingException
+      InitialLdapContext ctx, TopologyCacheFilter cacheFilter)
+  throws NamingException
   {
     SearchControls ctls = new SearchControls();
     ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
@@ -764,8 +769,13 @@
   }
 
   private static void updateReplicas(ServerDescriptor desc,
-      InitialLdapContext ctx) throws NamingException
+      InitialLdapContext ctx, TopologyCacheFilter cacheFilter)
+  throws NamingException
   {
+    if (!cacheFilter.searchBaseDNInformation())
+    {
+      return;
+    }
     SearchControls ctls = new SearchControls();
     ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
     ctls.setReturningAttributes(
@@ -788,42 +798,65 @@
       {
         Set<String> baseDns = getValues(sr, "ds-cfg-base-dn");
 
-        Set<String> entries = getBaseDNEntryCount(ctx, id);
+        Set<String> entries;
+        if (cacheFilter.searchMonitoringInformation())
+        {
+          entries = getBaseDNEntryCount(ctx, id);
+        }
+        else
+        {
+          entries = new HashSet<String>();
+        }
 
         Set<ReplicaDescriptor> replicas = desc.getReplicas();
         for (String baseDn : baseDns)
         {
-          SuffixDescriptor suffix = new SuffixDescriptor();
-          suffix.setDN(baseDn);
-          ReplicaDescriptor replica = new ReplicaDescriptor();
-          replica.setServer(desc);
-          replicas.add(replica);
-          HashSet<ReplicaDescriptor> r = new HashSet<ReplicaDescriptor>();
-          r.add(replica);
-          suffix.setReplicas(r);
-          replica.setSuffix(suffix);
-          int nEntries = -1;
-          for (String s : entries)
+          boolean addReplica = cacheFilter.searchAllBaseDNs();
+          if (!addReplica)
           {
-            int index = s.indexOf(" ");
-            if (index != -1)
+            for (String dn : cacheFilter.getBaseDNsToSearch())
             {
-              String dn = s.substring(index + 1);
-              if (Utils.areDnsEqual(baseDn, dn))
+              addReplica = Utils.areDnsEqual(dn, baseDn);
+              if (addReplica)
               {
-                try
-                {
-                  nEntries = Integer.parseInt(s.substring(0, index));
-                }
-                catch (Throwable t)
-                {
-                  /* Ignore */
-                }
                 break;
               }
             }
           }
-          replica.setEntries(nEntries);
+          if(addReplica)
+          {
+            SuffixDescriptor suffix = new SuffixDescriptor();
+            suffix.setDN(baseDn);
+            ReplicaDescriptor replica = new ReplicaDescriptor();
+            replica.setServer(desc);
+            replicas.add(replica);
+            HashSet<ReplicaDescriptor> r = new HashSet<ReplicaDescriptor>();
+            r.add(replica);
+            suffix.setReplicas(r);
+            replica.setSuffix(suffix);
+            int nEntries = -1;
+            for (String s : entries)
+            {
+              int index = s.indexOf(" ");
+              if (index != -1)
+              {
+                String dn = s.substring(index + 1);
+                if (Utils.areDnsEqual(baseDn, dn))
+                {
+                  try
+                  {
+                    nEntries = Integer.parseInt(s.substring(0, index));
+                  }
+                  catch (Throwable t)
+                  {
+                    /* Ignore */
+                  }
+                  break;
+                }
+              }
+            }
+            replica.setEntries(nEntries);
+          }
         }
         desc.setReplicas(replicas);
       }
@@ -831,7 +864,8 @@
   }
 
   private static void updateReplication(ServerDescriptor desc,
-      InitialLdapContext ctx) throws NamingException
+      InitialLdapContext ctx, TopologyCacheFilter cacheFilter)
+  throws NamingException
   {
     boolean replicationEnabled = false;
     boolean oneDomainReplicated = false;
@@ -868,56 +902,59 @@
     desc.serverProperties.put(ServerProperty.IS_REPLICATION_ENABLED,
         replicationEnabled ? Boolean.TRUE : Boolean.FALSE);
 
-    ctls = new SearchControls();
-    ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
-    ctls.setReturningAttributes(
-        new String[] {
-            "ds-cfg-base-dn",
-            "ds-cfg-replication-server",
-            "ds-cfg-server-id"
-        });
-    filter = "(objectclass=ds-cfg-replication-domain)";
+    if (cacheFilter.searchBaseDNInformation())
+    {
+      ctls = new SearchControls();
+      ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
+      ctls.setReturningAttributes(
+          new String[] {
+              "ds-cfg-base-dn",
+              "ds-cfg-replication-server",
+              "ds-cfg-server-id"
+          });
+      filter = "(objectclass=ds-cfg-replication-domain)";
 
-    jndiName = new LdapName(
+      jndiName = new LdapName(
       "cn=Multimaster Synchronization,cn=Synchronization Providers,cn=config");
 
-    try
-    {
-      NamingEnumeration syncProviders = ctx.search(jndiName, filter, ctls);
-
-      while(syncProviders.hasMore())
+      try
       {
-        SearchResult sr = (SearchResult)syncProviders.next();
+        NamingEnumeration syncProviders = ctx.search(jndiName, filter, ctls);
 
-        int id = Integer.parseInt(
-            getFirstValue(sr, "ds-cfg-server-id"));
-        Set<String> replicationServers = getValues(sr,
-            "ds-cfg-replication-server");
-        Set<String> dns = getValues(sr, "ds-cfg-base-dn");
-        oneDomainReplicated = dns.size() > 0;
-        for (String dn : dns)
+        while(syncProviders.hasMore())
         {
-          for (ReplicaDescriptor replica : desc.getReplicas())
+          SearchResult sr = (SearchResult)syncProviders.next();
+
+          int id = Integer.parseInt(
+              getFirstValue(sr, "ds-cfg-server-id"));
+          Set<String> replicationServers = getValues(sr,
+          "ds-cfg-replication-server");
+          Set<String> dns = getValues(sr, "ds-cfg-base-dn");
+          oneDomainReplicated = dns.size() > 0;
+          for (String dn : dns)
           {
-            if (areDnsEqual(replica.getSuffix().getDN(), dn))
+            for (ReplicaDescriptor replica : desc.getReplicas())
             {
-              replica.setReplicationId(id);
-              // Keep the values of the replication servers in lower case
-              // to make use of Sets as String simpler.
-              LinkedHashSet<String> repServers = new LinkedHashSet<String>();
-              for (String s: replicationServers)
+              if (areDnsEqual(replica.getSuffix().getDN(), dn))
               {
-                repServers.add(s.toLowerCase());
+                replica.setReplicationId(id);
+                // Keep the values of the replication servers in lower case
+                // to make use of Sets as String simpler.
+                LinkedHashSet<String> repServers = new LinkedHashSet<String>();
+                for (String s: replicationServers)
+                {
+                  repServers.add(s.toLowerCase());
+                }
+                replica.setReplicationServers(repServers);
               }
-              replica.setReplicationServers(repServers);
             }
           }
         }
       }
-    }
-    catch (NameNotFoundException nse)
-    {
-      /* ignore */
+      catch (NameNotFoundException nse)
+      {
+        /* ignore */
+      }
     }
 
     ctls = new SearchControls();
@@ -967,66 +1004,69 @@
       /* ignore */
     }
 
-    ctls = new SearchControls();
-    ctls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
-    ctls.setReturningAttributes(
-    new String[] {
-      "approx-older-change-not-synchronized-millis", "missing-changes",
-      "base-dn", "server-id"
-    });
-    filter = "(missing-changes=*)";
-
-    jndiName = new LdapName("cn=monitor");
-
-    if (oneDomainReplicated)
+    if (cacheFilter.searchMonitoringInformation())
     {
-      try
+      ctls = new SearchControls();
+      ctls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
+      ctls.setReturningAttributes(
+          new String[] {
+              "approx-older-change-not-synchronized-millis", "missing-changes",
+              "base-dn", "server-id"
+          });
+      filter = "(missing-changes=*)";
+
+      jndiName = new LdapName("cn=monitor");
+
+      if (oneDomainReplicated)
       {
-        NamingEnumeration monitorEntries = ctx.search(jndiName, filter, ctls);
-
-        while(monitorEntries.hasMore())
+        try
         {
-          SearchResult sr = (SearchResult)monitorEntries.next();
+          NamingEnumeration monitorEntries = ctx.search(jndiName, filter, ctls);
 
-          String dn = getFirstValue(sr, "base-dn");
-          int replicaId = -1;
-          try
+          while(monitorEntries.hasMore())
           {
-            replicaId = new Integer(getFirstValue(sr, "server-id"));
-          }
-          catch (Throwable t)
-          {
-          }
+            SearchResult sr = (SearchResult)monitorEntries.next();
 
-          for (ReplicaDescriptor replica: desc.getReplicas())
-          {
-            if (Utils.areDnsEqual(dn, replica.getSuffix().getDN()) &&
-                replica.isReplicated() &&
-                (replica.getReplicationId() == replicaId))
+            String dn = getFirstValue(sr, "base-dn");
+            int replicaId = -1;
+            try
             {
-              try
+              replicaId = new Integer(getFirstValue(sr, "server-id"));
+            }
+            catch (Throwable t)
+            {
+            }
+
+            for (ReplicaDescriptor replica: desc.getReplicas())
+            {
+              if (Utils.areDnsEqual(dn, replica.getSuffix().getDN()) &&
+                  replica.isReplicated() &&
+                  (replica.getReplicationId() == replicaId))
               {
-                replica.setAgeOfOldestMissingChange(
-                    new Long(getFirstValue(sr,
-                        "approx-older-change-not-synchronized-millis")));
-              }
-              catch (Throwable t)
-              {
-              }
-              try
-              {
-                replica.setMissingChanges(
-                    new Integer(getFirstValue(sr, "missing-changes")));
-              }
-              catch (Throwable t)
-              {
+                try
+                {
+                  replica.setAgeOfOldestMissingChange(
+                      new Long(getFirstValue(sr,
+                      "approx-older-change-not-synchronized-millis")));
+                }
+                catch (Throwable t)
+                {
+                }
+                try
+                {
+                  replica.setMissingChanges(
+                      new Integer(getFirstValue(sr, "missing-changes")));
+                }
+                catch (Throwable t)
+                {
+                }
               }
             }
           }
         }
-      }
-      catch (NameNotFoundException nse)
-      {
+        catch (NameNotFoundException nse)
+        {
+        }
       }
     }
 
@@ -1069,7 +1109,7 @@
    instance.
    */
   private static void updatePublicKeyCertificate(ServerDescriptor desc,
-      InitialLdapContext ctx) throws NamingException
+      InitialLdapContext ctx, TopologyCacheFilter filter) throws NamingException
   {
     /* TODO: this DN is declared in some core constants file. Create a constants
        file for the installer and import it into the core. */
@@ -1114,7 +1154,8 @@
   }
 
   private static void updateMiscellaneous(ServerDescriptor desc,
-      InitialLdapContext ctx) throws NamingException
+      InitialLdapContext ctx, TopologyCacheFilter cacheFilter)
+  throws NamingException
   {
     SearchControls ctls = new SearchControls();
     ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
diff --git a/opendj-sdk/opends/src/ads/org/opends/admin/ads/TopologyCache.java b/opendj-sdk/opends/src/ads/org/opends/admin/ads/TopologyCache.java
index c3cf586..47c390f 100644
--- a/opendj-sdk/opends/src/ads/org/opends/admin/ads/TopologyCache.java
+++ b/opendj-sdk/opends/src/ads/org/opends/admin/ads/TopologyCache.java
@@ -61,6 +61,7 @@
   private Set<SuffixDescriptor> suffixes = new HashSet<SuffixDescriptor>();
   private LinkedHashSet<PreferredConnection> preferredConnections =
     new LinkedHashSet<PreferredConnection>();
+  private TopologyCacheFilter filter = new TopologyCacheFilter();
 
   private final boolean isMultiThreaded = true;
   private final static int MULTITHREAD_TIMEOUT = 90 * 1000;
@@ -225,6 +226,15 @@
   }
 
   /**
+   * Returns the filter to be used when retrieving information.
+   * @return the filter to be used when retrieving information.
+   */
+  public TopologyCacheFilter getFilter()
+  {
+    return filter;
+  }
+
+  /**
    * Method used to wait at most a certain time (MULTITHREAD_TIMEOUT) for the
    * different threads to finish.
    * @param threadSet the list of threads (we assume that they are started)
@@ -269,7 +279,7 @@
   {
     return new ServerLoader(serverProperties, dn, pwd,
         trustManager == null ? null : trustManager.createCopy(),
-            getPreferredConnections());
+            getPreferredConnections(), getFilter());
   }
 
   /**
diff --git a/opendj-sdk/opends/src/ads/org/opends/admin/ads/TopologyCacheFilter.java b/opendj-sdk/opends/src/ads/org/opends/admin/ads/TopologyCacheFilter.java
new file mode 100644
index 0000000..dea7b36
--- /dev/null
+++ b/opendj-sdk/opends/src/ads/org/opends/admin/ads/TopologyCacheFilter.java
@@ -0,0 +1,126 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License").  You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE
+ * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
+ * add the following below this CDDL HEADER, with the fields enclosed
+ * by brackets "[]" replaced with your own identifying information:
+ *      Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ *      Copyright 2008 Sun Microsystems, Inc.
+ */
+package org.opends.admin.ads;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Class used to filter what we look for in the topology cache.
+ * This is done in particular to avoid problems of performance when we
+ * know what we are looking for.  It is particularly useful to avoid
+ * searching for monitoring information.
+ */
+public class TopologyCacheFilter
+{
+  private Set<String> baseDNs = new HashSet<String>();
+  private boolean searchMonitoringInformation = true;
+  private boolean searchBaseDNInformation = true;
+
+  /**
+   * Returns whether we must search for base DN information or not.
+   * @return <CODE>true</CODE> if we must search base DN information and
+   * <CODE>false</CODE> otherwise.
+   */
+  public boolean searchBaseDNInformation()
+  {
+    return searchBaseDNInformation;
+  }
+
+  /**
+   * Sets whether we must search for base DN information or not.
+   * @param searchBaseDNInformation whether we must search for base DN
+   * information or not.
+   */
+  public void setSearchBaseDNInformation(
+      boolean searchBaseDNInformation)
+  {
+    this.searchBaseDNInformation = searchBaseDNInformation;
+  }
+
+
+  /**
+   * Returns whether we must search for monitoring information or not.
+   * @return <CODE>true</CODE> if we must search monitoring information and
+   * <CODE>false</CODE> otherwise.
+   */
+  public boolean searchMonitoringInformation()
+  {
+    return searchMonitoringInformation;
+  }
+
+  /**
+   * Sets whether we must search for monitoring information or not.
+   * @param searchMonitoringInformation whether we must search for monitoring
+   * information or not.
+   */
+  public void setSearchMonitoringInformation(
+      boolean searchMonitoringInformation)
+  {
+    this.searchMonitoringInformation = searchMonitoringInformation;
+  }
+
+  /**
+   * Adds one of the base DNs we must search for.  If at least one baseDN
+   * is added using this method, only the added baseDNs are searched.  If no
+   * base DN is added, all the base DNs will be retrieved.
+   * @param dn the DN of the base DN to look for.
+   */
+  public void addBaseDNToSearch(String dn)
+  {
+    baseDNs.add(dn);
+  }
+
+  /**
+   * Removes a base DN fom the list of baseDNs to search.
+   * @param dn the DN of the base DN to be removed.
+   */
+  public void removeBaseDNToSearch(String dn)
+  {
+    baseDNs.remove(dn);
+  }
+
+  /**
+   * Returns the list of base DNs that will be searched for.  If the list is
+   * empty we will search for all the base DNs.
+   * @return the list of base DNs we will search for.
+   */
+  public Set<String> getBaseDNsToSearch()
+  {
+    return new HashSet<String>(baseDNs);
+  }
+
+  /**
+   * Tells whether this filter specifies to search for all the base DNs or not.
+   * @return <CODE>true</CODE> if the filter specifies to search for all the
+   * base DNs and <CODE>false</CODE> otherwise.
+   */
+  public boolean searchAllBaseDNs()
+  {
+    return baseDNs.isEmpty();
+  }
+}
diff --git a/opendj-sdk/opends/src/ads/org/opends/admin/ads/util/ServerLoader.java b/opendj-sdk/opends/src/ads/org/opends/admin/ads/util/ServerLoader.java
index f8eda0b..fba082a 100644
--- a/opendj-sdk/opends/src/ads/org/opends/admin/ads/util/ServerLoader.java
+++ b/opendj-sdk/opends/src/ads/org/opends/admin/ads/util/ServerLoader.java
@@ -42,6 +42,7 @@
 import org.opends.admin.ads.ADSContext;
 import org.opends.admin.ads.ServerDescriptor;
 import org.opends.admin.ads.TopologyCacheException;
+import org.opends.admin.ads.TopologyCacheFilter;
 import org.opends.admin.ads.ADSContext.ServerProperty;
 
 /**
@@ -62,6 +63,7 @@
   private String dn;
   private String pwd;
   private LinkedHashSet<PreferredConnection> preferredLDAPURLs;
+  private TopologyCacheFilter filter;
 
   private static final Logger LOG =
     Logger.getLogger(ServerLoader.class.getName());
@@ -77,10 +79,13 @@
    * @param preferredLDAPURLs the list of preferred LDAP URLs that we want
    * to use to connect to the server.  They will be used only if they correspond
    * to the URLs that we found in the the server properties.
+   * @param filter the topology cache filter to be used.  This can be used not
+   * to retrieve all the information.
    */
   public ServerLoader(Map<ServerProperty,Object> serverProperties,
       String dn, String pwd, ApplicationTrustManager trustManager,
-      LinkedHashSet<PreferredConnection> preferredLDAPURLs)
+      LinkedHashSet<PreferredConnection> preferredLDAPURLs,
+      TopologyCacheFilter filter)
   {
     this.serverProperties = serverProperties;
     this.dn = dn;
@@ -88,6 +93,7 @@
     this.trustManager = trustManager;
     this.preferredLDAPURLs =
       new LinkedHashSet<PreferredConnection>(preferredLDAPURLs);
+    this.filter = filter;
   }
 
   /**
@@ -151,7 +157,7 @@
     try
     {
       ctx = createContext();
-      serverDescriptor = ServerDescriptor.createStandalone(ctx);
+      serverDescriptor = ServerDescriptor.createStandalone(ctx, filter);
       serverDescriptor.setAdsProperties(serverProperties);
     }
     catch (NoPermissionException npe)
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliMain.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliMain.java
index d264828..a81d4aa 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliMain.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliMain.java
@@ -72,6 +72,7 @@
 import org.opends.admin.ads.SuffixDescriptor;
 import org.opends.admin.ads.TopologyCache;
 import org.opends.admin.ads.TopologyCacheException;
+import org.opends.admin.ads.TopologyCacheFilter;
 import org.opends.admin.ads.ADSContext.ADSPropertySyntax;
 import org.opends.admin.ads.ADSContext.AdministratorProperty;
 import org.opends.admin.ads.util.ApplicationTrustManager;
@@ -2531,8 +2532,11 @@
         {
           // We must recreate the cache because the trust manager in the
           // LDAPConnectionConsoleInteraction object might have changed.
+
           TopologyCache cache = new TopologyCache(adsContext,
               getTrustManager());
+          cache.getFilter().setSearchMonitoringInformation(false);
+          cache.getFilter().setSearchBaseDNInformation(false);
           cache.setPreferredConnections(getPreferredConnections(ctx[0]));
           cache.reloadTopology();
 
@@ -2611,6 +2615,8 @@
                         adminPwd, getTrustManager());
                     adsContext = new ADSContext(ctx[0]);
                     cache = new TopologyCache(adsContext, getTrustManager());
+                    cache.getFilter().setSearchMonitoringInformation(false);
+                    cache.getFilter().setSearchBaseDNInformation(false);
                     cache.setPreferredConnections(
                         getPreferredConnections(ctx[0]));
                     connected = true;
@@ -2806,8 +2812,12 @@
     LinkedList<String> suffixes = new LinkedList<String>();
     try
     {
-      ServerDescriptor server1 = ServerDescriptor.createStandalone(ctx1);
-      ServerDescriptor server2 = ServerDescriptor.createStandalone(ctx2);
+      TopologyCacheFilter filter = new TopologyCacheFilter();
+      filter.setSearchMonitoringInformation(false);
+      ServerDescriptor server1 =
+        ServerDescriptor.createStandalone(ctx1, filter);
+      ServerDescriptor server2 =
+        ServerDescriptor.createStandalone(ctx2, filter);
       Set<ReplicaDescriptor> replicas1 = server1.getReplicas();
       Set<ReplicaDescriptor> replicas2 = server2.getReplicas();
 
@@ -2929,9 +2939,11 @@
   {
     LinkedList<ReplicaDescriptor> suffixes =
       new LinkedList<ReplicaDescriptor>();
+    TopologyCacheFilter filter = new TopologyCacheFilter();
+    filter.setSearchMonitoringInformation(false);
     try
     {
-      ServerDescriptor server = ServerDescriptor.createStandalone(ctx);
+      ServerDescriptor server = ServerDescriptor.createStandalone(ctx, filter);
       suffixes.addAll(server.getReplicas());
     }
     catch (Throwable t)
@@ -4347,9 +4359,16 @@
       new HashMap<String, Set<Integer>>();
 
     ServerDescriptor server1;
+    TopologyCacheFilter filter = new TopologyCacheFilter();
+    filter.setSearchMonitoringInformation(false);
+    filter.addBaseDNToSearch(ADSContext.getAdministrationSuffixDN());
+    for (String dn : uData.getBaseDNs())
+    {
+      filter.addBaseDNToSearch(dn);
+    }
     try
     {
-      server1 = ServerDescriptor.createStandalone(ctx1);
+      server1 = ServerDescriptor.createStandalone(ctx1, filter);
     }
     catch (NamingException ne)
     {
@@ -4360,7 +4379,7 @@
     ServerDescriptor server2;
     try
     {
-      server2 = ServerDescriptor.createStandalone(ctx2);
+      server2 = ServerDescriptor.createStandalone(ctx2, filter);
     }
     catch (NamingException ne)
     {
@@ -4387,6 +4406,11 @@
         {
           TopologyCache cache = new TopologyCache(adsCtx1, getTrustManager());
           cache.setPreferredConnections(cnx);
+          cache.getFilter().setSearchMonitoringInformation(false);
+          for (String dn : uData.getBaseDNs())
+          {
+            cache.getFilter().addBaseDNToSearch(dn);
+          }
           cache.reloadTopology();
           messages.addAll(getErrorMessages(cache));
         }
@@ -4395,6 +4419,11 @@
         {
           TopologyCache cache = new TopologyCache(adsCtx2, getTrustManager());
           cache.setPreferredConnections(cnx);
+          cache.getFilter().setSearchMonitoringInformation(false);
+          for (String dn : uData.getBaseDNs())
+          {
+            cache.getFilter().addBaseDNToSearch(dn);
+          }
           cache.reloadTopology();
           messages.addAll(getErrorMessages(cache));
         }
@@ -4605,6 +4634,11 @@
       {
         cache1 = new TopologyCache(adsCtx1, getTrustManager());
         cache1.setPreferredConnections(cnx);
+        cache1.getFilter().setSearchMonitoringInformation(false);
+        for (String dn : uData.getBaseDNs())
+        {
+          cache1.getFilter().addBaseDNToSearch(dn);
+        }
         cache1.reloadTopology();
         usedReplicationServerIds.addAll(getReplicationServerIds(cache1));
       }
@@ -4613,6 +4647,11 @@
       {
         cache2 = new TopologyCache(adsCtx2, getTrustManager());
         cache2.setPreferredConnections(cnx);
+        cache2.getFilter().setSearchMonitoringInformation(false);
+        for (String dn : uData.getBaseDNs())
+        {
+          cache2.getFilter().addBaseDNToSearch(dn);
+        }
         cache2.reloadTopology();
         usedReplicationServerIds.addAll(getReplicationServerIds(cache2));
       }
@@ -4847,9 +4886,16 @@
       DisableReplicationUserData uData) throws ReplicationCliException
   {
     ServerDescriptor server;
+    TopologyCacheFilter filter = new TopologyCacheFilter();
+    filter.setSearchMonitoringInformation(false);
+    filter.addBaseDNToSearch(ADSContext.getAdministrationSuffixDN());
+    for (String dn : uData.getBaseDNs())
+    {
+      filter.addBaseDNToSearch(dn);
+    }
     try
     {
-      server = ServerDescriptor.createStandalone(ctx);
+      server = ServerDescriptor.createStandalone(ctx, filter);
     }
     catch (NamingException ne)
     {
@@ -4870,6 +4916,11 @@
       {
         cache = new TopologyCache(adsCtx, getTrustManager());
         cache.setPreferredConnections(getPreferredConnections(ctx));
+        cache.getFilter().setSearchMonitoringInformation(false);
+        for (String dn : uData.getBaseDNs())
+        {
+          cache.getFilter().addBaseDNToSearch(dn);
+        }
         cache.reloadTopology();
       }
     }
@@ -5074,6 +5125,10 @@
     {
       cache = new TopologyCache(adsCtx, getTrustManager());
       cache.setPreferredConnections(getPreferredConnections(ctx));
+      for (String dn : uData.getBaseDNs())
+      {
+        cache.getFilter().addBaseDNToSearch(dn);
+      }
       cache.reloadTopology();
     }
     catch (TopologyCacheException tce)
@@ -5885,9 +5940,12 @@
               cache.getAdsContext().getDirContext());
           String pwd = ConnectionUtils.getBindPassword(
               cache.getAdsContext().getDirContext());
-
+          TopologyCacheFilter filter = new TopologyCacheFilter();
+          filter.setSearchMonitoringInformation(false);
+          filter.setSearchBaseDNInformation(false);
           ServerLoader loader = new ServerLoader(s.getAdsProperties(),
-              dn, pwd, getTrustManager(), cache.getPreferredConnections());
+              dn, pwd, getTrustManager(), cache.getPreferredConnections(),
+              filter);
           InitialLdapContext ctx = null;
           try
           {
@@ -5960,7 +6018,11 @@
     int replicationId = -1;
     try
     {
-      ServerDescriptor source = ServerDescriptor.createStandalone(ctxSource);
+      TopologyCacheFilter filter = new TopologyCacheFilter();
+      filter.setSearchMonitoringInformation(false);
+      filter.addBaseDNToSearch(baseDN);
+      ServerDescriptor source = ServerDescriptor.createStandalone(ctxSource,
+          filter);
       for (ReplicaDescriptor replica : source.getReplicas())
       {
         if (Utils.areDnsEqual(replica.getSuffix().getDN(), baseDN))
@@ -6621,8 +6683,11 @@
       LinkedHashSet<PreferredConnection> cnx)
   throws ReplicationCliException
   {
+    TopologyCacheFilter filter = new TopologyCacheFilter();
+    filter.setSearchMonitoringInformation(false);
+    filter.setSearchBaseDNInformation(false);
     ServerLoader loader = new ServerLoader(server.getAdsProperties(), bindDn,
-        pwd, getTrustManager(), cnx);
+        pwd, getTrustManager(), cnx, filter);
     InitialLdapContext ctx = null;
     String lastBaseDN = null;
     String hostPort = null;
@@ -7383,7 +7448,10 @@
   throws NamingException
   {
     int domainId = -1;
-    ServerDescriptor server = ServerDescriptor.createStandalone(ctx);
+    TopologyCacheFilter filter = new TopologyCacheFilter();
+    filter.setSearchMonitoringInformation(false);
+    filter.addBaseDNToSearch(baseDN);
+    ServerDescriptor server = ServerDescriptor.createStandalone(ctx, filter);
     for (ReplicaDescriptor replica : server.getReplicas())
     {
       if (Utils.areDnsEqual(replica.getSuffix().getDN(), baseDN))
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
index 64a0b56..a642324 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
@@ -1095,6 +1095,7 @@
       }
       TopologyCache cache = new TopologyCache(adsContext,
           userData.getTrustManager());
+      cache.getFilter().setSearchMonitoringInformation(false);
       cache.reloadTopology();
 
       accepted = handleTopologyCache(cache, userData);
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java
index c2233f4..99aab0a 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java
@@ -1496,6 +1496,7 @@
           ADSContext adsContext = new ADSContext(ctx);
           TopologyCache cache = new TopologyCache(adsContext,
               getTrustManager());
+          cache.getFilter().setSearchMonitoringInformation(false);
           cache.reloadTopology();
           return cache;
         }
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Application.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Application.java
index 79b7191..6373cf6 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Application.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Application.java
@@ -33,6 +33,7 @@
 import org.opends.admin.ads.ADSContext;
 import org.opends.admin.ads.ServerDescriptor;
 import org.opends.admin.ads.TopologyCacheException;
+import org.opends.admin.ads.TopologyCacheFilter;
 import org.opends.admin.ads.util.ApplicationTrustManager;
 import org.opends.admin.ads.util.PreferredConnection;
 import org.opends.admin.ads.util.ServerLoader;
@@ -757,8 +758,11 @@
   {
     Map<ADSContext.ServerProperty, Object> adsProperties =
       server.getAdsProperties();
+    TopologyCacheFilter filter = new TopologyCacheFilter();
+    filter.setSearchMonitoringInformation(false);
+    filter.setSearchBaseDNInformation(false);
     ServerLoader loader = new ServerLoader(adsProperties, dn, pwd,
-        trustManager, cnx);
+        trustManager, cnx, filter);
 
     InitialLdapContext ctx = null;
     try
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
index b6d2a89..3c622d1 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
@@ -59,6 +59,7 @@
 import org.opends.admin.ads.SuffixDescriptor;
 import org.opends.admin.ads.TopologyCache;
 import org.opends.admin.ads.TopologyCacheException;
+import org.opends.admin.ads.TopologyCacheFilter;
 import org.opends.admin.ads.util.ApplicationTrustManager;
 import org.opends.admin.ads.util.ConnectionUtils;
 import org.opends.admin.ads.util.PreferredConnection;
@@ -2105,7 +2106,11 @@
       {
         rCtx = getRemoteConnection(server, getTrustManager(),
             getPreferredConnections());
-        ServerDescriptor s = ServerDescriptor.createStandalone(rCtx);
+        TopologyCacheFilter filter = new TopologyCacheFilter();
+        filter.setSearchMonitoringInformation(false);
+        filter.addBaseDNToSearch(ADSContext.getAdministrationSuffixDN());
+        filter.addBaseDNToSearch(Constants.SCHEMA_DN);
+        ServerDescriptor s = ServerDescriptor.createStandalone(rCtx, filter);
         for (ReplicaDescriptor replica : s.getReplicas())
         {
           String dn = replica.getSuffix().getDN();
@@ -2187,7 +2192,11 @@
           {
             rCtx = getRemoteConnection(server, getTrustManager(),
                 getPreferredConnections());
-            ServerDescriptor s = ServerDescriptor.createStandalone(rCtx);
+            TopologyCacheFilter filter = new TopologyCacheFilter();
+            filter.setSearchMonitoringInformation(false);
+            filter.addBaseDNToSearch(dn);
+            ServerDescriptor s = ServerDescriptor.createStandalone(rCtx,
+                filter);
             for (ReplicaDescriptor r : s.getReplicas())
             {
               if (areDnsEqual(r.getSuffix().getDN(), dn))
@@ -2348,8 +2357,11 @@
           }
 
           adsContext.createAdminData(null);
+          TopologyCacheFilter filter = new TopologyCacheFilter();
+          filter.setSearchMonitoringInformation(false);
+          filter.setSearchBaseDNInformation(false);
           ServerDescriptor server
-                  = ServerDescriptor.createStandalone(remoteCtx);
+                  = ServerDescriptor.createStandalone(remoteCtx, filter);
           server.updateAdsPropertiesWithServerProperties();
           adsContext.registerServer(server.getAdsProperties());
           createdRemoteAds = true;
@@ -2383,7 +2395,11 @@
       assert null != adsContext ; // Bound either to local or remote ADS.
 
       /* Register new server in ADS. */
-      ServerDescriptor server = ServerDescriptor.createStandalone(localCtx);
+      TopologyCacheFilter filter = new TopologyCacheFilter();
+      filter.setSearchMonitoringInformation(false);
+      filter.setSearchBaseDNInformation(false);
+      ServerDescriptor server = ServerDescriptor.createStandalone(localCtx,
+          filter);
       server.updateAdsPropertiesWithServerProperties();
       if (0 == adsContext.registerOrUpdateServer(server.getAdsProperties())) {
         if (isRemoteServer) registeredNewServerOnRemote = true;
@@ -3918,7 +3934,9 @@
     {
       type = suf.getType();
     }
-    ServerDescriptor s = ServerDescriptor.createStandalone(ctx);
+
+    ServerDescriptor s = ServerDescriptor.createStandalone(ctx,
+        new TopologyCacheFilter());
     Set<ReplicaDescriptor> replicas = s.getReplicas();
     for (ReplicaDescriptor replica : replicas)
     {

--
Gitblit v1.10.0