opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ConnectionHandlerDescriptor.java
@@ -35,6 +35,7 @@ import java.util.TreeSet; import org.opends.messages.Message; import org.opends.server.admin.std.meta.AdministrationConnectorCfgDefn; /** * This class is used to represent a Listener and is aimed to be used by the @@ -131,7 +132,9 @@ } private State state; private SortedSet<InetAddress> addresses = new TreeSet<InetAddress>(); private SortedSet<InetAddress> addresses = new TreeSet<InetAddress>( AdministrationConnectorCfgDefn.getInstance(). getListenAddressPropertyDefinition()); private int port; private Protocol protocol; private String toString; @@ -140,7 +143,7 @@ private int hashCode; /** * Constructor for thid class. * Constructor for the connection handler.. * @param addresses the list of InetAdresses of the listener. * @param port the port of the connection handler. * @param protocol the protocol of the listener. @@ -173,7 +176,7 @@ */ public SortedSet<InetAddress> getAddresses() { return new TreeSet<InetAddress>(addresses); return addresses; } /** @@ -222,7 +225,7 @@ } else if (o instanceof ConnectionHandlerDescriptor) { equals = hashCode() == o.hashCode(); equals = toString.equals(o.toString()); } return equals; } opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ConnectionHandlerTableModel.java
@@ -283,7 +283,7 @@ { buf.append("<br>"); } buf.append(address); buf.append(address.getCanonicalHostName()); added = true; if (desc.getPort() > 0) { opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
@@ -925,8 +925,8 @@ if (port > 0) { InetAddress address = addresses.first(); url = "ldaps://" + ConnectionUtils.getHostNameForLdapUrl(address.toString()) + ":" + port; ConnectionUtils.getHostNameForLdapUrl(address.getHostAddress()) + ":" + port; } } return url; opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/CustomSearchResult.java
@@ -57,6 +57,8 @@ private String dn; private Map<String, Set<Object>> attributes; private SortedSet<String> attrNames; private String toString; private int hashCode; /** * Constructor of an empty search result. This constructor is used by the @@ -69,6 +71,8 @@ this.dn = dn; attributes = new HashMap<String, Set<Object>>(); attrNames = new TreeSet<String>(); toString = calculateToString(); hashCode = calculateHashCode(); } /** @@ -134,6 +138,8 @@ attributes.put(name.toLowerCase(), values); } } toString = calculateToString(); hashCode = calculateHashCode(); } /** @@ -178,8 +184,49 @@ /** * {@inheritDoc} */ public boolean equals(Object o) { boolean equals = false; if (o != null) { equals = o == this; if (!equals && (o instanceof CustomSearchResult)) { CustomSearchResult sr = (CustomSearchResult)o; equals = getDN().equals(sr.getDN()); if (equals) { equals = getAttributeNames().equals(sr.getAttributeNames()); if (equals) { for (String attrName : getAttributeNames()) { equals = getAttributeValues(attrName).equals( sr.getAttributeValues(attrName)); if (!equals) { break; } } } } } } return equals; } /** * {@inheritDoc} */ public String toString() { return "dn: "+dn+"\nattributes: "+attributes; return toString; } /** * {@inheritDoc} */ public int hashCode() { return hashCode; } /** @@ -192,5 +239,17 @@ attrNames.add(attrName); attrName = attrName.toLowerCase(); attributes.put(attrName, values); toString = calculateToString(); hashCode = calculateHashCode(); } private String calculateToString() { return "dn: "+dn+"\nattributes: "+attributes; } private int calculateHashCode() { return 23 + toString.hashCode(); } } opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusGenericPanel.java
@@ -686,7 +686,7 @@ * Constructor. * @param combo the combo box. */ IgnoreItemListener(JComboBox combo) public IgnoreItemListener(JComboBox combo) { this.combo = combo; selectedItem = combo.getSelectedItem(); opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java
@@ -328,8 +328,6 @@ ex.add(oe); } updateMonitorInformation(ctx, bs, ex); try { readSchema(); @@ -349,42 +347,48 @@ { LOG.log(Level.WARNING, "Error reading configuration: "+oe, oe); } exceptions = Collections.unmodifiableList(ex); administrativeUsers = Collections.unmodifiableSet(as); listeners = Collections.unmodifiableSet(ls); backends = Collections.unmodifiableSet(bs); try { updateMonitorInformation(ctx, ex); } catch (Throwable t) { OnlineUpdateException oupe = new OnlineUpdateException( ERR_READING_CONFIG_LDAP.get(t.toString()), t); ex.add(oupe); } exceptions = Collections.unmodifiableList(ex); } private void updateMonitorInformation(InitialLdapContext ctx, Set<BackendDescriptor> bs, List<OpenDsException> ex) /** * Returns an array of monitoring attributes to be returned in the request. * @return an array of monitoring attributes to be returned in the request. */ protected String[] getMonitoringAttributes() { // Read monitoring information: since it is computed, it is faster // to get everything in just one request. SearchControls ctls = new SearchControls(); ctls.setSearchScope(SearchControls.SUBTREE_SCOPE); ctls.setReturningAttributes( new String[] { return new String[] { "approx-older-change-not-synchronized-millis", "missing-changes", "base-dn", "server-id", "javaVersion", "currentConnections", "ds-backend-id", "ds-backend-entry-count", "ds-base-dn-entry-count" }); String filter = "(objectclass=*)"; }; } try /** * Takes the provided search result and updates the monitoring information * accordingly. * @param sr the search result. * @param searchBaseDN the base search. * @throws NamingException if there is an error retrieving the values of the * search result. */ protected void handleMonitoringSearchResult(SearchResult sr, String searchBaseDN) throws NamingException { LdapName jndiName = new LdapName("cn=monitor"); NamingEnumeration monitorEntries = ctx.search(jndiName, filter, ctls); javaVersion = null; numberConnections = -1; while (monitorEntries.hasMore()) { SearchResult sr = (SearchResult)monitorEntries.next(); if (javaVersion == null) { javaVersion = ConnectionUtils.getFirstValue(sr, "javaVersion"); @@ -404,7 +408,7 @@ if ((dn != null) && (replicaId != null)) { for (BackendDescriptor backend : bs) for (BackendDescriptor backend : backends) { for (BaseDNDescriptor baseDN : backend.getBaseDns()) { @@ -443,7 +447,7 @@ if ((backendID != null) && ((entryCount != null) || (baseDnEntries != null))) { for (BackendDescriptor backend : bs) for (BackendDescriptor backend : backends) { if (backend.getBackendID().equalsIgnoreCase(backendID)) { @@ -485,6 +489,32 @@ } } } private void updateMonitorInformation(InitialLdapContext ctx, List<OpenDsException> ex) { // Read monitoring information: since it is computed, it is faster // to get everything in just one request. SearchControls ctls = new SearchControls(); ctls.setSearchScope(SearchControls.SUBTREE_SCOPE); ctls.setReturningAttributes( getMonitoringAttributes()); String filter = "(objectclass=*)"; try { LdapName jndiName = new LdapName("cn=monitor"); NamingEnumeration monitorEntries = ctx.search(jndiName, filter, ctls); javaVersion = null; numberConnections = -1; while (monitorEntries.hasMore()) { SearchResult sr = (SearchResult)monitorEntries.next(); handleMonitoringSearchResult(sr, "cn=monitor"); } } catch (NamingException ne) { @@ -498,7 +528,8 @@ ConnectionHandlerCfgClient connHandler, String name) throws OpenDsException { SortedSet<InetAddress> addresses = new TreeSet<InetAddress>(); SortedSet<InetAddress> addresses = new TreeSet<InetAddress>( getInetAddressComparator()); int port; ConnectionHandlerDescriptor.Protocol protocol; @@ -524,7 +555,7 @@ protocol = ConnectionHandlerDescriptor.Protocol.LDAP; } SortedSet<InetAddress> v = ldap.getListenAddress(); if (v == null) if (v != null) { addresses.addAll(v); } @@ -568,7 +599,8 @@ private ConnectionHandlerDescriptor getConnectionHandler( AdministrationConnectorCfgClient adminConnector) throws OpenDsException { SortedSet<InetAddress> addresses = new TreeSet<InetAddress>(); SortedSet<InetAddress> addresses = new TreeSet<InetAddress>( getInetAddressComparator()); ConnectionHandlerDescriptor.Protocol protocol = ConnectionHandlerDescriptor.Protocol.ADMINISTRATION_CONNECTOR; @@ -578,7 +610,7 @@ SortedSet<InetAddress> v = adminConnector.getListenAddress(); if (v == null) if (v != null) { addresses.addAll(v); } opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromFile.java
@@ -383,7 +383,8 @@ private ConnectionHandlerDescriptor getConnectionHandler( ConnectionHandlerCfg connHandler, String name) throws OpenDsException { SortedSet<InetAddress> addresses = new TreeSet<InetAddress>(); SortedSet<InetAddress> addresses = new TreeSet<InetAddress>( getInetAddressComparator()); int port; ConnectionHandlerDescriptor.Protocol protocol; @@ -408,7 +409,7 @@ protocol = ConnectionHandlerDescriptor.Protocol.LDAP; } SortedSet<InetAddress> v = ldap.getListenAddress(); if (v == null) if (v != null) { addresses.addAll(v); } @@ -450,7 +451,8 @@ private ConnectionHandlerDescriptor getConnectionHandler( AdministrationConnectorCfg adminConnector) throws OpenDsException { SortedSet<InetAddress> addresses = new TreeSet<InetAddress>(); SortedSet<InetAddress> addresses = new TreeSet<InetAddress>( getInetAddressComparator()); ConnectionHandlerDescriptor.Protocol protocol = ConnectionHandlerDescriptor.Protocol.ADMINISTRATION_CONNECTOR; @@ -460,7 +462,7 @@ SortedSet<InetAddress> v = adminConnector.getListenAddress(); if (v == null) if (v != null) { addresses.addAll(v); } opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigReader.java
@@ -30,8 +30,10 @@ import static org.opends.messages.AdminToolMessages.*; import java.io.File; import java.net.InetAddress; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Set; @@ -39,6 +41,7 @@ import org.opends.guitools.controlpanel.datamodel.ConnectionHandlerDescriptor; import org.opends.guitools.controlpanel.datamodel.VLVSortOrder; import org.opends.guitools.controlpanel.task.OfflineUpdateException; import org.opends.server.admin.std.meta.AdministrationConnectorCfgDefn; import org.opends.server.config.ConfigException; import org.opends.server.core.DirectoryServer; import org.opends.server.types.DN; @@ -311,4 +314,14 @@ } return sortOrder; } /** * Returns the comparator to be used to sort InetAddresses. * @return the comparator to be used to sort InetAddresses. */ protected Comparator<InetAddress> getInetAddressComparator() { return AdministrationConnectorCfgDefn.getInstance(). getListenAddressPropertyDefinition(); } }