Issue 1532: Remove ConfigEntry from Backend API. (DS-1532)
| | |
| | | <adm:one-to-one /> |
| | | <adm:profile name="ldap"> |
| | | <ldap:rdn-sequence> |
| | | cn=config |
| | | cn=Root DSE,cn=config |
| | | </ldap:rdn-sequence> |
| | | </adm:profile> |
| | | </adm:relation> |
| | |
| | | * If one or more of the managed object's properties could |
| | | * not be decoded. |
| | | */ |
| | | public static <S extends Configuration> |
| | | static <S extends Configuration> |
| | | ServerManagedObject<? extends S> decode( |
| | | ManagedObjectPath path, |
| | | AbstractManagedObjectDefinition<?, S> definition, |
| | |
| | | * should specify the name of a class implementing this interface. |
| | | * |
| | | * @param <T> |
| | | * The type of connection handler configuration handled by |
| | | * this connection handler implementation. |
| | | * The type of access control configuration handled by |
| | | * this access control provider implementation. |
| | | */ |
| | | public interface AccessControlProvider |
| | | <T extends AccessControlHandlerCfg> |
| | |
| | | import java.util.Set; |
| | | import java.util.concurrent.locks.Lock; |
| | | |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DeleteOperation; |
| | |
| | | |
| | | import static org.opends.server.messages.BackendMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | |
| | | import org.opends.server.admin.Configuration; |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | |
| | | /** |
| | | * Initializes this backend based on the information in the provided |
| | | * configuration entry. |
| | | * Configure this backend based on the information in the provided |
| | | * configuration. |
| | | * |
| | | * @param configEntry The configuration entry that contains the |
| | | * information to use to initialize this |
| | | * backend. |
| | | * @param baseDNs The set of base DNs that have been |
| | | * configured for this backend. |
| | | * @param cfg The configuration of this backend. |
| | | * |
| | | * @throws ConfigException |
| | | * If there is an error in the configuration. |
| | | */ |
| | | public abstract void configureBackend(Configuration cfg) |
| | | throws ConfigException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Initializes this backend based on the information provided |
| | | * when the backend was configured. |
| | | * |
| | | * @see #configureBackend |
| | | * |
| | | * @throws ConfigException If an unrecoverable problem arises in |
| | | * the process of performing the |
| | |
| | | * related to the server |
| | | * configuration. |
| | | */ |
| | | public abstract void initializeBackend(ConfigEntry configEntry, |
| | | DN[] baseDNs) |
| | | public abstract void initializeBackend() |
| | | throws ConfigException, InitializationException; |
| | | |
| | | |
| | |
| | | * <CODE>true</CODE>. Note that the server will not explicitly |
| | | * initialize this backend before calling this method. |
| | | * |
| | | * @param configEntry The configuration entry for this backend. |
| | | * @param baseDNs The set of base DNs configured for this |
| | | * backend. |
| | | * @param exportConfig The configuration to use when performing |
| | | * the export. |
| | | * |
| | | * @throws DirectoryException If a problem occurs while performing |
| | | * the LDIF export. |
| | | */ |
| | | public abstract void exportLDIF(ConfigEntry configEntry, |
| | | DN[] baseDNs, |
| | | LDIFExportConfig exportConfig) |
| | | public abstract void exportLDIF(LDIFExportConfig exportConfig) |
| | | throws DirectoryException; |
| | | |
| | | |
| | |
| | | * returns <CODE>true</CODE>. Note that the server will not |
| | | * explicitly initialize this backend before calling this method. |
| | | * |
| | | * @param configEntry The configuration entry for this backend. |
| | | * @param baseDNs The set of base DNs configured for this |
| | | * backend. |
| | | * @param importConfig The configuration to use when performing |
| | | * the import. |
| | | * |
| | | * @throws DirectoryException If a problem occurs while performing |
| | | * the LDIF import. |
| | | */ |
| | | public abstract void importLDIF(ConfigEntry configEntry, |
| | | DN[] baseDNs, |
| | | LDIFImportConfig importConfig) |
| | | public abstract void importLDIF(LDIFImportConfig importConfig) |
| | | throws DirectoryException; |
| | | |
| | | |
| | |
| | | * <CODE>true</CODE>. Note that the server will not explicitly |
| | | * initialize this backend before calling this method. |
| | | * |
| | | * @param configEntry The configuration entry for this backend. |
| | | * @param backupConfig The configuration to use when performing |
| | | * the backup. |
| | | * |
| | | * @throws DirectoryException If a problem occurs while performing |
| | | * the backup. |
| | | */ |
| | | public abstract void createBackup(ConfigEntry configEntry, |
| | | BackupConfig backupConfig) |
| | | public abstract void createBackup(BackupConfig backupConfig) |
| | | throws DirectoryException; |
| | | |
| | | |
| | |
| | | * <CODE>true</CODE>. Note that the server will not explicitly |
| | | * initialize this backend before calling this method. |
| | | * |
| | | * @param configEntry The configuration entry for this backend. |
| | | * @param restoreConfig The configuration to use when performing |
| | | * the restore. |
| | | * |
| | | * @throws DirectoryException If a problem occurs while performing |
| | | * the restore. |
| | | */ |
| | | public abstract void restoreBackup(ConfigEntry configEntry, |
| | | RestoreConfig restoreConfig) |
| | | public abstract void restoreBackup(RestoreConfig restoreConfig) |
| | | throws DirectoryException; |
| | | |
| | | |
| | |
| | | { |
| | | boolean thisMatches = false; |
| | | DN[] subBaseDNs = b.getBaseDNs(); |
| | | for (int i=0; i < subBaseDNs.length; i++) |
| | | for (DN dn : subBaseDNs) |
| | | { |
| | | if (subBaseDNs[i].equals(subSuffixDN)) |
| | | if (dn.equals(subSuffixDN)) |
| | | { |
| | | if (subBaseDNs.length > 1) |
| | | { |
| | |
| | | public boolean handlesEntry(DN entryDN) |
| | | { |
| | | DN[] baseDNs = getBaseDNs(); |
| | | for (int i=0; i < baseDNs.length; i++) |
| | | for (DN dn : baseDNs) |
| | | { |
| | | if (entryDN.isDescendantOf(baseDNs[i])) |
| | | if (entryDN.isDescendantOf(dn)) |
| | | { |
| | | Backend[] subBackends = subordinateBackends; |
| | | for (int j=0; j < subBackends.length; j++) |
| | | for (Backend b : subBackends) |
| | | { |
| | | if (subBackends[j].handlesEntry(entryDN)) |
| | | if (b.handlesEntry(entryDN)) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines the set of methods and structures that must be |
| | | * implemented by a Directory Server configuration handler. |
| | |
| | | |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DeleteOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.core.ModifyDNOperation; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.BackendConfigManager; |
| | | import org.opends.server.protocols.asn1.ASN1OctetString; |
| | | import org.opends.server.schema.BooleanSyntax; |
| | | import org.opends.server.schema.GeneralizedTimeSyntax; |
| | |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.util.Validator; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.BackupBackendCfg; |
| | | import org.opends.server.admin.std.meta.BackupBackendCfgDefn; |
| | | import org.opends.server.admin.Configuration; |
| | | |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void initializeBackend(ConfigEntry configEntry, DN[] baseDNs) |
| | | throws ConfigException, InitializationException |
| | | public void configureBackend(Configuration config) throws ConfigException |
| | | { |
| | | // Make sure that a configuration entry was provided. If not, then we will |
| | | // not be able to complete initialization. |
| | | if (configEntry == null) |
| | | if (config == null) |
| | | { |
| | | int msgID = MSGID_BACKUP_CONFIG_ENTRY_NULL; |
| | | String message = getMessage(msgID); |
| | | throw new ConfigException(msgID, message); |
| | | } |
| | | |
| | | BackupBackendCfg cfg = getBackupBackendCfg(configEntry); |
| | | |
| | | Validator.ensureTrue(config instanceof BackupBackendCfg); |
| | | |
| | | currentConfig = (BackupBackendCfg)config; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void initializeBackend() |
| | | throws ConfigException, InitializationException |
| | | { |
| | | // Create the set of base DNs that we will handle. In this case, it's just |
| | | // the DN of the base backup entry. |
| | | try |
| | |
| | | |
| | | |
| | | // Determine the set of backup directories that we will use by default. |
| | | Set<String> values = cfg.getBackupDirectory(); |
| | | Set<String> values = currentConfig.getBackupDirectory(); |
| | | backupDirectories = new LinkedHashSet<File>(values.size()); |
| | | for (String s : values) |
| | | { |
| | |
| | | |
| | | |
| | | // Register this as a change listener. |
| | | currentConfig = cfg; |
| | | cfg.addBackupChangeListener(this); |
| | | currentConfig.addBackupChangeListener(this); |
| | | |
| | | |
| | | // Register the backup base as a private suffix. |
| | |
| | | |
| | | |
| | | /** |
| | | * Exports the contents of this backend to LDIF. This method should only be |
| | | * called if <CODE>supportsLDIFExport</CODE> returns <CODE>true</CODE>. Note |
| | | * that the server will not explicitly initialize this backend before calling |
| | | * this method. |
| | | * |
| | | * @param configEntry The configuration entry for this backend. |
| | | * @param baseDNs The set of base DNs configured for this backend. |
| | | * @param exportConfig The configuration to use when performing the export. |
| | | * |
| | | * @throws DirectoryException If a problem occurs while performing the LDIF |
| | | * export. |
| | | * {@inheritDoc} |
| | | */ |
| | | public void exportLDIF(ConfigEntry configEntry, DN[] baseDNs, |
| | | LDIFExportConfig exportConfig) |
| | | public void exportLDIF(LDIFExportConfig exportConfig) |
| | | throws DirectoryException |
| | | { |
| | | int msgID = MSGID_BACKUP_EXPORT_NOT_SUPPORTED; |
| | |
| | | |
| | | |
| | | /** |
| | | * Imports information from an LDIF file into this backend. This method |
| | | * should only be called if <CODE>supportsLDIFImport</CODE> returns |
| | | * <CODE>true</CODE>. Note that the server will not explicitly initialize |
| | | * this backend before calling this method. |
| | | * |
| | | * @param configEntry The configuration entry for this backend. |
| | | * @param baseDNs The set of base DNs configured for this backend. |
| | | * @param importConfig The configuration to use when performing the import. |
| | | * |
| | | * @throws DirectoryException If a problem occurs while performing the LDIF |
| | | * import. |
| | | * {@inheritDoc} |
| | | */ |
| | | public void importLDIF(ConfigEntry configEntry, DN[] baseDNs, |
| | | LDIFImportConfig importConfig) |
| | | public void importLDIF(LDIFImportConfig importConfig) |
| | | throws DirectoryException |
| | | { |
| | | // This backend does not support LDIF imports. |
| | |
| | | |
| | | |
| | | /** |
| | | * Creates a backup of the contents of this backend in a form that may be |
| | | * restored at a later date if necessary. This method should only be called |
| | | * if <CODE>supportsBackup</CODE> returns <CODE>true</CODE>. Note that the |
| | | * server will not explicitly initialize this backend before calling this |
| | | * method. |
| | | * |
| | | * @param configEntry The configuration entry for this backend. |
| | | * @param backupConfig The configuration to use when performing the backup. |
| | | * |
| | | * @throws DirectoryException If a problem occurs while performing the |
| | | * backup. |
| | | * {@inheritDoc} |
| | | */ |
| | | public void createBackup(ConfigEntry configEntry, BackupConfig backupConfig) |
| | | public void createBackup(BackupConfig backupConfig) |
| | | throws DirectoryException |
| | | { |
| | | // This backend does not provide a backup/restore mechanism. |
| | |
| | | |
| | | |
| | | /** |
| | | * Restores a backup of the contents of this backend. This method should only |
| | | * be called if <CODE>supportsRestore</CODE> returns <CODE>true</CODE>. Note |
| | | * that the server will not explicitly initialize this backend before calling |
| | | * this method. |
| | | * |
| | | * @param configEntry The configuration entry for this backend. |
| | | * @param restoreConfig The configuration to use when performing the |
| | | * restore. |
| | | * |
| | | * @throws DirectoryException If a problem occurs while performing the |
| | | * restore. |
| | | * {@inheritDoc} |
| | | */ |
| | | public void restoreBackup(ConfigEntry configEntry, |
| | | RestoreConfig restoreConfig) |
| | | public void restoreBackup(RestoreConfig restoreConfig) |
| | | throws DirectoryException |
| | | { |
| | | // This backend does not provide a backup/restore mechanism. |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationChangeAcceptable( |
| | | BackupBackendCfg configEntry, |
| | | List<String> unacceptableReasons) |
| | | BackupBackendCfg cfg, List<String> unacceptableReasons) |
| | | { |
| | | // We'll accept anything here. The only configurable attribute is the |
| | | // default set of backup directories, but that doesn't require any |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | BackupBackendCfg configEntry) |
| | | public ConfigChangeResult applyConfigurationChange(BackupBackendCfg cfg) |
| | | { |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | |
| | | Set<String> values = configEntry.getBackupDirectory(); |
| | | Set<String> values = cfg.getBackupDirectory(); |
| | | backupDirectories = new LinkedHashSet<File>(values.size()); |
| | | for (String s : values) |
| | | { |
| | | backupDirectories.add(getFileForPath(s)); |
| | | } |
| | | |
| | | currentConfig = configEntry; |
| | | currentConfig = cfg; |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Gets the backup backend configuration corresponding to a backup |
| | | * backend config entry. |
| | | * |
| | | * @param configEntry A backup backend config entry. |
| | | * @return Returns the backup backend configuration. |
| | | * @throws ConfigException If the config entry could not be decoded. |
| | | */ |
| | | static BackupBackendCfg getBackupBackendCfg(ConfigEntry configEntry) |
| | | throws ConfigException { |
| | | return BackendConfigManager.getConfiguration( |
| | | BackupBackendCfgDefn.getInstance(), configEntry); |
| | | } |
| | | } |
| | | |
| | |
| | | import java.util.LinkedList; |
| | | |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DeleteOperation; |
| | |
| | | import org.opends.server.util.LDIFException; |
| | | import org.opends.server.util.LDIFReader; |
| | | import org.opends.server.util.LDIFWriter; |
| | | import org.opends.server.util.Validator; |
| | | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | | import org.opends.server.admin.Configuration; |
| | | |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Set the base DNs for this backend. This is used by the unit tests |
| | | * to set the base DNs without having to provide a configuration |
| | | * object when initializing the backend. |
| | | * @param baseDNs The set of base DNs to be served by this memory backend. |
| | | */ |
| | | public void setBaseDNs(DN[] baseDNs) |
| | | { |
| | | this.baseDNs = baseDNs; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public synchronized void initializeBackend(ConfigEntry configEntry, |
| | | DN[] baseDNs) |
| | | public void configureBackend(Configuration config) throws ConfigException |
| | | { |
| | | if (config != null) |
| | | { |
| | | Validator.ensureTrue(config instanceof BackendCfg); |
| | | BackendCfg cfg = (BackendCfg)config; |
| | | DN[] baseDNs = new DN[cfg.getBackendBaseDN().size()]; |
| | | cfg.getBackendBaseDN().toArray(baseDNs); |
| | | setBaseDNs(baseDNs); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public synchronized void initializeBackend() |
| | | throws ConfigException, InitializationException |
| | | { |
| | | // We won't support anything other than exactly one base DN in this |
| | |
| | | throw new ConfigException(msgID, message); |
| | | } |
| | | |
| | | |
| | | this.baseDNs = baseDNs; |
| | | |
| | | baseDNSet = new HashSet<DN>(); |
| | | for (DN dn : baseDNs) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public synchronized void exportLDIF(ConfigEntry configEntry, DN[] baseDNs, |
| | | LDIFExportConfig exportConfig) |
| | | public synchronized void exportLDIF(LDIFExportConfig exportConfig) |
| | | throws DirectoryException |
| | | { |
| | | // Create the LDIF writer. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public synchronized void importLDIF(ConfigEntry configEntry, DN[] baseDNs, |
| | | LDIFImportConfig importConfig) |
| | | public synchronized void importLDIF(LDIFImportConfig importConfig) |
| | | throws DirectoryException |
| | | { |
| | | clearMemoryBackend(); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void createBackup(ConfigEntry configEntry, BackupConfig backupConfig) |
| | | public void createBackup(BackupConfig backupConfig) |
| | | throws DirectoryException |
| | | { |
| | | int msgID = MSGID_MEMORYBACKEND_BACKUP_RESTORE_NOT_SUPPORTED; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void restoreBackup(ConfigEntry configEntry, |
| | | RestoreConfig restoreConfig) |
| | | public void restoreBackup(RestoreConfig restoreConfig) |
| | | throws DirectoryException |
| | | { |
| | | int msgID = MSGID_MEMORYBACKEND_BACKUP_RESTORE_NOT_SUPPORTED; |
| | |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.core.ModifyDNOperation; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.BackendConfigManager; |
| | | import org.opends.server.protocols.asn1.ASN1OctetString; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | |
| | | import org.opends.server.util.DynamicConstants; |
| | | import org.opends.server.util.LDIFWriter; |
| | | import org.opends.server.util.TimeThread; |
| | | import org.opends.server.util.Validator; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | | import org.opends.server.admin.Configuration; |
| | | |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void initializeBackend(ConfigEntry configEntry, DN[] baseDNs) |
| | | throws ConfigException, InitializationException |
| | | public void configureBackend(Configuration config) throws ConfigException |
| | | { |
| | | Validator.ensureNotNull(config); |
| | | Validator.ensureTrue(config instanceof BackendCfg); |
| | | |
| | | BackendCfg cfg = (BackendCfg)config; |
| | | ConfigEntry configEntry = DirectoryServer.getConfigEntry(cfg.dn()); |
| | | |
| | | |
| | | // Make sure that a configuration entry was provided. If not, then we will |
| | | // not be able to complete initialization. |
| | | if (configEntry == null) |
| | |
| | | throw new ConfigException(msgID, message); |
| | | } |
| | | |
| | | BackendCfg cfg = BackendConfigManager.getBackendCfg(configEntry); |
| | | configEntryDN = configEntry.getDN(); |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | // Construct the set of objectclasses to include in the base monitor entry. |
| | | monitorObjectClasses = new LinkedHashMap<ObjectClass,String>(2); |
| | | ObjectClass topOC = DirectoryServer.getObjectClass(OC_TOP, true); |
| | | monitorObjectClasses.put(topOC, OC_TOP); |
| | | |
| | | ObjectClass monitorOC = DirectoryServer.getObjectClass(OC_MONITOR_ENTRY, |
| | | true); |
| | | monitorObjectClasses.put(monitorOC, OC_MONITOR_ENTRY); |
| | | |
| | | |
| | | // Define an empty sets for the supported controls and features. |
| | | supportedControls = new HashSet<String>(0); |
| | | supportedFeatures = new HashSet<String>(0); |
| | | |
| | | // Create the set of base DNs that we will handle. In this case, it's just |
| | | // the DN of the base monitor entry. |
| | | try |
| | |
| | | |
| | | int msgID = MSGID_MONITOR_CANNOT_DECODE_MONITOR_ROOT_DN; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | throw new InitializationException(msgID, message, e); |
| | | throw new ConfigException(msgID, message, e); |
| | | } |
| | | |
| | | // FIXME -- Deal with this more correctly. |
| | | this.baseDNs = new DN[] { baseMonitorDN }; |
| | | |
| | | |
| | | // Construct the set of objectclasses to include in the base monitor entry. |
| | | monitorObjectClasses = new LinkedHashMap<ObjectClass,String>(2); |
| | | ObjectClass topOC = DirectoryServer.getObjectClass(OC_TOP, true); |
| | | monitorObjectClasses.put(topOC, OC_TOP); |
| | | |
| | | ObjectClass monitorOC = DirectoryServer.getObjectClass(OC_MONITOR_ENTRY, |
| | | true); |
| | | monitorObjectClasses.put(monitorOC, OC_MONITOR_ENTRY); |
| | | |
| | | |
| | | // Define an empty sets for the supported controls and features. |
| | | supportedControls = new HashSet<String>(0); |
| | | supportedFeatures = new HashSet<String>(0); |
| | | |
| | | |
| | | // Register with the Directory Server as a configurable component. |
| | | currentConfig = cfg; |
| | | cfg.addChangeListener(this); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void initializeBackend() |
| | | throws ConfigException, InitializationException |
| | | { |
| | | // Register with the Directory Server as a configurable component. |
| | | currentConfig.addChangeListener(this); |
| | | |
| | | |
| | | // Register the monitor base as a private suffix. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void exportLDIF(ConfigEntry configEntry, DN[] baseDNs, |
| | | LDIFExportConfig exportConfig) |
| | | public void exportLDIF(LDIFExportConfig exportConfig) |
| | | throws DirectoryException |
| | | { |
| | | // TODO export-ldif reports nonsense for upTime etc. |
| | | |
| | | configEntryDN = configEntry.getDN(); |
| | | |
| | | |
| | | // Get the set of user-defined attributes for the configuration entry. Any |
| | | // attributes that we don't recognize will be included directly in the base |
| | | // monitor entry. |
| | | userDefinedAttributes = new ArrayList<Attribute>(); |
| | | for (List<Attribute> attrs : |
| | | configEntry.getEntry().getUserAttributes().values()) |
| | | { |
| | | for (Attribute a : attrs) |
| | | { |
| | | if (! isMonitorConfigAttribute(a)) |
| | | { |
| | | userDefinedAttributes.add(a); |
| | | } |
| | | } |
| | | } |
| | | for (List<Attribute> attrs : |
| | | configEntry.getEntry().getOperationalAttributes().values()) |
| | | { |
| | | for (Attribute a : attrs) |
| | | { |
| | | if (! isMonitorConfigAttribute(a)) |
| | | { |
| | | userDefinedAttributes.add(a); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // Create the set of base DNs that we will handle. In this case, it's just |
| | | // the DN of the base monitor entry. |
| | | try |
| | | { |
| | | baseMonitorDN = DN.decode(DN_MONITOR_ROOT); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_MONITOR_CANNOT_DECODE_MONITOR_ROOT_DN; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | message, msgID, e); |
| | | } |
| | | |
| | | // Construct the set of objectclasses to include in the base monitor entry. |
| | | monitorObjectClasses = new LinkedHashMap<ObjectClass,String>(2); |
| | | ObjectClass topOC = DirectoryServer.getObjectClass(OC_TOP, true); |
| | | monitorObjectClasses.put(topOC, OC_TOP); |
| | | |
| | | ObjectClass monitorOC = DirectoryServer.getObjectClass(OC_MONITOR_ENTRY, |
| | | true); |
| | | monitorObjectClasses.put(monitorOC, OC_MONITOR_ENTRY); |
| | | |
| | | |
| | | // Create the LDIF writer. |
| | | LDIFWriter ldifWriter; |
| | | try |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void importLDIF(ConfigEntry configEntry, DN[] baseDNs, |
| | | LDIFImportConfig importConfig) |
| | | public void importLDIF(LDIFImportConfig importConfig) |
| | | throws DirectoryException |
| | | { |
| | | // This backend does not support LDIF imports. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void createBackup(ConfigEntry configEntry, BackupConfig backupConfig) |
| | | public void createBackup(BackupConfig backupConfig) |
| | | throws DirectoryException |
| | | { |
| | | // This backend does not provide a backup/restore mechanism. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void restoreBackup(ConfigEntry configEntry, |
| | | RestoreConfig restoreConfig) |
| | | public void restoreBackup(RestoreConfig restoreConfig) |
| | | throws DirectoryException |
| | | { |
| | | // This backend does not provide a backup/restore mechanism. |
| | |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.core.ModifyDNOperation; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.BackendConfigManager; |
| | | import org.opends.server.protocols.asn1.ASN1OctetString; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.util.LDIFWriter; |
| | | import org.opends.server.util.Validator; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.admin.std.server.RootDSEBackendCfg; |
| | | import org.opends.server.admin.std.meta.RootDSEBackendCfgDefn; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.Configuration; |
| | | |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void configureBackend(Configuration config) throws ConfigException |
| | | { |
| | | Validator.ensureNotNull(config); |
| | | Validator.ensureTrue(config instanceof RootDSEBackendCfg); |
| | | currentConfig = (RootDSEBackendCfg)config; |
| | | configEntryDN = config.dn(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void initializeBackend(ConfigEntry configEntry, DN[] baseDNs) |
| | | public void initializeBackend() |
| | | throws ConfigException, InitializationException |
| | | { |
| | | ConfigEntry configEntry = |
| | | DirectoryServer.getConfigEntry(configEntryDN); |
| | | |
| | | // Make sure that a configuration entry was provided. If not, then we will |
| | | // not be able to complete initialization. |
| | | if (configEntry == null) |
| | |
| | | throw new ConfigException(msgID, message); |
| | | } |
| | | |
| | | configEntryDN = configEntry.getDN(); |
| | | RootDSEBackendCfg cfg = getRootDSEBackendCfg(configEntry); |
| | | |
| | | |
| | | // Get the set of user-defined attributes for the configuration entry. Any |
| | | // attributes that we don't recognize will be included directly in the root |
| | | // DSE. |
| | |
| | | // backends defined in the server. |
| | | try |
| | | { |
| | | Set<DN> subDNs = cfg.getSubordinateBaseDN(); |
| | | Set<DN> subDNs = currentConfig.getSubordinateBaseDN(); |
| | | if (subDNs.isEmpty()) |
| | | { |
| | | // This is fine -- we'll just use the set of user-defined suffixes. |
| | |
| | | |
| | | // Determine whether all root DSE attributes should be treated as user |
| | | // attributes. |
| | | showAllAttributes = cfg.isShowAllAttributes(); |
| | | showAllAttributes = currentConfig.isShowAllAttributes(); |
| | | |
| | | |
| | | // Construct the set of "static" attributes that will always be present in |
| | |
| | | |
| | | |
| | | // Register as a change listener. |
| | | currentConfig = cfg; |
| | | cfg.addChangeListener(this); |
| | | currentConfig.addChangeListener(this); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void exportLDIF(ConfigEntry configEntry, DN[] baseDNs, |
| | | LDIFExportConfig exportConfig) |
| | | public void exportLDIF(LDIFExportConfig exportConfig) |
| | | throws DirectoryException |
| | | { |
| | | // Create the LDIF writer. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void importLDIF(ConfigEntry configEntry, DN[] baseDNs, |
| | | LDIFImportConfig importConfig) |
| | | public void importLDIF(LDIFImportConfig importConfig) |
| | | throws DirectoryException |
| | | { |
| | | // This backend does not support LDIF imports. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void createBackup(ConfigEntry configEntry, BackupConfig backupConfig) |
| | | public void createBackup(BackupConfig backupConfig) |
| | | throws DirectoryException |
| | | { |
| | | // This backend does not provide a backup/restore mechanism. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void restoreBackup(ConfigEntry configEntry, |
| | | RestoreConfig restoreConfig) |
| | | public void restoreBackup(RestoreConfig restoreConfig) |
| | | throws DirectoryException |
| | | { |
| | | // This backend does not provide a backup/restore mechanism. |
| | |
| | | |
| | | |
| | | |
| | | private static RootDSEBackendCfg getRootDSEBackendCfg(ConfigEntry configEntry) |
| | | throws ConfigException { |
| | | return BackendConfigManager.getConfiguration( |
| | | RootDSEBackendCfgDefn.getInstance(), configEntry); |
| | | } |
| | | } |
| | | |
| | |
| | | import org.opends.server.core.ModifyDNOperation; |
| | | import org.opends.server.core.SchemaConfigManager; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.BackendConfigManager; |
| | | import org.opends.server.schema.AttributeTypeSyntax; |
| | | import org.opends.server.schema.DITContentRuleSyntax; |
| | | import org.opends.server.schema.DITStructureRuleSyntax; |
| | |
| | | import org.opends.server.util.DynamicConstants; |
| | | import org.opends.server.util.LDIFException; |
| | | import org.opends.server.util.LDIFWriter; |
| | | import org.opends.server.util.Validator; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.admin.std.server.SchemaBackendCfg; |
| | | import org.opends.server.admin.std.meta.SchemaBackendCfgDefn; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.Configuration; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * Initialization shared by multiple backend methods. |
| | | * @param configEntry The configuration entry that contains the |
| | | * information to use to initialize this |
| | | * backend. |
| | | * @param baseDNs The set of base DNs that have been |
| | | * configured for this backend. |
| | | * @throws ConfigException If an unrecoverable problem arises in |
| | | * the process of performing the |
| | | * initialization. |
| | | * {@inheritDoc} |
| | | */ |
| | | private void initializeCommon(ConfigEntry configEntry, DN[] baseDNs) |
| | | public void configureBackend(Configuration config) |
| | | throws ConfigException |
| | | { |
| | | // Make sure that a configuration entry was provided. If not, then we will |
| | | // not be able to complete initialization. |
| | | if (configEntry == null) |
| | | if (config == null) |
| | | { |
| | | int msgID = MSGID_SCHEMA_CONFIG_ENTRY_NULL; |
| | | String message = getMessage(msgID); |
| | | throw new ConfigException(msgID, message); |
| | | } |
| | | |
| | | SchemaBackendCfg cfg = getSchemaBackendCfg(configEntry); |
| | | Validator.ensureTrue(config instanceof SchemaBackendCfg); |
| | | SchemaBackendCfg cfg = (SchemaBackendCfg)config; |
| | | ConfigEntry configEntry = DirectoryServer.getConfigEntry(cfg.dn()); |
| | | |
| | | configEntryDN = configEntry.getDN(); |
| | | |
| | | // Get all of the attribute types that we will use for schema elements. |
| | |
| | | |
| | | |
| | | configEntryDN = configEntry.getDN(); |
| | | |
| | | DN[] baseDNs = new DN[cfg.getBackendBaseDN().size()]; |
| | | cfg.getBackendBaseDN().toArray(baseDNs); |
| | | this.baseDNs = baseDNs; |
| | | |
| | | creatorsName = new AttributeValue(creatorsNameType, baseDNs[0].toString()); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void initializeBackend(ConfigEntry configEntry, DN[] baseDNs) |
| | | public void initializeBackend() |
| | | throws ConfigException, InitializationException |
| | | { |
| | | initializeCommon(configEntry, baseDNs); |
| | | |
| | | // Register each of the suffixes with the Directory Server. Also, register |
| | | // the first one as the schema base. |
| | | DirectoryServer.setSchemaDN(baseDNs[0]); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void exportLDIF(ConfigEntry configEntry, DN[] baseDNs, |
| | | LDIFExportConfig exportConfig) |
| | | public void exportLDIF(LDIFExportConfig exportConfig) |
| | | throws DirectoryException |
| | | { |
| | | try |
| | | { |
| | | initializeCommon(configEntry, baseDNs); |
| | | } |
| | | catch (ConfigException e) |
| | | { |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | e.getMessage(), e.getMessageID()); |
| | | } |
| | | |
| | | // Create the LDIF writer. |
| | | LDIFWriter ldifWriter; |
| | | try |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void importLDIF(ConfigEntry configEntry, DN[] baseDNs, |
| | | LDIFImportConfig importConfig) |
| | | public void importLDIF(LDIFImportConfig importConfig) |
| | | throws DirectoryException |
| | | { |
| | | // This backend does not support LDIF imports. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void createBackup(ConfigEntry configEntry, BackupConfig backupConfig) |
| | | public void createBackup(BackupConfig backupConfig) |
| | | throws DirectoryException |
| | | { |
| | | // Get the properties to use for the backup. We don't care whether or not |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void restoreBackup(ConfigEntry configEntry, |
| | | RestoreConfig restoreConfig) |
| | | public void restoreBackup(RestoreConfig restoreConfig) |
| | | throws DirectoryException |
| | | { |
| | | // First, make sure that the requested backup exists. |
| | |
| | | |
| | | |
| | | |
| | | private static SchemaBackendCfg getSchemaBackendCfg(ConfigEntry configEntry) |
| | | throws ConfigException { |
| | | return BackendConfigManager.getConfiguration( |
| | | SchemaBackendCfgDefn.getInstance(), configEntry); |
| | | } |
| | | } |
| | | |
| | |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DeleteOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.core.ModifyDNOperation; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.BackendConfigManager; |
| | | import org.opends.server.util.LDIFException; |
| | | import org.opends.server.util.Validator; |
| | | |
| | |
| | | import org.opends.server.types.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import org.opends.server.admin.std.server.JEBackendCfg; |
| | | import org.opends.server.admin.std.meta.JEBackendCfgDefn; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.Configuration; |
| | | |
| | | /** |
| | | * This is an implementation of a Directory Server Backend which stores entries |
| | |
| | | * The configuration of this JE backend. |
| | | */ |
| | | private Config config; |
| | | private JEBackendCfg currentConfig; |
| | | private JEBackendCfg cfg; |
| | | |
| | | /** |
| | | * The root JE container to use for this backend. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void initializeBackend(ConfigEntry configEntry, DN[] baseDNs) |
| | | throws ConfigException, InitializationException |
| | | public void configureBackend(Configuration cfg) |
| | | throws ConfigException |
| | | { |
| | | Validator.ensureNotNull(configEntry); |
| | | JEBackendCfg backendCfg = getJEBackendCfg(configEntry); |
| | | Validator.ensureNotNull(cfg); |
| | | Validator.ensureTrue(cfg instanceof JEBackendCfg); |
| | | |
| | | // Initialize a config object |
| | | config = new Config(); |
| | | config.initializeConfig(backendCfg, baseDNs); |
| | | Config config = new Config(); |
| | | config.initializeConfig((JEBackendCfg)cfg); |
| | | |
| | | this.cfg = (JEBackendCfg)cfg; |
| | | this.config = config; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void initializeBackend() |
| | | throws ConfigException, InitializationException |
| | | { |
| | | // Open the database environment |
| | | try |
| | | { |
| | |
| | | |
| | | try |
| | | { |
| | | rootContainer.openEntryContainers(baseDNs); |
| | | rootContainer.openEntryContainers(config.getBaseDNs()); |
| | | } |
| | | catch (DatabaseException databaseException) |
| | | { |
| | |
| | | { |
| | | // Log an informational message about the number of entries. |
| | | int msgID = MSGID_JEB_BACKEND_STARTED; |
| | | String message = getMessage(msgID, rootContainer.getEntryCount()); |
| | | String message = getMessage(msgID, cfg.getBackendId(), |
| | | rootContainer.getEntryCount()); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.NOTICE, message, |
| | | msgID); |
| | | } |
| | |
| | | message, databaseException); |
| | | } |
| | | |
| | | for (DN dn : baseDNs) |
| | | for (DN dn : config.getBaseDNs()) |
| | | { |
| | | try |
| | | { |
| | |
| | | DirectoryServer.registerMonitorProvider(monitorProvider); |
| | | |
| | | // Register this backend as a change listener. |
| | | currentConfig = backendCfg; |
| | | backendCfg.addJEChangeListener(this); |
| | | backendCfg.addJEChangeListener(config); |
| | | backendCfg.addJEChangeListener(rootContainer); |
| | | cfg.addJEChangeListener(this); |
| | | cfg.addJEChangeListener(config); |
| | | cfg.addJEChangeListener(rootContainer); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void finalizeBackend() |
| | | { |
| | | // Deregister as a change listener. |
| | | currentConfig.removeJEChangeListener(rootContainer); |
| | | currentConfig.removeJEChangeListener(config); |
| | | currentConfig.removeJEChangeListener(this); |
| | | cfg.removeJEChangeListener(rootContainer); |
| | | cfg.removeJEChangeListener(config); |
| | | cfg.removeJEChangeListener(this); |
| | | |
| | | // Deregister our base DNs. |
| | | for (DN dn : rootContainer.getBaseDNs()) |
| | |
| | | // Make sure the thread counts are zero for next initialization. |
| | | threadTotalCount.set(0); |
| | | threadWriteCount.set(0); |
| | | |
| | | // We will not reuse the config object. |
| | | config = null; |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void exportLDIF(ConfigEntry configEntry, DN[] baseDNs, |
| | | LDIFExportConfig exportConfig) |
| | | public void exportLDIF(LDIFExportConfig exportConfig) |
| | | throws DirectoryException |
| | | { |
| | | // Initialize a config object. |
| | | config = new Config(); |
| | | |
| | | try |
| | | { |
| | | config.initializeConfig(configEntry, baseDNs); |
| | | } |
| | | catch (ConfigException e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | e.getMessage(), |
| | | e.getMessageID()); |
| | | } |
| | | |
| | | // If the backend already has the root container open, we must use the same |
| | | // underlying root container |
| | | boolean openRootContainer = rootContainer == null; |
| | |
| | | rootContainer.open(config.getBackendDirectory(), |
| | | config.getBackendPermission(), |
| | | true, false, false, false, true, true); |
| | | rootContainer.openEntryContainers(baseDNs); |
| | | rootContainer.openEntryContainers(config.getBaseDNs()); |
| | | } |
| | | |
| | | ExportJob exportJob = new ExportJob(exportConfig); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void importLDIF(ConfigEntry configEntry, DN[] baseDNs, |
| | | LDIFImportConfig importConfig) |
| | | public void importLDIF(LDIFImportConfig importConfig) |
| | | throws DirectoryException |
| | | { |
| | | // Initialize a config object. |
| | | config = new Config(); |
| | | |
| | | try |
| | | { |
| | | config.initializeConfig(configEntry, baseDNs); |
| | | } |
| | | catch (ConfigException e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | e.getMessage(), |
| | | e.getMessageID()); |
| | | } |
| | | |
| | | try |
| | | { |
| | | ImportJob importJob = new ImportJob(this, config, importConfig); |
| | |
| | | /** |
| | | * Verify the integrity of the backend instance. |
| | | * @param verifyConfig The verify configuration. |
| | | * @param configEntry The backend instance configuration entry. |
| | | * @param baseDNs The set of base DNs that have been configured for this |
| | | * backend. |
| | | * @param statEntry Optional entry to save stats into. |
| | | * @throws ConfigException If an unrecoverable problem arises during |
| | | * initialization. |
| | |
| | | * configuration. |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | */ |
| | | public void verifyBackend(VerifyConfig verifyConfig, ConfigEntry configEntry, |
| | | DN[] baseDNs, Entry statEntry) |
| | | public void verifyBackend(VerifyConfig verifyConfig, Entry statEntry) |
| | | throws InitializationException, ConfigException, DirectoryException |
| | | { |
| | | // Initialize a config object. |
| | | config = new Config(); |
| | | config.initializeConfig(configEntry, baseDNs); |
| | | |
| | | // If the backend already has the root container open, we must use the same |
| | | // underlying root container |
| | | boolean openRootContainer = rootContainer == null; |
| | |
| | | rootContainer.open(config.getBackendDirectory(), |
| | | config.getBackendPermission(), |
| | | true, false, false, false, true, true); |
| | | rootContainer.openEntryContainers(baseDNs); |
| | | rootContainer.openEntryContainers(config.getBaseDNs()); |
| | | } |
| | | |
| | | VerifyJob verifyJob = new VerifyJob(config, verifyConfig); |
| | |
| | | * Rebuild index(es) in the backend instance. Note that the server will not |
| | | * explicitly initialize this backend before calling this method. |
| | | * @param rebuildConfig The rebuild configuration. |
| | | * @param configEntry The backend instance configuration entry. |
| | | * @param baseDNs The set of base DNs that have been configured for this |
| | | * backend. |
| | | * @throws ConfigException If an unrecoverable problem arises during |
| | | * initialization. |
| | | * @throws InitializationException If a problem occurs during initialization |
| | |
| | | * configuration. |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | */ |
| | | public void rebuildBackend(RebuildConfig rebuildConfig, |
| | | ConfigEntry configEntry, DN[] baseDNs) |
| | | public void rebuildBackend(RebuildConfig rebuildConfig) |
| | | throws InitializationException, ConfigException, DirectoryException |
| | | { |
| | | JEBackendCfg backendCfg = getJEBackendCfg(configEntry); |
| | | |
| | | // If the backend already has the root container open, we must use the same |
| | | // underlying root container |
| | | boolean openRootContainer = rootContainer == null; |
| | |
| | | { |
| | | if (openRootContainer) |
| | | { |
| | | // Initialize a config object. |
| | | config = new Config(); |
| | | config.initializeConfig(backendCfg, baseDNs); |
| | | |
| | | // Open the database environment |
| | | rootContainer = new RootContainer(config, this); |
| | | rootContainer.open(); |
| | | rootContainer.openEntryContainers(baseDNs); |
| | | rootContainer.openEntryContainers(config.getBaseDNs()); |
| | | } |
| | | |
| | | RebuildJob rebuildJob = new RebuildJob(rebuildConfig); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void createBackup(ConfigEntry configEntry, BackupConfig backupConfig) |
| | | public void createBackup(BackupConfig backupConfig) |
| | | throws DirectoryException |
| | | { |
| | | BackupManager backupManager = |
| | | new BackupManager(getBackendID()); |
| | | backupManager.createBackup(configEntry, backupConfig); |
| | | backupManager.createBackup(cfg, backupConfig); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void restoreBackup(ConfigEntry configEntry, |
| | | RestoreConfig restoreConfig) |
| | | public void restoreBackup(RestoreConfig restoreConfig) |
| | | throws DirectoryException |
| | | { |
| | | BackupManager backupManager = |
| | | new BackupManager(getBackendID()); |
| | | backupManager.restoreBackup(configEntry, restoreConfig); |
| | | backupManager.restoreBackup(cfg, restoreConfig); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | // Put the new configuration in place. |
| | | currentConfig = cfg; |
| | | this.cfg = cfg; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | * Clears all the entries from the backend. This method is for test cases |
| | | * that use the JE backend. |
| | | * |
| | | * @param configEntry The configuration entry that contains the information |
| | | * to use to initialize this backend. |
| | | * @param baseDNs The set of base DNs that have been configured for this |
| | | * backend. |
| | | * |
| | | * @throws ConfigException If an unrecoverable problem arises in the |
| | | * process of performing the initialization. |
| | | * |
| | | * @throws JebException If an error occurs while removing the data. |
| | | */ |
| | | public void clearBackend(ConfigEntry configEntry, DN[] baseDNs) |
| | | public void clearBackend() |
| | | throws ConfigException, JebException |
| | | { |
| | | Config config = new Config(); |
| | | config.initializeConfig(configEntry, baseDNs); |
| | | EnvManager.removeFiles(config.getBackendDirectory().getPath()); |
| | | } |
| | | |
| | | /** |
| | | * Gets the JE backend configuration corresponding to a JE |
| | | * backend config entry. |
| | | * |
| | | * @param configEntry A JE backend config entry. |
| | | * @return Returns the JE backend configuration. |
| | | * @throws ConfigException If the config entry could not be decoded. |
| | | */ |
| | | static JEBackendCfg getJEBackendCfg(ConfigEntry configEntry) |
| | | throws ConfigException { |
| | | return BackendConfigManager.getConfiguration( |
| | | JEBackendCfgDefn.getInstance(), configEntry); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.backends.jeb; |
| | | |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.util.DynamicConstants; |
| | |
| | | import static org.opends.server.messages.JebMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.admin.std.server.JEBackendCfg; |
| | | |
| | | /** |
| | | * A backup manager for JE backends. |
| | |
| | | * log files that are unchanged since the previous backup. The remaining |
| | | * zip entries are the JE log files themselves, which, for an incremental, |
| | | * only include those files that have changed. |
| | | * @param configEntry The configuration entry of the backend instance for |
| | | * @param cfg The configuration of the backend instance for |
| | | * which the backup is required. |
| | | * @param backupConfig The configuration to use when performing the backup. |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | */ |
| | | public void createBackup(ConfigEntry configEntry, BackupConfig backupConfig) |
| | | public void createBackup(JEBackendCfg cfg, BackupConfig backupConfig) |
| | | throws DirectoryException |
| | | { |
| | | // Parse our backend configuration. |
| | | Config config = new Config(); |
| | | try |
| | | { |
| | | config.initializeConfig(configEntry, null); |
| | | config.initializeConfig(cfg); |
| | | } |
| | | catch (ConfigException e) |
| | | { |
| | |
| | | |
| | | /** |
| | | * Restore a JE backend from backup, or verify the backup. |
| | | * @param configEntry The configuration entry of the backend instance to be |
| | | * @param cfg The configuration of the backend instance to be |
| | | * restored. |
| | | * @param restoreConfig The configuration to use when performing the restore. |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | */ |
| | | public void restoreBackup(ConfigEntry configEntry, |
| | | public void restoreBackup(JEBackendCfg cfg, |
| | | RestoreConfig restoreConfig) |
| | | throws DirectoryException |
| | | { |
| | |
| | | Config config = new Config(); |
| | | try |
| | | { |
| | | config.initializeConfig(configEntry, null); |
| | | config.initializeConfig(cfg); |
| | | } |
| | | catch (ConfigException e) |
| | | { |
| | |
| | | |
| | | |
| | | /** |
| | | * Initialize this JE backend configuration from a configuration entry. |
| | | * Initialize this JE backend configuration from its configuration. |
| | | * |
| | | * @param configEntry The backend configuration entry. |
| | | * @param baseDNs The set of base DNs that have been configured for this |
| | | * backend. |
| | | * @param cfg The backend configuration. |
| | | * @throws ConfigException If there is an error in the configuration entry. |
| | | */ |
| | | public void initializeConfig(ConfigEntry configEntry, DN[] baseDNs) |
| | | public void initializeConfig(JEBackendCfg cfg) |
| | | throws ConfigException |
| | | { |
| | | initializeConfig(BackendImpl.getJEBackendCfg(configEntry), configEntry, |
| | | baseDNs); |
| | | initializeConfig(cfg, DirectoryServer.getConfigEntry(cfg.dn())); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Initialize this JE backend configuration from a configuration entry. |
| | | * |
| | | * @param cfg The backend configuration entry. |
| | | * @param baseDNs The set of base DNs that have been configured for this |
| | | * backend. |
| | | * @throws ConfigException If there is an error in the configuration entry. |
| | | */ |
| | | public void initializeConfig(JEBackendCfg cfg, DN[] baseDNs) |
| | | throws ConfigException |
| | | { |
| | | initializeConfig(cfg, DirectoryServer.getConfigEntry(cfg.dn()), baseDNs); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Initialize this JE backend configuration from a configuration object |
| | | * Initialize this JE backend configuration from its configuration object |
| | | * and its configuration entry. |
| | | * |
| | | * @param cfg The backend configuration object. |
| | | * @param configEntry The backend configuration entry. |
| | | * @param baseDNs The set of base DNs that have been configured for this |
| | | * backend. |
| | | * @throws ConfigException If there is an error in the configuration entry. |
| | | */ |
| | | private void initializeConfig(JEBackendCfg cfg, ConfigEntry configEntry, |
| | | DN[] baseDNs) |
| | | private void initializeConfig(JEBackendCfg cfg, ConfigEntry configEntry) |
| | | throws ConfigException |
| | | { |
| | | DN[] baseDNs = new DN[cfg.getBackendBaseDN().size()]; |
| | | cfg.getBackendBaseDN().toArray(baseDNs); |
| | | |
| | | // Set the base DNs. |
| | | this.baseDNs = baseDNs; |
| | | |
| | |
| | | entryContainers.remove(baseDN); |
| | | } |
| | | |
| | | env.close(); |
| | | if (env != null) env.close(); |
| | | } |
| | | |
| | | /** |
| | |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.core.ModifyDNOperation; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.BackendConfigManager; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.BackupConfig; |
| | |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.util.Validator; |
| | | import org.opends.server.admin.std.server.TaskBackendCfg; |
| | | import org.opends.server.admin.std.meta.TaskBackendCfgDefn; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.Configuration; |
| | | |
| | | |
| | | /** |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void initializeBackend(ConfigEntry configEntry, DN[] baseDNs) |
| | | throws ConfigException, InitializationException |
| | | public void configureBackend(Configuration config) throws ConfigException |
| | | { |
| | | Validator.ensureNotNull(configEntry); |
| | | TaskBackendCfg cfg = getTaskBackendCfg(configEntry); |
| | | Validator.ensureNotNull(config); |
| | | Validator.ensureTrue(config instanceof TaskBackendCfg); |
| | | |
| | | configEntryDN = cfg.dn(); |
| | | TaskBackendCfg cfg = (TaskBackendCfg)config; |
| | | |
| | | DN[] baseDNs = new DN[cfg.getBackendBaseDN().size()]; |
| | | cfg.getBackendBaseDN().toArray(baseDNs); |
| | | |
| | | ConfigEntry configEntry = DirectoryServer.getConfigEntry(cfg.dn()); |
| | | |
| | | configEntryDN = configEntry.getDN(); |
| | | |
| | | |
| | | // Make sure that the provided set of base DNs contains exactly one value. |
| | |
| | | String message = getMessage(msgID, |
| | | String.valueOf(recurringTaskBaseString), |
| | | getExceptionMessage(e)); |
| | | throw new InitializationException(msgID, message, e); |
| | | throw new ConfigException(msgID, message, e); |
| | | } |
| | | |
| | | String scheduledTaskBaseString = SCHEDULED_TASK_BASE_RDN + "," + |
| | |
| | | String message = getMessage(msgID, |
| | | String.valueOf(scheduledTaskBaseString), |
| | | getExceptionMessage(e)); |
| | | throw new InitializationException(msgID, message, e); |
| | | throw new ConfigException(msgID, message, e); |
| | | } |
| | | } |
| | | |
| | |
| | | // Get the path to the task data backing file. |
| | | taskBackingFile = cfg.getTaskBackingFile(); |
| | | |
| | | // Define an empty sets for the supported controls and features. |
| | | supportedControls = new HashSet<String>(0); |
| | | supportedFeatures = new HashSet<String>(0); |
| | | |
| | | currentConfig = cfg; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void initializeBackend() |
| | | throws ConfigException, InitializationException |
| | | { |
| | | // Create the scheduler and initialize it from the backing file. |
| | | taskScheduler = new TaskScheduler(this); |
| | | taskScheduler.start(); |
| | | |
| | | |
| | | // Define an empty sets for the supported controls and features. |
| | | supportedControls = new HashSet<String>(0); |
| | | supportedFeatures = new HashSet<String>(0); |
| | | |
| | | |
| | | // Register with the Directory Server as a configurable component. |
| | | currentConfig = cfg; |
| | | cfg.addTaskChangeListener(this); |
| | | currentConfig.addTaskChangeListener(this); |
| | | |
| | | |
| | | // Register the task base as a private suffix. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void exportLDIF(ConfigEntry configEntry, DN[] baseDNs, |
| | | LDIFExportConfig exportConfig) |
| | | public void exportLDIF(LDIFExportConfig exportConfig) |
| | | throws DirectoryException |
| | | { |
| | | // FIXME -- Implement support for exporting to LDIF. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void importLDIF(ConfigEntry configEntry, DN[] baseDNs, |
| | | LDIFImportConfig importConfig) |
| | | public void importLDIF(LDIFImportConfig importConfig) |
| | | throws DirectoryException |
| | | { |
| | | // This backend does not support LDIF imports. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void createBackup(ConfigEntry configEntry, BackupConfig backupConfig) |
| | | public void createBackup(BackupConfig backupConfig) |
| | | throws DirectoryException |
| | | { |
| | | // NYI -- Create the backup. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void restoreBackup(ConfigEntry configEntry, |
| | | RestoreConfig restoreConfig) |
| | | public void restoreBackup(RestoreConfig restoreConfig) |
| | | throws DirectoryException |
| | | { |
| | | // NYI -- Restore the backup. |
| | |
| | | |
| | | |
| | | |
| | | private static TaskBackendCfg getTaskBackendCfg(ConfigEntry configEntry) |
| | | throws ConfigException { |
| | | return BackendConfigManager.getConfiguration( |
| | | TaskBackendCfgDefn.getInstance(), configEntry); |
| | | } |
| | | } |
| | | |
| | |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.admin.server.ConfigurationDeleteListener; |
| | | import org.opends.server.admin.server.ServerManagementContext; |
| | | import org.opends.server.admin.server.ServerManagedObject; |
| | | import org.opends.server.admin.server.ConfigExceptionFactory; |
| | | import org.opends.server.admin.server.ServerManagedObjectDecodingException; |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | | import org.opends.server.admin.std.server.RootCfg; |
| | | import org.opends.server.admin.std.meta.BackendCfgDefn; |
| | | import org.opends.server.admin.Configuration; |
| | | import org.opends.server.admin.AbstractManagedObjectDefinition; |
| | | import org.opends.server.admin.ManagedObjectPath; |
| | | import org.opends.server.admin.DefinitionDecodingException; |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | |
| | | // Perform the necessary initialization for the backend entry. |
| | | DN[] baseDNs = new DN[backendCfg.getBackendBaseDN().size()]; |
| | | baseDNs = backendCfg.getBackendBaseDN().toArray(baseDNs); |
| | | try |
| | | { |
| | | backend.initializeBackend( |
| | | DirectoryServer.getConfigEntry(backendCfg.dn()), baseDNs); |
| | | initializeBackend(backend, backendCfg); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | |
| | | try |
| | | { |
| | | backend.initializeBackend( |
| | | DirectoryServer.getConfigEntry(cfg.dn()), baseDNs); |
| | | initializeBackend(backend, cfg); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | // Perform the necessary initialization for the backend entry. |
| | | try |
| | | { |
| | | backend.initializeBackend( |
| | | DirectoryServer.getConfigEntry(cfg.dn()), baseDNs); |
| | | initializeBackend(backend, cfg); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Gets the configuration corresponding to a config entry. |
| | | * |
| | | * @param <S> |
| | | * The type of server configuration. |
| | | * @param definition |
| | | * The required definition of the required managed object. |
| | | * @param configEntry |
| | | * A configuration entry. |
| | | * @return Returns the server-side configuration. |
| | | * @throws ConfigException |
| | | * If the entry could not be decoded. |
| | | */ |
| | | public static <S extends Configuration> S getConfiguration( |
| | | AbstractManagedObjectDefinition<?, S> definition, ConfigEntry configEntry) |
| | | throws ConfigException { |
| | | |
| | | try { |
| | | ServerManagedObject<? extends S> mo = ServerManagedObject |
| | | .decode(ManagedObjectPath.emptyPath(), definition, |
| | | configEntry); |
| | | return mo.getConfiguration(); |
| | | } catch (DefinitionDecodingException e) { |
| | | throw ConfigExceptionFactory.getInstance() |
| | | .createDecodingExceptionAdaptor(configEntry.getDN(), e); |
| | | } catch (ServerManagedObjectDecodingException e) { |
| | | throw ConfigExceptionFactory.getInstance() |
| | | .createDecodingExceptionAdaptor(e); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Gets the backend configuration corresponding to a backend config entry. |
| | | * |
| | | * @param configEntry A backend config entry. |
| | | * @return Returns the backend configuration. |
| | | * @throws ConfigException If the config entry could not be decoded. |
| | | */ |
| | | public static BackendCfg getBackendCfg(ConfigEntry configEntry) |
| | | throws ConfigException |
| | | @SuppressWarnings("unchecked") |
| | | private static void initializeBackend(Backend backend, BackendCfg cfg) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | return getConfiguration(BackendCfgDefn.getInstance(), configEntry); |
| | | backend.configureBackend(cfg); |
| | | backend.initializeBackend(); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | import javax.management.MBeanServerFactory; |
| | | |
| | | import org.opends.server.admin.ClassLoaderProvider; |
| | | import org.opends.server.admin.server.ServerManagementContext; |
| | | import org.opends.server.admin.std.server.PasswordValidatorCfg; |
| | | import org.opends.server.admin.std.server.SynchronizationProviderCfg; |
| | | import org.opends.server.admin.std.server.RootDSEBackendCfg; |
| | | import org.opends.server.admin.std.server.RootCfg; |
| | | import org.opends.server.api.*; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.opends.server.api.plugin.StartupPluginResult; |
| | |
| | | |
| | | // Make sure to initialize the root DSE backend separately after all other |
| | | // backends. |
| | | ConfigEntry rootDSEConfigEntry; |
| | | RootDSEBackendCfg rootDSECfg; |
| | | try |
| | | { |
| | | DN rootDSEConfigDN = DN.decode(DN_ROOT_DSE_CONFIG); |
| | | rootDSEConfigEntry = configHandler.getConfigEntry(rootDSEConfigDN); |
| | | RootCfg root = |
| | | ServerManagementContext.getInstance().getRootConfiguration(); |
| | | rootDSECfg = root.getRootDSEBackend(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | throw new InitializationException(msgID, message, e); |
| | | } |
| | | |
| | | DN[] baseDNs = { DN.nullDN() }; |
| | | rootDSEBackend = new RootDSEBackend(); |
| | | rootDSEBackend.initializeBackend(rootDSEConfigEntry, baseDNs); |
| | | rootDSEBackend.configureBackend(rootDSECfg); |
| | | rootDSEBackend.initializeBackend(); |
| | | } |
| | | |
| | | |
| | |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import org.opends.server.admin.Configuration; |
| | | |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void configureBackend(Configuration cfg) throws ConfigException |
| | | { |
| | | // No action is required. |
| | | } |
| | | |
| | | /** |
| | | * Initializes this backend based on the information in the provided |
| | | * configuration entry. |
| | | * |
| | | * @param configEntry The configuration entry that contains the information |
| | | * to use to initialize this backend. |
| | | * @param baseDNs The set of base DNs that have been configured for this |
| | | * backend. |
| | | * |
| | | * @throws ConfigException If an unrecoverable problem arises in the |
| | | * process of performing the initialization. |
| | | * |
| | | * @throws InitializationException If a problem occurs during initialization |
| | | * that is not related to the server |
| | | * configuration. |
| | | * {@inheritDoc} |
| | | */ |
| | | public void initializeBackend(ConfigEntry configEntry, DN[] baseDNs) |
| | | public void initializeBackend() |
| | | throws ConfigException, InitializationException |
| | | { |
| | | // No action is required, since all initialization was performed in the |
| | |
| | | new LDIFExportConfig(tempConfig, ExistingFileBehavior.OVERWRITE); |
| | | |
| | | // FIXME -- Add all the appropriate configuration options. |
| | | exportLDIF(configRootEntry, baseDNs, exportConfig); |
| | | writeLDIF(exportConfig); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | |
| | | |
| | | /** |
| | | * Exports the contents of this backend to LDIF. This method should only be |
| | | * called if <CODE>supportsLDIFExport</CODE> returns <CODE>true</CODE>. Note |
| | | * that the server will not explicitly initialize this backend before calling |
| | | * this method. |
| | | * |
| | | * @param configEntry The configuration entry for this backend. |
| | | * @param baseDNs The set of base DNs configured for this backend. |
| | | * @param exportConfig The configuration to use when performing the export. |
| | | * |
| | | * @throws DirectoryException If a problem occurs while performing the LDIF |
| | | * export. |
| | | * {@inheritDoc} |
| | | */ |
| | | public void exportLDIF(ConfigEntry configEntry, DN[] baseDNs, |
| | | LDIFExportConfig exportConfig) |
| | | public void exportLDIF(LDIFExportConfig exportConfig) |
| | | throws DirectoryException |
| | | { |
| | | // TODO We would need export-ldif to initialize this backend. |
| | | writeLDIF(exportConfig); |
| | | } |
| | | |
| | | |
| | | |
| | | private void writeLDIF(LDIFExportConfig exportConfig) |
| | | throws DirectoryException |
| | | { |
| | | LDIFWriter writer; |
| | | try |
| | | { |
| | |
| | | |
| | | |
| | | /** |
| | | * Imports information from an LDIF file into this backend. This method |
| | | * should only be called if <CODE>supportsLDIFImport</CODE> returns |
| | | * <CODE>true</CODE>. Note that the server will not explicitly initialize |
| | | * this backend before calling this method. |
| | | * |
| | | * @param configEntry The configuration entry for this backend. |
| | | * @param baseDNs The set of base DNs configured for this backend. |
| | | * @param importConfig The configuration to use when performing the import. |
| | | * |
| | | * @throws DirectoryException If a problem occurs while performing the LDIF |
| | | * import. |
| | | * {@inheritDoc} |
| | | */ |
| | | public void importLDIF(ConfigEntry configEntry, DN[] baseDNs, |
| | | LDIFImportConfig importConfig) |
| | | public void importLDIF(LDIFImportConfig importConfig) |
| | | throws DirectoryException |
| | | { |
| | | int msgID = MSGID_CONFIG_FILE_UNWILLING_TO_IMPORT; |
| | |
| | | |
| | | |
| | | /** |
| | | * Creates a backup of the contents of this backend in a form that may be |
| | | * restored at a later date if necessary. This method should only be called |
| | | * if <CODE>supportsBackup</CODE> returns <CODE>true</CODE>. Note that the |
| | | * server will not explicitly initialize this backend before calling this |
| | | * method. |
| | | * |
| | | * @param configEntry The configuration entry for this backend. |
| | | * @param backupConfig The configuration to use when performing the backup. |
| | | * |
| | | * @throws DirectoryException If a problem occurs while performing the |
| | | * backup. |
| | | * {@inheritDoc} |
| | | */ |
| | | public void createBackup(ConfigEntry configEntry, BackupConfig backupConfig) |
| | | public void createBackup(BackupConfig backupConfig) |
| | | throws DirectoryException |
| | | { |
| | | // Get the properties to use for the backup. We don't care whether or not |
| | |
| | | |
| | | |
| | | /** |
| | | * Restores a backup of the contents of this backend. This method should only |
| | | * be called if <CODE>supportsRestore</CODE> returns <CODE>true</CODE>. Note |
| | | * that the server will not explicitly initialize this backend before calling |
| | | * this method. |
| | | * |
| | | * @param configEntry The configuration entry for this backend. |
| | | * @param restoreConfig The configuration to use when performing the |
| | | * restore. |
| | | * |
| | | * @throws DirectoryException If a problem occurs while performing the |
| | | * restore. |
| | | * {@inheritDoc} |
| | | */ |
| | | public void restoreBackup(ConfigEntry configEntry, |
| | | RestoreConfig restoreConfig) |
| | | public void restoreBackup(RestoreConfig restoreConfig) |
| | | throws DirectoryException |
| | | { |
| | | // First, make sure that the requested backup exists. |
| | |
| | | /** |
| | | * The message ID of an informational message indicating that a JE backend |
| | | * instance has started, and providing the current number of entries |
| | | * stored in the backend. This message takes one argument which is the |
| | | * current number of entries stored in the backend. |
| | | * stored in the backend. This message takes two arguments which are the |
| | | * backend ID and the current number of entries stored in the backend. |
| | | */ |
| | | public static final int MSGID_JEB_BACKEND_STARTED = |
| | | CATEGORY_MASK_JEB | SEVERITY_MASK_NOTICE | 42; |
| | |
| | | registerMessage(MSGID_JEB_IO_ERROR, |
| | | "I/O error during backend operation: %s"); |
| | | registerMessage(MSGID_JEB_BACKEND_STARTED, |
| | | "A database backend containing %d entries has started"); |
| | | "The database backend %s containing %d entries has " + |
| | | "started"); |
| | | registerMessage(MSGID_JEB_IMPORT_PARENT_NOT_FOUND, |
| | | "The parent entry '%s' does not exist"); |
| | | registerMessage(MSGID_JEB_IMPORT_ENTRY_EXISTS, |
| | |
| | | /** |
| | | * The message ID for the message that will be used if the backend selected |
| | | * for an LDIF import does not support that operation. This takes a single |
| | | * argument, which is the requested base DN. |
| | | * argument, which is the requested backend ID. |
| | | */ |
| | | public static final int MSGID_LDIFIMPORT_CANNOT_IMPORT = |
| | | CATEGORY_MASK_TOOLS | SEVERITY_MASK_SEVERE_ERROR | 214; |
| | |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.ATTR_BACKEND_BASE_DN; |
| | | import static org.opends.server.config.ConfigConstants.ATTR_BACKEND_CLASS; |
| | | import static org.opends.server.config.ConfigConstants.ATTR_BACKEND_ID; |
| | | import static org.opends.server.config.ConfigConstants.DN_BACKEND_BASE; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugInfo; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.ToolMessages.*; |
| | | import static org.opends.server.messages.ReplicationMessages.*; |
| | |
| | | |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.MultimasterDomainCfg; |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.DirectoryThread; |
| | | import org.opends.server.api.SynchronizationProvider; |
| | | import org.opends.server.backends.jeb.BackendImpl; |
| | | import org.opends.server.backends.task.Task; |
| | | import org.opends.server.backends.task.TaskState; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.config.DNConfigAttribute; |
| | | import org.opends.server.config.StringConfigAttribute; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DeleteOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | // Null when none is being processed. |
| | | private IEContext ieContext = null; |
| | | |
| | | // The backend informations necessary to make an import or export. |
| | | // The backend information necessary to make an import or export. |
| | | private Backend backend; |
| | | private ConfigEntry backendConfigEntry; |
| | | private List<DN> branches = new ArrayList<DN>(0); |
| | | |
| | | private int listenerThreadNumber = 10; |
| | |
| | | String dn) throws Exception |
| | | { |
| | | BackendImpl backend = (BackendImpl)DirectoryServer.getBackend(beID); |
| | | DN[] baseDNs = backend.getBaseDNs(); |
| | | |
| | | // FIXME Should getConfigEntry be part of TaskUtils ? |
| | | ConfigEntry configEntry = TaskUtils.getConfigEntry(backend); |
| | | |
| | | // FIXME Should setBackendEnabled be part of TaskUtils ? |
| | | TaskUtils.setBackendEnabled(configEntry, false); |
| | | TaskUtils.disableBackend(beID); |
| | | |
| | | try |
| | | { |
| | |
| | | |
| | | try |
| | | { |
| | | backend.clearBackend(configEntry, baseDNs); |
| | | backend.clearBackend(); |
| | | } |
| | | finally |
| | | { |
| | |
| | | } |
| | | finally |
| | | { |
| | | TaskUtils.setBackendEnabled(configEntry, true); |
| | | TaskUtils.enableBackend(beID); |
| | | } |
| | | |
| | | if (createBaseEntry) |
| | |
| | | ReplLDIFOutputStream os = new ReplLDIFOutputStream(this); |
| | | |
| | | LDIFExportConfig exportConfig = new LDIFExportConfig(os); |
| | | List<DN> includeBranches = new ArrayList<DN>(1); |
| | | includeBranches.add(this.baseDN); |
| | | exportConfig.setIncludeBranches(includeBranches); |
| | | |
| | | // Launch the export. |
| | | try |
| | | { |
| | | DN[] baseDNs = {this.baseDN}; |
| | | backend.exportLDIF(backendConfigEntry, baseDNs, exportConfig); |
| | | backend.exportLDIF(exportConfig); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | |
| | | */ |
| | | protected void retrievesBackendInfos(DN baseDN) throws DirectoryException |
| | | { |
| | | ArrayList<Backend> backendList = new ArrayList<Backend>(); |
| | | ArrayList<ConfigEntry> entryList = new ArrayList<ConfigEntry>(); |
| | | ArrayList<List<DN>> dnList = new ArrayList<List<DN>>(); |
| | | |
| | | Backend backend = null; |
| | | ConfigEntry backendConfigEntry = null; |
| | | List<DN> branches = new ArrayList<DN>(0); |
| | | |
| | | // Retrieves the backend related to this domain |
| | | Backend domainBackend = DirectoryServer.getBackend(baseDN); |
| | | if (domainBackend == null) |
| | |
| | | ResultCode.OTHER, message, msgID, null); |
| | | } |
| | | |
| | | // Retrieves its config entry and its DNs |
| | | int code = getBackends(backendList, entryList, dnList); |
| | | if (code != 0) |
| | | { |
| | | int msgID = MSGID_CANNOT_DECODE_BASE_DN; |
| | | String message = getMessage(msgID, DN_BACKEND_BASE); |
| | | throw new DirectoryException( |
| | | ResultCode.OTHER, message, msgID, null); |
| | | } |
| | | |
| | | int numBackends = backendList.size(); |
| | | for (int i=0; i < numBackends; i++) |
| | | { |
| | | Backend b = backendList.get(i); |
| | | |
| | | if (domainBackend.getBackendID() != b.getBackendID()) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | if (backend == null) |
| | | { |
| | | backend = domainBackend; |
| | | backendConfigEntry = entryList.get(i).duplicate(); |
| | | branches = dnList.get(i); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_LDIFIMPORT_MULTIPLE_BACKENDS_FOR_ID; |
| | | String message = getMessage(msgID, domainBackend.getBackendID()); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | throw new DirectoryException( |
| | | ResultCode.OTHER, message, msgID, null); |
| | | } |
| | | } |
| | | |
| | | if (backend == null) |
| | | // Retrieves its configuration |
| | | BackendCfg backendCfg = TaskUtils.getConfigEntry(domainBackend); |
| | | if (backendCfg == null) |
| | | { |
| | | int msgID = MSGID_LDIFIMPORT_NO_BACKENDS_FOR_ID; |
| | | String message = getMessage(msgID, domainBackend.getBackendID()); |
| | |
| | | throw new DirectoryException( |
| | | ResultCode.OTHER, message, msgID, null); |
| | | } |
| | | else if (! backend.supportsLDIFExport()) |
| | | |
| | | if (! domainBackend.supportsLDIFExport()) |
| | | { |
| | | int msgID = MSGID_LDIFIMPORT_CANNOT_IMPORT; |
| | | String message = getMessage(msgID, 0); // FIXME |
| | | String message = getMessage(msgID, domainBackend.getBackendID()); |
| | | logError(ErrorLogCategory.BACKEND, |
| | | ErrorLogSeverity.SEVERE_ERROR, message, msgID); |
| | | throw new DirectoryException( |
| | |
| | | } |
| | | |
| | | |
| | | this.backend = backend; |
| | | this.backendConfigEntry = backendConfigEntry; |
| | | this.branches = branches; |
| | | this.backend = domainBackend; |
| | | this.branches = new ArrayList<DN>(backendCfg.getBackendBaseDN().size()); |
| | | for (DN dn : backendCfg.getBackendBaseDN()) |
| | | { |
| | | this.branches.add(dn); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * Retrieves information about the backends defined in the Directory Server |
| | | * configuration. |
| | | * |
| | | * @param backendList A list into which instantiated (but not initialized) |
| | | * backend instances will be placed. |
| | | * @param entryList A list into which the config entries associated with |
| | | * the backends will be placed. |
| | | * @param dnList A list into which the set of base DNs for each backend |
| | | * will be placed. |
| | | */ |
| | | private static int getBackends(ArrayList<Backend> backendList, |
| | | ArrayList<ConfigEntry> entryList, |
| | | ArrayList<List<DN>> dnList) |
| | | throws DirectoryException |
| | | { |
| | | // Get the base entry for all backend configuration. |
| | | DN backendBaseDN = null; |
| | | try |
| | | { |
| | | backendBaseDN = DN.decode(DN_BACKEND_BASE); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | int msgID = MSGID_CANNOT_DECODE_BASE_DN; |
| | | String message = getMessage(msgID, DN_BACKEND_BASE, de.getErrorMessage()); |
| | | throw new DirectoryException( |
| | | ResultCode.OTHER, message, msgID, null); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_DECODE_BASE_DN; |
| | | String message = getMessage(msgID, DN_BACKEND_BASE, |
| | | stackTraceToSingleLineString(e)); |
| | | throw new DirectoryException( |
| | | ResultCode.OTHER, message, msgID, null); |
| | | } |
| | | |
| | | ConfigEntry baseEntry = null; |
| | | try |
| | | { |
| | | baseEntry = DirectoryServer.getConfigEntry(backendBaseDN); |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | | int msgID = MSGID_CANNOT_RETRIEVE_BACKEND_BASE_ENTRY; |
| | | String message = getMessage(msgID, DN_BACKEND_BASE, ce.getMessage()); |
| | | throw new DirectoryException( |
| | | ResultCode.OTHER, message, msgID, null); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_RETRIEVE_BACKEND_BASE_ENTRY; |
| | | String message = getMessage(msgID, DN_BACKEND_BASE, |
| | | stackTraceToSingleLineString(e)); |
| | | throw new DirectoryException( |
| | | ResultCode.OTHER, message, msgID, null); |
| | | } |
| | | |
| | | |
| | | // Iterate through the immediate children, attempting to parse them as |
| | | // backends. |
| | | for (ConfigEntry configEntry : baseEntry.getChildren().values()) |
| | | { |
| | | // Get the backend ID attribute from the entry. If there isn't one, then |
| | | // skip the entry. |
| | | String backendID = null; |
| | | try |
| | | { |
| | | int msgID = MSGID_CONFIG_BACKEND_ATTR_DESCRIPTION_BACKEND_ID; |
| | | StringConfigAttribute idStub = |
| | | new StringConfigAttribute(ATTR_BACKEND_ID, getMessage(msgID), |
| | | true, false, true); |
| | | StringConfigAttribute idAttr = |
| | | (StringConfigAttribute) configEntry.getConfigAttribute(idStub); |
| | | if (idAttr == null) |
| | | { |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | backendID = idAttr.activeValue(); |
| | | } |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | | int msgID = MSGID_CANNOT_DETERMINE_BACKEND_ID; |
| | | String message = getMessage(msgID, String.valueOf(configEntry.getDN()), |
| | | ce.getMessage()); |
| | | throw new DirectoryException( |
| | | ResultCode.OTHER, message, msgID, null); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_DETERMINE_BACKEND_ID; |
| | | String message = getMessage(msgID, String.valueOf(configEntry.getDN()), |
| | | stackTraceToSingleLineString(e)); |
| | | throw new DirectoryException( |
| | | ResultCode.OTHER, message, msgID, null); |
| | | } |
| | | |
| | | |
| | | // Get the backend class name attribute from the entry. If there isn't |
| | | // one, then just skip the entry. |
| | | String backendClassName = null; |
| | | try |
| | | { |
| | | int msgID = MSGID_CONFIG_BACKEND_ATTR_DESCRIPTION_CLASS; |
| | | StringConfigAttribute classStub = |
| | | new StringConfigAttribute(ATTR_BACKEND_CLASS, getMessage(msgID), |
| | | true, false, false); |
| | | StringConfigAttribute classAttr = |
| | | (StringConfigAttribute) configEntry.getConfigAttribute(classStub); |
| | | if (classAttr == null) |
| | | { |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | backendClassName = classAttr.activeValue(); |
| | | } |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | | int msgID = MSGID_CANNOT_DETERMINE_BACKEND_CLASS; |
| | | String message = getMessage(msgID, String.valueOf(configEntry.getDN()), |
| | | ce.getMessage()); |
| | | throw new DirectoryException( |
| | | ResultCode.OTHER, message, msgID, null); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_DETERMINE_BACKEND_CLASS; |
| | | String message = getMessage(msgID, String.valueOf(configEntry.getDN()), |
| | | stackTraceToSingleLineString(e)); |
| | | throw new DirectoryException( |
| | | ResultCode.OTHER, message, msgID, null); |
| | | } |
| | | |
| | | Class backendClass = null; |
| | | try |
| | | { |
| | | backendClass = Class.forName(backendClassName); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_BACKEND_CLASS; |
| | | String message = getMessage(msgID, backendClassName, |
| | | String.valueOf(configEntry.getDN()), |
| | | stackTraceToSingleLineString(e)); |
| | | throw new DirectoryException( |
| | | ResultCode.OTHER, message, msgID, null); |
| | | } |
| | | |
| | | Backend backend = null; |
| | | try |
| | | { |
| | | backend = (Backend) backendClass.newInstance(); |
| | | backend.setBackendID(backendID); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_INSTANTIATE_BACKEND_CLASS; |
| | | String message = getMessage(msgID, backendClassName, |
| | | String.valueOf(configEntry.getDN()), |
| | | stackTraceToSingleLineString(e)); |
| | | throw new DirectoryException( |
| | | ResultCode.OTHER, message, msgID, null); } |
| | | |
| | | |
| | | // Get the base DN attribute from the entry. If there isn't one, then |
| | | // just skip this entry. |
| | | List<DN> baseDNs = null; |
| | | try |
| | | { |
| | | int msgID = MSGID_CONFIG_BACKEND_ATTR_DESCRIPTION_BASE_DNS; |
| | | DNConfigAttribute baseDNStub = |
| | | new DNConfigAttribute(ATTR_BACKEND_BASE_DN, getMessage(msgID), |
| | | true, true, true); |
| | | DNConfigAttribute baseDNAttr = |
| | | (DNConfigAttribute) configEntry.getConfigAttribute(baseDNStub); |
| | | if (baseDNAttr == null) |
| | | { |
| | | msgID = MSGID_NO_BASES_FOR_BACKEND; |
| | | String message = getMessage(msgID, |
| | | String.valueOf(configEntry.getDN())); |
| | | throw new DirectoryException( |
| | | DirectoryServer.getServerErrorResultCode(), message,msgID, null); |
| | | } |
| | | else |
| | | { |
| | | baseDNs = baseDNAttr.activeValues(); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_DETERMINE_BASES_FOR_BACKEND; |
| | | String message = getMessage(msgID, String.valueOf(configEntry.getDN()), |
| | | stackTraceToSingleLineString(e)); |
| | | throw new DirectoryException( |
| | | ResultCode.OTHER, message, msgID, null); } |
| | | |
| | | |
| | | backendList.add(backend); |
| | | entryList.add(configEntry); |
| | | dnList.add(baseDNs); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | /** |
| | | * Initializes this domain from another source server. |
| | | * |
| | | * @param source The source from which to initialize |
| | |
| | | /** |
| | | * Process backend before import. |
| | | * @param backend The backend. |
| | | * @param backendConfigEntry The config entry of the backend. |
| | | * @throws Exception |
| | | */ |
| | | private void preBackendImport(Backend backend, |
| | | ConfigEntry backendConfigEntry) |
| | | private void preBackendImport(Backend backend) |
| | | throws Exception |
| | | { |
| | | // Stop saving state |
| | |
| | | clearJEBackend(false,backend.getBackendID(),null); |
| | | |
| | | // FIXME setBackendEnabled should be part of TaskUtils ? |
| | | TaskUtils.setBackendEnabled(backendConfigEntry, false); |
| | | TaskUtils.disableBackend(backend.getBackendID()); |
| | | |
| | | // Acquire an exclusive lock for the backend. |
| | | String lockFile = LockFileManager.getBackendLockFileName(backend); |
| | |
| | | ieContext.entryLeftCount = initializeMessage.getEntryCount(); |
| | | ieContext.initTaskCounters(initializeMessage.getEntryCount()); |
| | | |
| | | preBackendImport(this.backend, this.backendConfigEntry); |
| | | preBackendImport(this.backend); |
| | | |
| | | DN[] baseDNs = {baseDN}; |
| | | ieContext.ldifImportInputStream = new ReplLDIFInputStream(this); |
| | | importConfig = |
| | | new LDIFImportConfig(ieContext.ldifImportInputStream); |
| | |
| | | // ExistingFileBehavior.OVERWRITE); |
| | | |
| | | // Process import |
| | | this.backend.importLDIF(this.backendConfigEntry, baseDNs, importConfig); |
| | | this.backend.importLDIF(importConfig); |
| | | |
| | | stateSavingDisabled = false; |
| | | |
| | |
| | | importConfig.close(); |
| | | |
| | | // Re-enable backend |
| | | closeBackendImport(this.backend, this.backendConfigEntry); |
| | | closeBackendImport(this.backend); |
| | | |
| | | // Update the task that initiated the import |
| | | if ((ieContext != null ) && (ieContext.initializeTask != null)) |
| | |
| | | /** |
| | | * Make post import operations. |
| | | * @param backend The backend implied in the import. |
| | | * @param backendConfigEntry The config entry of the backend. |
| | | * @exception DirectoryException Thrown when an error occurs. |
| | | */ |
| | | protected void closeBackendImport(Backend backend, |
| | | ConfigEntry backendConfigEntry) |
| | | protected void closeBackendImport(Backend backend) |
| | | throws DirectoryException |
| | | { |
| | | String lockFile = LockFileManager.getBackendLockFileName(backend); |
| | |
| | | } |
| | | |
| | | // FIXME setBackendEnabled should be part taskUtils ? |
| | | TaskUtils.setBackendEnabled(backendConfigEntry, true); |
| | | TaskUtils.enableBackend(backend.getBackendID()); |
| | | } |
| | | |
| | | /** |
| | |
| | | import static org.opends.server.messages.ToolMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.util.ServerConstants.DATE_FORMAT_GMT_TIME; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.opends.server.util.ServerConstants. |
| | | BACKUP_DIRECTORY_DESCRIPTOR_FILE; |
| | |
| | | import org.opends.server.types.Operation; |
| | | import org.opends.server.types.Privilege; |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | |
| | | private boolean backupBackend(Backend b, File backupLocation) |
| | | { |
| | | // Get the config entry for this backend. |
| | | ConfigEntry configEntry = configEntries.get(b.getBackendID()); |
| | | BackendCfg cfg = TaskUtils.getConfigEntry(b); |
| | | |
| | | |
| | | // If the directory doesn't exist, then create it. If it does exist, then |
| | |
| | | } |
| | | else |
| | | { |
| | | backupDir = new BackupDirectory(backupLocation.getPath(), |
| | | configEntry.getDN()); |
| | | backupDir = new BackupDirectory(backupLocation.getPath(), cfg.dn()); |
| | | } |
| | | } |
| | | else |
| | |
| | | } |
| | | |
| | | backupDir = new BackupDirectory(backupLocation.getPath(), |
| | | configEntry.getDN()); |
| | | cfg.dn()); |
| | | } |
| | | |
| | | |
| | |
| | | try |
| | | { |
| | | DirectoryServer.notifyBackupBeginning(b, backupConfig); |
| | | b.createBackup(configEntry, backupConfig); |
| | | b.createBackup(backupConfig); |
| | | DirectoryServer.notifyBackupEnded(b, backupConfig, true); |
| | | } |
| | | catch (DirectoryException de) |
| | |
| | | import static org.opends.server.messages.ToolMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import org.opends.server.backends.task.Task; |
| | | import org.opends.server.backends.task.TaskState; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.LockFileManager; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | |
| | | // Get the backend into which the LDIF should be imported. |
| | | Backend backend; |
| | | ConfigEntry configEntry; |
| | | ArrayList<DN> defaultIncludeBranches; |
| | | |
| | | backend = DirectoryServer.getBackend(backendID); |
| | |
| | | return TaskState.STOPPED_BY_ERROR; |
| | | } |
| | | |
| | | // Get the config entry for this backend. |
| | | configEntry = TaskUtils.getConfigEntry(backend); |
| | | |
| | | defaultIncludeBranches = new ArrayList<DN>(backend.getBaseDNs().length); |
| | | for (DN dn : backend.getBaseDNs()) |
| | | { |
| | |
| | | { |
| | | for (String s : excludeBranchStrings) |
| | | { |
| | | DN excludeBranch = null; |
| | | DN excludeBranch; |
| | | try |
| | | { |
| | | excludeBranch = DN.decode(s); |
| | |
| | | includeBranches = new ArrayList<DN>(); |
| | | for (String s : includeBranchStrings) |
| | | { |
| | | DN includeBranch = null; |
| | | DN includeBranch; |
| | | try |
| | | { |
| | | includeBranch = DN.decode(s); |
| | |
| | | try |
| | | { |
| | | DirectoryServer.notifyExportBeginning(backend, exportConfig); |
| | | backend.exportLDIF(configEntry, baseDNs, exportConfig); |
| | | backend.exportLDIF(exportConfig); |
| | | DirectoryServer.notifyExportEnded(backend, exportConfig, true); |
| | | } |
| | | catch (DirectoryException de) |
| | |
| | | import org.opends.server.core.LockFileManager; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | |
| | | // Get the backend into which the LDIF should be imported. |
| | | Backend backend; |
| | | ConfigEntry configEntry; |
| | | ArrayList<DN> defaultIncludeBranches; |
| | | ArrayList<DN> excludeBranches = new ArrayList<DN>(); |
| | | |
| | |
| | | return TaskState.STOPPED_BY_ERROR; |
| | | } |
| | | |
| | | // Get the config entry for this backend. |
| | | configEntry = TaskUtils.getConfigEntry(backend); |
| | | |
| | | // Find backends with subordinate base DNs that should be excluded from the |
| | | // import. |
| | | |
| | |
| | | // Disable the backend. |
| | | try |
| | | { |
| | | TaskUtils.setBackendEnabled(configEntry, false); |
| | | TaskUtils.disableBackend(backendID); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | |
| | | // Launch the import. |
| | | try |
| | | { |
| | | backend.importLDIF(configEntry, baseDNs, importConfig); |
| | | backend.importLDIF(importConfig); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | |
| | | // Enable the backend. |
| | | try |
| | | { |
| | | TaskUtils.setBackendEnabled(configEntry, true); |
| | | TaskUtils.enableBackend(backendID); |
| | | // It is necessary to retrieve the backend structure again |
| | | // because disabling and enabling it again may have resulted |
| | | // in a new backend being registered to the server. |
| | |
| | | import org.opends.server.core.LockFileManager; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.config.ConfigEntry; |
| | | |
| | | import static org.opends.server.core.DirectoryServer.getAttributeType; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | return TaskState.STOPPED_BY_ERROR; |
| | | } |
| | | |
| | | // Get the config entry for this backend. |
| | | ConfigEntry configEntry = TaskUtils.getConfigEntry(backend); |
| | | DN[] baseDNs = backend.getBaseDNs(); |
| | | |
| | | // Acquire a shared lock for the backend if we are rebuilding attribute |
| | | // indexes only. If we are rebuilding one or more system indexes, we have |
| | | // to aquire exclusive lock. |
| | |
| | | // Disable the backend. |
| | | try |
| | | { |
| | | TaskUtils.setBackendEnabled(configEntry, false); |
| | | TaskUtils.disableBackend(backend.getBackendID()); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | |
| | | try |
| | | { |
| | | BackendImpl jebBackend = (BackendImpl)backend; |
| | | jebBackend.rebuildBackend(rebuildConfig, configEntry, baseDNs); |
| | | jebBackend.rebuildBackend(rebuildConfig); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | // Enable the backend. |
| | | try |
| | | { |
| | | TaskUtils.setBackendEnabled(configEntry, true); |
| | | TaskUtils.enableBackend(backend.getBackendID()); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | |
| | | // Get the DN of the backend configuration entry from the backup. |
| | | DN configEntryDN = backupDir.getConfigEntryDN(); |
| | | |
| | | // Get the backend configuration entry. |
| | | ConfigEntry configEntry; |
| | | try |
| | | { |
| | | // Get the backend configuration entry. |
| | | configEntry = DirectoryServer.getConfigEntry(configEntryDN); |
| | | } |
| | | catch (ConfigException e) |
| | |
| | | // Disable the backend. |
| | | try |
| | | { |
| | | TaskUtils.setBackendEnabled(configEntry, false); |
| | | TaskUtils.disableBackend(backendID); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | |
| | | // Perform the restore. |
| | | try |
| | | { |
| | | backend.restoreBackup(configEntry, restoreConfig); |
| | | backend.restoreBackup(restoreConfig); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | |
| | | // Enable the backend. |
| | | try |
| | | { |
| | | TaskUtils.setBackendEnabled(configEntry, true); |
| | | TaskUtils.enableBackend(backendID); |
| | | // it is necessary to retrieve the backend structure again |
| | | // because disabling and enabling it again may have resulted |
| | | // in a new backend being registered to the server. |
| | |
| | | import org.opends.server.types.ModificationType; |
| | | import org.opends.server.types.RawModification; |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | | import org.opends.server.admin.std.server.RootCfg; |
| | | import org.opends.server.admin.server.ServerManagementContext; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashSet; |
| | |
| | | true, false, true); |
| | | StringConfigAttribute idAttr = |
| | | (StringConfigAttribute) configEntry.getConfigAttribute(idStub); |
| | | String backendID = idAttr.activeValue(); |
| | | return backendID; |
| | | return idAttr.activeValue(); |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | |
| | | // FIXME The error messages should not be the LDIF import messages |
| | | |
| | | // Get the base entry for all backend configuration. |
| | | DN backendBaseDN = null; |
| | | DN backendBaseDN; |
| | | try |
| | | { |
| | | backendBaseDN = DN.decode(DN_BACKEND_BASE); |
| | |
| | | return configEntries; |
| | | } |
| | | |
| | | ConfigEntry baseEntry = null; |
| | | ConfigEntry baseEntry; |
| | | try |
| | | { |
| | | baseEntry = DirectoryServer.getConfigEntry(backendBaseDN); |
| | |
| | | { |
| | | // Get the backend ID attribute from the entry. If there isn't one, then |
| | | // skip the entry. |
| | | String backendID = null; |
| | | String backendID; |
| | | try |
| | | { |
| | | int msgID = MSGID_CONFIG_BACKEND_ATTR_DESCRIPTION_BACKEND_ID; |
| | |
| | | * @return The configuration entry of the backend, or null if it could not |
| | | * be found. |
| | | */ |
| | | public static ConfigEntry getConfigEntry(Backend backend) |
| | | public static BackendCfg getConfigEntry(Backend backend) |
| | | { |
| | | Map<String,ConfigEntry> configEntries = getBackendConfigEntries(); |
| | | return configEntries.get(backend.getBackendID()); |
| | | RootCfg root = ServerManagementContext.getInstance(). |
| | | getRootConfiguration(); |
| | | try |
| | | { |
| | | return root.getBackend(backend.getBackendID()); |
| | | } |
| | | catch (ConfigException e) |
| | | { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Enable or disable a backend using an internal modify operation on the |
| | | * Enables a backend using an internal modify operation on the |
| | | * backend configuration entry. |
| | | * |
| | | * @param configEntry The configuration entry of the backend to be enabled |
| | | * or disabled. |
| | | * @param enable Specifies whether the backend should be enabled or disabled. |
| | | * @param backendID Identifies the backend to be enabled. |
| | | * @throws DirectoryException If the internal modify operation failed. |
| | | */ |
| | | public static void setBackendEnabled(ConfigEntry configEntry, boolean enable) |
| | | public static void enableBackend(String backendID) |
| | | throws DirectoryException |
| | | { |
| | | DN configEntryDN; |
| | | RootCfg root = ServerManagementContext.getInstance().getRootConfiguration(); |
| | | try |
| | | { |
| | | BackendCfg cfg = root.getBackend(backendID); |
| | | configEntryDN = cfg.dn(); |
| | | } |
| | | catch (ConfigException e) |
| | | { |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | e.getMessage(), e.getMessageID(), e); |
| | | } |
| | | |
| | | ArrayList<ASN1OctetString> valueList = new ArrayList<ASN1OctetString>(1); |
| | | if (enable) |
| | | { |
| | | valueList.add(new ASN1OctetString("TRUE")); |
| | | } |
| | | else |
| | | { |
| | | valueList.add(new ASN1OctetString("FALSE")); |
| | | } |
| | | LDAPAttribute a = new LDAPAttribute(ATTR_BACKEND_ENABLED, valueList); |
| | | |
| | | LDAPModification m = new LDAPModification(ModificationType.REPLACE, a); |
| | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | String backendDNString = configEntry.getDN().toString(); |
| | | String backendDNString = configEntryDN.toString(); |
| | | ASN1OctetString rawEntryDN = |
| | | new ASN1OctetString(backendDNString); |
| | | ModifyOperation internalModify = conn.processModify(rawEntryDN, modList); |
| | |
| | | if (resultCode != ResultCode.SUCCESS) |
| | | { |
| | | int msgID; |
| | | if (enable) |
| | | { |
| | | msgID = TaskMessages.MSGID_TASK_CANNOT_ENABLE_BACKEND; |
| | | String message = getMessage(msgID, backendDNString); |
| | | throw new DirectoryException(resultCode, message, msgID); |
| | | } |
| | | else |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Disables a backend using an internal modify operation on the |
| | | * backend configuration entry. |
| | | * |
| | | * @param backendID Identifies the backend to be disabled. |
| | | * @throws DirectoryException If the internal modify operation failed. |
| | | */ |
| | | public static void disableBackend(String backendID) |
| | | throws DirectoryException |
| | | { |
| | | msgID = TaskMessages.MSGID_TASK_CANNOT_DISABLE_BACKEND; |
| | | DN configEntryDN; |
| | | RootCfg root = ServerManagementContext.getInstance().getRootConfiguration(); |
| | | try |
| | | { |
| | | BackendCfg cfg = root.getBackend(backendID); |
| | | configEntryDN = cfg.dn(); |
| | | } |
| | | catch (ConfigException e) |
| | | { |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | e.getMessage(), e.getMessageID(), e); |
| | | } |
| | | |
| | | ArrayList<ASN1OctetString> valueList = new ArrayList<ASN1OctetString>(1); |
| | | valueList.add(new ASN1OctetString("FALSE")); |
| | | LDAPAttribute a = new LDAPAttribute(ATTR_BACKEND_ENABLED, valueList); |
| | | |
| | | LDAPModification m = new LDAPModification(ModificationType.REPLACE, a); |
| | | |
| | | ArrayList<RawModification> modList = new ArrayList<RawModification>(1); |
| | | modList.add(m); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | String backendDNString = configEntryDN.toString(); |
| | | ASN1OctetString rawEntryDN = |
| | | new ASN1OctetString(backendDNString); |
| | | ModifyOperation internalModify = conn.processModify(rawEntryDN, modList); |
| | | |
| | | ResultCode resultCode = internalModify.getResultCode(); |
| | | if (resultCode != ResultCode.SUCCESS) |
| | | { |
| | | int msgID; |
| | | msgID = TaskMessages.MSGID_TASK_CANNOT_DISABLE_BACKEND; |
| | | String message = getMessage(msgID, backendDNString); |
| | | throw new DirectoryException(resultCode, message, msgID); |
| | | } |
| | |
| | | import java.util.TimeZone; |
| | | |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.CoreConfigManager; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.util.StaticUtils; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | | |
| | | |
| | | /** |
| | |
| | | { |
| | | try |
| | | { |
| | | directoryServer.bootstrapClient(); |
| | | directoryServer.initializeJMX(); |
| | | DirectoryServer.bootstrapClient(); |
| | | DirectoryServer.initializeJMX(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | // Get information about the backends defined in the server, and determine |
| | | // whether we are backing up multiple backends or a single backend. |
| | | ArrayList<Backend> backendList = new ArrayList<Backend>(); |
| | | ArrayList<ConfigEntry> entryList = new ArrayList<ConfigEntry>(); |
| | | ArrayList<BackendCfg> entryList = new ArrayList<BackendCfg>(); |
| | | ArrayList<List<DN>> dnList = new ArrayList<List<DN>>(); |
| | | BackendToolUtils.getBackends(backendList, entryList, dnList); |
| | | int numBackends = backendList.size(); |
| | | |
| | | boolean multiple; |
| | | ArrayList<Backend> backendsToArchive = new ArrayList<Backend>(numBackends); |
| | | HashMap<String,ConfigEntry> configEntries = |
| | | new HashMap<String,ConfigEntry>(numBackends); |
| | | HashMap<String,BackendCfg> configEntries = |
| | | new HashMap<String,BackendCfg>(numBackends); |
| | | if (backUpAll.isPresent()) |
| | | { |
| | | for (int i=0; i < numBackends; i++) |
| | |
| | | |
| | | |
| | | // Get the config entry for this backend. |
| | | ConfigEntry configEntry = configEntries.get(b.getBackendID()); |
| | | BackendCfg configEntry = configEntries.get(b.getBackendID()); |
| | | |
| | | |
| | | // Get the path to the directory to use for this backup. If we will be |
| | |
| | | |
| | | // If the directory doesn't exist, then create it. If it does exist, then |
| | | // see if it has a backup descriptor file. |
| | | BackupDirectory backupDir = null; |
| | | BackupDirectory backupDir; |
| | | backupDirFile = new File(backupDirPath); |
| | | if (backupDirFile.exists()) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | backupDir = new BackupDirectory(backupDirPath, configEntry.getDN()); |
| | | backupDir = new BackupDirectory(backupDirPath, configEntry.dn()); |
| | | } |
| | | } |
| | | else |
| | |
| | | continue; |
| | | } |
| | | |
| | | backupDir = new BackupDirectory(backupDirPath, configEntry.getDN()); |
| | | backupDir = new BackupDirectory(backupDirPath, configEntry.dn()); |
| | | } |
| | | |
| | | |
| | |
| | | // Perform the backup. |
| | | try |
| | | { |
| | | b.createBackup(configEntry, backupConfig); |
| | | b.createBackup(backupConfig); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | | import org.opends.server.admin.std.server.RootCfg; |
| | | import org.opends.server.admin.server.ServerManagementContext; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | * @return 0 if everything went fine. 1 if an error occurred. |
| | | * |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public static int getBackends(ArrayList<Backend> backendList, |
| | | ArrayList<ConfigEntry> entryList, |
| | | ArrayList<BackendCfg> entryList, |
| | | ArrayList<List<DN>> dnList) |
| | | { |
| | | // Get the base entry for all backend configuration. |
| | | DN backendBaseDN = null; |
| | | DN backendBaseDN; |
| | | try |
| | | { |
| | | backendBaseDN = DN.decode(DN_BACKEND_BASE); |
| | |
| | | return 1; |
| | | } |
| | | |
| | | ConfigEntry baseEntry = null; |
| | | ConfigEntry baseEntry; |
| | | try |
| | | { |
| | | baseEntry = DirectoryServer.getConfigEntry(backendBaseDN); |
| | |
| | | |
| | | // Iterate through the immediate children, attempting to parse them as |
| | | // backends. |
| | | RootCfg root = ServerManagementContext.getInstance().getRootConfiguration(); |
| | | for (ConfigEntry configEntry : baseEntry.getChildren().values()) |
| | | { |
| | | // Get the backend ID attribute from the entry. If there isn't one, then |
| | | // skip the entry. |
| | | String backendID = null; |
| | | String backendID; |
| | | try |
| | | { |
| | | int msgID = MSGID_CONFIG_BACKEND_ATTR_DESCRIPTION_BACKEND_ID; |
| | |
| | | |
| | | // Get the backend class name attribute from the entry. If there isn't |
| | | // one, then just skip the entry. |
| | | String backendClassName = null; |
| | | String backendClassName; |
| | | try |
| | | { |
| | | int msgID = MSGID_CONFIG_BACKEND_ATTR_DESCRIPTION_CLASS; |
| | |
| | | return 1; |
| | | } |
| | | |
| | | Class backendClass = null; |
| | | Class backendClass; |
| | | try |
| | | { |
| | | backendClass = Class.forName(backendClassName); |
| | |
| | | return 1; |
| | | } |
| | | |
| | | Backend backend = null; |
| | | Backend backend; |
| | | BackendCfg cfg; |
| | | try |
| | | { |
| | | backend = (Backend) backendClass.newInstance(); |
| | | backend.setBackendID(backendID); |
| | | cfg = root.getBackend(backendID); |
| | | backend.configureBackend(cfg); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | |
| | | |
| | | backendList.add(backend); |
| | | entryList.add(configEntry); |
| | | entryList.add(cfg); |
| | | dnList.add(baseDNs); |
| | | } |
| | | return 0; |
| | |
| | | |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.CoreConfigManager; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.util.StaticUtils; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | | |
| | | |
| | | /** |
| | |
| | | { |
| | | try |
| | | { |
| | | directoryServer.bootstrapClient(); |
| | | directoryServer.initializeJMX(); |
| | | DirectoryServer.bootstrapClient(); |
| | | DirectoryServer.initializeJMX(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | // and also finding backends with subordinate base DNs that should be |
| | | // excluded from the export. |
| | | Backend backend = null; |
| | | ConfigEntry configEntry = null; |
| | | List<DN> baseDNList = null; |
| | | List<DN> defaultIncludeBranches = null; |
| | | ArrayList<DN> excludeBranches = null; |
| | | |
| | | ArrayList<Backend> backendList = new ArrayList<Backend>(); |
| | | ArrayList<ConfigEntry> entryList = new ArrayList<ConfigEntry>(); |
| | | ArrayList<BackendCfg> entryList = new ArrayList<BackendCfg>(); |
| | | ArrayList<List<DN>> dnList = new ArrayList<List<DN>>(); |
| | | BackendToolUtils.getBackends(backendList, entryList, dnList); |
| | | |
| | |
| | | if (backend == null) |
| | | { |
| | | backend = b; |
| | | configEntry = entryList.get(i); |
| | | baseDNList = dnList.get(i); |
| | | defaultIncludeBranches = dnList.get(i); |
| | | } |
| | |
| | | excludeBranches = new ArrayList<DN>(); |
| | | for (String s : excludeBranchStrings.getValues()) |
| | | { |
| | | DN excludeBranch = null; |
| | | DN excludeBranch; |
| | | try |
| | | { |
| | | excludeBranch = DN.decode(s); |
| | |
| | | includeBranches = new ArrayList<DN>(); |
| | | for (String s : includeBranchStrings.getValues()) |
| | | { |
| | | DN includeBranch = null; |
| | | DN includeBranch; |
| | | try |
| | | { |
| | | includeBranch = DN.decode(s); |
| | |
| | | // Launch the export. |
| | | try |
| | | { |
| | | backend.exportLDIF(configEntry, baseDNs, exportConfig); |
| | | backend.exportLDIF(exportConfig); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | |
| | | |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.CoreConfigManager; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.util.StaticUtils; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | | |
| | | |
| | | /** |
| | |
| | | // imported and finding backends with subordinate base DNs that should be |
| | | // excluded from the import. |
| | | Backend backend = null; |
| | | ConfigEntry configEntry = null; |
| | | List<DN> defaultIncludeBranches = null; |
| | | List<DN> excludeBranches = new ArrayList<DN>(); |
| | | |
| | | ArrayList<Backend> backendList = new ArrayList<Backend>(); |
| | | ArrayList<ConfigEntry> entryList = new ArrayList<ConfigEntry>(); |
| | | ArrayList<BackendCfg> entryList = new ArrayList<BackendCfg>(); |
| | | ArrayList<List<DN>> dnList = new ArrayList<List<DN>>(); |
| | | int code = BackendToolUtils.getBackends(backendList, entryList, dnList); |
| | | if (code != 0) |
| | |
| | | if (backend == null) |
| | | { |
| | | backend = b; |
| | | configEntry = entryList.get(i); |
| | | defaultIncludeBranches = dnList.get(i); |
| | | } |
| | | else |
| | |
| | | |
| | | for (String s : excludeBranchStrings.getValues()) |
| | | { |
| | | DN excludeBranch = null; |
| | | DN excludeBranch; |
| | | try |
| | | { |
| | | excludeBranch = DN.decode(s); |
| | |
| | | includeBranches = new ArrayList<DN>(); |
| | | for (String s : includeBranchStrings.getValues()) |
| | | { |
| | | DN includeBranch = null; |
| | | DN includeBranch; |
| | | try |
| | | { |
| | | includeBranch = DN.decode(s); |
| | |
| | | int retCode = 0; |
| | | try |
| | | { |
| | | backend.importLDIF(configEntry, baseDNs, importConfig); |
| | | backend.importLDIF(importConfig); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | |
| | | |
| | | import static org.opends.server.messages.ToolMessages.*; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import org.opends.server.loggers.ThreadFilterTextErrorLogPublisher; |
| | | import org.opends.server.loggers.TextWriter; |
| | |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.backends.jeb.BackendImpl; |
| | | import org.opends.server.backends.jeb.RebuildConfig; |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | } |
| | | |
| | | // Decode the base DN provided by the user. |
| | | DN rebuildBaseDN = null; |
| | | DN rebuildBaseDN; |
| | | try |
| | | { |
| | | rebuildBaseDN = DN.decode(baseDNString.getValue()); |
| | |
| | | |
| | | // Get information about the backends defined in the server. |
| | | Backend backend = null; |
| | | ConfigEntry configEntry = null; |
| | | DN[] baseDNArray = null; |
| | | DN[] baseDNArray; |
| | | |
| | | ArrayList<Backend> backendList = new ArrayList<Backend>(); |
| | | ArrayList<ConfigEntry> entryList = new ArrayList<ConfigEntry>(); |
| | | ArrayList<BackendCfg> entryList = new ArrayList<BackendCfg>(); |
| | | ArrayList<List<DN>> dnList = new ArrayList<List<DN>>(); |
| | | int code = BackendToolUtils.getBackends(backendList, entryList, dnList); |
| | | |
| | |
| | | for (int i=0; i < numBackends; i++) |
| | | { |
| | | Backend b = backendList.get(i); |
| | | ConfigEntry entry = entryList.get(i); |
| | | List<DN> baseDNs = dnList.get(i); |
| | | |
| | | for (DN baseDN : baseDNs) |
| | |
| | | if (backend == null) |
| | | { |
| | | backend = b; |
| | | configEntry = entry; |
| | | baseDNArray = new DN[baseDNs.size()]; |
| | | baseDNs.toArray(baseDNArray); |
| | | } |
| | |
| | | try |
| | | { |
| | | BackendImpl jebBackend = (BackendImpl)backend; |
| | | jebBackend.rebuildBackend(rebuildConfig, configEntry, baseDNArray); |
| | | jebBackend.rebuildBackend(rebuildConfig); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | import java.util.List; |
| | | |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.CoreConfigManager; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.util.StaticUtils; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | | |
| | | |
| | | /** |
| | |
| | | { |
| | | try |
| | | { |
| | | directoryServer.bootstrapClient(); |
| | | directoryServer.initializeJMX(); |
| | | DirectoryServer.bootstrapClient(); |
| | | DirectoryServer.initializeJMX(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | |
| | | |
| | | // Open the backup directory and make sure it is valid. |
| | | BackupDirectory backupDir = null; |
| | | BackupDirectory backupDir; |
| | | try |
| | | { |
| | | backupDir = BackupDirectory.readBackupDirectoryDescriptor( |
| | |
| | | |
| | | // If a backup ID was specified, then make sure it is valid. If none was |
| | | // provided, then choose the latest backup from the archive. |
| | | String backupID = null; |
| | | String backupID; |
| | | if (backupIDString.isPresent()) |
| | | { |
| | | backupID = backupIDString.getValue(); |
| | |
| | | // Get information about the backends defined in the server and determine |
| | | // which to use for the restore. |
| | | ArrayList<Backend> backendList = new ArrayList<Backend>(); |
| | | ArrayList<ConfigEntry> entryList = new ArrayList<ConfigEntry>(); |
| | | ArrayList<BackendCfg> entryList = new ArrayList<BackendCfg>(); |
| | | ArrayList<List<DN>> dnList = new ArrayList<List<DN>>(); |
| | | BackendToolUtils.getBackends(backendList, entryList, dnList); |
| | | |
| | | |
| | | Backend backend = null; |
| | | ConfigEntry configEntry = null; |
| | | int numBackends = backendList.size(); |
| | | for (int i=0; i < numBackends; i++) |
| | | { |
| | | Backend b = backendList.get(i); |
| | | ConfigEntry e = entryList.get(i); |
| | | if (e.getDN().equals(configEntryDN)) |
| | | BackendCfg e = entryList.get(i); |
| | | if (e.dn().equals(configEntryDN)) |
| | | { |
| | | backend = b; |
| | | configEntry = e; |
| | | break; |
| | | } |
| | | } |
| | |
| | | // Perform the restore. |
| | | try |
| | | { |
| | | backend.restoreBackup(configEntry, restoreConfig); |
| | | backend.restoreBackup(restoreConfig); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.backends.jeb.BackendImpl; |
| | | import org.opends.server.backends.jeb.VerifyConfig; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.CoreConfigManager; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.util.StaticUtils; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | |
| | | // Decode the base DN provided by the user. |
| | | DN verifyBaseDN = null; |
| | | DN verifyBaseDN ; |
| | | try |
| | | { |
| | | verifyBaseDN = DN.decode(baseDNString.getValue()); |
| | |
| | | // Get information about the backends defined in the server. Iterate |
| | | // through them, finding the one backend to be verified. |
| | | Backend backend = null; |
| | | ConfigEntry configEntry = null; |
| | | DN[] baseDNArray = null; |
| | | |
| | | ArrayList<Backend> backendList = new ArrayList<Backend>(); |
| | | ArrayList<ConfigEntry> entryList = new ArrayList<ConfigEntry>(); |
| | | ArrayList<BackendCfg> entryList = new ArrayList<BackendCfg>(); |
| | | ArrayList<List<DN>> dnList = new ArrayList<List<DN>>(); |
| | | BackendToolUtils.getBackends(backendList, entryList, dnList); |
| | | |
| | |
| | | for (int i=0; i < numBackends; i++) |
| | | { |
| | | Backend b = backendList.get(i); |
| | | ConfigEntry entry = entryList.get(i); |
| | | List<DN> baseDNs = dnList.get(i); |
| | | |
| | | for (DN baseDN : baseDNs) |
| | |
| | | if (backend == null) |
| | | { |
| | | backend = b; |
| | | configEntry = entry; |
| | | baseDNArray = new DN[baseDNs.size()]; |
| | | baseDNs.toArray(baseDNArray); |
| | | } |
| | | else |
| | | { |
| | |
| | | try |
| | | { |
| | | BackendImpl jebBackend = (BackendImpl)backend; |
| | | jebBackend.verifyBackend(verifyConfig, configEntry, baseDNArray, null); |
| | | jebBackend.verifyBackend(verifyConfig, null); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | objectClass: ds-cfg-je-backend |
| | | ds-cfg-backend-enabled: true |
| | | ds-cfg-backend-class: org.opends.server.backends.jeb.BackendImpl |
| | | ds-cfg-backend-id: indexTestRoot |
| | | ds-cfg-backend-id: indexRoot |
| | | ds-cfg-backend-writability-mode: enabled |
| | | ds-cfg-backend-base-dn: dc=test,dc=com |
| | | ds-cfg-backend-base-dn: dc=test1,dc=com |
| | |
| | | import java.util.HashMap; |
| | | import java.util.Enumeration; |
| | | import java.util.Map; |
| | | import java.util.Comparator; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.logging.Logger; |
| | | import java.util.logging.Handler; |
| | |
| | | import org.opends.server.backends.MemoryBackend; |
| | | import org.opends.server.backends.jeb.BackendImpl; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.LockFileManager; |
| | |
| | | import org.opends.server.types.FilePermission; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.OperatingSystem; |
| | | import org.opends.server.types.NullOutputStream; |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.util.ChangeRecordEntry; |
| | | import org.opends.server.util.AddChangeRecordEntry; |
| | | import org.opends.server.util.DeleteChangeRecordEntry; |
| | | import org.opends.server.util.ModifyChangeRecordEntry; |
| | | import org.opends.server.util.ModifyDNChangeRecordEntry; |
| | | |
| | | import static org.testng.Assert.*; |
| | | import static org.testng.Assert.assertEquals; |
| | |
| | | * @throws SocketException in case of underlying exception. |
| | | */ |
| | | private static ServerSocket bindPort(int port) |
| | | throws IOException, SocketException |
| | | throws IOException |
| | | { |
| | | ServerSocket serverLdapSocket; |
| | | serverLdapSocket = new ServerSocket(); |
| | |
| | | * @throws IOException in case of underlying exception. |
| | | * @throws SocketException in case of underlying exception. |
| | | */ |
| | | public static ServerSocket bindFreePort() throws IOException, SocketException |
| | | public static ServerSocket bindFreePort() throws IOException |
| | | { |
| | | ServerSocket serverLdapSocket; |
| | | serverLdapSocket = new ServerSocket(); |
| | |
| | | { |
| | | memoryBackend = new MemoryBackend(); |
| | | memoryBackend.setBackendID("test"); |
| | | memoryBackend.initializeBackend(null, new DN[] { baseDN }); |
| | | memoryBackend.setBaseDNs(new DN[] { baseDN }); |
| | | memoryBackend.initializeBackend(); |
| | | DirectoryServer.registerBackend(memoryBackend); |
| | | } |
| | | |
| | |
| | | throws Exception |
| | | { |
| | | BackendImpl backend = (BackendImpl)DirectoryServer.getBackend(beID); |
| | | DN[] baseDNs = backend.getBaseDNs(); |
| | | ConfigEntry configEntry = TaskUtils.getConfigEntry(backend); |
| | | |
| | | TaskUtils.setBackendEnabled(configEntry, false); |
| | | TaskUtils.disableBackend(beID); |
| | | |
| | | try |
| | | { |
| | |
| | | |
| | | try |
| | | { |
| | | backend.clearBackend(configEntry, baseDNs); |
| | | backend.clearBackend(); |
| | | } |
| | | finally |
| | | { |
| | |
| | | } |
| | | finally |
| | | { |
| | | TaskUtils.setBackendEnabled(configEntry, true); |
| | | TaskUtils.enableBackend(beID); |
| | | } |
| | | |
| | | if (createBaseEntry) |
| | |
| | | LDIFReader reader = new LDIFReader(ldifImportConfig); |
| | | |
| | | List<Entry> entries = new ArrayList<Entry>(); |
| | | Entry entry = null; |
| | | Entry entry; |
| | | while ((entry = reader.readEntry()) != null) { |
| | | entries.add(entry); |
| | | } |
| | |
| | | */ |
| | | public static String makeLdif(String... lines) { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | for (int i = 0; i < lines.length; i++) { |
| | | buffer.append(lines[i]).append(EOL); |
| | | for (String line : lines) { |
| | | buffer.append(line).append(EOL); |
| | | } |
| | | // Append an extra line so we can append LDIF Strings. |
| | | buffer.append(EOL); |
| | |
| | | } |
| | | |
| | | /** |
| | | * @return clear everything written to System.out since the last time |
| | | * clear everything written to System.out since the last time |
| | | * clearSystemOutContents was called. |
| | | */ |
| | | public synchronized static void clearSystemOutContents() { |
| | |
| | | } |
| | | |
| | | /** |
| | | * @return clear everything written to System.err since the last time |
| | | * clear everything written to System.err since the last time |
| | | * clearSystemErrContents was called. |
| | | */ |
| | | public synchronized static void clearSystemErrContents() { |
| | |
| | | */ |
| | | private static byte[] readFileBytes(File file) |
| | | throws IOException { |
| | | FileInputStream fis = null; |
| | | byte[] bytes = null; |
| | | FileInputStream fis; |
| | | byte[] bytes; |
| | | fis = new FileInputStream(file); |
| | | bytes = readInputStreamBytes(fis, true); |
| | | return bytes; |
| | |
| | | ByteArrayOutputStream bout = new ByteArrayOutputStream(1024); |
| | | try { |
| | | byte[] buf = new byte[1024]; |
| | | int bytesRead = 0; |
| | | int bytesRead; |
| | | while ((bytesRead = is.read(buf)) != -1) { |
| | | bout.write(buf, 0, bytesRead); |
| | | } // end of while ((read(buf) != -1) |
| | |
| | | |
| | | import java.io.File; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.admin.std.server.SchemaBackendCfg; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DeleteOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.core.ModifyDNOperation; |
| | | import org.opends.server.core.SchemaConfigManager; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.ByteStringFactory; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.DITContentRule; |
| | | import org.opends.server.types.DN; |
| | |
| | | import org.opends.server.types.LDIFExportConfig; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.MatchingRuleUse; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.ModificationType; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.RDN; |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.types.SearchScope; |
| | |
| | | private SchemaBackend schemaBackend; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Ensures that the Directory Server is running and gets a reference to the |
| | | * schema backend. |
| | |
| | | throws Exception |
| | | { |
| | | SchemaBackend schemaBackend = new SchemaBackend(); |
| | | schemaBackend.initializeBackend(null, new DN[0]); |
| | | schemaBackend.configureBackend(null); |
| | | } |
| | | |
| | | |
| | |
| | | public void testExportLDIF() |
| | | throws Exception |
| | | { |
| | | DN configEntryDN = |
| | | DN.decode("ds-cfg-backend-id=schema,cn=Backends,cn=config"); |
| | | DN[] baseDNs = { DN.decode("cn=schema") }; |
| | | |
| | | ConfigEntry configEntry = |
| | | DirectoryServer.getConfigHandler().getConfigEntry(configEntryDN); |
| | | |
| | | File tempFile = File.createTempFile("schema", "testExportLDIF"); |
| | | tempFile.deleteOnExit(); |
| | | LDIFExportConfig exportConfig = |
| | | new LDIFExportConfig(tempFile.getAbsolutePath(), |
| | | ExistingFileBehavior.OVERWRITE); |
| | | |
| | | schemaBackend.exportLDIF(configEntry, baseDNs, exportConfig); |
| | | schemaBackend.exportLDIF(exportConfig); |
| | | |
| | | assertTrue(tempFile.exists()); |
| | | assertTrue(tempFile.length() > 0); |
| | |
| | | public void testImportLDIF() |
| | | throws Exception |
| | | { |
| | | DN configEntryDN = |
| | | DN.decode("cn=schema,cn=Backends,cn=config"); |
| | | DN[] baseDNs = { DN.decode("cn=schema") }; |
| | | |
| | | ConfigEntry configEntry = |
| | | DirectoryServer.getConfigHandler().getConfigEntry(configEntryDN); |
| | | |
| | | File tempFile = File.createTempFile("schema", "testImportLDIF"); |
| | | tempFile.deleteOnExit(); |
| | | |
| | | LDIFImportConfig importConfig = |
| | | new LDIFImportConfig(tempFile.getAbsolutePath()); |
| | | |
| | | schemaBackend.importLDIF(configEntry, baseDNs, importConfig); |
| | | schemaBackend.importLDIF(importConfig); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | homeDirName = "db_index_test"; |
| | | |
| | | backend = (BackendImpl)DirectoryServer.getBackend("indexTestRoot"); |
| | | backend = (BackendImpl)DirectoryServer.getBackend("indexRoot"); |
| | | |
| | | topEntries = TestCaseUtils.makeEntries( |
| | | "dn: dc=test,dc=com", |
| | |
| | | "ds-cfg-backend-enabled: true", |
| | | "ds-cfg-backend-writability-mode: enabled", |
| | | "ds-cfg-backend-class: org.opends.server.backends.jeb.BackendImpl", |
| | | "ds-cfg-backend-id: indexTestRoot", |
| | | "ds-cfg-backend-id: indexRoot", |
| | | "ds-cfg-backend-directory:: " + |
| | | Base64.encode(homeDirName.getBytes()), |
| | | "ds-cfg-backend-import-temp-directory: importTmp"); |
| | |
| | | JEBackendCfg cfg = AdminTestCaseUtils.getConfiguration( |
| | | JEBackendCfgDefn.getInstance(), configEntry); |
| | | Config backendConfig = new Config(); |
| | | backendConfig.initializeConfig(cfg, |
| | | cfg.getBackendBaseDN().toArray(new DN[0])); |
| | | backendConfig.initializeConfig(cfg); |
| | | RootContainer rootContainer = new RootContainer(backendConfig, null); |
| | | rootContainer.open(new File(homeDirName), |
| | | new FilePermission(true, true, true), |
| | |
| | | package org.opends.server.backends.jeb; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.std.server.JEBackendCfg; |
| | | import org.opends.server.admin.std.meta.JEBackendCfgDefn; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.asn1.ASN1OctetString; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.util.Base64; |
| | | import static org.opends.server.util.ServerConstants.OC_TOP; |
| | |
| | | import org.opends.server.types.*; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | import org.testng.annotations.AfterTest; |
| | | import org.testng.annotations.AfterClass; |
| | | import static org.testng.Assert.*; |
| | | import static org.testng.Assert.assertEquals; |
| | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.util.*; |
| | | |
| | | import com.sleepycat.je.DatabaseEntry; |
| | | |
| | | public class TestImportJob extends JebTestCase |
| | | { |
| | |
| | | "ds-cfg-backend-import-temp-directory:: " + Base64.encode(importDirName.getBytes())); |
| | | |
| | | ConfigEntry backendConfigEntry = new ConfigEntry(configEntry, null); |
| | | JEBackendCfg cfg = AdminTestCaseUtils.getConfiguration( |
| | | JEBackendCfgDefn.getInstance(), configEntry); |
| | | |
| | | Entry indexEntry = TestCaseUtils.makeEntry( |
| | | "dn: cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config\n" + |
| | |
| | | }; |
| | | |
| | | backendConfig = new Config(); |
| | | backendConfig.initializeConfig(backendConfigEntry, baseDNs); |
| | | backendConfig.initializeConfig(cfg); |
| | | } |
| | | |
| | | @AfterClass |
| | |
| | | import org.opends.server.tasks.TaskUtils; |
| | | import static org.opends.server.util.ServerConstants.OC_TOP; |
| | | import static org.opends.server.util.ServerConstants.OC_EXTENSIBLE_OBJECT; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | |
| | |
| | | |
| | | public class TestRebuildJob extends JebTestCase |
| | | { |
| | | private String cfgDN= |
| | | "ds-cfg-backend-id=rebuildRoot,cn=Backends,cn=config"; |
| | | private String beID="rebuildRoot"; |
| | | private static String suffix="dc=rebuild,dc=jeb"; |
| | | private static String vBranch="ou=rebuild tests," + suffix; |
| | |
| | | //Attribute type in stat entry containing error count |
| | | private String errorCount="verify-error-count"; |
| | | |
| | | private DN configDN; |
| | | private DN[] baseDNs; |
| | | private ConfigEntry configEntry; |
| | | private BackendImpl be; |
| | | |
| | | @DataProvider(name = "systemIndexes") |
| | |
| | | @BeforeClass |
| | | public void setup() throws Exception { |
| | | TestCaseUtils.startServer(); |
| | | configDN = DN.decode(cfgDN); |
| | | baseDNs = new DN[] { |
| | | DN.decode(suffix) |
| | | }; |
| | | configEntry = DirectoryServer.getConfigEntry(configDN); |
| | | } |
| | | |
| | | @AfterClass |
| | |
| | | rebuildConfig.setBaseDN(baseDNs[0]); |
| | | rebuildConfig.addRebuildIndex(index); |
| | | be=(BackendImpl) DirectoryServer.getBackend(beID); |
| | | be.rebuildBackend(rebuildConfig, configEntry, baseDNs); |
| | | be.rebuildBackend(rebuildConfig); |
| | | |
| | | assertEquals(verifyBackend("mail"), 0); |
| | | |
| | |
| | | rebuildConfig.setBaseDN(baseDNs[0]); |
| | | rebuildConfig.addRebuildIndex(index); |
| | | be=(BackendImpl) DirectoryServer.getBackend(beID); |
| | | be.rebuildBackend(rebuildConfig, configEntry, baseDNs); |
| | | be.rebuildBackend(rebuildConfig); |
| | | } |
| | | |
| | | @Test(dataProvider = "systemIndexes", |
| | |
| | | rebuildConfig.setBaseDN(baseDNs[0]); |
| | | rebuildConfig.addRebuildIndex(index); |
| | | be=(BackendImpl) DirectoryServer.getBackend(beID); |
| | | be.rebuildBackend(rebuildConfig, configEntry, baseDNs); |
| | | be.rebuildBackend(rebuildConfig); |
| | | } |
| | | |
| | | @Test(dataProvider = "systemIndexes") |
| | |
| | | rebuildConfig.addRebuildIndex(index); |
| | | be=(BackendImpl) DirectoryServer.getBackend(beID); |
| | | |
| | | TaskUtils.setBackendEnabled(configEntry, false); |
| | | TaskUtils.disableBackend(beID); |
| | | |
| | | be.rebuildBackend(rebuildConfig, configEntry, baseDNs); |
| | | be.rebuildBackend(rebuildConfig); |
| | | |
| | | //TODO: Verify dn2uri database as well. |
| | | if(!index.equalsIgnoreCase("dn2uri")) |
| | |
| | | assertEquals(verifyBackend(index), 0); |
| | | } |
| | | |
| | | TaskUtils.setBackendEnabled(configEntry, true); |
| | | TaskUtils.enableBackend(beID); |
| | | } |
| | | |
| | | @Test |
| | |
| | | |
| | | be=(BackendImpl) DirectoryServer.getBackend(beID); |
| | | |
| | | TaskUtils.setBackendEnabled(configEntry, false); |
| | | TaskUtils.disableBackend(beID); |
| | | |
| | | be.rebuildBackend(rebuildConfig, configEntry, baseDNs); |
| | | be.rebuildBackend(rebuildConfig); |
| | | |
| | | assertEquals(verifyBackend(null), 0); |
| | | |
| | | TaskUtils.setBackendEnabled(configEntry, true); |
| | | TaskUtils.enableBackend(beID); |
| | | } |
| | | |
| | | @Test |
| | |
| | | verifyConfig.addCleanIndex(index); |
| | | } |
| | | Entry statEntry=bldStatEntry(""); |
| | | be.verifyBackend(verifyConfig, configEntry, baseDNs, statEntry); |
| | | be.verifyBackend(verifyConfig, statEntry); |
| | | |
| | | return getStatEntryCount(statEntry, errorCount); |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.backends.jeb; |
| | | |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.types.*; |
| | |
| | | |
| | | public class TestVerifyJob extends JebTestCase |
| | | { |
| | | private String cfgDN= |
| | | "ds-cfg-backend-id=verifyRoot,cn=Backends,cn=config"; |
| | | //Root suffix for verify backend |
| | | private static String suffix="dc=verify,dc=jeb"; |
| | | private static String vBranch="ou=verify tests," + suffix; |
| | |
| | | private String numUsersLine="define numusers= #numEntries#"; |
| | | //Attribute type in stat entry containing error count |
| | | private String errorCount="verify-error-count"; |
| | | private DN configDN; |
| | | private DN[] baseDNs; |
| | | private ConfigEntry configEntry; |
| | | private BackendImpl be; |
| | | private RootContainer rContainer; |
| | | private EntryContainer eContainer; |
| | | private DN2ID dn2id; |
| | | private ID2Entry id2entry; |
| | |
| | | @BeforeClass |
| | | public void setup() throws Exception { |
| | | TestCaseUtils.startServer(); |
| | | configDN = DN.decode(cfgDN); |
| | | baseDNs = new DN[] { |
| | | DN.decode(suffix) |
| | | }; |
| | | configEntry = DirectoryServer.getConfigEntry(configDN); |
| | | } |
| | | |
| | | @AfterClass |
| | |
| | | verifyConfig.setBaseDN(baseDNs[0]); |
| | | Entry statEntry=bldStatEntry(""); |
| | | be=(BackendImpl) DirectoryServer.getBackend(beID); |
| | | be.verifyBackend(verifyConfig, configEntry, baseDNs, statEntry); |
| | | be.verifyBackend(verifyConfig, statEntry); |
| | | assertEquals(getStatEntryCount(statEntry, errorCount), 0); |
| | | } |
| | | |
| | |
| | | verifyConfig.addCleanIndex("givenName"); |
| | | Entry statEntry=bldStatEntry(""); |
| | | be=(BackendImpl) DirectoryServer.getBackend(beID); |
| | | be.verifyBackend(verifyConfig, configEntry, baseDNs, statEntry); |
| | | be.verifyBackend(verifyConfig, statEntry); |
| | | assertEquals(getStatEntryCount(statEntry, errorCount), 0); |
| | | } |
| | | |
| | |
| | | verifyConfig.addCleanIndex(index); |
| | | Entry statEntry=bldStatEntry(""); |
| | | be=(BackendImpl) DirectoryServer.getBackend(beID); |
| | | be.verifyBackend(verifyConfig, configEntry, baseDNs, statEntry); |
| | | be.verifyBackend(verifyConfig, statEntry); |
| | | assertEquals(getStatEntryCount(statEntry, errorCount), 0); |
| | | } |
| | | |
| | |
| | | verifyConfig.addCleanIndex("userPassword"); |
| | | Entry statEntry=bldStatEntry(""); |
| | | be=(BackendImpl) DirectoryServer.getBackend(beID); |
| | | be.verifyBackend(verifyConfig, configEntry, baseDNs, statEntry); |
| | | be.verifyBackend(verifyConfig, statEntry); |
| | | assertEquals(getStatEntryCount(statEntry, errorCount), 0); |
| | | } |
| | | |
| | |
| | | verifyConfig.addCleanIndex(badIndexName); |
| | | Entry statEntry=bldStatEntry(""); |
| | | be=(BackendImpl) DirectoryServer.getBackend(beID); |
| | | be.verifyBackend(verifyConfig, configEntry, baseDNs, statEntry); |
| | | be.verifyBackend(verifyConfig, statEntry); |
| | | } |
| | | |
| | | /* end tests */ |
| | |
| | | else |
| | | verifyConfig.addCleanIndex(indexToDo); |
| | | Entry statEntry=bldStatEntry(""); |
| | | be.verifyBackend(verifyConfig, configEntry, baseDNs, statEntry); |
| | | be.verifyBackend(verifyConfig, statEntry); |
| | | assertEquals(getStatEntryCount(statEntry, errorCount), expectedErrors); |
| | | } |
| | | |
| | |
| | | private void preTest(int numEntries) throws Exception { |
| | | cleanAndLoad(numEntries); |
| | | be=(BackendImpl) DirectoryServer.getBackend(beID); |
| | | rContainer= be.getRootContainer(); |
| | | RootContainer rContainer = be.getRootContainer(); |
| | | eContainer= rContainer.getEntryContainer(DN.decode(suffix)); |
| | | id2child=eContainer.getID2Children(); |
| | | id2entry=eContainer.getID2Entry(); |
| | |
| | | */ |
| | | package org.opends.server.tools; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.DN_BACKEND_BASE; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.util.Base64; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.backends.jeb.BackendImpl; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.LockFileManager; |
| | | import static org.testng.Assert.*; |
| | | import java.io.*; |
| | | import java.util.*; |
| | | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.opends.server.tools.ToolsTestCase; |
| | | import org.opends.server.tasks.TaskUtils; |
| | | import org.opends.server.tools.ImportLDIF; |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Attribute; |
| | | import static org.testng.Assert.*; |
| | | |
| | | |
| | | |
| | |
| | | private File tempDir; |
| | | private String ldifFilePath; |
| | | String configFilePath ; |
| | | private BackendImpl backend; |
| | | private String homeDirName; |
| | | private ConfigEntry backendConfigEntry; |
| | | private String beID; |
| | | |
| | | /** |
| | |
| | | { |
| | | TestCaseUtils.startServer(); |
| | | beID = "userRoot"; |
| | | configFilePath = DirectoryServer.getInstance().getConfigFile(); |
| | | backend = (BackendImpl)DirectoryServer.getBackend(beID); |
| | | backendConfigEntry = TaskUtils.getConfigEntry(backend); |
| | | TaskUtils.setBackendEnabled(backendConfigEntry, false); |
| | | configFilePath = DirectoryServer.getConfigFile(); |
| | | TaskUtils.disableBackend(beID); |
| | | |
| | | String entry = |
| | | "dn: dc=example,dc=com\n" + |
| | |
| | | String rejectFilePath = reject.getAbsolutePath(); |
| | | String[] args = |
| | | { |
| | | "-f", DirectoryServer.getInstance().getConfigFile(), |
| | | "-f", DirectoryServer.getConfigFile(), |
| | | "-l",ldifFilePath, |
| | | "-n", beID, |
| | | "-R", rejectFilePath |
| | |
| | | |
| | | String[] args = |
| | | { |
| | | "-f", DirectoryServer.getInstance().getConfigFile(), |
| | | "-f", DirectoryServer.getConfigFile(), |
| | | "-l",ldifFilePath, |
| | | "-n", beID, |
| | | "-R",rejectFilePath, |
| | |
| | | String rejectFilePath = reject.getAbsolutePath(); |
| | | String[] args = |
| | | { |
| | | "-f", DirectoryServer.getInstance().getConfigFile(), |
| | | "-f", DirectoryServer.getConfigFile(), |
| | | "-l",ldifFilePath, |
| | | "-n", beID, |
| | | "-R",rejectFilePath, |
| | |
| | | String rejectFilePath = reject.getAbsolutePath(); |
| | | String[] args = |
| | | { |
| | | "-f", DirectoryServer.getInstance().getConfigFile(), |
| | | "-f", DirectoryServer.getConfigFile(), |
| | | "-l",ldifFilePath, |
| | | "-n", beID, |
| | | "-R",rejectFilePath, |
| | |
| | | String rejectFilePath = reject.getAbsolutePath(); |
| | | String[] args = |
| | | { |
| | | "-f", DirectoryServer.getInstance().getConfigFile(), |
| | | "-f", DirectoryServer.getConfigFile(), |
| | | "-l",ldifFilePath, |
| | | "-n", beID, |
| | | "-R",rejectFilePath, |
| | |
| | | String rejectFilePath = reject.getAbsolutePath(); |
| | | String[] args = |
| | | { |
| | | "-f", DirectoryServer.getInstance().getConfigFile(), |
| | | "-f", DirectoryServer.getConfigFile(), |
| | | "-l",ldifFilePath, |
| | | "-n", beID, |
| | | "-R",rejectFilePath, |
| | |
| | | String rejectFilePath = reject.getAbsolutePath(); |
| | | String[] args = |
| | | { |
| | | "-f", DirectoryServer.getInstance().getConfigFile(), |
| | | "-f", DirectoryServer.getConfigFile(), |
| | | "-l",ldifFilePath, |
| | | "-n", beID, |
| | | "-R",rejectFilePath, |
| | |
| | | { |
| | | if(attrs != null && attrs.length > 0) |
| | | { |
| | | TaskUtils.setBackendEnabled(backendConfigEntry, true); |
| | | TaskUtils.enableBackend(beID); |
| | | Entry entry = DirectoryServer.getEntry(DN.decode( |
| | | " uid=user.0,dc=example,dc=com")); |
| | | TaskUtils.setBackendEnabled(backendConfigEntry,false); |
| | | TaskUtils.disableBackend(beID); |
| | | assertNotNull(entry); |
| | | List<Attribute> list = entry.getAttributes(); |
| | | for(int i=0;i<attrs.length;i++) |
| | | for(Attribute a : attrs) |
| | | { |
| | | if(assertType) |
| | | { |
| | | assertTrue(list.contains(attrs[i])); |
| | | assertTrue(list.contains(a)); |
| | | } |
| | | else |
| | | { |
| | | assertFalse(list.contains(attrs[i])); |
| | | assertFalse(list.contains(a)); |
| | | } |
| | | } |
| | | } |
| | |
| | | public void cleanUp() throws Exception |
| | | { |
| | | //reinstate the backend. |
| | | TaskUtils.setBackendEnabled(backendConfigEntry, true); |
| | | TaskUtils.enableBackend(beID); |
| | | TestCaseUtils.deleteDirectory(tempDir); |
| | | } |
| | | } |