com.unboundid.ldap.sdk.unboundidds.tasks.ReloadGlobalIndexTask Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of unboundid-ldapsdk Show documentation
Show all versions of unboundid-ldapsdk Show documentation
The UnboundID LDAP SDK for Java is a fast, comprehensive, and easy-to-use
Java API for communicating with LDAP directory servers and performing
related tasks like reading and writing LDIF, encoding and decoding data
using base64 and ASN.1 BER, and performing secure communication. This
package contains the Standard Edition of the LDAP SDK, which is a
complete, general-purpose library for communicating with LDAPv3 directory
servers.
/*
* Copyright 2015-2018 Ping Identity Corporation
* All Rights Reserved.
*/
/*
* Copyright (C) 2015-2018 Ping Identity Corporation
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (GPLv2 only)
* or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see .
*/
package com.unboundid.ldap.sdk.unboundidds.tasks;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import com.unboundid.ldap.sdk.Attribute;
import com.unboundid.ldap.sdk.Entry;
import com.unboundid.util.NotMutable;
import com.unboundid.util.StaticUtils;
import com.unboundid.util.ThreadSafety;
import com.unboundid.util.ThreadSafetyLevel;
import com.unboundid.util.Validator;
import static com.unboundid.ldap.sdk.unboundidds.tasks.TaskMessages.*;
/**
* This class defines a Directory Proxy Server task that can be used to reload
* the contents of the global index.
*
*
* NOTE: This class, and other classes within the
* {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
* supported for use against Ping Identity, UnboundID, and
* Nokia/Alcatel-Lucent 8661 server products. These classes provide support
* for proprietary functionality or for external specifications that are not
* considered stable or mature enough to be guaranteed to work in an
* interoperable way with other types of LDAP servers.
*
*
* The properties that are available for use with this type of task include:
*
* - The base DN for the entry-balancing request processor.
* - An optional set of attributes for which to reload the index
* information.
* - A flag indicating whether to perform the reload in the background.
* - A flag indicating whether to reload entries from backend Directory
* Server instances rather than a peer Directory Proxy Server
* instance.
* - An optional maximum number of entries per second to access when
* priming.
*
*/
@NotMutable()
@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
public final class ReloadGlobalIndexTask
extends Task
{
/**
* The fully-qualified name of the Java class that is used for the re-encode
* entries task.
*/
static final String RELOAD_GLOBAL_INDEX_TASK_CLASS =
"com.unboundid.directory.proxy.tasks.ReloadTask";
/**
* The name of the attribute used to indicate whether the reload should be
* done in the background.
*/
private static final String ATTR_BACKGROUND_RELOAD =
"ds-task-reload-background";
/**
* The name of the attribute used to specify the base DN for the
* entry-balancing request processor.
*/
private static final String ATTR_BASE_DN = "ds-task-reload-base-dn";
/**
* The name of the attribute used to specify the names of the attributes for
* which to reload the indexes.
*/
private static final String ATTR_INDEX_NAME = "ds-task-reload-index-name";
/**
* The name of the attribute used to specify a target rate limit for the
* maximum number of entries per second.
*/
private static final String ATTR_MAX_ENTRIES_PER_SECOND =
"ds-task-search-entry-per-second";
/**
* The name of the attribute used to indicate whether the data should be
* loaded from backend Directory Server instances rather than a peer Directory
* Proxy Server instance.
*/
private static final String ATTR_RELOAD_FROM_DS = "ds-task-reload-from-ds";
/**
* The name of the object class used in reload global index task entries.
*/
private static final String OC_RELOAD_GLOBAL_INDEX_TASK =
"ds-task-reload-index";
/**
* The task property that will be used for the request processor base DN.
*/
private static final TaskProperty PROPERTY_BACKGROUND_RELOAD =
new TaskProperty(ATTR_BACKGROUND_RELOAD,
INFO_DISPLAY_NAME_RELOAD_GLOBAL_INDEX_BACKGROUND.get(),
INFO_DESCRIPTION_RELOAD_GLOBAL_INDEX_BACKGROUND.get(),
Boolean.class, false, false, false);
/**
* The task property that will be used for the request processor base DN.
*/
private static final TaskProperty PROPERTY_BASE_DN = new TaskProperty(
ATTR_BASE_DN, INFO_DISPLAY_NAME_RELOAD_GLOBAL_INDEX_BASE_DN.get(),
INFO_DESCRIPTION_RELOAD_GLOBAL_INDEX_BASE_DN.get(), String.class, true,
false, false);
/**
* The task property that will be used for the request processor base DN.
*/
private static final TaskProperty PROPERTY_INDEX_NAME = new TaskProperty(
ATTR_INDEX_NAME, INFO_DISPLAY_NAME_RELOAD_GLOBAL_INDEX_ATTR_NAME.get(),
INFO_DESCRIPTION_RELOAD_GLOBAL_INDEX_ATTR_NAME.get(), String.class,
false, true, false);
/**
* The task property that will be used for the request processor base DN.
*/
private static final TaskProperty PROPERTY_MAX_ENTRIES_PER_SECOND =
new TaskProperty(ATTR_MAX_ENTRIES_PER_SECOND,
INFO_DISPLAY_NAME_RELOAD_GLOBAL_INDEX_MAX_ENTRIES_PER_SECOND.get(),
INFO_DESCRIPTION_RELOAD_GLOBAL_INDEX_MAX_ENTRIES_PER_SECOND.get(),
Long.class, false, false, false);
/**
* The task property that will be used for the request processor base DN.
*/
static final TaskProperty PROPERTY_RELOAD_FROM_DS = new TaskProperty(
ATTR_RELOAD_FROM_DS,
INFO_DISPLAY_NAME_RELOAD_GLOBAL_INDEX_RELOAD_FROM_DS.get(),
INFO_DESCRIPTION_RELOAD_GLOBAL_INDEX_RELOAD_FROM_DS.get(), Boolean.class,
false, false, false);
/**
* The serial version UID for this serializable class.
*/
private static final long serialVersionUID = 9152807987055252560L;
// Indicates whether to reload from backend Directory Server instances.
private final Boolean reloadFromDS;
// Indicates whether to reload in the background.
private final Boolean reloadInBackground;
// The names of the indexes to reload.
private final List indexNames;
// The target maximum rate limit to use when loading entry data.
private final Long maxEntriesPerSecond;
// The base DN for the entry-balancing request processor.
private final String baseDN;
/**
* Creates a new uninitialized reload global index task instance which should
* only be used for obtaining general information about this task, including
* the task name, description, and supported properties. Attempts to use a
* task created with this constructor for any other reason will likely fail.
*/
public ReloadGlobalIndexTask()
{
reloadFromDS = null;
reloadInBackground = null;
indexNames = null;
maxEntriesPerSecond = null;
baseDN = null;
}
/**
* Creates a new reload global index task with the provided information.
*
* @param taskID The task ID to use for this task. If it is
* {@code null} then a UUID will be generated for
* use as the task ID.
* @param baseDN The base DN of the entry-balancing request
* processor for which to reload index
* information.
* @param indexNames The names of the attributes for which to
* reload index data. This may be {@code null}
* or empty to indicate that all indexes should
* be reloaded.
* @param reloadFromDS Indicates whether to load index data from
* backend Directory Server instances rather than
* a peer Directory Proxy Server instance. This
* may be {@code null} to indicate that the
* Directory Proxy Server should automatically
* select the appropriate source for obtaining
* index data.
* @param reloadInBackground Indicates whether to perform the reload in
* the background, so that the task completes
* immediately.
* @param maxEntriesPerSecond The maximum target rate at which to reload
* index data (in entries per second). A value
* of zero indicates no limit. A value of
* {@code null} indicates that the Directory
* Proxy Server should attempt to determine the
* limit based on its configuration.
*/
public ReloadGlobalIndexTask(final String taskID, final String baseDN,
final List indexNames,
final Boolean reloadFromDS,
final Boolean reloadInBackground,
final Long maxEntriesPerSecond)
{
this(taskID, baseDN, indexNames, reloadFromDS, reloadInBackground,
maxEntriesPerSecond, null, null, null, null, null);
}
/**
* Creates a new reload global index task with the provided information.
*
* @param taskID The task ID to use for this task. If it is
* {@code null} then a UUID will be generated
* for use as the task ID.
* @param baseDN The base DN of the entry-balancing request
* processor for which to reload index
* information.
* @param indexNames The names of the attributes for which to
* reload index data. This may be
* {@code null} or empty to indicate that all
* indexes should be reloaded.
* @param reloadFromDS Indicates whether to load index data from
* backend Directory Server instances rather
* than a peer Directory Proxy Server
* instance. This may be {@code null} to
* indicate that the Directory Proxy Server
* should automatically select the appropriate
* source for obtaining index data.
* @param reloadInBackground Indicates whether to perform the reload in
* the background, so that the task completes
* immediately.
* @param maxEntriesPerSecond The maximum target rate at which to reload
* index data (in entries per second). A
* value of zero indicates no limit. A value
* of {@code null} indicates that the
* Directory Proxy Server should attempt to
* determine the limit based on its
* configuration.
* @param scheduledStartTime The time that this task should start
* running.
* @param dependencyIDs The list of task IDs that will be required
* to complete before this task will be
* eligible to start.
* @param failedDependencyAction Indicates what action should be taken if
* any of the dependencies for this task do
* not complete successfully.
* @param notifyOnCompletion The list of e-mail addresses of individuals
* that should be notified when this task
* completes.
* @param notifyOnError The list of e-mail addresses of individuals
* that should be notified if this task does
* not complete successfully.
*/
public ReloadGlobalIndexTask(final String taskID, final String baseDN,
final List indexNames, final Boolean reloadFromDS,
final Boolean reloadInBackground, final Long maxEntriesPerSecond,
final Date scheduledStartTime,
final List dependencyIDs,
final FailedDependencyAction failedDependencyAction,
final List notifyOnCompletion,
final List notifyOnError)
{
this(taskID, baseDN, indexNames, reloadFromDS, reloadInBackground,
maxEntriesPerSecond, scheduledStartTime, dependencyIDs,
failedDependencyAction, null, notifyOnCompletion, null,
notifyOnError, null, null, null);
}
/**
* Creates a new reload global index task with the provided information.
*
* @param taskID The task ID to use for this task. If it is
* {@code null} then a UUID will be generated
* for use as the task ID.
* @param baseDN The base DN of the entry-balancing request
* processor for which to reload index
* information.
* @param indexNames The names of the attributes for which to
* reload index data. This may be
* {@code null} or empty to indicate that all
* indexes should be reloaded.
* @param reloadFromDS Indicates whether to load index data from
* backend Directory Server instances rather
* than a peer Directory Proxy Server
* instance. This may be {@code null} to
* indicate that the Directory Proxy Server
* should automatically select the appropriate
* source for obtaining index data.
* @param reloadInBackground Indicates whether to perform the reload in
* the background, so that the task completes
* immediately.
* @param maxEntriesPerSecond The maximum target rate at which to reload
* index data (in entries per second). A
* value of zero indicates no limit. A value
* of {@code null} indicates that the
* Directory Proxy Server should attempt to
* determine the limit based on its
* configuration.
* @param scheduledStartTime The time that this task should start
* running.
* @param dependencyIDs The list of task IDs that will be required
* to complete before this task will be
* eligible to start.
* @param failedDependencyAction Indicates what action should be taken if
* any of the dependencies for this task do
* not complete successfully.
* @param notifyOnStart The list of e-mail addresses of individuals
* that should be notified when this task
* starts running.
* @param notifyOnCompletion The list of e-mail addresses of individuals
* that should be notified when this task
* completes.
* @param notifyOnSuccess The list of e-mail addresses of individuals
* that should be notified if this task
* completes successfully.
* @param notifyOnError The list of e-mail addresses of individuals
* that should be notified if this task does
* not complete successfully.
* @param alertOnStart Indicates whether the server should send an
* alert notification when this task starts.
* @param alertOnSuccess Indicates whether the server should send an
* alert notification if this task completes
* successfully.
* @param alertOnError Indicates whether the server should send an
* alert notification if this task fails to
* complete successfully.
*/
public ReloadGlobalIndexTask(final String taskID, final String baseDN,
final List indexNames, final Boolean reloadFromDS,
final Boolean reloadInBackground, final Long maxEntriesPerSecond,
final Date scheduledStartTime,
final List dependencyIDs,
final FailedDependencyAction failedDependencyAction,
final List notifyOnStart,
final List notifyOnCompletion,
final List notifyOnSuccess,
final List notifyOnError, final Boolean alertOnStart,
final Boolean alertOnSuccess, final Boolean alertOnError)
{
super(taskID, RELOAD_GLOBAL_INDEX_TASK_CLASS, scheduledStartTime,
dependencyIDs, failedDependencyAction, notifyOnStart,
notifyOnCompletion, notifyOnSuccess, notifyOnError, alertOnStart,
alertOnSuccess, alertOnError);
Validator.ensureNotNull(baseDN);
this.baseDN = baseDN;
this.reloadFromDS = reloadFromDS;
this.reloadInBackground = reloadInBackground;
this.maxEntriesPerSecond = maxEntriesPerSecond;
if (indexNames == null)
{
this.indexNames = Collections.emptyList();
}
else
{
this.indexNames =
Collections.unmodifiableList(new ArrayList<>(indexNames));
}
}
/**
* Creates a new reload global index task from the provided entry.
*
* @param entry The entry to use to create this reload global index task.
*
* @throws TaskException If the provided entry cannot be parsed as a reload
* global index task entry.
*/
public ReloadGlobalIndexTask(final Entry entry)
throws TaskException
{
super(entry);
// Get the base DN. It must be present.
baseDN = entry.getAttributeValue(ATTR_BASE_DN);
if (baseDN == null)
{
throw new TaskException(
ERR_RELOAD_GLOBAL_INDEX_MISSING_REQUIRED_ATTR.get(ATTR_BASE_DN));
}
// Get the names of the indexes to reload. It may be empty or null.
final String[] nameArray = entry.getAttributeValues(ATTR_INDEX_NAME);
if ((nameArray == null) || (nameArray.length == 0))
{
indexNames = Collections.emptyList();
}
else
{
indexNames = Collections.unmodifiableList(Arrays.asList(nameArray));
}
// Get the flag indicating whether to reload from backend Directory Server
// instances.
reloadFromDS = entry.getAttributeValueAsBoolean(ATTR_RELOAD_FROM_DS);
// Get the flag indicating whether to reload in a background thread.
reloadInBackground =
entry.getAttributeValueAsBoolean(ATTR_BACKGROUND_RELOAD);
// Get the value specifying the maximum reload rate in entries per second.
maxEntriesPerSecond =
entry.getAttributeValueAsLong(ATTR_MAX_ENTRIES_PER_SECOND);
}
/**
* Creates a new reload global index task from the provided set of task
* properties.
*
* @param properties The set of task properties and their corresponding
* values to use for the task. It must not be
* {@code null}.
*
* @throws TaskException If the provided set of properties cannot be used to
* create a valid reload global index task.
*/
public ReloadGlobalIndexTask(final Map> properties)
throws TaskException
{
super(RELOAD_GLOBAL_INDEX_TASK_CLASS, properties);
final List attrs = new ArrayList<>(10);
Boolean background = null;
Boolean fromDS = null;
Long maxPerSecond = null;
String baseDNStr = null;
for (final Map.Entry> e : properties.entrySet())
{
final TaskProperty p = e.getKey();
final String attrName = p.getAttributeName();
final List