opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java
@@ -94,40 +94,32 @@ * The set of standard "static" attributes that we will always include in the * root DSE entry and won't change while the server is running. */ private ArrayList<Attribute> staticDSEAttributes; /** * The set of user-defined attributes that will be included in the root DSE * entry. */ private ArrayList<Attribute> userDefinedAttributes; private List<Attribute> staticDSEAttributes; /** The set of user-defined attributes that will be included in the root DSE entry. */ private List<Attribute> userDefinedAttributes; /** * Indicates whether the attributes of the root DSE should always be treated * as user attributes even if they are defined as operational in the schema. */ private boolean showAllAttributes; /** * The set of subordinate base DNs and their associated backends that will be * used for non-base searches. */ private ConcurrentHashMap<DN, Backend<?>> subordinateBaseDNs; /** The set of objectclasses that will be used in the root DSE entry. */ private HashMap<ObjectClass,String> dseObjectClasses; private Map<ObjectClass, String> dseObjectClasses; /** The current configuration state. */ private RootDSEBackendCfg currentConfig; /** The DN of the configuration entry for this backend. */ private DN configEntryDN; /** The DN for the root DSE. */ private DN rootDSEDN; /** The set of base DNs for this backend. */ private DN[] baseDNs; /** * The set of subordinate base DNs and their associated backends that will be * used for non-base searches. */ private ConcurrentHashMap<DN, Backend<?>> subordinateBaseDNs; @@ -143,7 +135,6 @@ // Perform all initialization in initializeBackend. } /** {@inheritDoc} */ @Override public void configureBackend(RootDSEBackendCfg config, ServerContext serverContext) throws ConfigException { @@ -152,12 +143,10 @@ configEntryDN = config.dn(); } /** {@inheritDoc} */ @Override public void openBackend() throws ConfigException, InitializationException { ConfigEntry configEntry = DirectoryServer.getConfigEntry(configEntryDN); ConfigEntry configEntry = DirectoryServer.getConfigEntry(configEntryDN); // Make sure that a configuration entry was provided. If not, then we will // not be able to complete initialization. @@ -257,10 +246,9 @@ /** * Get the set of user-defined attributes for the configuration entry. Any * attributes that we do not recognize will be included directly in the root * DSE. * attributes that we do not recognize will be included directly in the root DSE. */ private void addAllUserDefinedAttrs(ArrayList<Attribute> userDefinedAttrs, Entry configEntry) private void addAllUserDefinedAttrs(List<Attribute> userDefinedAttrs, Entry configEntry) { for (List<Attribute> attrs : configEntry.getUserAttributes().values()) { @@ -284,7 +272,6 @@ } } /** {@inheritDoc} */ @Override public void closeBackend() { @@ -310,14 +297,12 @@ || attrType.hasName(ATTR_COMMON_NAME); } /** {@inheritDoc} */ @Override public DN[] getBaseDNs() { return baseDNs; } /** {@inheritDoc} */ @Override public synchronized long getEntryCount() { @@ -325,7 +310,6 @@ return 1; } /** {@inheritDoc} */ @Override public boolean isIndexed(AttributeType attributeType, IndexType indexType) { @@ -333,10 +317,8 @@ return true; } /** {@inheritDoc} */ @Override public ConditionResult hasSubordinates(DN entryDN) throws DirectoryException public ConditionResult hasSubordinates(DN entryDN) throws DirectoryException { final long ret = getNumberOfChildren(entryDN); if(ret < 0) @@ -346,7 +328,6 @@ return ConditionResult.valueOf(ret != 0); } /** {@inheritDoc} */ @Override public long getNumberOfEntriesInBaseDN(DN baseDN) throws DirectoryException { @@ -372,7 +353,6 @@ return count; } /** {@inheritDoc} */ @Override public long getNumberOfChildren(DN parentDN) throws DirectoryException { @@ -397,10 +377,8 @@ return count; } /** {@inheritDoc} */ @Override public Entry getEntry(DN entryDN) throws DirectoryException public Entry getEntry(DN entryDN) throws DirectoryException { // If the requested entry was the root DSE, then create and return it. if (entryDN == null || entryDN.isRootDN()) @@ -458,9 +436,8 @@ */ private Entry getRootDSE(ClientConnection connection) { HashMap<AttributeType,List<Attribute>> dseUserAttrs = new HashMap<>(); HashMap<AttributeType,List<Attribute>> dseOperationalAttrs = new HashMap<>(); Map<AttributeType, List<Attribute>> dseUserAttrs = new HashMap<>(); Map<AttributeType, List<Attribute>> dseOperationalAttrs = new HashMap<>(); Attribute publicNamingContextAttr = createAttribute( ATTR_NAMING_CONTEXTS, ATTR_NAMING_CONTEXTS_LC, @@ -506,26 +483,10 @@ addAttribute(supportedLDAPVersionAttr, dseUserAttrs, dseOperationalAttrs); // Add the "supportedAuthPasswordSchemes" attribute. Set<String> authPWSchemes = DirectoryServer.getAuthPasswordStorageSchemes().keySet(); if (!authPWSchemes.isEmpty()) { Attribute supportedAuthPWSchemesAttr = createAttribute(ATTR_SUPPORTED_AUTH_PW_SCHEMES, ATTR_SUPPORTED_AUTH_PW_SCHEMES_LC, authPWSchemes); ArrayList<Attribute> supportedAuthPWSchemesAttrs = newArrayList(supportedAuthPWSchemesAttr); if (showAllAttributes || !supportedSASLMechAttr.getAttributeType().isOperational()) { dseUserAttrs.put(supportedAuthPWSchemesAttr.getAttributeType(), supportedAuthPWSchemesAttrs); } else { dseOperationalAttrs.put(supportedAuthPWSchemesAttr.getAttributeType(), supportedAuthPWSchemesAttrs); } } Attribute supportedAuthPWSchemesAttr = createAttribute( ATTR_SUPPORTED_AUTH_PW_SCHEMES, ATTR_SUPPORTED_AUTH_PW_SCHEMES_LC, DirectoryServer.getAuthPasswordStorageSchemes().keySet()); addAttribute(supportedAuthPWSchemesAttr, dseUserAttrs, dseOperationalAttrs); // Obtain TLS protocol and cipher support. @@ -535,10 +496,8 @@ { // Only return the list of enabled protocols / ciphers for the connection // handler to which the client is connected. supportedTlsProtocols = connection.getConnectionHandler() .getEnabledSSLProtocols(); supportedTlsCiphers = connection.getConnectionHandler() .getEnabledSSLCipherSuites(); supportedTlsProtocols = connection.getConnectionHandler().getEnabledSSLProtocols(); supportedTlsCiphers = connection.getConnectionHandler().getEnabledSSLCipherSuites(); } else { @@ -579,7 +538,7 @@ return e; } private void addAll(ArrayList<Attribute> attributes, private void addAll(Collection<Attribute> attributes, Map<AttributeType, List<Attribute>> userAttrs, Map<AttributeType, List<Attribute>> operationalAttrs) { for (Attribute a : attributes) @@ -599,23 +558,21 @@ } } private void addAttribute(Attribute publicNamingContextAttr, HashMap<AttributeType, List<Attribute>> userAttrs, HashMap<AttributeType, List<Attribute>> operationalAttrs) private void addAttribute(Attribute attribute, Map<AttributeType, List<Attribute>> userAttrs, Map<AttributeType, List<Attribute>> operationalAttrs) { if (!publicNamingContextAttr.isEmpty()) if (!attribute.isEmpty()) { List<Attribute> privateNamingContextAttrs = newArrayList(publicNamingContextAttr); final AttributeType attrType = publicNamingContextAttr.getAttributeType(); List<Attribute> attrs = newArrayList(attribute); final AttributeType attrType = attribute.getAttributeType(); if (showAllAttributes || !attrType.isOperational()) { userAttrs.put(attrType, privateNamingContextAttrs); userAttrs.put(attrType, attrs); } else { operationalAttrs.put(attrType, privateNamingContextAttrs); operationalAttrs.put(attrType, attrs); } } } @@ -643,10 +600,8 @@ return builder.toAttribute(); } /** {@inheritDoc} */ @Override public boolean entryExists(DN entryDN) throws DirectoryException public boolean entryExists(DN entryDN) throws DirectoryException { // If the specified DN was the null DN, then it exists. if (entryDN.isRootDN()) @@ -673,25 +628,20 @@ return false; } /** {@inheritDoc} */ @Override public void addEntry(Entry entry, AddOperation addOperation) throws DirectoryException public void addEntry(Entry entry, AddOperation addOperation) throws DirectoryException { throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, ERR_BACKEND_ADD_NOT_SUPPORTED.get(entry.getName(), getBackendID())); } /** {@inheritDoc} */ @Override public void deleteEntry(DN entryDN, DeleteOperation deleteOperation) throws DirectoryException public void deleteEntry(DN entryDN, DeleteOperation deleteOperation) throws DirectoryException { throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, ERR_BACKEND_DELETE_NOT_SUPPORTED.get(entryDN, getBackendID())); } /** {@inheritDoc} */ @Override public void replaceEntry(Entry oldEntry, Entry newEntry, ModifyOperation modifyOperation) throws DirectoryException @@ -700,17 +650,14 @@ ERR_ROOTDSE_MODIFY_NOT_SUPPORTED.get(newEntry.getName(), configEntryDN)); } /** {@inheritDoc} */ @Override public void renameEntry(DN currentDN, Entry entry, ModifyDNOperation modifyDNOperation) public void renameEntry(DN currentDN, Entry entry, ModifyDNOperation modifyDNOperation) throws DirectoryException { throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, ERR_BACKEND_MODIFY_DN_NOT_SUPPORTED.get(currentDN, getBackendID())); } /** {@inheritDoc} */ @Override public void search(SearchOperation searchOperation) throws DirectoryException, CanceledOperationException { @@ -827,21 +774,18 @@ return (Map) DirectoryServer.getPublicNamingContexts(); } /** {@inheritDoc} */ @Override public Set<String> getSupportedControls() { return Collections.emptySet(); } /** {@inheritDoc} */ @Override public Set<String> getSupportedFeatures() { return Collections.emptySet(); } /** {@inheritDoc} */ @Override public boolean supports(BackendOperation backendOperation) { @@ -849,7 +793,6 @@ return backendOperation.equals(BackendOperation.LDIF_EXPORT); } /** {@inheritDoc} */ @Override public void exportLDIF(LDIFExportConfig exportConfig) throws DirectoryException @@ -892,7 +835,6 @@ } } /** {@inheritDoc} */ @Override public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext) throws DirectoryException @@ -901,35 +843,27 @@ ERR_BACKEND_IMPORT_AND_EXPORT_NOT_SUPPORTED.get(getBackendID())); } /** {@inheritDoc} */ @Override public void createBackup(BackupConfig backupConfig) throws DirectoryException public void createBackup(BackupConfig backupConfig) throws DirectoryException { LocalizableMessage message = ERR_ROOTDSE_BACKUP_AND_RESTORE_NOT_SUPPORTED.get(); throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message); } /** {@inheritDoc} */ @Override public void removeBackup(BackupDirectory backupDirectory, String backupID) throws DirectoryException public void removeBackup(BackupDirectory backupDirectory, String backupID) throws DirectoryException { LocalizableMessage message = ERR_ROOTDSE_BACKUP_AND_RESTORE_NOT_SUPPORTED.get(); throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message); } /** {@inheritDoc} */ @Override public void restoreBackup(RestoreConfig restoreConfig) throws DirectoryException public void restoreBackup(RestoreConfig restoreConfig) throws DirectoryException { LocalizableMessage message = ERR_ROOTDSE_BACKUP_AND_RESTORE_NOT_SUPPORTED.get(); throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message); } /** {@inheritDoc} */ @Override public boolean isConfigurationAcceptable(RootDSEBackendCfg config, List<LocalizableMessage> unacceptableReasons, @@ -938,11 +872,8 @@ return isConfigurationChangeAcceptable(config, unacceptableReasons); } /** {@inheritDoc} */ @Override public boolean isConfigurationChangeAcceptable( RootDSEBackendCfg cfg, List<LocalizableMessage> unacceptableReasons) public boolean isConfigurationChangeAcceptable(RootDSEBackendCfg cfg, List<LocalizableMessage> unacceptableReasons) { boolean configIsAcceptable = true; @@ -980,7 +911,6 @@ return configIsAcceptable; } /** {@inheritDoc} */ @Override public ConfigChangeResult applyConfigurationChange(RootDSEBackendCfg cfg) { opendj-server-legacy/src/main/java/org/opends/server/backends/task/Task.java
@@ -40,6 +40,7 @@ import javax.mail.MessagingException; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.LocalizableMessageDescriptor.Arg2; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.ModificationType; @@ -62,23 +63,16 @@ * This class defines a task that may be executed by the task backend within the * Directory Server. */ public abstract class Task implements Comparable<Task> public abstract class Task implements Comparable<Task> { private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); /** The DN for the task entry. */ private DN taskEntryDN; /** The entry that actually defines this task. */ private Entry taskEntry; /** * The action to take if one of the dependencies for this task does not * complete successfully. */ /** The action to take if one of the dependencies for this task does not complete successfully. */ private FailedDependencyAction failedDependencyAction; /** The counter used for log messages associated with this task. */ @@ -95,7 +89,7 @@ * a way that the information could be reparsed from its * string value. */ private LinkedList<String> logMessages; private List<String> logMessages; /** * The set of e-mail addresses of the users to notify when the task is done @@ -111,10 +105,8 @@ /** The time that processing actually started for this task. */ private long actualStartTime; /** The time that actual processing ended for this task. */ private long completionTime; /** The time that this task was scheduled to start processing. */ private long scheduledStartTime; @@ -126,16 +118,12 @@ /** The unique ID assigned to this task. */ private String taskID; /** The task backend with which this task is associated. */ private TaskBackend taskBackend; /** The current state of this task. */ private TaskState taskState; /** The task state that may be set when the task is interrupted. */ private TaskState taskInterruptState; /** The scheduler with which this task is associated. */ private TaskScheduler taskScheduler; @@ -204,7 +192,6 @@ taskBackend = taskScheduler.getTaskBackend(); // Get the task ID and recurring task ID values. At least one of them must // be provided. If it's a recurring task and there is no task ID, then // generate one on the fly. @@ -216,13 +203,9 @@ { throw new InitializationException(ERR_TASK_MISSING_ATTR.get(taskEntry.getName(), ATTR_TASK_ID)); } else { taskID = UUID.randomUUID().toString(); } taskID = UUID.randomUUID().toString(); } // Get the current state from the task. If there is none, then assume it's // a new task. String stateString = getAttributeValue(ATTR_TASK_STATE, false); @@ -240,102 +223,16 @@ } } // Get the scheduled start time for the task, if there is one. It may be // in either UTC time (a date followed by a 'Z') or in the local time zone // (not followed by a 'Z'). scheduledStartTime = -1; String timeString = getAttributeValue(ATTR_TASK_SCHEDULED_START_TIME, false); if (timeString != null) { SimpleDateFormat dateFormat; if (timeString.endsWith("Z")) { dateFormat = new SimpleDateFormat(DATE_FORMAT_GMT_TIME); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); } else { dateFormat = new SimpleDateFormat(DATE_FORMAT_COMPACT_LOCAL_TIME); } try { scheduledStartTime = dateFormat.parse(timeString).getTime(); } catch (Exception e) { logger.traceException(e); LocalizableMessage message = ERR_TASK_CANNOT_PARSE_SCHEDULED_START_TIME.get(timeString, taskDN); throw new InitializationException(message, e); } } scheduledStartTime = getTime(taskDN, ATTR_TASK_SCHEDULED_START_TIME, ERR_TASK_CANNOT_PARSE_SCHEDULED_START_TIME); // Get the actual start time for the task, if there is one. actualStartTime = -1; timeString = getAttributeValue(ATTR_TASK_ACTUAL_START_TIME, false); if (timeString != null) { SimpleDateFormat dateFormat; if (timeString.endsWith("Z")) { dateFormat = new SimpleDateFormat(DATE_FORMAT_GMT_TIME); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); } else { dateFormat = new SimpleDateFormat(DATE_FORMAT_COMPACT_LOCAL_TIME); } try { actualStartTime = dateFormat.parse(timeString).getTime(); } catch (Exception e) { logger.traceException(e); LocalizableMessage message = ERR_TASK_CANNOT_PARSE_ACTUAL_START_TIME.get(timeString, taskDN); throw new InitializationException(message, e); } } actualStartTime = getTime(taskDN, ATTR_TASK_ACTUAL_START_TIME, ERR_TASK_CANNOT_PARSE_ACTUAL_START_TIME); // Get the completion time for the task, if there is one. completionTime = -1; timeString = getAttributeValue(ATTR_TASK_COMPLETION_TIME, false); if (timeString != null) { SimpleDateFormat dateFormat; if (timeString.endsWith("Z")) { dateFormat = new SimpleDateFormat(DATE_FORMAT_GMT_TIME); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); } else { dateFormat = new SimpleDateFormat(DATE_FORMAT_COMPACT_LOCAL_TIME); } try { completionTime = dateFormat.parse(timeString).getTime(); } catch (Exception e) { logger.traceException(e); LocalizableMessage message = ERR_TASK_CANNOT_PARSE_COMPLETION_TIME.get(timeString, taskDN); throw new InitializationException(message, e); } } completionTime = getTime(taskDN, ATTR_TASK_COMPLETION_TIME, ERR_TASK_CANNOT_PARSE_COMPLETION_TIME); // Get information about any dependencies that the task might have. dependencyIDs = getAttributeValues(ATTR_TASK_DEPENDENCY_IDS); @@ -352,13 +249,10 @@ } } // Get the information about the e-mail addresses to use for notification // purposes. // Get the information about the e-mail addresses to use for notification purposes notifyOnCompletion = getAttributeValues(ATTR_TASK_NOTIFY_ON_COMPLETION); notifyOnError = getAttributeValues(ATTR_TASK_NOTIFY_ON_ERROR); // Get the log messages for the task. logMessages = getAttributeValues(ATTR_TASK_LOG_MESSAGES); if (logMessages != null) { @@ -366,7 +260,35 @@ } } private long getTime(String taskDN, String attrName, Arg2<Object, Object> errorMsg) throws InitializationException { String timeString = getAttributeValue(attrName, false); if (timeString != null) { SimpleDateFormat dateFormat; if (timeString.endsWith("Z")) { dateFormat = new SimpleDateFormat(DATE_FORMAT_GMT_TIME); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); } else { dateFormat = new SimpleDateFormat(DATE_FORMAT_COMPACT_LOCAL_TIME); } try { return dateFormat.parse(timeString).getTime(); } catch (Exception e) { logger.traceException(e); throw new InitializationException(errorMsg.get(timeString, taskDN), e); } } return -1; } /** * Retrieves the single value for the requested attribute as a string. @@ -422,8 +344,6 @@ return value.toString(); } /** * Retrieves the values for the requested attribute as a list of strings. * @@ -437,11 +357,9 @@ * requested attribute in the entry with * different sets of options. */ private LinkedList<String> getAttributeValues(String attributeName) throws InitializationException private LinkedList<String> getAttributeValues(String attributeName) throws InitializationException { LinkedList<String> valueStrings = new LinkedList<>(); List<Attribute> attrList = taskEntry.getAttribute(attributeName.toLowerCase()); if (attrList == null || attrList.isEmpty()) { @@ -460,8 +378,6 @@ return valueStrings; } /** * Retrieves the DN of the entry containing the definition for this task. * @@ -472,8 +388,6 @@ return taskEntryDN; } /** * Retrieves the entry containing the definition for this task. * @@ -484,8 +398,6 @@ return taskEntry; } /** * Retrieves the operation used to create this task in the server. Note that * this will only be available when the task is first added to the scheduler, @@ -502,8 +414,6 @@ return operation; } /** * Specifies the operation used to create this task in the server. * @@ -514,8 +424,6 @@ this.operation = operation; } /** * Retrieves the unique identifier assigned to this task. * @@ -526,8 +434,6 @@ return taskID; } /** * Retrieves the unique identifier assigned to the recurring task that is * associated with this task, if there is one. @@ -541,8 +447,6 @@ return recurringTaskID; } /** * Retrieves the current state for this task. * @@ -577,8 +481,6 @@ TaskState.isCancelled(taskInterruptState); } /** * Sets the state for this task and updates the associated task entry as * necessary. It does not automatically persist the updated task information @@ -610,7 +512,6 @@ } } /** * Sets a state for this task that is the result of a call to * {@link #interruptTask(TaskState, LocalizableMessage)}. @@ -624,7 +525,6 @@ this.taskInterruptState = state; } /** * Gets the interrupt state for this task that was set as a * result of a call to {@link #interruptTask(TaskState, LocalizableMessage)}. @@ -636,7 +536,6 @@ return this.taskInterruptState; } /** * Returns a state for this task after processing has completed. * If the task was interrupted with a call to @@ -650,17 +549,13 @@ */ protected TaskState getFinalTaskState() { if (this.taskInterruptState == null) { return TaskState.COMPLETED_SUCCESSFULLY; } else if (this.taskInterruptState != null) { return this.taskInterruptState; } return TaskState.COMPLETED_SUCCESSFULLY; } /** * Replaces an attribute values of the task entry. * @@ -699,7 +594,6 @@ } } /** * Retrieves the scheduled start time for this task, if there is one. The * value returned will be in the same format as the return value for @@ -714,8 +608,6 @@ return scheduledStartTime; } /** * Retrieves the time that this task actually started running, if it has * started. The value returned will be in the same format as the return value @@ -729,8 +621,6 @@ return actualStartTime; } /** * Sets the actual start time for this task and updates the associated task * entry as necessary. It does not automatically persist the updated task @@ -764,8 +654,6 @@ } } /** * Retrieves the time that this task completed all of its associated * processing (regardless of whether it was successful), if it has completed. @@ -780,8 +668,6 @@ return completionTime; } /** * Sets the completion time for this task and updates the associated task * entry as necessary. It does not automatically persist the updated task @@ -817,8 +703,6 @@ } } /** * Retrieves the set of task IDs for any tasks on which this task is * dependent. This list must not be directly modified by the caller. @@ -830,8 +714,6 @@ return dependencyIDs; } /** * Retrieves the action that should be taken if any of the dependencies for * this task do not complete successfully. @@ -844,8 +726,6 @@ return failedDependencyAction; } /** * Retrieves the set of e-mail addresses for the users that should receive a * notification message when processing for this task has completed. This @@ -862,8 +742,6 @@ return notifyOnCompletion; } /** * Retrieves the set of e-mail addresses for the users that should receive a * notification message if processing for this task does not complete @@ -994,8 +872,6 @@ } } /** * Compares this task with the provided task for the purposes of ordering in a * sorted list. Any completed task will always be ordered before an @@ -1018,29 +894,7 @@ { if (completionTime > 0) { if (task.completionTime > 0) { // They have both completed, so order by completion time. if (completionTime < task.completionTime) { return -1; } else if (completionTime > task.completionTime) { return 1; } else { // They have the same completion time, so order by task ID. return taskID.compareTo(task.taskID); } } else { // Completed tasks are always ordered before those that haven't // completed. return -1; } return compareTimes(task, completionTime, task.completionTime); } else if (task.completionTime > 0) { @@ -1050,28 +904,7 @@ if (actualStartTime > 0) { if (task.actualStartTime > 0) { // They are both running, so order by actual start time. if (actualStartTime < task.actualStartTime) { return -1; } else if (actualStartTime > task.actualStartTime) { return 1; } else { // They have the same actual start time, so order by task ID. return taskID.compareTo(task.taskID); } } else { // Running tasks are always ordered before those that haven't started. return -1; } return compareTimes(task, actualStartTime, task.actualStartTime); } else if (task.actualStartTime > 0) { @@ -1079,7 +912,6 @@ return 1; } // Neither task has started, so order by scheduled start time, or if nothing // else by task ID. if (scheduledStartTime < task.scheduledStartTime) @@ -1096,7 +928,33 @@ } } private int compareTimes(Task task, long time1, long time2) { if (time2 > 0) { // They are both running, so order by actual start time. // OR they have both completed, so order by completion time. if (time1 < time2) { return -1; } else if (time1 > time2) { return 1; } else { // They have the same actual start/completion time, so order by task ID. return taskID.compareTo(task.taskID); } } else { // Running tasks are always ordered before those that haven't started. // OR completed tasks are always ordered before those that haven't completed. return -1; } } /** * Begins execution for this task. This is a wrapper around the @@ -1111,26 +969,18 @@ setTaskState(TaskState.RUNNING); taskScheduler.writeState(); TaskState taskState = this.taskState; try { taskState = runTask(); return runTask(); } catch (Exception e) { logger.traceException(e); taskState = TaskState.STOPPED_BY_ERROR; logger.error(ERR_TASK_EXECUTE_FAILED, taskEntry.getName(), stackTraceToSingleLineString(e)); return TaskState.STOPPED_BY_ERROR; } return taskState; } /** * If appropriate, send an e-mail message with information about the * completed task. @@ -1183,8 +1033,6 @@ } } /** * Performs any task-specific initialization that may be required before * processing can start. This default implementation does not do anything, @@ -1201,8 +1049,6 @@ // No action is performed by default. } /** * Performs the actual core processing for this task. This method should not * return until all processing associated with this task has completed. @@ -1211,15 +1057,13 @@ */ protected abstract TaskState runTask(); /** * Performs any necessary processing to prematurely interrupt the execution of * this task. By default no action is performed, but if it is feasible to * gracefully interrupt a task, then subclasses should override this method to * do so. * * Implementations of this method are exprected to call * Implementations of this method are expected to call * {@link #setTaskInterruptState(TaskState)} if the interruption is accepted * by this task. * @@ -1231,20 +1075,15 @@ { // No action is performed by default. // NOTE: if you implement this make sure to override isInterruptable // to return 'true' // NOTE: if you implement this make sure to override isInterruptable() to return 'true' } /** * Indicates whether or not this task is interruptable or not. * Indicates whether or not this task is interruptible or not. * * @return boolean where true indicates that this task can be interrupted. */ public boolean isInterruptable() { return false; } } opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
@@ -111,7 +111,6 @@ implements ConfigurationChangeListener<ReplicationDomainCfg>, AlertGenerator { /** * Set of attributes that will return all the user attributes and the * replication related operational attributes when used in a search operation. @@ -169,11 +168,8 @@ } } /** * The fully-qualified name of this class. */ private static final String CLASS_NAME = LDAPReplicationDomain.class .getName(); /** The fully-qualified name of this class. */ private static final String CLASS_NAME = LDAPReplicationDomain.class.getName(); /** * The attribute used to mark conflicting entries. @@ -236,31 +232,17 @@ private ExternalChangelogDomain eclDomain; /** * A boolean indicating if the thread used to save the persistentServerState * is terminated. */ /** A boolean indicating if the thread used to save the persistentServerState is terminated. */ private volatile boolean done = true; private final ServerStateFlush flushThread; /** * The attribute name used to store the generation id in the backend. */ private static final String REPLICATION_GENERATION_ID = "ds-sync-generation-id"; /** * The attribute name used to store the fractional include configuration in * the backend. */ static final String REPLICATION_FRACTIONAL_INCLUDE = "ds-sync-fractional-include"; /** * The attribute name used to store the fractional exclude configuration in * the backend. */ static final String REPLICATION_FRACTIONAL_EXCLUDE = "ds-sync-fractional-exclude"; /** The attribute name used to store the generation id in the backend. */ private static final String REPLICATION_GENERATION_ID = "ds-sync-generation-id"; /** The attribute name used to store the fractional include configuration in the backend. */ static final String REPLICATION_FRACTIONAL_INCLUDE = "ds-sync-fractional-include"; /** The attribute name used to store the fractional exclude configuration in the backend. */ static final String REPLICATION_FRACTIONAL_EXCLUDE = "ds-sync-fractional-exclude"; /** * Fractional replication variables. @@ -269,10 +251,7 @@ /** Holds the fractional configuration for this domain, if any. */ private final FractionalConfig fractionalConfig; /** * The list of attributes that cannot be used in fractional replication * configuration. */ /** The list of attributes that cannot be used in fractional replication configuration. */ private static final String[] FRACTIONAL_PROHIBITED_ATTRIBUTES = new String[] { "objectClass", @@ -298,13 +277,9 @@ * the fractional replication ldif import plugin. */ private int importErrorMessageId = -1; /** * LocalizableMessage type for ERR_FULL_UPDATE_IMPORT_FRACTIONAL_BAD_REMOTE. */ /** LocalizableMessage type for ERR_FULL_UPDATE_IMPORT_FRACTIONAL_BAD_REMOTE. */ static final int IMPORT_ERROR_MESSAGE_BAD_REMOTE = 1; /** * LocalizableMessage type for ERR_FULL_UPDATE_IMPORT_FRACTIONAL_REMOTE_IS_FRACTIONAL. */ /** LocalizableMessage type for ERR_FULL_UPDATE_IMPORT_FRACTIONAL_REMOTE_IS_FRACTIONAL. */ static final int IMPORT_ERROR_MESSAGE_REMOTE_IS_FRACTIONAL = 2; /* @@ -343,7 +318,6 @@ super("Replica DS(" + getServerId() + ") state checkpointer for domain \"" + getBaseDN() + "\""); } /** {@inheritDoc} */ @Override public void run() { @@ -389,7 +363,6 @@ this.startCSN = replServerMaxCSN; } /** {@inheritDoc} */ @Override public void run() { @@ -804,21 +777,18 @@ this.attrValIt = attrValIt; } /** {@inheritDoc} */ @Override public boolean hasNext() { return attrValIt.hasNext(); } /** {@inheritDoc} */ @Override public String next() { return attrValIt.next().toString(); } /** {@inheritDoc} */ // Should not be needed anyway @Override public void remove() @@ -978,7 +948,6 @@ } } // Check consistency of all classes attributes for (String attrName : newFractionalAllClassesAttributes) { @@ -1262,7 +1231,7 @@ return hasSomeAttributesToFilter; } private static boolean isMandatoryAttribute(Set<ObjectClass> entryClasses, AttributeType attributeType) private static boolean isMandatoryAttribute(Set<ObjectClass> entryClasses, AttributeType attributeType) { for (ObjectClass objectClass : entryClasses) { @@ -1503,9 +1472,7 @@ throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, msg); } // FIXME should the next call use the initWindow parameter rather than the // instance variable? super.initializeRemote(target, requestorID, initTask, getInitWindow()); super.initializeRemote(target, requestorID, initTask, initWindow); } /** @@ -1707,7 +1674,6 @@ return true; } /** * Implement the handleConflictResolution phase of the ModifyDNOperation. * @@ -1957,7 +1923,6 @@ addOperation.setAttachment(SYNCHROCONTEXT, ctx); } /** {@inheritDoc} */ @Override public void publishReplicaOfflineMsg() { @@ -2043,10 +2008,12 @@ } } // If the operation is a DELETE on the base entry of the suffix // that is replicated, the generation is now lost because the // DB is empty. We need to save it again the next time we add an entry. if (op.getOperationType().equals(OperationType.DELETE) /* * If the operation is a DELETE on the base entry of the suffix * that is replicated, the generation is now lost because the * DB is empty. We need to save it again the next time we add an entry. */ if (OperationType.DELETE.equals(op.getOperationType()) && ((PostOperationDeleteOperation) op) .getEntryDN().equals(getBaseDN())) { @@ -2202,18 +2169,14 @@ op.run(); } /** * Delete this ReplicationDomain. */ /** Delete this ReplicationDomain. */ void delete() { shutdown(); removeECLDomainCfg(); } /** * Shutdown this ReplicationDomain. */ /** Shutdown this ReplicationDomain. */ public void shutdown() { if (shutdown.compareAndSet(false, true)) @@ -2484,7 +2447,6 @@ return pendingChanges.putLocalOperation(operation); } /** * Find the Unique Id of the entry with the provided DN by doing a * search of the entry and extracting its entryUUID from its attributes. @@ -2652,9 +2614,7 @@ if (result == ResultCode.NO_SUCH_OBJECT) { /* * Find if the entry is still in the database. */ /* Find if the entry is still in the database. */ DN currentDN = findEntryDN(entryUUID); if (currentDN == null) { @@ -2823,7 +2783,6 @@ } } /** * Solve a conflict detected when replaying a ADD operation. * @@ -2963,7 +2922,6 @@ return conflict; } /** * Rename an entry that was conflicting so that it stays below the * baseDN of the replicationDomain. @@ -2990,7 +2948,6 @@ } } /** * Generate a modification to add the conflict attribute to an entry * whose Dn is now conflicting with another entry. @@ -3226,7 +3183,6 @@ return result; } /** * Load the GenerationId from the root entry of the domain * from the REPLICATION_GENERATION_ID attribute in database @@ -3242,10 +3198,7 @@ logger.trace("Attempt to read generation ID from DB " + getBaseDN()); } /* * Search the database entry that is used to periodically * save the generation id */ // Search the database entry that is used to periodically save the generation id final SearchRequest request = newSearchRequest(getBaseDN(), SearchScope.BASE_OBJECT) .addAttribute(REPLICATION_GENERATION_ID); InternalSearchOperation search = conn.processSearch(request); @@ -3690,7 +3643,6 @@ * <<Total Update */ /** * Push the schema modifications contained in the given parameter as a * modification that would happen on a local server. The modifications are not @@ -3770,7 +3722,6 @@ return true; } /** {@inheritDoc} */ @Override public ConfigChangeResult applyConfigurationChange( ReplicationDomainCfg configuration) @@ -3796,7 +3747,6 @@ return ccr; } /** {@inheritDoc} */ @Override public boolean isConfigurationChangeAcceptable( ReplicationDomainCfg configuration, List<LocalizableMessage> unacceptableReasons) @@ -3822,7 +3772,6 @@ } } /** {@inheritDoc} */ @Override public Map<String, String> getAlerts() { @@ -3833,24 +3782,19 @@ return alerts; } /** {@inheritDoc} */ @Override public String getClassName() { return CLASS_NAME; } /** {@inheritDoc} */ @Override public DN getComponentEntryDN() { return config.dn(); } /** * Starts the Replication Domain. */ /** Starts the Replication Domain. */ public void start() { // Create the ServerStateFlush thread @@ -3859,11 +3803,7 @@ startListenService(); } /** * Remove from this domain configuration, the configuration of the * external change log. */ /** Remove the configuration of the external changelog from this domain configuration. */ private void removeECLDomainCfg() { try @@ -3957,7 +3897,6 @@ return buffer.toString(); } /** {@inheritDoc} */ @Override public void sessionInitiated(ServerStatus initStatus, ServerState rsState) { @@ -4205,7 +4144,6 @@ return searchForChangedEntries(baseDN, fromCSN, null, resultListener); } /** * This method should return the total number of objects in the * replicated domain. @@ -4229,7 +4167,6 @@ return backend.getNumberOfEntriesInBaseDN(getBaseDN()); } /** {@inheritDoc} */ @Override public boolean processUpdate(UpdateMsg updateMsg) { @@ -4761,8 +4698,7 @@ } else { Set<String> attrList = fractionalSpecificClassesAttributes.get(classNameLower); Set<String> attrList = fractionalSpecificClassesAttributes.get(classNameLower); if (attrList == null) { attrList = new LinkedHashSet<>(); opendj-server-legacy/src/main/java/org/opends/server/replication/server/ReplicationDomainMonitorData.java
@@ -36,16 +36,12 @@ import org.opends.server.replication.common.ServerState; import org.opends.server.util.TimeThread; /** * This class defines the Monitor Data that are consolidated across a * replication domain. */ /** This class defines the Monitor Data that are consolidated across a replication domain. */ class ReplicationDomainMonitorData { private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); /** * * - For each server, the max (most recent) CSN produced * * - For each server, its state i.e. the last processed from of each @@ -121,9 +117,7 @@ return res != null ? res : 0; } /** * Build the monitor data that are computed from the collected ones. */ /** Build the monitor data that are computed from the collected ones. */ public void completeComputing() { StringBuilder mds = new StringBuilder(); @@ -139,7 +133,7 @@ final ServerState lsiState = entry.getValue(); long lsiMissingChanges = computeMissingChanges(mds, lsiServerId, lsiState); if (logger.isTraceEnabled()) { mds.append("=" + lsiMissingChanges); mds.append("=").append(lsiMissingChanges); } this.missingChanges.put(lsiServerId, lsiMissingChanges); @@ -152,9 +146,9 @@ { final Integer lsiServerId = entry.getKey(); final ServerState lsiState = entry.getValue(); long lsiMissingChanges = computeMissingChanges(mds, Integer.MIN_VALUE, lsiState); long lsiMissingChanges = computeMissingChanges(mds, null, lsiState); if (logger.isTraceEnabled()) { mds.append("=" + lsiMissingChanges); mds.append("=").append(lsiMissingChanges); } this.missingChangesRS.put(lsiServerId, lsiMissingChanges); @@ -179,7 +173,8 @@ int missingChangesLsiLsj = CSN.diffSeqNum(lsjMaxCSN, lsiLastCSN); if (logger.isTraceEnabled()) { mds.append("+ diff(" + lsjMaxCSN + "-" + lsiLastCSN + ")=" + missingChangesLsiLsj); mds.append("+ diff(") .append(lsjMaxCSN).append("-").append(lsiLastCSN).append(")=").append(missingChangesLsiLsj); } /* THIS BIT OF CODE IS IRRELEVANT TO RSs. @@ -198,7 +193,7 @@ { missingChangesLsiLsj = 0; if (logger.isTraceEnabled()) { mds.append(" (diff replaced by 0 as for server id " + lsiServerId + ")"); mds.append(" (diff replaced by 0 as for server id ").append(lsiServerId).append(")"); } } @@ -223,7 +218,7 @@ { final Integer serverId = entry.getKey(); final CSN csn = entry.getValue(); mds.append("\nmaxCSNs(" + serverId + ")= " + csn.toStringUI()); mds.append("\nmaxCSNs(").append(serverId).append(")= ").append(csn.toStringUI()); } // LDAP data @@ -231,10 +226,11 @@ { final Integer serverId = entry.getKey(); final ServerState ss = entry.getValue(); mds.append("\nLSData(" + serverId + ")=\t" + "state=[" + ss + "] afmd=" + getApproxFirstMissingDate(serverId) + " missingDelay=" + getApproxDelay(serverId) + " missingCount=" + missingChanges.get(serverId)); mds.append("\nLSData(").append(serverId).append(")=\t") .append("state=[").append(ss) .append("] afmd=").append(getApproxFirstMissingDate(serverId)) .append(" missingDelay=").append(getApproxDelay(serverId)) .append(" missingCount=").append(missingChanges.get(serverId)); } // RS data @@ -242,8 +238,9 @@ { final Integer serverId = entry.getKey(); final ServerState ss = entry.getValue(); mds.append("\nRSData(" + serverId + ")=\t" + "state=[" + ss + "] missingCount=" + missingChangesRS.get(serverId)); mds.append("\nRSData(").append(serverId).append(")=\t") .append("state=[").append(ss) .append("] missingCount=").append(missingChangesRS.get(serverId)); } mds.append("\n--");