001/*
002 * Copyright 2015-2024 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2015-2024 Ping Identity Corporation
007 *
008 * Licensed under the Apache License, Version 2.0 (the "License");
009 * you may not use this file except in compliance with the License.
010 * You may obtain a copy of the License at
011 *
012 *    http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 */
020/*
021 * Copyright (C) 2015-2024 Ping Identity Corporation
022 *
023 * This program is free software; you can redistribute it and/or modify
024 * it under the terms of the GNU General Public License (GPLv2 only)
025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
026 * as published by the Free Software Foundation.
027 *
028 * This program is distributed in the hope that it will be useful,
029 * but WITHOUT ANY WARRANTY; without even the implied warranty of
030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
031 * GNU General Public License for more details.
032 *
033 * You should have received a copy of the GNU General Public License
034 * along with this program; if not, see <http://www.gnu.org/licenses>.
035 */
036package com.unboundid.ldap.sdk.unboundidds.tasks;
037
038
039
040import java.util.ArrayList;
041import java.util.Arrays;
042import java.util.Collections;
043import java.util.Date;
044import java.util.LinkedHashMap;
045import java.util.List;
046import java.util.Map;
047
048import com.unboundid.ldap.sdk.Attribute;
049import com.unboundid.ldap.sdk.Entry;
050import com.unboundid.util.NotMutable;
051import com.unboundid.util.NotNull;
052import com.unboundid.util.Nullable;
053import com.unboundid.util.StaticUtils;
054import com.unboundid.util.ThreadSafety;
055import com.unboundid.util.ThreadSafetyLevel;
056import com.unboundid.util.Validator;
057
058import static com.unboundid.ldap.sdk.unboundidds.tasks.TaskMessages.*;
059
060
061
062/**
063 * This class defines a Directory Proxy Server task that can be used to reload
064 * the contents of the global index.
065 * <BR>
066 * <BLOCKQUOTE>
067 *   <B>NOTE:</B>  This class, and other classes within the
068 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
069 *   supported for use against Ping Identity, UnboundID, and
070 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
071 *   for proprietary functionality or for external specifications that are not
072 *   considered stable or mature enough to be guaranteed to work in an
073 *   interoperable way with other types of LDAP servers.
074 * </BLOCKQUOTE>
075 * <BR>
076 * The properties that are available for use with this type of task include:
077 * <UL>
078 *   <LI>The base DN for the entry-balancing request processor.</LI>
079 *   <LI>An optional set of attributes for which to reload the index
080 *       information.</LI>
081 *   <LI>A flag indicating whether to perform the reload in the background.</LI>
082 *   <LI>A flag indicating whether to reload entries from backend Directory
083 *       Server instances rather than a peer Directory Proxy Server
084 *       instance.</LI>
085 *   <LI>An optional maximum number of entries per second to access when
086 *       priming.</LI>
087 * </UL>
088 */
089@NotMutable()
090@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
091public final class ReloadGlobalIndexTask
092       extends Task
093{
094  /**
095   * The fully-qualified name of the Java class that is used for the re-encode
096   * entries task.
097   */
098  @NotNull static final String RELOAD_GLOBAL_INDEX_TASK_CLASS =
099       "com.unboundid.directory.proxy.tasks.ReloadTask";
100
101
102
103  /**
104   * The name of the attribute used to indicate whether the reload should be
105   * done in the background.
106   */
107  @NotNull private static final String ATTR_BACKGROUND_RELOAD =
108       "ds-task-reload-background";
109
110
111
112  /**
113   * The name of the attribute used to specify the base DN for the
114   * entry-balancing request processor.
115   */
116  @NotNull private static final String ATTR_BASE_DN = "ds-task-reload-base-dn";
117
118
119
120  /**
121   * The name of the attribute used to specify the names of the attributes for
122   * which to reload the indexes.
123   */
124  @NotNull private static final String ATTR_INDEX_NAME =
125       "ds-task-reload-index-name";
126
127
128
129  /**
130   * The name of the attribute used to specify a target rate limit for the
131   * maximum number of entries per second.
132   */
133  @NotNull private static final String ATTR_MAX_ENTRIES_PER_SECOND =
134       "ds-task-search-entry-per-second";
135
136
137
138  /**
139   * The name of the attribute used to indicate whether the data should be
140   * loaded from backend Directory Server instances rather than a peer Directory
141   * Proxy Server instance.
142   */
143  @NotNull private static final String ATTR_RELOAD_FROM_DS =
144       "ds-task-reload-from-ds";
145
146
147
148  /**
149   * The name of the object class used in reload global index task entries.
150   */
151  @NotNull private static final String OC_RELOAD_GLOBAL_INDEX_TASK =
152       "ds-task-reload-index";
153
154
155
156  /**
157   * The task property that will be used for the request processor base DN.
158   */
159  @NotNull private static final TaskProperty PROPERTY_BACKGROUND_RELOAD =
160       new TaskProperty(ATTR_BACKGROUND_RELOAD,
161            INFO_DISPLAY_NAME_RELOAD_GLOBAL_INDEX_BACKGROUND.get(),
162            INFO_DESCRIPTION_RELOAD_GLOBAL_INDEX_BACKGROUND.get(),
163            Boolean.class, false, false, false);
164
165
166
167  /**
168   * The task property that will be used for the request processor base DN.
169   */
170  @NotNull private static final TaskProperty PROPERTY_BASE_DN =
171       new TaskProperty(ATTR_BASE_DN,
172            INFO_DISPLAY_NAME_RELOAD_GLOBAL_INDEX_BASE_DN.get(),
173            INFO_DESCRIPTION_RELOAD_GLOBAL_INDEX_BASE_DN.get(), String.class,
174            true, false, false);
175
176
177
178  /**
179   * The task property that will be used for the request processor base DN.
180   */
181  @NotNull private static final TaskProperty PROPERTY_INDEX_NAME =
182       new TaskProperty(ATTR_INDEX_NAME,
183            INFO_DISPLAY_NAME_RELOAD_GLOBAL_INDEX_ATTR_NAME.get(),
184            INFO_DESCRIPTION_RELOAD_GLOBAL_INDEX_ATTR_NAME.get(), String.class,
185            false, true, false);
186
187
188
189  /**
190   * The task property that will be used for the request processor base DN.
191   */
192  @NotNull private static final TaskProperty PROPERTY_MAX_ENTRIES_PER_SECOND =
193       new TaskProperty(ATTR_MAX_ENTRIES_PER_SECOND,
194            INFO_DISPLAY_NAME_RELOAD_GLOBAL_INDEX_MAX_ENTRIES_PER_SECOND.get(),
195            INFO_DESCRIPTION_RELOAD_GLOBAL_INDEX_MAX_ENTRIES_PER_SECOND.get(),
196            Long.class, false, false, false);
197
198
199
200  /**
201   * The task property that will be used for the request processor base DN.
202   */
203  @NotNull static final TaskProperty PROPERTY_RELOAD_FROM_DS = new TaskProperty(
204       ATTR_RELOAD_FROM_DS,
205       INFO_DISPLAY_NAME_RELOAD_GLOBAL_INDEX_RELOAD_FROM_DS.get(),
206       INFO_DESCRIPTION_RELOAD_GLOBAL_INDEX_RELOAD_FROM_DS.get(), Boolean.class,
207       false, false, false);
208
209
210
211  /**
212   * The serial version UID for this serializable class.
213   */
214  private static final long serialVersionUID = 9152807987055252560L;
215
216
217
218  // Indicates whether to reload from backend Directory Server instances.
219  @Nullable private final Boolean reloadFromDS;
220
221  // Indicates whether to reload in the background.
222  @Nullable private final Boolean reloadInBackground;
223
224  // The names of the indexes to reload.
225  @NotNull private final List<String> indexNames;
226
227  // The target maximum rate limit to use when loading entry data.
228  @Nullable private final Long maxEntriesPerSecond;
229
230  // The base DN for the entry-balancing request processor.
231  @NotNull private final String baseDN;
232
233
234
235  /**
236   * Creates a new uninitialized reload global index task instance which should
237   * only be used for obtaining general information about this task, including
238   * the task name, description, and supported properties.  Attempts to use a
239   * task created with this constructor for any other reason will likely fail.
240   */
241  public ReloadGlobalIndexTask()
242  {
243    reloadFromDS        = null;
244    reloadInBackground  = null;
245    indexNames          = null;
246    maxEntriesPerSecond = null;
247    baseDN              = null;
248  }
249
250
251
252  /**
253   * Creates a new reload global index task with the provided information.
254   *
255   * @param  taskID               The task ID to use for this task.  If it is
256   *                              {@code null} then a UUID will be generated for
257   *                              use as the task ID.
258   * @param  baseDN               The base DN of the entry-balancing request
259   *                              processor for which to reload index
260   *                              information.
261   * @param  indexNames           The names of the attributes for which to
262   *                              reload index data.  This may be {@code null}
263   *                              or empty to indicate that all indexes should
264   *                              be reloaded.
265   * @param  reloadFromDS         Indicates whether to load index data from
266   *                              backend Directory Server instances rather than
267   *                              a peer Directory Proxy Server instance.  This
268   *                              may be {@code null} to indicate that the
269   *                              Directory Proxy Server should automatically
270   *                              select the appropriate source for obtaining
271   *                              index data.
272   * @param  reloadInBackground   Indicates whether to perform the reload in
273   *                              the background, so that the task completes
274   *                              immediately.
275   * @param  maxEntriesPerSecond  The maximum target rate at which to reload
276   *                              index data (in entries per second).  A value
277   *                              of zero indicates no limit.  A value of
278   *                              {@code null} indicates that the Directory
279   *                              Proxy Server should attempt to determine the
280   *                              limit based on its configuration.
281   */
282  public ReloadGlobalIndexTask(@Nullable final String taskID,
283                               @NotNull final String baseDN,
284                               @Nullable final List<String> indexNames,
285                               @Nullable final Boolean reloadFromDS,
286                               @Nullable final Boolean reloadInBackground,
287                               @Nullable final Long maxEntriesPerSecond)
288  {
289    this(taskID, baseDN, indexNames, reloadFromDS, reloadInBackground,
290         maxEntriesPerSecond, null, null, null, null, null);
291  }
292
293
294
295  /**
296   * Creates a new reload global index task with the provided information.
297   *
298   * @param  taskID                  The task ID to use for this task.  If it is
299   *                                 {@code null} then a UUID will be generated
300   *                                 for use as the task ID.
301   * @param  baseDN                  The base DN of the entry-balancing request
302   *                                 processor for which to reload index
303   *                                 information.
304   * @param  indexNames              The names of the attributes for which to
305   *                                 reload index data.  This may be
306   *                                 {@code null} or empty to indicate that all
307   *                                 indexes should be reloaded.
308   * @param  reloadFromDS            Indicates whether to load index data from
309   *                                 backend Directory Server instances rather
310   *                                 than a peer Directory Proxy Server
311   *                                 instance.  This may be {@code null} to
312   *                                 indicate that the Directory Proxy Server
313   *                                 should automatically select the appropriate
314   *                                 source for obtaining index data.
315   * @param  reloadInBackground      Indicates whether to perform the reload in
316   *                                 the background, so that the task completes
317   *                                 immediately.
318   * @param  maxEntriesPerSecond     The maximum target rate at which to reload
319   *                                 index data (in entries per second).  A
320   *                                 value of zero indicates no limit.  A value
321   *                                 of {@code null} indicates that the
322   *                                 Directory Proxy Server should attempt to
323   *                                 determine the limit based on its
324   *                                 configuration.
325   * @param  scheduledStartTime      The time that this task should start
326   *                                 running.
327   * @param  dependencyIDs           The list of task IDs that will be required
328   *                                 to complete before this task will be
329   *                                 eligible to start.
330   * @param  failedDependencyAction  Indicates what action should be taken if
331   *                                 any of the dependencies for this task do
332   *                                 not complete successfully.
333   * @param  notifyOnCompletion      The list of e-mail addresses of individuals
334   *                                 that should be notified when this task
335   *                                 completes.
336   * @param  notifyOnError           The list of e-mail addresses of individuals
337   *                                 that should be notified if this task does
338   *                                 not complete successfully.
339   */
340  public ReloadGlobalIndexTask(@Nullable final String taskID,
341              @NotNull final String baseDN,
342              @Nullable final List<String> indexNames,
343              @Nullable final Boolean reloadFromDS,
344              @Nullable final Boolean reloadInBackground,
345              @Nullable final Long maxEntriesPerSecond,
346              @Nullable final Date scheduledStartTime,
347              @Nullable final List<String> dependencyIDs,
348              @Nullable final FailedDependencyAction failedDependencyAction,
349              @Nullable final List<String> notifyOnCompletion,
350              @Nullable final List<String> notifyOnError)
351  {
352    this(taskID, baseDN, indexNames, reloadFromDS, reloadInBackground,
353         maxEntriesPerSecond, scheduledStartTime, dependencyIDs,
354         failedDependencyAction, null, notifyOnCompletion, null,
355         notifyOnError, null, null, null);
356  }
357
358
359
360  /**
361   * Creates a new reload global index task with the provided information.
362   *
363   * @param  taskID                  The task ID to use for this task.  If it is
364   *                                 {@code null} then a UUID will be generated
365   *                                 for use as the task ID.
366   * @param  baseDN                  The base DN of the entry-balancing request
367   *                                 processor for which to reload index
368   *                                 information.
369   * @param  indexNames              The names of the attributes for which to
370   *                                 reload index data.  This may be
371   *                                 {@code null} or empty to indicate that all
372   *                                 indexes should be reloaded.
373   * @param  reloadFromDS            Indicates whether to load index data from
374   *                                 backend Directory Server instances rather
375   *                                 than a peer Directory Proxy Server
376   *                                 instance.  This may be {@code null} to
377   *                                 indicate that the Directory Proxy Server
378   *                                 should automatically select the appropriate
379   *                                 source for obtaining index data.
380   * @param  reloadInBackground      Indicates whether to perform the reload in
381   *                                 the background, so that the task completes
382   *                                 immediately.
383   * @param  maxEntriesPerSecond     The maximum target rate at which to reload
384   *                                 index data (in entries per second).  A
385   *                                 value of zero indicates no limit.  A value
386   *                                 of {@code null} indicates that the
387   *                                 Directory Proxy Server should attempt to
388   *                                 determine the limit based on its
389   *                                 configuration.
390   * @param  scheduledStartTime      The time that this task should start
391   *                                 running.
392   * @param  dependencyIDs           The list of task IDs that will be required
393   *                                 to complete before this task will be
394   *                                 eligible to start.
395   * @param  failedDependencyAction  Indicates what action should be taken if
396   *                                 any of the dependencies for this task do
397   *                                 not complete successfully.
398   * @param  notifyOnStart           The list of e-mail addresses of individuals
399   *                                 that should be notified when this task
400   *                                 starts running.
401   * @param  notifyOnCompletion      The list of e-mail addresses of individuals
402   *                                 that should be notified when this task
403   *                                 completes.
404   * @param  notifyOnSuccess         The list of e-mail addresses of individuals
405   *                                 that should be notified if this task
406   *                                 completes successfully.
407   * @param  notifyOnError           The list of e-mail addresses of individuals
408   *                                 that should be notified if this task does
409   *                                 not complete successfully.
410   * @param  alertOnStart            Indicates whether the server should send an
411   *                                 alert notification when this task starts.
412   * @param  alertOnSuccess          Indicates whether the server should send an
413   *                                 alert notification if this task completes
414   *                                 successfully.
415   * @param  alertOnError            Indicates whether the server should send an
416   *                                 alert notification if this task fails to
417   *                                 complete successfully.
418   */
419  public ReloadGlobalIndexTask(@Nullable final String taskID,
420              @NotNull final String baseDN,
421              @Nullable final List<String> indexNames,
422              @Nullable final Boolean reloadFromDS,
423              @Nullable final Boolean reloadInBackground,
424              @Nullable final Long maxEntriesPerSecond,
425              @Nullable final Date scheduledStartTime,
426              @Nullable final List<String> dependencyIDs,
427              @Nullable final FailedDependencyAction failedDependencyAction,
428              @Nullable final List<String> notifyOnStart,
429              @Nullable final List<String> notifyOnCompletion,
430              @Nullable final List<String> notifyOnSuccess,
431              @Nullable final List<String> notifyOnError,
432              @Nullable final Boolean alertOnStart,
433              @Nullable final Boolean alertOnSuccess,
434              @Nullable final Boolean alertOnError)
435  {
436    super(taskID, RELOAD_GLOBAL_INDEX_TASK_CLASS, scheduledStartTime,
437         dependencyIDs, failedDependencyAction, notifyOnStart,
438         notifyOnCompletion, notifyOnSuccess, notifyOnError, alertOnStart,
439         alertOnSuccess, alertOnError);
440
441    Validator.ensureNotNull(baseDN);
442
443    this.baseDN              = baseDN;
444    this.reloadFromDS        = reloadFromDS;
445    this.reloadInBackground  = reloadInBackground;
446    this.maxEntriesPerSecond = maxEntriesPerSecond;
447
448    if (indexNames == null)
449    {
450      this.indexNames = Collections.emptyList();
451    }
452    else
453    {
454      this.indexNames =
455           Collections.unmodifiableList(new ArrayList<>(indexNames));
456    }
457  }
458
459
460
461  /**
462   * Creates a new reload global index task from the provided entry.
463   *
464   * @param  entry  The entry to use to create this reload global index task.
465   *
466   * @throws  TaskException  If the provided entry cannot be parsed as a reload
467   *                         global index task entry.
468   */
469  public ReloadGlobalIndexTask(@NotNull final Entry entry)
470         throws TaskException
471  {
472    super(entry);
473
474    // Get the base DN.  It must be present.
475    baseDN = entry.getAttributeValue(ATTR_BASE_DN);
476    if (baseDN == null)
477    {
478      throw new TaskException(
479           ERR_RELOAD_GLOBAL_INDEX_MISSING_REQUIRED_ATTR.get(ATTR_BASE_DN));
480    }
481
482    // Get the names of the indexes to reload.  It may be empty or null.
483    final String[] nameArray = entry.getAttributeValues(ATTR_INDEX_NAME);
484    if ((nameArray == null) || (nameArray.length == 0))
485    {
486      indexNames = Collections.emptyList();
487    }
488    else
489    {
490      indexNames = Collections.unmodifiableList(Arrays.asList(nameArray));
491    }
492
493    // Get the flag indicating whether to reload from backend Directory Server
494    // instances.
495    reloadFromDS = entry.getAttributeValueAsBoolean(ATTR_RELOAD_FROM_DS);
496
497    // Get the flag indicating whether to reload in a background thread.
498    reloadInBackground =
499         entry.getAttributeValueAsBoolean(ATTR_BACKGROUND_RELOAD);
500
501    // Get the value specifying the maximum reload rate in entries per second.
502    maxEntriesPerSecond =
503         entry.getAttributeValueAsLong(ATTR_MAX_ENTRIES_PER_SECOND);
504  }
505
506
507
508  /**
509   * Creates a new reload global index task from the provided set of task
510   * properties.
511   *
512   * @param  properties  The set of task properties and their corresponding
513   *                     values to use for the task.  It must not be
514   *                     {@code null}.
515   *
516   * @throws  TaskException  If the provided set of properties cannot be used to
517   *                         create a valid reload global index task.
518   */
519  public ReloadGlobalIndexTask(
520              @NotNull final Map<TaskProperty,List<Object>> properties)
521         throws TaskException
522  {
523    super(RELOAD_GLOBAL_INDEX_TASK_CLASS, properties);
524
525    final List<String> attrs = new ArrayList<>(10);
526    Boolean background   = null;
527    Boolean fromDS       = null;
528    Long    maxPerSecond = null;
529    String  baseDNStr    = null;
530
531    for (final Map.Entry<TaskProperty,List<Object>> e : properties.entrySet())
532    {
533      final TaskProperty p = e.getKey();
534      final String attrName = p.getAttributeName();
535      final List<Object> values = e.getValue();
536
537      if (attrName.equalsIgnoreCase(ATTR_BASE_DN))
538      {
539        baseDNStr = parseString(p, values, null);
540      }
541      else if (attrName.equalsIgnoreCase(ATTR_INDEX_NAME))
542      {
543        final String[] nameArray = parseStrings(p, values, null);
544        if (nameArray != null)
545        {
546          attrs.addAll(Arrays.asList(nameArray));
547        }
548      }
549      else if (attrName.equalsIgnoreCase(ATTR_RELOAD_FROM_DS))
550      {
551        fromDS = parseBoolean(p, values, null);
552      }
553      else if (attrName.equalsIgnoreCase(ATTR_BACKGROUND_RELOAD))
554      {
555        background = parseBoolean(p, values, null);
556      }
557      else if (attrName.equalsIgnoreCase(ATTR_MAX_ENTRIES_PER_SECOND))
558      {
559        maxPerSecond = parseLong(p, values, null);
560      }
561    }
562
563    if (baseDNStr == null)
564    {
565      throw new TaskException(
566           ERR_RELOAD_GLOBAL_INDEX_MISSING_REQUIRED_PROPERTY.get(ATTR_BASE_DN));
567    }
568
569    baseDN              = baseDNStr;
570    indexNames          = Collections.unmodifiableList(attrs);
571    reloadFromDS        = fromDS;
572    reloadInBackground  = background;
573    maxEntriesPerSecond = maxPerSecond;
574  }
575
576
577
578  /**
579   * {@inheritDoc}
580   */
581  @Override()
582  @NotNull()
583  public String getTaskName()
584  {
585    return INFO_TASK_NAME_RELOAD_GLOBAL_INDEX.get();
586  }
587
588
589
590  /**
591   * {@inheritDoc}
592   */
593  @Override()
594  @NotNull()
595  public String getTaskDescription()
596  {
597    return INFO_TASK_DESCRIPTION_RELOAD_GLOBAL_INDEX.get();
598  }
599
600
601
602  /**
603   * Retrieves the base DN of the entry-balancing request processor for which to
604   * reload index data.
605   *
606   * @return  The base DN of the entry-balancing request processor for which to
607   *          reload index data.
608   */
609  @NotNull()
610  public String getBaseDN()
611  {
612    return baseDN;
613  }
614
615
616
617  /**
618   * Retrieves the names of the indexes to be reloaded.
619   *
620   * @return  The names of the indexes to be reloaded, or an empty list if the
621   *          Directory Proxy Server should reload all indexes.
622   */
623  @NotNull()
624  public List<String> getIndexNames()
625  {
626    return indexNames;
627  }
628
629
630
631  /**
632   * Indicates whether to reload index information from backend Directory
633   * Servers rather than a peer Directory Proxy Server.
634   *
635   * @return  {@code true} if the index information should be reloaded from
636   *          backend Directory Servers, {@code false} if the index information
637   *          should be reloaded from a peer Directory Proxy Server instance, or
638   *          {@code null} if the Directory Proxy Server should automatically
639   *          determine the reload data source.
640   */
641  @Nullable()
642  public Boolean reloadFromDS()
643  {
644    return reloadFromDS;
645  }
646
647
648
649  /**
650   * Indicates whether to perform the index reload processing in the background.
651   *
652   * @return  {@code true} if the index reload processing should be performed
653   *          in the background (so that the task completes immediately),
654   *          {@code false} if not, or {@code null} if the Directory Proxy
655   *          Server should determine whether to perform the reload in the
656   *          background.
657   */
658  @Nullable()
659  public Boolean reloadInBackground()
660  {
661    return reloadInBackground;
662  }
663
664
665
666  /**
667   * Retrieves the maximum reload rate in entries per second, if defined.
668   *
669   * @return  The maximum rate at which to reload index data, in entries per
670   *          second, zero if no limit should be imposed, or {@code null} if the
671   *          Directory Proxy Server should determine the maximum reload rate.
672   */
673  @Nullable()
674  public Long getMaxEntriesPerSecond()
675  {
676    return maxEntriesPerSecond;
677  }
678
679
680
681  /**
682   * {@inheritDoc}
683   */
684  @Override()
685  @NotNull()
686  protected List<String> getAdditionalObjectClasses()
687  {
688    return Collections.singletonList(OC_RELOAD_GLOBAL_INDEX_TASK);
689  }
690
691
692
693  /**
694   * {@inheritDoc}
695   */
696  @Override()
697  @NotNull()
698  protected List<Attribute> getAdditionalAttributes()
699  {
700    final ArrayList<Attribute> attrList = new ArrayList<>(5);
701
702    attrList.add(new Attribute(ATTR_BASE_DN, baseDN));
703
704    if (! indexNames.isEmpty())
705    {
706      attrList.add(new Attribute(ATTR_INDEX_NAME, indexNames));
707    }
708
709    if (reloadFromDS != null)
710    {
711      attrList.add(new Attribute(ATTR_RELOAD_FROM_DS,
712           String.valueOf(reloadFromDS)));
713    }
714
715    if (reloadInBackground != null)
716    {
717      attrList.add(new Attribute(ATTR_BACKGROUND_RELOAD,
718           String.valueOf(reloadInBackground)));
719    }
720
721    if (maxEntriesPerSecond != null)
722    {
723      attrList.add(new Attribute(ATTR_MAX_ENTRIES_PER_SECOND,
724           String.valueOf(maxEntriesPerSecond)));
725    }
726
727    return attrList;
728  }
729
730
731
732  /**
733   * {@inheritDoc}
734   */
735  @Override()
736  @NotNull()
737  public List<TaskProperty> getTaskSpecificProperties()
738  {
739    return Collections.unmodifiableList(Arrays.asList(
740         PROPERTY_BASE_DN,
741         PROPERTY_INDEX_NAME,
742         PROPERTY_RELOAD_FROM_DS,
743         PROPERTY_BACKGROUND_RELOAD,
744         PROPERTY_MAX_ENTRIES_PER_SECOND));
745  }
746
747
748
749  /**
750   * {@inheritDoc}
751   */
752  @Override()
753  @NotNull()
754  public Map<TaskProperty,List<Object>> getTaskPropertyValues()
755  {
756    final LinkedHashMap<TaskProperty,List<Object>> props =
757         new LinkedHashMap<>(StaticUtils.computeMapCapacity(15));
758
759    props.put(PROPERTY_BASE_DN,
760         Collections.<Object>singletonList(baseDN));
761    props.put(PROPERTY_INDEX_NAME,
762         Collections.<Object>unmodifiableList(indexNames));
763
764    if (reloadFromDS == null)
765    {
766      props.put(PROPERTY_RELOAD_FROM_DS,
767           Collections.emptyList());
768    }
769    else
770    {
771      props.put(PROPERTY_RELOAD_FROM_DS,
772           Collections.<Object>singletonList(reloadFromDS));
773    }
774
775    if (reloadInBackground == null)
776    {
777      props.put(PROPERTY_BACKGROUND_RELOAD,
778           Collections.emptyList());
779    }
780    else
781    {
782      props.put(PROPERTY_BACKGROUND_RELOAD,
783           Collections.<Object>singletonList(reloadInBackground));
784    }
785
786    if (maxEntriesPerSecond == null)
787    {
788      props.put(PROPERTY_MAX_ENTRIES_PER_SECOND,
789           Collections.emptyList());
790    }
791    else
792    {
793      props.put(PROPERTY_MAX_ENTRIES_PER_SECOND,
794           Collections.<Object>singletonList(maxEntriesPerSecond));
795    }
796
797    props.putAll(super.getTaskPropertyValues());
798    return Collections.unmodifiableMap(props);
799  }
800}