| | |
| | | import org.opends.server.admin.client.ldap.LDAPManagementContext; |
| | | import org.opends.server.admin.std.client.*; |
| | | import org.opends.server.admin.std.meta.LocalDBIndexCfgDefn.IndexType; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.OpenDsException; |
| | | import org.opends.server.util.ServerConstants; |
| | |
| | | private CustomSearchResult systemInformation; |
| | | private CustomSearchResult entryCaches; |
| | | private CustomSearchResult workQueue; |
| | | private CustomSearchResult versionMonitor; |
| | | |
| | | private boolean isLocal = true; |
| | | |
| | | private Map<String, CustomSearchResult> hmConnectionHandlersMonitor = |
| | | new HashMap<String, CustomSearchResult>(); |
| | |
| | | * The work queue monitoring entry DN. |
| | | */ |
| | | protected DN workQueueDN = DN.nullDN(); |
| | | /** |
| | | * The version monitoring entry DN. |
| | | */ |
| | | protected DN versionDN = DN.nullDN(); |
| | | |
| | | { |
| | | try |
| | |
| | | systemInformationDN = DN.decode("cn=System Information,cn=monitor"); |
| | | entryCachesDN = DN.decode("cn=Entry Caches,cn=monitor"); |
| | | workQueueDN = DN.decode("cn=Work Queue,cn=monitor"); |
| | | versionDN = DN.decode("cn=Version,cn=monitor"); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the version entry of the monitoring tree. |
| | | * @return the version entry of the monitoring tree. |
| | | */ |
| | | public CustomSearchResult getVersionMonitor() |
| | | { |
| | | return versionMonitor; |
| | | } |
| | | |
| | | /** |
| | | * Returns the monitoring entry for the system information. |
| | | * @return the monitoring entry for the system information. |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Sets whether this server represents the local instance or a remote server. |
| | | * @param isLocal whether this server represents the local instance or a |
| | | * remote server (in another machine or in another installation on the same |
| | | * machine). |
| | | */ |
| | | public void setIsLocal(boolean isLocal) |
| | | { |
| | | this.isLocal = isLocal; |
| | | } |
| | | |
| | | /** |
| | | * Returns <CODE>true</CODE> if we are trying to manage the local host and |
| | | * <CODE>false</CODE> otherwise. |
| | | * @return <CODE>true</CODE> if we are trying to manage the local host and |
| | | * <CODE>false</CODE> otherwise. |
| | | */ |
| | | public boolean isLocal() |
| | | { |
| | | return isLocal; |
| | | } |
| | | |
| | | /** |
| | | * Reads configuration and monitoring information using the provided |
| | | * connection. |
| | | * @param ctx the connection to be used to read the information. |
| | |
| | | systemInformation = null; |
| | | entryCaches = null; |
| | | workQueue = null; |
| | | versionMonitor = null; |
| | | |
| | | hmConnectionHandlersMonitor.clear(); |
| | | |
| | | if (mustReadSchema()) |
| | | { |
| | | try |
| | | { |
| | | readSchema(ctx); |
| | | if (getSchema() != null) |
| | | { |
| | | // Update the schema: so that when we call the server code the |
| | | // latest schema read on the server we are managing is used. |
| | | DirectoryServer.setSchema(getSchema()); |
| | | } |
| | | } |
| | | catch (OpenDsException oe) |
| | | { |
| | | ex.add(oe); |
| | | } |
| | | } |
| | | |
| | | try |
| | | { |
| | | // Get the Directory Server configuration handler and use it. |
| | |
| | | { |
| | | ex.add(oe); |
| | | } |
| | | |
| | | try |
| | | { |
| | | readSchema(); |
| | | } |
| | | catch (OpenDsException oe) |
| | | { |
| | | ex.add(oe); |
| | | } |
| | | } |
| | | catch (final Throwable t) |
| | | { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Reads the schema from the files. |
| | | * @param ctx the connection to be used to load the schema. |
| | | * @throws OpenDsException if an error occurs reading the schema. |
| | | */ |
| | | private void readSchema(InitialLdapContext ctx) throws OpenDsException |
| | | { |
| | | if (isLocal) |
| | | { |
| | | super.readSchema(); |
| | | } |
| | | else |
| | | { |
| | | RemoteSchemaLoader loader = new RemoteSchemaLoader(); |
| | | try |
| | | { |
| | | loader.readSchema(ctx); |
| | | } |
| | | catch (NamingException ne) |
| | | { |
| | | throw new OnlineUpdateException( |
| | | ERR_READING_SCHEMA_LDAP.get(ne.toString()), ne); |
| | | } |
| | | schema = loader.getSchema(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Takes the provided search result and updates the monitoring information |
| | | * accordingly. |
| | | * @param sr the search result. |
| | |
| | | { |
| | | systemInformation = csr; |
| | | } |
| | | else if ((versionMonitor == null) && isVersionMonitor(csr)) |
| | | { |
| | | versionMonitor = csr; |
| | | } |
| | | else if (isConnectionHandler(csr)) |
| | | { |
| | | String statistics = " Statistics"; |
| | |
| | | return monitorDN.equals(DN.decode(csr.getDN())); |
| | | } |
| | | |
| | | private boolean isVersionMonitor(CustomSearchResult csr) |
| | | throws OpenDsException |
| | | { |
| | | return versionDN.equals(DN.decode(csr.getDN())); |
| | | } |
| | | |
| | | private boolean isSystemInformation(CustomSearchResult csr) |
| | | throws OpenDsException |
| | | { |