ConfigFromDirContext.java revision eb4855e3f510e32c6034710868ef87e67081f921
41eeec8620877f96835b4d543b6a6b615847d6f2Till Mossakowski * CDDL HEADER START
333780eae2be9f20fe46dedbf5eb46ffa0cbfd02Christian Maeder * The contents of this file are subject to the terms of the
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu Prodescu * Common Development and Distribution License, Version 1.0 only
41eeec8620877f96835b4d543b6a6b615847d6f2Till Mossakowski * (the "License"). You may not use this file except in compliance
cfbd735270fe52115cef0508d265785efcb99cd7Christian Maeder * with the License.
41eeec8620877f96835b4d543b6a6b615847d6f2Till Mossakowski * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
41eeec8620877f96835b4d543b6a6b615847d6f2Till Mossakowski * or http://forgerock.org/license/CDDLv1.0.html.
703d52d129c8ac510a6f3e8fe28008dbf82ef772Till Mossakowski * See the License for the specific language governing permissions
41eeec8620877f96835b4d543b6a6b615847d6f2Till Mossakowski * and limitations under the License.
41eeec8620877f96835b4d543b6a6b615847d6f2Till Mossakowski * When distributing Covered Code, include this CDDL HEADER in each
41eeec8620877f96835b4d543b6a6b615847d6f2Till Mossakowski * file and include the License file at legal-notices/CDDLv1_0.txt.
d5aadb569823a9d41ef761433f27dd00d7e4e147Christian Maeder * If applicable, add the following below this CDDL HEADER, with the
d5aadb569823a9d41ef761433f27dd00d7e4e147Christian Maeder * fields enclosed by brackets "[]" replaced with your own identifying
d5aadb569823a9d41ef761433f27dd00d7e4e147Christian Maeder * information:
d5aadb569823a9d41ef761433f27dd00d7e4e147Christian Maeder * Portions Copyright [yyyy] [name of copyright owner]
d5aadb569823a9d41ef761433f27dd00d7e4e147Christian Maeder * CDDL HEADER END
697e63e30aa3c309a1ef1f9357745111f8dfc5a9Christian Maeder * Copyright 2008-2011 Sun Microsystems, Inc.
0cbb0121c81f5307eeefe7ffbeeac79ff6c5cdf2Jorina Freya Gerken * Portions Copyright 2013-2015 ForgeRock AS.
55c5e901b5c3466300009135585bc70bd576dcb6Christian Maederpackage org.opends.guitools.controlpanel.util;
697e63e30aa3c309a1ef1f9357745111f8dfc5a9Christian Maederimport static org.opends.messages.AdminToolMessages.*;
a5c67efbd82e10368fda4e30d528157066d45c03Christian Maederimport javax.naming.directory.SearchControls;
04d04d19fdd5320953c78ad5b6d2d11f85bc4bcfChristian Maederimport javax.naming.ldap.InitialLdapContext;
333780eae2be9f20fe46dedbf5eb46ffa0cbfd02Christian Maederimport org.forgerock.i18n.LocalizableMessage;
2c81e2bd9f9dee247c74a642c03620a2f799d0a4Razvan Pascanuimport org.forgerock.i18n.slf4j.LocalizedLogger;
d5aadb569823a9d41ef761433f27dd00d7e4e147Christian Maederimport org.forgerock.opendj.config.server.ConfigException;
c458c6f5a2ce173d8af7a7f5cb434813eb870937Jorina Freya Gerkenimport org.opends.guitools.controlpanel.datamodel.AbstractIndexDescriptor;
0a5165c161ce13d434b5c0488b533a8de98aafaaChristian Maederimport org.opends.guitools.controlpanel.datamodel.BackendDescriptor;
4b136ad539bd9f4e115dff4eee4d552a42d4437eChristian Maederimport org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor;
4b136ad539bd9f4e115dff4eee4d552a42d4437eChristian Maederimport org.opends.guitools.controlpanel.datamodel.ConnectionHandlerDescriptor;
4b136ad539bd9f4e115dff4eee4d552a42d4437eChristian Maederimport org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
fd4856f5eeac6f144f6116002233e5ce4cc8f41bJorina Freya Gerkenimport org.opends.guitools.controlpanel.datamodel.IndexDescriptor;
4b136ad539bd9f4e115dff4eee4d552a42d4437eChristian Maederimport org.opends.guitools.controlpanel.datamodel.IndexTypeDescriptor;
4b136ad539bd9f4e115dff4eee4d552a42d4437eChristian Maederimport org.opends.guitools.controlpanel.datamodel.VLVIndexDescriptor;
7ec5cb48d588cc641d27fb2dbeccb6c28856c8daChristian Maederimport org.opends.guitools.controlpanel.datamodel.VLVSortOrder;
7ec5cb48d588cc641d27fb2dbeccb6c28856c8daChristian Maederimport org.opends.guitools.controlpanel.task.OnlineUpdateException;
c458c6f5a2ce173d8af7a7f5cb434813eb870937Jorina Freya Gerkenimport org.opends.server.admin.client.AuthorizationException;
fd4856f5eeac6f144f6116002233e5ce4cc8f41bJorina Freya Gerkenimport org.opends.server.admin.client.CommunicationException;
e953bea49e7f0e1a43bccf2a66c5e2a2b50848e0Christian Maederimport org.opends.server.admin.client.ConcurrentModificationException;
e953bea49e7f0e1a43bccf2a66c5e2a2b50848e0Christian Maederimport org.opends.server.admin.client.ManagementContext;
0a5165c161ce13d434b5c0488b533a8de98aafaaChristian Maederimport org.opends.server.admin.client.ldap.JNDIDirContextAdaptor;
0a5165c161ce13d434b5c0488b533a8de98aafaaChristian Maederimport org.opends.server.admin.client.ldap.LDAPManagementContext;
d11391a2447a2005329a95b5d770f24e62bf5b63Christian Maederimport org.opends.server.admin.std.client.AdministrationConnectorCfgClient;
d11391a2447a2005329a95b5d770f24e62bf5b63Christian Maederimport org.opends.server.admin.std.client.BackendCfgClient;
0a5165c161ce13d434b5c0488b533a8de98aafaaChristian Maederimport org.opends.server.admin.std.client.BackendIndexCfgClient;
0a5165c161ce13d434b5c0488b533a8de98aafaaChristian Maederimport org.opends.server.admin.std.client.BackendVLVIndexCfgClient;
d11391a2447a2005329a95b5d770f24e62bf5b63Christian Maederimport org.opends.server.admin.std.client.BackupBackendCfgClient;
d11391a2447a2005329a95b5d770f24e62bf5b63Christian Maederimport org.opends.server.admin.std.client.ConnectionHandlerCfgClient;
4b136ad539bd9f4e115dff4eee4d552a42d4437eChristian Maederimport org.opends.server.admin.std.client.HTTPConnectionHandlerCfgClient;
4b136ad539bd9f4e115dff4eee4d552a42d4437eChristian Maederimport org.opends.server.admin.std.client.JMXConnectionHandlerCfgClient;
0a5165c161ce13d434b5c0488b533a8de98aafaaChristian Maederimport org.opends.server.admin.std.client.LDAPConnectionHandlerCfgClient;
c458c6f5a2ce173d8af7a7f5cb434813eb870937Jorina Freya Gerkenimport org.opends.server.admin.std.client.LDIFBackendCfgClient;
54a0a1e10bd93721cf52dbd9b816c8f108997ec0Christian Maederimport org.opends.server.admin.std.client.LDIFConnectionHandlerCfgClient;
54a0a1e10bd93721cf52dbd9b816c8f108997ec0Christian Maederimport org.opends.server.admin.std.client.LocalDBBackendCfgClient;
54a0a1e10bd93721cf52dbd9b816c8f108997ec0Christian Maederimport org.opends.server.admin.std.client.LocalDBIndexCfgClient;
54a0a1e10bd93721cf52dbd9b816c8f108997ec0Christian Maederimport org.opends.server.admin.std.client.LocalDBVLVIndexCfgClient;
54a0a1e10bd93721cf52dbd9b816c8f108997ec0Christian Maederimport org.opends.server.admin.std.client.MemoryBackendCfgClient;
4b136ad539bd9f4e115dff4eee4d552a42d4437eChristian Maederimport org.opends.server.admin.std.client.MonitorBackendCfgClient;
afe76697dd6888856a066934a1112a38809b27faChristian Maederimport org.opends.server.admin.std.client.PluggableBackendCfgClient;
ce3e8067c8e5c5ffe7e76d75ead46e2b67adcafcChristian Maederimport org.opends.server.admin.std.client.ReplicationDomainCfgClient;
ce3e8067c8e5c5ffe7e76d75ead46e2b67adcafcChristian Maederimport org.opends.server.admin.std.client.ReplicationServerCfgClient;
ce3e8067c8e5c5ffe7e76d75ead46e2b67adcafcChristian Maederimport org.opends.server.admin.std.client.ReplicationSynchronizationProviderCfgClient;
ce3e8067c8e5c5ffe7e76d75ead46e2b67adcafcChristian Maederimport org.opends.server.admin.std.client.RootCfgClient;
ce3e8067c8e5c5ffe7e76d75ead46e2b67adcafcChristian Maederimport org.opends.server.admin.std.client.RootDNCfgClient;
fd4856f5eeac6f144f6116002233e5ce4cc8f41bJorina Freya Gerkenimport org.opends.server.admin.std.client.RootDNUserCfgClient;
afe76697dd6888856a066934a1112a38809b27faChristian Maederimport org.opends.server.admin.std.client.SNMPConnectionHandlerCfgClient;
fb88eac77c89b668f5c306173a6fbe2d513e4bccMarkus Grossimport org.opends.server.admin.std.client.TaskBackendCfgClient;
fb88eac77c89b668f5c306173a6fbe2d513e4bccMarkus Grossimport org.opends.server.backends.jeb.RemoveOnceLocalDBBackendIsPluggable;
ce3e8067c8e5c5ffe7e76d75ead46e2b67adcafcChristian Maederimport org.opends.server.backends.pluggable.SuffixContainer;
ce3e8067c8e5c5ffe7e76d75ead46e2b67adcafcChristian Maederimport org.opends.server.config.ConfigConstants;
54a0a1e10bd93721cf52dbd9b816c8f108997ec0Christian Maederimport org.opends.server.core.DirectoryServer;
4b136ad539bd9f4e115dff4eee4d552a42d4437eChristian Maederimport org.opends.server.tools.tasks.TaskEntry;
0a5165c161ce13d434b5c0488b533a8de98aafaaChristian Maederimport org.opends.server.types.OpenDsException;
4b136ad539bd9f4e115dff4eee4d552a42d4437eChristian Maederimport org.opends.server.util.ServerConstants;
ce3e8067c8e5c5ffe7e76d75ead46e2b67adcafcChristian Maeder * A class that reads the configuration and monitoring information using a
e49fd57c63845c7806860a9736ad09f6d44dbaedChristian Maeder * DirContext through LDAP.
afe76697dd6888856a066934a1112a38809b27faChristian Maederpublic class ConfigFromDirContext extends ConfigReader
0a5165c161ce13d434b5c0488b533a8de98aafaaChristian Maeder private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
2c81e2bd9f9dee247c74a642c03620a2f799d0a4Razvan Pascanu private static final String DATABASE_ENVIRONMENT_SUFFIX = " Database Environment";
54a0a1e10bd93721cf52dbd9b816c8f108997ec0Christian Maeder private static final String SYNC_PROVIDER_NAME = "Multimaster Synchronization";
e49fd57c63845c7806860a9736ad09f6d44dbaedChristian Maeder private CustomSearchResult systemInformation;
0cbb0121c81f5307eeefe7ffbeeac79ff6c5cdf2Jorina Freya Gerken private boolean isLocal = true;
4b136ad539bd9f4e115dff4eee4d552a42d4437eChristian Maeder private final Map<String, CustomSearchResult> hmConnectionHandlersMonitor =
4b136ad539bd9f4e115dff4eee4d552a42d4437eChristian Maeder /** The monitor root entry DN. */
0a5165c161ce13d434b5c0488b533a8de98aafaaChristian Maeder /** The JVM memory usage monitoring entry DN. */
54a0a1e10bd93721cf52dbd9b816c8f108997ec0Christian Maeder protected DN jvmMemoryUsageDN = DN.rootDN();
54a0a1e10bd93721cf52dbd9b816c8f108997ec0Christian Maeder /** The system information monitoring entry DN. */
54a0a1e10bd93721cf52dbd9b816c8f108997ec0Christian Maeder protected DN systemInformationDN = DN.rootDN();
54a0a1e10bd93721cf52dbd9b816c8f108997ec0Christian Maeder /**The entry cache monitoring entry DN. */
4b136ad539bd9f4e115dff4eee4d552a42d4437eChristian Maeder /** The work queue monitoring entry DN. */
f45fad43ee1673ab280fbc700821d5d20a493eaaChristian Maeder /** The version monitoring entry DN. */
4b136ad539bd9f4e115dff4eee4d552a42d4437eChristian Maeder jvmMemoryUsageDN = DN.valueOf("cn=JVM Memory Usage,cn=monitor");
0cbb0121c81f5307eeefe7ffbeeac79ff6c5cdf2Jorina Freya Gerken systemInformationDN = DN.valueOf("cn=System Information,cn=monitor");
0a5165c161ce13d434b5c0488b533a8de98aafaaChristian Maeder entryCachesDN = DN.valueOf("cn=Entry Caches,cn=monitor");
04d04d19fdd5320953c78ad5b6d2d11f85bc4bcfChristian Maeder workQueueDN = DN.valueOf("cn=Work Queue,cn=monitor");
04d04d19fdd5320953c78ad5b6d2d11f85bc4bcfChristian Maeder versionDN = DN.valueOf("cn=Version,cn=monitor");
0cbb0121c81f5307eeefe7ffbeeac79ff6c5cdf2Jorina Freya Gerken throw new RuntimeException("Could not decode DNs: "+t, t);
0a5165c161ce13d434b5c0488b533a8de98aafaaChristian Maeder /** The date formatter to be used to parse GMT dates. */
0a5165c161ce13d434b5c0488b533a8de98aafaaChristian Maeder public static final SimpleDateFormat utcParser = new SimpleDateFormat(ServerConstants.DATE_FORMAT_GMT_TIME);
9192fdd8f0e682ac0f0183dd854d5210fbfa4ec5Christian Maeder utcParser.setTimeZone(TimeZone.getTimeZone("UTC"));
54a0a1e10bd93721cf52dbd9b816c8f108997ec0Christian Maeder /** The date formatter to be used to format dates. */
54a0a1e10bd93721cf52dbd9b816c8f108997ec0Christian Maeder public static final DateFormat formatter = DateFormat.getDateTimeInstance();
07eb349813c50aff304df13337b5cbc42f48c0a5Jorina Freya Gerken * Returns the monitoring entry for the entry caches.
07eb349813c50aff304df13337b5cbc42f48c0a5Jorina Freya Gerken * @return the monitoring entry for the entry caches.
07eb349813c50aff304df13337b5cbc42f48c0a5Jorina Freya Gerken public CustomSearchResult getEntryCaches()
return jvmMemoryUsage;
return rootMonitor;
return versionMonitor;
return systemInformation;
return workQueue;
public boolean isLocal()
return isLocal;
final Set<ConnectionHandlerDescriptor> connectionHandlers = new HashSet<ConnectionHandlerDescriptor>();
catch (final Throwable t)
catch (Throwable t)
catch (Throwable t)
private void readSchemaIfNeeded(final InitialLdapContext context, final List<OpenDsException> errors)
if (mustReadSchema())
final Set<ConnectionHandlerDescriptor> connectionHandlers, final Set<BackendDescriptor> backendDescriptors,
ManagementContext mCtx = LDAPManagementContext.createFromContext(JNDIDirContextAdaptor.adapt(context));
BaseDNDescriptor baseDN = new BaseDNDescriptor(BaseDNDescriptor.Type.NOT_REPLICATED, dn, null, -1, -1, -1);
final Set<VLVIndexDescriptor> vlvIndexes, final BackendCfgClient backend, final List<OpenDsException> errors)
private void readBackendIndexes(final Set<IndexDescriptor> indexes, final List<OpenDsException> errors,
null, IndexTypeDescriptor.fromBackendIndexTypes(index.getIndexType()), index.getIndexEntryLimit()));
final Set<VLVIndexDescriptor> vlvIndexes, final BackendCfgClient backend, final List<OpenDsException> errors)
null, IndexTypeDescriptor.fromLocalDBIndexTypes(index.getIndexType()), index.getIndexEntryLimit()));
private boolean readIfReplicationIsSecure(final RootCfgClient root, final List<OpenDsException> errors)
private ReplicationSynchronizationProviderCfgClient readSyncProviderIfExists(final RootCfgClient root)
return (ReplicationSynchronizationProviderCfgClient) root.getSynchronizationProvider(SYNC_PROVIDER_NAME);
return null;
final Set<BackendDescriptor> backendDescriptors, final ReplicationSynchronizationProviderCfgClient sync,
if (isLocal)
super.readSchema();
throws NamingException
if (v != null)
catch (Throwable t)
catch (Throwable t)
catch (Throwable t)
catch (Throwable t)
private void handleTaskSearchResult(SearchResult sr, String searchBaseDN, Collection<TaskEntry> taskEntries,
public void updateTaskInformation(InitialLdapContext ctx, List<OpenDsException> ex, Collection<TaskEntry> ts)
private ConnectionHandlerDescriptor getConnectionHandler(ConnectionHandlerCfgClient connHandler, String name)
throws OpenDsException
int port;
ConnectionHandlerDescriptor.State state = connHandler.isEnabled() ? ConnectionHandlerDescriptor.State.ENABLED
private ConnectionHandlerDescriptor getConnectionHandler(AdministrationConnectorCfgClient adminConnector)
throws OpenDsException
ConnectionHandlerDescriptor.Protocol protocol = ConnectionHandlerDescriptor.Protocol.ADMINISTRATION_CONNECTOR;
return new ConnectionHandlerDescriptor(
addresses, port, protocol, state, INFO_CTRL_PANEL_CONN_HANDLER_ADMINISTRATION.get().toString(), emptySet);
boolean isConnectionHandler = false;
isConnectionHandler = true;
return isConnectionHandler;
boolean isTaskEntry = false;
isTaskEntry = true;
return isTaskEntry;
boolean hasAllAddresses = true;
hasAllAddresses = false;
if (hasAllAddresses)
return monitorEntries;