001/*
002 * Copyright 2008-2024 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2008-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) 2008-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.monitors;
037
038
039
040import java.util.ArrayList;
041import java.util.Collections;
042import java.util.List;
043import java.util.logging.Level;
044
045import com.unboundid.ldap.sdk.Entry;
046import com.unboundid.ldap.sdk.Filter;
047import com.unboundid.ldap.sdk.LDAPConnection;
048import com.unboundid.ldap.sdk.LDAPInterface;
049import com.unboundid.ldap.sdk.LDAPSearchException;
050import com.unboundid.ldap.sdk.SearchResult;
051import com.unboundid.ldap.sdk.SearchResultEntry;
052import com.unboundid.ldap.sdk.SearchScope;
053import com.unboundid.util.Debug;
054import com.unboundid.util.DebugType;
055import com.unboundid.util.NotNull;
056import com.unboundid.util.Nullable;
057import com.unboundid.util.ThreadSafety;
058import com.unboundid.util.ThreadSafetyLevel;
059
060
061
062/**
063 * This class provides a set of methods for retrieving Directory Server monitor
064 * entries.  In particular, it provides methods for retrieving all monitor
065 * entries from the server, as well as retrieving monitor entries of specific
066 * types.
067 * <BR>
068 * <BLOCKQUOTE>
069 *   <B>NOTE:</B>  This class, and other classes within the
070 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
071 *   supported for use against Ping Identity, UnboundID, and
072 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
073 *   for proprietary functionality or for external specifications that are not
074 *   considered stable or mature enough to be guaranteed to work in an
075 *   interoperable way with other types of LDAP servers.
076 * </BLOCKQUOTE>
077 * <BR>
078 * <H2>Example</H2>
079 * The following example demonstrates the process for retrieving all monitor
080 * entries published by the directory server and printing the information
081 * contained in each using the generic API for accessing monitor entry data:
082 * <PRE>
083 * List&lt;MonitorEntry&gt; allMonitorEntries =
084 *      MonitorManager.getMonitorEntries(connection);
085 * for (MonitorEntry e : allMonitorEntries)
086 * {
087 *   String monitorName = e.getMonitorName();
088 *   String displayName = e.getMonitorDisplayName();
089 *   Map&lt;String,MonitorAttribute&gt; monitorAttributes =
090 *        e.getMonitorAttributes();
091 * }
092 * </PRE>
093 */
094@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
095public final class MonitorManager
096{
097  /**
098   * Prevent this class from being instantiated.
099   */
100  private MonitorManager()
101  {
102    // No implementation is required.
103  }
104
105
106
107  /**
108   * Retrieves a list of all monitor entries available in the Directory Server.
109   *
110   * @param  connection  The connection to use to communicate with the Directory
111   *                     Server.
112   *
113   * @return  A list of all monitor entries available in the Directory Server.
114   *
115   * @throws  LDAPSearchException  If a problem occurs while communicating with
116   *                               the Directory Server.
117   */
118  @NotNull()
119  public static List<MonitorEntry> getMonitorEntries(
120              @NotNull final LDAPConnection connection)
121         throws LDAPSearchException
122  {
123    return getMonitorEntries((LDAPInterface) connection);
124  }
125
126
127
128  /**
129   * Retrieves a list of all monitor entries available in the Directory Server.
130   *
131   * @param  connection  The connection to use to communicate with the Directory
132   *                     Server.
133   *
134   * @return  A list of all monitor entries available in the Directory Server.
135   *
136   * @throws  LDAPSearchException  If a problem occurs while communicating with
137   *                               the Directory Server.
138   */
139  @NotNull()
140  public static List<MonitorEntry> getMonitorEntries(
141              @NotNull final LDAPInterface connection)
142         throws LDAPSearchException
143  {
144    final Filter filter = Filter.createEqualityFilter("objectClass",
145                         MonitorEntry.GENERIC_MONITOR_OC);
146
147    final SearchResult searchResult =
148         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
149                           filter);
150
151    final ArrayList<MonitorEntry> monitorEntries =
152         new ArrayList<>(searchResult.getEntryCount());
153    for (final SearchResultEntry e : searchResult.getSearchEntries())
154    {
155      monitorEntries.add(MonitorEntry.decode(e));
156    }
157
158    return Collections.unmodifiableList(monitorEntries);
159  }
160
161
162
163  /**
164   * Retrieves the general monitor entry from the Directory Server.
165   *
166   * @param  connection  The connection to use to communicate with the Directory
167   *                     Server.
168   *
169   * @return  The general monitor entry from the Directory Server, or
170   *          {@code null} if it is not available.
171   *
172   * @throws  LDAPSearchException  If a problem occurs while communicating with
173   *                               the Directory Server.
174   */
175  @Nullable()
176  public static GeneralMonitorEntry getGeneralMonitorEntry(
177              @NotNull final LDAPConnection connection)
178         throws LDAPSearchException
179  {
180    return getGeneralMonitorEntry((LDAPInterface) connection);
181  }
182
183
184
185  /**
186   * Retrieves the general monitor entry from the Directory Server.
187   *
188   * @param  connection  The connection to use to communicate with the Directory
189   *                     Server.
190   *
191   * @return  The general monitor entry from the Directory Server, or
192   *          {@code null} if it is not available.
193   *
194   * @throws  LDAPSearchException  If a problem occurs while communicating with
195   *                               the Directory Server.
196   */
197  @Nullable()
198  public static GeneralMonitorEntry getGeneralMonitorEntry(
199              @NotNull final LDAPInterface connection)
200         throws LDAPSearchException
201  {
202    final Filter filter = Filter.createPresenceFilter("objectClass");
203
204    final SearchResult searchResult =
205         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.BASE,
206                           filter);
207
208    final int numEntries = searchResult.getEntryCount();
209    if (numEntries == 0)
210    {
211      Debug.debug(Level.FINE, DebugType.MONITOR,
212           "No entries returned in getGeneralMonitorEntry");
213
214      return null;
215    }
216
217    return new GeneralMonitorEntry(searchResult.getSearchEntries().get(0));
218  }
219
220
221
222  /**
223   * Retrieves the active operations monitor entry from the Directory Server.
224   *
225   * @param  connection  The connection to use to communicate with the Directory
226   *                     Server.
227   *
228   * @return  The active operations monitor entry from the Directory Server, or
229   *          {@code null} if it is not available.
230   *
231   * @throws  LDAPSearchException  If a problem occurs while communicating with
232   *                               the Directory Server.
233   */
234  @Nullable()
235  public static ActiveOperationsMonitorEntry getActiveOperationsMonitorEntry(
236              @NotNull final LDAPConnection connection)
237         throws LDAPSearchException
238  {
239    return getActiveOperationsMonitorEntry((LDAPInterface) connection);
240  }
241
242
243
244  /**
245   * Retrieves the active operations monitor entry from the Directory Server.
246   *
247   * @param  connection  The connection to use to communicate with the Directory
248   *                     Server.
249   *
250   * @return  The active operations monitor entry from the Directory Server, or
251   *          {@code null} if it is not available.
252   *
253   * @throws  LDAPSearchException  If a problem occurs while communicating with
254   *                               the Directory Server.
255   */
256  @Nullable()
257  public static ActiveOperationsMonitorEntry getActiveOperationsMonitorEntry(
258              @NotNull final LDAPInterface connection)
259         throws LDAPSearchException
260  {
261    final Filter filter = Filter.createEqualityFilter("objectClass",
262         ActiveOperationsMonitorEntry.ACTIVE_OPERATIONS_MONITOR_OC);
263
264    final SearchResult searchResult =
265         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
266                           filter);
267
268    final int numEntries = searchResult.getEntryCount();
269    if (numEntries == 0)
270    {
271      Debug.debug(Level.FINE, DebugType.MONITOR,
272           "No entries returned in getActiveOperationsMonitorEntry");
273
274      return null;
275    }
276    else if (numEntries != 1)
277    {
278      Debug.debug(Level.FINE, DebugType.MONITOR,
279           "Multiple entries returned in getActiveOperationsMonitorEntry");
280    }
281
282    return new ActiveOperationsMonitorEntry(
283                    searchResult.getSearchEntries().get(0));
284  }
285
286
287
288  /**
289   * Retrieves a list of all backend monitor entries available in the Directory
290   * Server.
291   *
292   * @param  connection  The connection to use to communicate with the Directory
293   *                     Server.
294   *
295   * @return  A list of all backend monitor entries available in the Directory
296   *          Server.
297   *
298   * @throws  LDAPSearchException  If a problem occurs while communicating with
299   *                               the Directory Server.
300   */
301  @NotNull()
302  public static List<BackendMonitorEntry> getBackendMonitorEntries(
303              @NotNull final LDAPConnection connection)
304         throws LDAPSearchException
305  {
306    return getBackendMonitorEntries((LDAPInterface) connection);
307  }
308
309
310
311  /**
312   * Retrieves a list of all backend monitor entries available in the Directory
313   * Server.
314   *
315   * @param  connection  The connection to use to communicate with the Directory
316   *                     Server.
317   *
318   * @return  A list of all backend monitor entries available in the Directory
319   *          Server.
320   *
321   * @throws  LDAPSearchException  If a problem occurs while communicating with
322   *                               the Directory Server.
323   */
324  @NotNull()
325  public static List<BackendMonitorEntry> getBackendMonitorEntries(
326              @NotNull final LDAPInterface connection)
327         throws LDAPSearchException
328  {
329    final Filter filter = Filter.createEqualityFilter("objectClass",
330                         BackendMonitorEntry.BACKEND_MONITOR_OC);
331
332    final SearchResult searchResult =
333         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
334                           filter);
335
336    final ArrayList<BackendMonitorEntry> monitorEntries =
337         new ArrayList<>(searchResult.getEntryCount());
338    for (final SearchResultEntry e : searchResult.getSearchEntries())
339    {
340      monitorEntries.add(new BackendMonitorEntry(e));
341    }
342
343    return Collections.unmodifiableList(monitorEntries);
344  }
345
346
347
348  /**
349   * Retrieves the client connection monitor entry from the Directory Server.
350   *
351   * @param  connection  The connection to use to communicate with the Directory
352   *                     Server.
353   *
354   * @return  The client connection monitor entry from the Directory Server, or
355   *          {@code null} if it is not available.
356   *
357   * @throws  LDAPSearchException  If a problem occurs while communicating with
358   *                               the Directory Server.
359   */
360  @Nullable()
361  public static ClientConnectionMonitorEntry getClientConnectionMonitorEntry(
362              @NotNull final LDAPConnection connection)
363         throws LDAPSearchException
364  {
365    return getClientConnectionMonitorEntry((LDAPInterface) connection);
366  }
367
368
369
370  /**
371   * Retrieves the client connection monitor entry from the Directory Server.
372   *
373   * @param  connection  The connection to use to communicate with the Directory
374   *                     Server.
375   *
376   * @return  The client connection monitor entry from the Directory Server, or
377   *          {@code null} if it is not available.
378   *
379   * @throws  LDAPSearchException  If a problem occurs while communicating with
380   *                               the Directory Server.
381   */
382  @Nullable()
383  public static ClientConnectionMonitorEntry getClientConnectionMonitorEntry(
384              @NotNull final LDAPInterface connection)
385         throws LDAPSearchException
386  {
387    final Filter filter = Filter.createEqualityFilter("objectClass",
388         ClientConnectionMonitorEntry.CLIENT_CONNECTION_MONITOR_OC);
389
390    final SearchResult searchResult =
391         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
392                           filter);
393
394    final int numEntries = searchResult.getEntryCount();
395    if (numEntries == 0)
396    {
397      Debug.debug(Level.FINE, DebugType.MONITOR,
398           "No entries returned in getClientConnectionMonitorEntry");
399
400      return null;
401    }
402    else if (numEntries != 1)
403    {
404      Debug.debug(Level.FINE, DebugType.MONITOR,
405           "Multiple entries returned in getClientConnectionMonitorEntry");
406    }
407
408    return new ClientConnectionMonitorEntry(
409                    searchResult.getSearchEntries().get(0));
410  }
411
412
413
414  /**
415   * Retrieves a list of all connection handler monitor entries available in the
416   * Directory Server.
417   *
418   * @param  connection  The connection to use to communicate with the Directory
419   *                     Server.
420   *
421   * @return  A list of all connection handler monitor entries available in the
422   *          Directory Server.
423   *
424   * @throws  LDAPSearchException  If a problem occurs while communicating with
425   *                               the Directory Server.
426   */
427  @NotNull()
428  public static List<ConnectionHandlerMonitorEntry>
429              getConnectionHandlerMonitorEntries(
430                   @NotNull final LDAPConnection connection)
431         throws LDAPSearchException
432  {
433    return getConnectionHandlerMonitorEntries((LDAPInterface) connection);
434  }
435
436
437
438  /**
439   * Retrieves a list of all connection handler monitor entries available in the
440   * Directory Server.
441   *
442   * @param  connection  The connection to use to communicate with the Directory
443   *                     Server.
444   *
445   * @return  A list of all connection handler monitor entries available in the
446   *          Directory Server.
447   *
448   * @throws  LDAPSearchException  If a problem occurs while communicating with
449   *                               the Directory Server.
450   */
451  @NotNull()
452  public static List<ConnectionHandlerMonitorEntry>
453              getConnectionHandlerMonitorEntries(
454                   @NotNull final LDAPInterface connection)
455         throws LDAPSearchException
456  {
457    final Filter filter = Filter.createEqualityFilter("objectClass",
458         ConnectionHandlerMonitorEntry.CONNECTION_HANDLER_MONITOR_OC);
459
460    final SearchResult searchResult =
461         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
462                           filter);
463
464    final ArrayList<ConnectionHandlerMonitorEntry> monitorEntries =
465         new ArrayList<>(searchResult.getEntryCount());
466    for (final SearchResultEntry e : searchResult.getSearchEntries())
467    {
468      monitorEntries.add(new ConnectionHandlerMonitorEntry(e));
469    }
470
471    return Collections.unmodifiableList(monitorEntries);
472  }
473
474
475
476  /**
477   * Retrieves the disk space usage monitor entry from the Directory Server.
478   *
479   * @param  connection  The connection to use to communicate with the Directory
480   *                     Server.
481   *
482   * @return  The disk space usage monitor entry from the Directory Server, or
483   *          {@code null} if it is not available.
484   *
485   * @throws  LDAPSearchException  If a problem occurs while communicating with
486   *                               the Directory Server.
487   */
488  @Nullable()
489  public static DiskSpaceUsageMonitorEntry getDiskSpaceUsageMonitorEntry(
490              @NotNull final LDAPConnection connection)
491         throws LDAPSearchException
492  {
493    return getDiskSpaceUsageMonitorEntry((LDAPInterface) connection);
494  }
495
496
497
498  /**
499   * Retrieves the disk space usage monitor entry from the Directory Server.
500   *
501   * @param  connection  The connection to use to communicate with the Directory
502   *                     Server.
503   *
504   * @return  The disk space usage monitor entry from the Directory Server, or
505   *          {@code null} if it is not available.
506   *
507   * @throws  LDAPSearchException  If a problem occurs while communicating with
508   *                               the Directory Server.
509   */
510  @Nullable()
511  public static DiskSpaceUsageMonitorEntry getDiskSpaceUsageMonitorEntry(
512              @NotNull final LDAPInterface connection)
513         throws LDAPSearchException
514  {
515    final Filter filter = Filter.createEqualityFilter("objectClass",
516         DiskSpaceUsageMonitorEntry.DISK_SPACE_USAGE_MONITOR_OC);
517
518    final SearchResult searchResult =
519         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
520                           filter);
521
522    final int numEntries = searchResult.getEntryCount();
523    if (numEntries == 0)
524    {
525      Debug.debug(Level.FINE, DebugType.MONITOR,
526           "No entries returned in getDiskSpaceUsageMonitorEntry");
527
528      return null;
529    }
530    else if (numEntries != 1)
531    {
532      Debug.debug(Level.FINE, DebugType.MONITOR,
533           "Multiple entries returned in getDiskSpaceUsageMonitorEntry");
534    }
535
536    return new DiskSpaceUsageMonitorEntry(
537                    searchResult.getSearchEntries().get(0));
538  }
539
540
541
542  /**
543   * Retrieves the entry cache monitor entry from the Directory Server.
544   *
545   * @param  connection  The connection to use to communicate with the Directory
546   *                     Server.
547   *
548   * @return  The entry cache monitor entry from the Directory Server, or
549   *          {@code null} if it is not available.
550   *
551   * @throws  LDAPSearchException  If a problem occurs while communicating with
552   *                               the Directory Server.
553   */
554  @Nullable()
555  public static EntryCacheMonitorEntry getEntryCacheMonitorEntry(
556              @NotNull final LDAPConnection connection)
557         throws LDAPSearchException
558  {
559    return getEntryCacheMonitorEntry((LDAPInterface) connection);
560  }
561
562
563
564  /**
565   * Retrieves the entry cache monitor entry from the Directory Server.
566   *
567   * @param  connection  The connection to use to communicate with the Directory
568   *                     Server.
569   *
570   * @return  The entry cache monitor entry from the Directory Server, or
571   *          {@code null} if it is not available.
572   *
573   * @throws  LDAPSearchException  If a problem occurs while communicating with
574   *                               the Directory Server.
575   */
576  @Nullable()
577  public static EntryCacheMonitorEntry getEntryCacheMonitorEntry(
578              @NotNull final LDAPInterface connection)
579         throws LDAPSearchException
580  {
581    final Filter filter = Filter.createEqualityFilter("objectClass",
582                         EntryCacheMonitorEntry.ENTRY_CACHE_MONITOR_OC);
583
584    final SearchResult searchResult =
585         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
586                           filter);
587
588    final int numEntries = searchResult.getEntryCount();
589    if (numEntries == 0)
590    {
591      Debug.debug(Level.FINE, DebugType.MONITOR,
592           "No entries returned in getEntryCacheMonitorEntry");
593
594      return null;
595    }
596    else if (numEntries != 1)
597    {
598      Debug.debug(Level.FINE, DebugType.MONITOR,
599           "Multiple entries returned in getEntryCacheMonitorEntry");
600    }
601
602    return new EntryCacheMonitorEntry(searchResult.getSearchEntries().get(0));
603  }
604
605
606
607  /**
608   * Retrieves the FIFO entry cache monitor entries from the Directory Server.
609   *
610   * @param  connection  The connection to use to communicate with the Directory
611   *                     Server.
612   *
613   * @return  The entry cache monitor entry from the Directory Server, or
614   *          {@code null} if it is not available.
615   *
616   * @throws  LDAPSearchException  If a problem occurs while communicating with
617   *                               the Directory Server.
618   */
619  @NotNull()
620  public static List<FIFOEntryCacheMonitorEntry>
621              getFIFOEntryCacheMonitorEntries(
622                   @NotNull final LDAPConnection connection)
623         throws LDAPSearchException
624  {
625    return getFIFOEntryCacheMonitorEntries((LDAPInterface) connection);
626  }
627
628
629
630  /**
631   * Retrieves the FIFO entry cache monitor entries from the Directory Server.
632   *
633   * @param  connection  The connection to use to communicate with the Directory
634   *                     Server.
635   *
636   * @return  The entry cache monitor entry from the Directory Server, or
637   *          {@code null} if it is not available.
638   *
639   * @throws  LDAPSearchException  If a problem occurs while communicating with
640   *                               the Directory Server.
641   */
642  @NotNull()
643  public static List<FIFOEntryCacheMonitorEntry>
644              getFIFOEntryCacheMonitorEntries(
645                   @NotNull final LDAPInterface connection)
646         throws LDAPSearchException
647  {
648    final Filter filter = Filter.createEqualityFilter("objectClass",
649         FIFOEntryCacheMonitorEntry.FIFO_ENTRY_CACHE_MONITOR_OC);
650
651    final SearchResult searchResult =
652         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
653                           filter);
654
655    final ArrayList<FIFOEntryCacheMonitorEntry> monitorEntries =
656         new ArrayList<>(searchResult.getEntryCount());
657    for (final SearchResultEntry e : searchResult.getSearchEntries())
658    {
659      monitorEntries.add(new FIFOEntryCacheMonitorEntry(e));
660    }
661
662    return Collections.unmodifiableList(monitorEntries);
663  }
664
665
666
667  /**
668   * Retrieves a list of all gauge monitor entries available in the Directory
669   * Server.  This may include monitor entries for gauges of different types
670   * (e.g., numeric gauges and indicator gauges).
671   *
672   * @param  connection  The connection to use to communicate with the Directory
673   *                     Server.
674   *
675   * @return  A list of all gauge monitor entries available in the Directory
676   *          Server.
677   *
678   * @throws  LDAPSearchException  If a problem occurs while communicating with
679   *                               the Directory Server.
680   */
681  @NotNull()
682  public static List<GaugeMonitorEntry> getGaugeMonitorEntries(
683              @NotNull final LDAPInterface connection)
684         throws LDAPSearchException
685  {
686    final Filter filter = Filter.createEqualityFilter("objectClass",
687         GaugeMonitorEntry.GAUGE_MONITOR_OC);
688
689    final SearchResult searchResult =
690         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
691                           filter);
692
693    final ArrayList<GaugeMonitorEntry> monitorEntries =
694         new ArrayList<>(searchResult.getEntryCount());
695    for (final SearchResultEntry e : searchResult.getSearchEntries())
696    {
697      try
698      {
699        monitorEntries.add((GaugeMonitorEntry) MonitorEntry.decode(e));
700      }
701      catch (final Exception ex)
702      {
703        Debug.debugException(ex);
704      }
705    }
706
707    return Collections.unmodifiableList(monitorEntries);
708  }
709
710
711
712  /**
713   * Retrieves the group cache monitor entry from the Directory Server.
714   *
715   * @param  connection  The connection to use to communicate with the Directory
716   *                     Server.
717   *
718   * @return  The group cache monitor entry from the Directory Server, or
719   *          {@code null} if it is not available.
720   *
721   * @throws  LDAPSearchException  If a problem occurs while communicating with
722   *                               the Directory Server.
723   */
724  @Nullable()
725  public static GroupCacheMonitorEntry getGroupCacheMonitorEntry(
726              @NotNull final LDAPInterface connection)
727         throws LDAPSearchException
728  {
729    final Filter filter = Filter.createEqualityFilter("objectClass",
730                         GroupCacheMonitorEntry.GROUP_CACHE_MONITOR_OC);
731
732    final SearchResult searchResult =
733         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
734                           filter);
735
736    final int numEntries = searchResult.getEntryCount();
737    if (numEntries == 0)
738    {
739      Debug.debug(Level.FINE, DebugType.MONITOR,
740           "No entries returned in getGroupCacheMonitorEntry");
741
742      return null;
743    }
744    else if (numEntries != 1)
745    {
746      Debug.debug(Level.FINE, DebugType.MONITOR,
747           "Multiple entries returned in getGroupCacheMonitorEntry");
748    }
749
750    return new GroupCacheMonitorEntry(searchResult.getSearchEntries().get(0));
751  }
752
753
754
755  /**
756   * Retrieves the host system recent CPU and memory monitor entry from the
757   * Directory Server.
758   *
759   * @param  connection  The connection to use to communicate with the Directory
760   *                     Server.
761   *
762   * @return  The host system recent CPU and memory monitor entry from the
763   *          Directory Server, or {@code null} if it is not available.
764   *
765   * @throws  LDAPSearchException  If a problem occurs while communicating with
766   *                               the Directory Server.
767   */
768  @Nullable()
769  public static HostSystemRecentCPUAndMemoryMonitorEntry
770              getHostSystemRecentCPUAndMemoryMonitorEntry(
771                   @NotNull final LDAPInterface connection)
772         throws LDAPSearchException
773  {
774    final Filter filter = Filter.createEqualityFilter("objectClass",
775         HostSystemRecentCPUAndMemoryMonitorEntry.
776              HOST_SYSTEM_RECENT_CPU_AND_MEMORY_MONITOR_OC);
777
778    final SearchResult searchResult =
779         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
780                           filter);
781
782    final int numEntries = searchResult.getEntryCount();
783    if (numEntries == 0)
784    {
785      Debug.debug(Level.FINE, DebugType.MONITOR,
786           "No entries returned in " +
787                "getHostSystemRecentCPUAndMemoryMonitorEntry");
788
789      return null;
790    }
791    else if (numEntries != 1)
792    {
793      Debug.debug(Level.FINE, DebugType.MONITOR,
794           "Multiple entries returned in " +
795                "getHostSystemRecentCPUAndMemoryMonitorEntry");
796    }
797
798    return new HostSystemRecentCPUAndMemoryMonitorEntry(
799         searchResult.getSearchEntries().get(0));
800  }
801
802
803
804  /**
805   * Retrieves a list of all index monitor entries available in the Directory
806   * Server.
807   *
808   * @param  connection  The connection to use to communicate with the Directory
809   *                     Server.
810   *
811   * @return  A list of all index monitor entries available in the Directory
812   *          Server.
813   *
814   * @throws  LDAPSearchException  If a problem occurs while communicating with
815   *                               the Directory Server.
816   */
817  @NotNull()
818  public static List<IndexMonitorEntry> getIndexMonitorEntries(
819              @NotNull final LDAPConnection connection)
820         throws LDAPSearchException
821  {
822    return getIndexMonitorEntries((LDAPInterface) connection);
823  }
824
825
826
827  /**
828   * Retrieves a list of all index monitor entries available in the Directory
829   * Server.
830   *
831   * @param  connection  The connection to use to communicate with the Directory
832   *                     Server.
833   *
834   * @return  A list of all index monitor entries available in the Directory
835   *          Server.
836   *
837   * @throws  LDAPSearchException  If a problem occurs while communicating with
838   *                               the Directory Server.
839   */
840  @NotNull()
841  public static List<IndexMonitorEntry> getIndexMonitorEntries(
842              @NotNull final LDAPInterface connection)
843         throws LDAPSearchException
844  {
845    final Filter filter = Filter.createEqualityFilter("objectClass",
846                         IndexMonitorEntry.INDEX_MONITOR_OC);
847
848    final SearchResult searchResult =
849         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
850                           filter);
851
852    final ArrayList<IndexMonitorEntry> monitorEntries =
853         new ArrayList<>(searchResult.getEntryCount());
854    for (final SearchResultEntry e : searchResult.getSearchEntries())
855    {
856      monitorEntries.add(new IndexMonitorEntry(e));
857    }
858
859    return Collections.unmodifiableList(monitorEntries);
860  }
861
862
863
864  /**
865   * Retrieves a list of all indicator gauge monitor entries available in the
866   * Directory Server.
867   *
868   * @param  connection  The connection to use to communicate with the Directory
869   *                     Server.
870   *
871   * @return  A list of all indicator gauge monitor entries available in the
872   *          Directory Server.
873   *
874   * @throws  LDAPSearchException  If a problem occurs while communicating with
875   *                               the Directory Server.
876   */
877  @NotNull()
878  public static List<IndicatorGaugeMonitorEntry>
879              getIndicatorGaugeMonitorEntries(
880                   @NotNull final LDAPInterface connection)
881         throws LDAPSearchException
882  {
883    final Filter filter = Filter.createEqualityFilter("objectClass",
884         GaugeMonitorEntry.GAUGE_MONITOR_OC);
885
886    final SearchResult searchResult =
887         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
888                           filter);
889
890    final ArrayList<IndicatorGaugeMonitorEntry> monitorEntries =
891         new ArrayList<>(searchResult.getEntryCount());
892    for (final SearchResultEntry e : searchResult.getSearchEntries())
893    {
894      monitorEntries.add(new IndicatorGaugeMonitorEntry(e));
895    }
896
897    return Collections.unmodifiableList(monitorEntries);
898  }
899
900
901
902  /**
903   * Retrieves a list of all JE environment monitor entries available in the
904   * Directory Server.
905   *
906   * @param  connection  The connection to use to communicate with the Directory
907   *                     Server.
908   *
909   * @return  A list of all JE environment monitor entries available in the
910   *          Directory Server.
911   *
912   * @throws  LDAPSearchException  If a problem occurs while communicating with
913   *                               the Directory Server.
914   */
915  @NotNull()
916  public static List<JEEnvironmentMonitorEntry> getJEEnvironmentMonitorEntries(
917              @NotNull final LDAPConnection connection)
918         throws LDAPSearchException
919  {
920    return getJEEnvironmentMonitorEntries((LDAPInterface) connection);
921  }
922
923
924
925  /**
926   * Retrieves a list of all JE environment monitor entries available in the
927   * Directory Server.
928   *
929   * @param  connection  The connection to use to communicate with the Directory
930   *                     Server.
931   *
932   * @return  A list of all JE environment monitor entries available in the
933   *          Directory Server.
934   *
935   * @throws  LDAPSearchException  If a problem occurs while communicating with
936   *                               the Directory Server.
937   */
938  @NotNull()
939  public static List<JEEnvironmentMonitorEntry> getJEEnvironmentMonitorEntries(
940              @NotNull final LDAPInterface connection)
941         throws LDAPSearchException
942  {
943    final Filter filter = Filter.createEqualityFilter("objectClass",
944                         JEEnvironmentMonitorEntry.JE_ENVIRONMENT_MONITOR_OC);
945
946    final SearchResult searchResult =
947         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
948                           filter);
949
950    final ArrayList<JEEnvironmentMonitorEntry> monitorEntries =
951         new ArrayList<>(searchResult.getEntryCount());
952    for (final SearchResultEntry e : searchResult.getSearchEntries())
953    {
954      monitorEntries.add(new JEEnvironmentMonitorEntry(e));
955    }
956
957    return Collections.unmodifiableList(monitorEntries);
958  }
959
960
961
962  /**
963   * Retrieves a list of all LDAP external server monitor entries available in
964   * the Directory Server.
965   *
966   * @param  connection  The connection to use to communicate with the Directory
967   *                     Server.
968   *
969   * @return  A list of all LDAP external server monitor entries available in
970   *          the Directory Server.
971   *
972   * @throws  LDAPSearchException  If a problem occurs while communicating with
973   *                               the Directory Server.
974   */
975  @NotNull()
976  public static List<LDAPExternalServerMonitorEntry>
977              getLDAPExternalServerMonitorEntries(
978                   @NotNull final LDAPConnection connection)
979         throws LDAPSearchException
980  {
981    return getLDAPExternalServerMonitorEntries((LDAPInterface) connection);
982  }
983
984
985
986  /**
987   * Retrieves a list of all LDAP external server monitor entries available in
988   * the Directory Server.
989   *
990   * @param  connection  The connection to use to communicate with the Directory
991   *                     Server.
992   *
993   * @return  A list of all LDAP external server monitor entries available in
994   *          the Directory Server.
995   *
996   * @throws  LDAPSearchException  If a problem occurs while communicating with
997   *                               the Directory Server.
998   */
999  @NotNull()
1000  public static List<LDAPExternalServerMonitorEntry>
1001              getLDAPExternalServerMonitorEntries(
1002                   @NotNull final LDAPInterface connection)
1003         throws LDAPSearchException
1004  {
1005    final Filter filter = Filter.createEqualityFilter("objectClass",
1006         LDAPExternalServerMonitorEntry.LDAP_EXTERNAL_SERVER_MONITOR_OC);
1007
1008    final SearchResult searchResult =
1009         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
1010                           filter);
1011
1012    final ArrayList<LDAPExternalServerMonitorEntry> monitorEntries =
1013         new ArrayList<>(searchResult.getEntryCount());
1014    for (final SearchResultEntry e : searchResult.getSearchEntries())
1015    {
1016      monitorEntries.add(new LDAPExternalServerMonitorEntry(e));
1017    }
1018
1019    return Collections.unmodifiableList(monitorEntries);
1020  }
1021
1022
1023
1024  /**
1025   * Retrieves a list of all LDAP statistics monitor entries available in the
1026   * Directory Server.
1027   *
1028   * @param  connection  The connection to use to communicate with the Directory
1029   *                     Server.
1030   *
1031   * @return  A list of all LDAP statistics monitor entries available in the
1032   *          Directory Server.
1033   *
1034   * @throws  LDAPSearchException  If a problem occurs while communicating with
1035   *                               the Directory Server.
1036   */
1037  @NotNull()
1038  public static List<LDAPStatisticsMonitorEntry>
1039              getLDAPStatisticsMonitorEntries(
1040                   @NotNull final LDAPConnection connection)
1041         throws LDAPSearchException
1042  {
1043    return getLDAPStatisticsMonitorEntries((LDAPInterface) connection);
1044  }
1045
1046
1047
1048  /**
1049   * Retrieves a list of all LDAP statistics monitor entries available in the
1050   * Directory Server.
1051   *
1052   * @param  connection  The connection to use to communicate with the Directory
1053   *                     Server.
1054   *
1055   * @return  A list of all LDAP statistics monitor entries available in the
1056   *          Directory Server.
1057   *
1058   * @throws  LDAPSearchException  If a problem occurs while communicating with
1059   *                               the Directory Server.
1060   */
1061  @NotNull()
1062  public static List<LDAPStatisticsMonitorEntry>
1063              getLDAPStatisticsMonitorEntries(
1064                   @NotNull final LDAPInterface connection)
1065         throws LDAPSearchException
1066  {
1067    final Filter filter = Filter.createEqualityFilter("objectClass",
1068                         LDAPStatisticsMonitorEntry.LDAP_STATISTICS_MONITOR_OC);
1069
1070    final SearchResult searchResult =
1071         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
1072                           filter);
1073
1074    final ArrayList<LDAPStatisticsMonitorEntry> monitorEntries =
1075         new ArrayList<>(searchResult.getEntryCount());
1076    for (final SearchResultEntry e : searchResult.getSearchEntries())
1077    {
1078      monitorEntries.add(new LDAPStatisticsMonitorEntry(e));
1079    }
1080
1081    return Collections.unmodifiableList(monitorEntries);
1082  }
1083
1084
1085
1086  /**
1087   * Retrieves a list of all load-balancing algorithm monitor entries available
1088   * in the Directory Proxy Server.
1089   *
1090   * @param  connection  The connection to use to communicate with the Directory
1091   *                     Proxy Server.
1092   *
1093   * @return  A list of all load-balancing algorithm monitor entries available
1094   *          in the Directory Proxy Server.
1095   *
1096   * @throws  LDAPSearchException  If a problem occurs while communicating with
1097   *                               the Directory Proxy Server.
1098   */
1099  @NotNull()
1100  public static List<LoadBalancingAlgorithmMonitorEntry>
1101              getLoadBalancingAlgorithmMonitorEntries(
1102                   @NotNull final LDAPConnection connection)
1103         throws LDAPSearchException
1104  {
1105    return getLoadBalancingAlgorithmMonitorEntries((LDAPInterface) connection);
1106  }
1107
1108
1109
1110  /**
1111   * Retrieves a list of all load-balancing algorithm monitor entries available
1112   * in the Directory Proxy Server.
1113   *
1114   * @param  connection  The connection to use to communicate with the Directory
1115   *                     Proxy Server.
1116   *
1117   * @return  A list of all load-balancing algorithm monitor entries available
1118   *          in the Directory Proxy Server.
1119   *
1120   * @throws  LDAPSearchException  If a problem occurs while communicating with
1121   *                               the Directory Proxy Server.
1122   */
1123  @NotNull()
1124  public static List<LoadBalancingAlgorithmMonitorEntry>
1125              getLoadBalancingAlgorithmMonitorEntries(
1126                   @NotNull final LDAPInterface connection)
1127         throws LDAPSearchException
1128  {
1129    final Filter filter = Filter.createEqualityFilter("objectClass",
1130         LoadBalancingAlgorithmMonitorEntry.
1131              LOAD_BALANCING_ALGORITHM_MONITOR_OC);
1132
1133    final SearchResult searchResult =
1134         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
1135                           filter);
1136
1137    final ArrayList<LoadBalancingAlgorithmMonitorEntry> monitorEntries =
1138         new ArrayList<>(searchResult.getEntryCount());
1139    for (final SearchResultEntry e : searchResult.getSearchEntries())
1140    {
1141      monitorEntries.add(new LoadBalancingAlgorithmMonitorEntry(e));
1142    }
1143
1144    return Collections.unmodifiableList(monitorEntries);
1145  }
1146
1147
1148
1149  /**
1150   * Retrieves the memory usage monitor entry from the Directory Server.
1151   *
1152   * @param  connection  The connection to use to communicate with the Directory
1153   *                     Server.
1154   *
1155   * @return  The memory usage monitor entry from the Directory Server, or
1156   *          {@code null} if it is not available.
1157   *
1158   * @throws  LDAPSearchException  If a problem occurs while communicating with
1159   *                               the Directory Server.
1160   */
1161  @Nullable()
1162  public static MemoryUsageMonitorEntry getMemoryUsageMonitorEntry(
1163              @NotNull final LDAPConnection connection)
1164         throws LDAPSearchException
1165  {
1166    return getMemoryUsageMonitorEntry((LDAPInterface) connection);
1167  }
1168
1169
1170
1171  /**
1172   * Retrieves the memory usage monitor entry from the Directory Server.
1173   *
1174   * @param  connection  The connection to use to communicate with the Directory
1175   *                     Server.
1176   *
1177   * @return  The memory usage monitor entry from the Directory Server, or
1178   *          {@code null} if it is not available.
1179   *
1180   * @throws  LDAPSearchException  If a problem occurs while communicating with
1181   *                               the Directory Server.
1182   */
1183  @Nullable()
1184  public static MemoryUsageMonitorEntry getMemoryUsageMonitorEntry(
1185              @NotNull final LDAPInterface connection)
1186         throws LDAPSearchException
1187  {
1188    final Filter filter = Filter.createEqualityFilter("objectClass",
1189                         MemoryUsageMonitorEntry.MEMORY_USAGE_MONITOR_OC);
1190
1191    final SearchResult searchResult =
1192         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
1193                           filter);
1194
1195    final int numEntries = searchResult.getEntryCount();
1196    if (numEntries == 0)
1197    {
1198      Debug.debug(Level.FINE, DebugType.MONITOR,
1199           "No entries returned in getMemoryUsageMonitorEntry");
1200
1201      return null;
1202    }
1203    else if (numEntries != 1)
1204    {
1205      Debug.debug(Level.FINE, DebugType.MONITOR,
1206           "Multiple entries returned in getMemoryUsageMonitorEntry");
1207    }
1208
1209    return new MemoryUsageMonitorEntry(searchResult.getSearchEntries().get(0));
1210  }
1211
1212
1213
1214  /**
1215   * Retrieves a list of all numeric gauge monitor entries available in the
1216   * Directory Server.
1217   *
1218   * @param  connection  The connection to use to communicate with the Directory
1219   *                     Server.
1220   *
1221   * @return  A list of all numeric gauge monitor entries available in the
1222   *          Directory Server.
1223   *
1224   * @throws  LDAPSearchException  If a problem occurs while communicating with
1225   *                               the Directory Server.
1226   */
1227  @NotNull()
1228  public static List<NumericGaugeMonitorEntry>
1229              getNumericGaugeMonitorEntries(
1230                   @NotNull final LDAPInterface connection)
1231         throws LDAPSearchException
1232  {
1233    final Filter filter = Filter.createEqualityFilter("objectClass",
1234         GaugeMonitorEntry.GAUGE_MONITOR_OC);
1235
1236    final SearchResult searchResult =
1237         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
1238                           filter);
1239
1240    final ArrayList<NumericGaugeMonitorEntry> monitorEntries =
1241         new ArrayList<>(searchResult.getEntryCount());
1242    for (final SearchResultEntry e : searchResult.getSearchEntries())
1243    {
1244      monitorEntries.add(new NumericGaugeMonitorEntry(e));
1245    }
1246
1247    return Collections.unmodifiableList(monitorEntries);
1248  }
1249
1250
1251
1252  /**
1253   * Retrieves the per application processing time histogram monitor entries
1254   * from the Directory Server.
1255   *
1256   * @param  connection  The connection to use to communicate with the Directory
1257   *                     Server.
1258   *
1259   * @return  The per application processing time histogram monitor entries from
1260   *          the Directory Server.  If none are available, an empty list is
1261   *          returned.
1262   *
1263   * @throws  LDAPSearchException  If a problem occurs while communicating with
1264   *                               the Directory Server.
1265   */
1266  @NotNull()
1267  public static List<PerApplicationProcessingTimeHistogramMonitorEntry>
1268              getPerApplicationProcessingTimeHistogramMonitorEntries(
1269                   @NotNull final LDAPConnection connection)
1270         throws LDAPSearchException
1271  {
1272    return getPerApplicationProcessingTimeHistogramMonitorEntries(
1273         (LDAPInterface) connection);
1274  }
1275
1276
1277
1278  /**
1279   * Retrieves the per application processing time histogram monitor entries
1280   * from the Directory Server.
1281   *
1282   * @param  connection  The connection to use to communicate with the Directory
1283   *                     Server.
1284   *
1285   * @return  The per application processing time histogram monitor entries from
1286   *          the Directory Server.  If none are available, an empty list is
1287   *          returned.
1288   *
1289   * @throws  LDAPSearchException  If a problem occurs while communicating with
1290   *                               the Directory Server.
1291   */
1292  @NotNull()
1293  public static List<PerApplicationProcessingTimeHistogramMonitorEntry>
1294              getPerApplicationProcessingTimeHistogramMonitorEntries(
1295                   @NotNull final LDAPInterface connection)
1296         throws LDAPSearchException
1297  {
1298    final Filter filter = Filter.createEqualityFilter("objectClass",
1299         PerApplicationProcessingTimeHistogramMonitorEntry.
1300              PER_APPLICATION_PROCESSING_TIME_HISTOGRAM_MONITOR_OC);
1301
1302    final SearchResult searchResult =
1303         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
1304                           filter);
1305
1306    final int numEntries = searchResult.getEntryCount();
1307    if (numEntries == 0)
1308    {
1309      Debug.debug(Level.FINE, DebugType.MONITOR,
1310           "No entries returned in " +
1311                "getPerApplicationProcessingTimeHistogramMonitorEntries");
1312
1313      return Collections.emptyList();
1314    }
1315
1316    final List<PerApplicationProcessingTimeHistogramMonitorEntry> entries =
1317         new ArrayList<>(searchResult.getEntryCount());
1318
1319    for (final Entry entry: searchResult.getSearchEntries())
1320    {
1321      entries.add(new PerApplicationProcessingTimeHistogramMonitorEntry(entry));
1322    }
1323
1324    return entries;
1325  }
1326
1327
1328
1329  /**
1330   * Retrieves the processing time histogram monitor entry from the Directory
1331   * Server.
1332   *
1333   * @param  connection  The connection to use to communicate with the Directory
1334   *                     Server.
1335   *
1336   * @return  The processing time histogram monitor entry from the Directory
1337   *          Server, or {@code null} if it is not available.
1338   *
1339   * @throws  LDAPSearchException  If a problem occurs while communicating with
1340   *                               the Directory Server.
1341   */
1342  @Nullable()
1343  public static ProcessingTimeHistogramMonitorEntry
1344              getProcessingTimeHistogramMonitorEntry(
1345                   @NotNull final LDAPConnection connection)
1346         throws LDAPSearchException
1347  {
1348    return getProcessingTimeHistogramMonitorEntry((LDAPInterface) connection);
1349  }
1350
1351
1352
1353  /**
1354   * Retrieves the processing time histogram monitor entry from the Directory
1355   * Server.
1356   *
1357   * @param  connection  The connection to use to communicate with the Directory
1358   *                     Server.
1359   *
1360   * @return  The processing time histogram monitor entry from the Directory
1361   *          Server, or {@code null} if it is not available.
1362   *
1363   * @throws  LDAPSearchException  If a problem occurs while communicating with
1364   *                               the Directory Server.
1365   */
1366  @Nullable()
1367  public static ProcessingTimeHistogramMonitorEntry
1368              getProcessingTimeHistogramMonitorEntry(
1369                   @NotNull final LDAPInterface connection)
1370         throws LDAPSearchException
1371  {
1372    final Filter filter = Filter.createEqualityFilter("objectClass",
1373                         ProcessingTimeHistogramMonitorEntry.
1374                              PROCESSING_TIME_HISTOGRAM_MONITOR_OC);
1375
1376    final SearchResult searchResult =
1377         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
1378                           filter);
1379
1380    final int numEntries = searchResult.getEntryCount();
1381    if (numEntries == 0)
1382    {
1383      Debug.debug(Level.FINE, DebugType.MONITOR,
1384           "No entries returned in getProcessingTimeHistogramMonitorEntry");
1385
1386      return null;
1387    }
1388    else if (numEntries != 1)
1389    {
1390      Debug.debug(Level.FINE, DebugType.MONITOR,
1391           "Multiple entries returned in " +
1392                "getProcessingTimeHistogramMonitorEntry");
1393    }
1394
1395    return new ProcessingTimeHistogramMonitorEntry(
1396                    searchResult.getSearchEntries().get(0));
1397  }
1398
1399
1400
1401  /**
1402   * Retrieves a list of all replica monitor entries available in the Directory
1403   * Server.
1404   *
1405   * @param  connection  The connection to use to communicate with the Directory
1406   *                     Server.
1407   *
1408   * @return  A list of all replica monitor entries available in the Directory
1409   *          Server.
1410   *
1411   * @throws  LDAPSearchException  If a problem occurs while communicating with
1412   *                               the Directory Server.
1413   */
1414  @NotNull()
1415  public static List<ReplicaMonitorEntry> getReplicaMonitorEntries(
1416              @NotNull final LDAPConnection connection)
1417         throws LDAPSearchException
1418  {
1419    return getReplicaMonitorEntries((LDAPInterface) connection);
1420  }
1421
1422
1423
1424  /**
1425   * Retrieves a list of all replica monitor entries available in the Directory
1426   * Server.
1427   *
1428   * @param  connection  The connection to use to communicate with the Directory
1429   *                     Server.
1430   *
1431   * @return  A list of all replica monitor entries available in the Directory
1432   *          Server.
1433   *
1434   * @throws  LDAPSearchException  If a problem occurs while communicating with
1435   *                               the Directory Server.
1436   */
1437  @NotNull()
1438  public static List<ReplicaMonitorEntry> getReplicaMonitorEntries(
1439              @NotNull final LDAPInterface connection)
1440         throws LDAPSearchException
1441  {
1442    final Filter filter = Filter.createEqualityFilter("objectClass",
1443         ReplicaMonitorEntry.REPLICA_MONITOR_OC);
1444
1445    final SearchResult searchResult =
1446         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
1447                           filter);
1448
1449    final ArrayList<ReplicaMonitorEntry> monitorEntries =
1450         new ArrayList<>(searchResult.getEntryCount());
1451    for (final SearchResultEntry e : searchResult.getSearchEntries())
1452    {
1453      monitorEntries.add(new ReplicaMonitorEntry(e));
1454    }
1455
1456    return Collections.unmodifiableList(monitorEntries);
1457  }
1458
1459
1460
1461  /**
1462   * Retrieves the replication server monitor entry from the Directory Server.
1463   *
1464   * @param  connection  The connection to use to communicate with the Directory
1465   *                     Server.
1466   *
1467   * @return  The replication server monitor entry from the Directory Server, or
1468   *          {@code null} if it is not available.
1469   *
1470   * @throws  LDAPSearchException  If a problem occurs while communicating with
1471   *                               the Directory Server.
1472   */
1473  @Nullable()
1474  public static ReplicationServerMonitorEntry getReplicationServerMonitorEntry(
1475              @NotNull final LDAPConnection connection)
1476         throws LDAPSearchException
1477  {
1478    return getReplicationServerMonitorEntry((LDAPInterface) connection);
1479  }
1480
1481
1482
1483  /**
1484   * Retrieves the replication server monitor entry from the Directory Server.
1485   *
1486   * @param  connection  The connection to use to communicate with the Directory
1487   *                     Server.
1488   *
1489   * @return  The replication server monitor entry from the Directory Server, or
1490   *          {@code null} if it is not available.
1491   *
1492   * @throws  LDAPSearchException  If a problem occurs while communicating with
1493   *                               the Directory Server.
1494   */
1495  @Nullable()
1496  public static ReplicationServerMonitorEntry getReplicationServerMonitorEntry(
1497              @NotNull final LDAPInterface connection)
1498         throws LDAPSearchException
1499  {
1500    final Filter filter = Filter.createEqualityFilter("objectClass",
1501         ReplicationServerMonitorEntry.REPLICATION_SERVER_MONITOR_OC);
1502
1503    final SearchResult searchResult =
1504         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
1505                           filter);
1506
1507    final int numEntries = searchResult.getEntryCount();
1508    if (numEntries == 0)
1509    {
1510      Debug.debug(Level.FINE, DebugType.MONITOR,
1511           "No entries returned in getReplicationServerMonitorEntry");
1512
1513      return null;
1514    }
1515    else if (numEntries != 1)
1516    {
1517      Debug.debug(Level.FINE, DebugType.MONITOR,
1518           "Multiple entries returned in " +
1519                "getReplicationServerMonitorEntry");
1520    }
1521
1522    return new ReplicationServerMonitorEntry(
1523                    searchResult.getSearchEntries().get(0));
1524  }
1525
1526
1527
1528  /**
1529   * Retrieves a list of all replication summary monitor entries available in
1530   * the Directory Server.
1531   *
1532   * @param  connection  The connection to use to communicate with the Directory
1533   *                     Server.
1534   *
1535   * @return  A list of all replication summary monitor entries available in the
1536   *          Directory Server.
1537   *
1538   * @throws  LDAPSearchException  If a problem occurs while communicating with
1539   *                               the Directory Server.
1540   */
1541  @NotNull()
1542  public static List<ReplicationSummaryMonitorEntry>
1543              getReplicationSummaryMonitorEntries(
1544                   @NotNull final LDAPConnection connection)
1545         throws LDAPSearchException
1546  {
1547    return getReplicationSummaryMonitorEntries((LDAPInterface) connection);
1548  }
1549
1550
1551
1552  /**
1553   * Retrieves a list of all replication summary monitor entries available in
1554   * the Directory Server.
1555   *
1556   * @param  connection  The connection to use to communicate with the Directory
1557   *                     Server.
1558   *
1559   * @return  A list of all replication summary monitor entries available in the
1560   *          Directory Server.
1561   *
1562   * @throws  LDAPSearchException  If a problem occurs while communicating with
1563   *                               the Directory Server.
1564   */
1565  @NotNull()
1566  public static List<ReplicationSummaryMonitorEntry>
1567              getReplicationSummaryMonitorEntries(
1568                   @NotNull final LDAPInterface connection)
1569         throws LDAPSearchException
1570  {
1571    final Filter filter = Filter.createEqualityFilter("objectClass",
1572         ReplicationSummaryMonitorEntry.REPLICATION_SUMMARY_MONITOR_OC);
1573
1574    final SearchResult searchResult =
1575         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
1576                           filter);
1577
1578    final ArrayList<ReplicationSummaryMonitorEntry> monitorEntries =
1579         new ArrayList<>(searchResult.getEntryCount());
1580    for (final SearchResultEntry e : searchResult.getSearchEntries())
1581    {
1582      monitorEntries.add(new ReplicationSummaryMonitorEntry(e));
1583    }
1584
1585    return Collections.unmodifiableList(monitorEntries);
1586  }
1587
1588
1589
1590  /**
1591   * Retrieves the result code monitor entry from the Directory Server.
1592   *
1593   * @param  connection  The connection to use to communicate with the Directory
1594   *                     Server.
1595   *
1596   * @return  The result code monitor entry from the Directory Server, or
1597   *          {@code null} if it is not available.
1598   *
1599   * @throws  LDAPSearchException  If a problem occurs while communicating with
1600   *                               the Directory Server.
1601   */
1602  @Nullable()
1603  public static ResultCodeMonitorEntry getResultCodeMonitorEntry(
1604              @NotNull final LDAPInterface connection)
1605         throws LDAPSearchException
1606  {
1607    final Filter filter = Filter.createEqualityFilter("objectClass",
1608         ResultCodeMonitorEntry.RESULT_CODE_MONITOR_OC);
1609
1610    final SearchResult searchResult = connection.search(
1611         MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB, filter);
1612
1613    final int numEntries = searchResult.getEntryCount();
1614    if (numEntries == 0)
1615    {
1616      Debug.debug(Level.FINE, DebugType.MONITOR,
1617           "No entries returned in getResultCodeMonitorEntry");
1618
1619      return null;
1620    }
1621    else if (numEntries != 1)
1622    {
1623      Debug.debug(Level.FINE, DebugType.MONITOR,
1624           "Multiple entries returned in getResultCodeMonitorEntry");
1625    }
1626
1627    return new ResultCodeMonitorEntry(searchResult.getSearchEntries().get(0));
1628  }
1629
1630
1631
1632  /**
1633   * Retrieves the system info monitor entry from the Directory Server.
1634   *
1635   * @param  connection  The connection to use to communicate with the Directory
1636   *                     Server.
1637   *
1638   * @return  The system info monitor entry from the Directory Server, or
1639   *          {@code null} if it is not available.
1640   *
1641   * @throws  LDAPSearchException  If a problem occurs while communicating with
1642   *                               the Directory Server.
1643   */
1644  @Nullable()
1645  public static SystemInfoMonitorEntry getSystemInfoMonitorEntry(
1646              @NotNull final LDAPConnection connection)
1647         throws LDAPSearchException
1648  {
1649    return getSystemInfoMonitorEntry((LDAPInterface) connection);
1650  }
1651
1652
1653
1654  /**
1655   * Retrieves the system info monitor entry from the Directory Server.
1656   *
1657   * @param  connection  The connection to use to communicate with the Directory
1658   *                     Server.
1659   *
1660   * @return  The system info monitor entry from the Directory Server, or
1661   *          {@code null} if it is not available.
1662   *
1663   * @throws  LDAPSearchException  If a problem occurs while communicating with
1664   *                               the Directory Server.
1665   */
1666  @Nullable()
1667  public static SystemInfoMonitorEntry getSystemInfoMonitorEntry(
1668              @NotNull final LDAPInterface connection)
1669         throws LDAPSearchException
1670  {
1671    final Filter filter = Filter.createEqualityFilter("objectClass",
1672                         SystemInfoMonitorEntry.SYSTEM_INFO_MONITOR_OC);
1673
1674    final SearchResult searchResult =
1675         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
1676                           filter);
1677
1678    final int numEntries = searchResult.getEntryCount();
1679    if (numEntries == 0)
1680    {
1681      Debug.debug(Level.FINE, DebugType.MONITOR,
1682           "No entries returned in getSystemInfoMonitorEntry");
1683
1684      return null;
1685    }
1686    else if (numEntries != 1)
1687    {
1688      Debug.debug(Level.FINE, DebugType.MONITOR,
1689           "Multiple entries returned in getSystemInfoMonitorEntry");
1690    }
1691
1692    return new SystemInfoMonitorEntry(searchResult.getSearchEntries().get(0));
1693  }
1694
1695
1696
1697  /**
1698   * Retrieves the stack trace monitor entry from the Directory Server.
1699   *
1700   * @param  connection  The connection to use to communicate with the Directory
1701   *                     Server.
1702   *
1703   * @return  The stack trace monitor entry from the Directory Server, or
1704   *          {@code null} if it is not available.
1705   *
1706   * @throws  LDAPSearchException  If a problem occurs while communicating with
1707   *                               the Directory Server.
1708   */
1709  @Nullable()
1710  public static StackTraceMonitorEntry getStackTraceMonitorEntry(
1711              @NotNull final LDAPConnection connection)
1712         throws LDAPSearchException
1713  {
1714    return getStackTraceMonitorEntry((LDAPInterface) connection);
1715  }
1716
1717
1718
1719  /**
1720   * Retrieves the stack trace monitor entry from the Directory Server.
1721   *
1722   * @param  connection  The connection to use to communicate with the Directory
1723   *                     Server.
1724   *
1725   * @return  The stack trace monitor entry from the Directory Server, or
1726   *          {@code null} if it is not available.
1727   *
1728   * @throws  LDAPSearchException  If a problem occurs while communicating with
1729   *                               the Directory Server.
1730   */
1731  @Nullable()
1732  public static StackTraceMonitorEntry getStackTraceMonitorEntry(
1733              @NotNull final LDAPInterface connection)
1734         throws LDAPSearchException
1735  {
1736    final Filter filter = Filter.createEqualityFilter("objectClass",
1737                         StackTraceMonitorEntry.STACK_TRACE_MONITOR_OC);
1738
1739    final SearchResult searchResult =
1740         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
1741                           filter);
1742
1743    final int numEntries = searchResult.getEntryCount();
1744    if (numEntries == 0)
1745    {
1746      Debug.debug(Level.FINE, DebugType.MONITOR,
1747           "No entries returned in getStackTraceMonitorEntry");
1748
1749      return null;
1750    }
1751    else if (numEntries != 1)
1752    {
1753      Debug.debug(Level.FINE, DebugType.MONITOR,
1754           "Multiple entries returned in getStackTraceMonitorEntry");
1755    }
1756
1757    return new StackTraceMonitorEntry(searchResult.getSearchEntries().get(0));
1758  }
1759
1760
1761
1762  /**
1763   * Retrieves the traditional work queue monitor entry from the Directory
1764   * Server.
1765   *
1766   * @param  connection  The connection to use to communicate with the Directory
1767   *                     Server.
1768   *
1769   * @return  The traditional work queue monitor entry from the Directory
1770   *          Server, or {@code null} if it is not available.
1771   *
1772   * @throws  LDAPSearchException  If a problem occurs while communicating with
1773   *                               the Directory Server.
1774   */
1775  @Nullable()
1776  public static TraditionalWorkQueueMonitorEntry
1777              getTraditionalWorkQueueMonitorEntry(
1778                   @NotNull final LDAPConnection connection)
1779         throws LDAPSearchException
1780  {
1781    return getTraditionalWorkQueueMonitorEntry((LDAPInterface) connection);
1782  }
1783
1784
1785
1786  /**
1787   * Retrieves the traditional work queue monitor entry from the Directory
1788   * Server.
1789   *
1790   * @param  connection  The connection to use to communicate with the Directory
1791   *                     Server.
1792   *
1793   * @return  The traditional work queue monitor entry from the Directory
1794   *          Server, or {@code null} if it is not available.
1795   *
1796   * @throws  LDAPSearchException  If a problem occurs while communicating with
1797   *                               the Directory Server.
1798   */
1799  @Nullable()
1800  public static TraditionalWorkQueueMonitorEntry
1801              getTraditionalWorkQueueMonitorEntry(
1802                   @NotNull final LDAPInterface connection)
1803         throws LDAPSearchException
1804  {
1805    final Filter filter = Filter.createEqualityFilter("objectClass",
1806         TraditionalWorkQueueMonitorEntry.TRADITIONAL_WORK_QUEUE_MONITOR_OC);
1807
1808    final SearchResult searchResult =
1809         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
1810                           filter);
1811
1812    final int numEntries = searchResult.getEntryCount();
1813    if (numEntries == 0)
1814    {
1815      Debug.debug(Level.FINE, DebugType.MONITOR,
1816           "No entries returned in getTraditionalWorkQueueMonitorEntry");
1817
1818      return null;
1819    }
1820    else if (numEntries != 1)
1821    {
1822      Debug.debug(Level.FINE, DebugType.MONITOR,
1823           "Multiple entries returned in getTraditionalWorkQueueMonitorEntry");
1824    }
1825
1826    return new TraditionalWorkQueueMonitorEntry(
1827                    searchResult.getSearchEntries().get(0));
1828  }
1829
1830
1831
1832  /**
1833   * Retrieves the UnboundID work queue monitor entry from the Directory Server.
1834   *
1835   * @param  connection  The connection to use to communicate with the Directory
1836   *                     Server.
1837   *
1838   * @return  The UnboundID work queue monitor entry from the Directory Server,
1839   *          or {@code null} if it is not available.
1840   *
1841   * @throws  LDAPSearchException  If a problem occurs while communicating with
1842   *                               the Directory Server.
1843   */
1844  @Nullable()
1845  public static UnboundIDWorkQueueMonitorEntry
1846              getUnboundIDWorkQueueMonitorEntry(
1847                   @NotNull final LDAPConnection connection)
1848         throws LDAPSearchException
1849  {
1850    return getUnboundIDWorkQueueMonitorEntry((LDAPInterface) connection);
1851  }
1852
1853
1854
1855  /**
1856   * Retrieves the UnboundID work queue monitor entry from the Directory Server.
1857   *
1858   * @param  connection  The connection to use to communicate with the Directory
1859   *                     Server.
1860   *
1861   * @return  The UnboundID work queue monitor entry from the Directory Server,
1862   *          or {@code null} if it is not available.
1863   *
1864   * @throws  LDAPSearchException  If a problem occurs while communicating with
1865   *                               the Directory Server.
1866   */
1867  @Nullable()
1868  public static UnboundIDWorkQueueMonitorEntry
1869              getUnboundIDWorkQueueMonitorEntry(
1870                   @NotNull final LDAPInterface connection)
1871         throws LDAPSearchException
1872  {
1873    final Filter filter = Filter.createEqualityFilter("objectClass",
1874         UnboundIDWorkQueueMonitorEntry.UNBOUNDID_WORK_QUEUE_MONITOR_OC);
1875
1876    final SearchResult searchResult =
1877         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
1878                           filter);
1879
1880    final int numEntries = searchResult.getEntryCount();
1881    if (numEntries == 0)
1882    {
1883      Debug.debug(Level.FINE, DebugType.MONITOR,
1884           "No entries returned in getUnboundIDWorkQueueMonitorEntry");
1885
1886      return null;
1887    }
1888    else if (numEntries != 1)
1889    {
1890      Debug.debug(Level.FINE, DebugType.MONITOR,
1891           "Multiple entries returned in getUnboundIDWorkQueueMonitorEntry");
1892    }
1893
1894    return new UnboundIDWorkQueueMonitorEntry(
1895                    searchResult.getSearchEntries().get(0));
1896  }
1897
1898
1899
1900  /**
1901   * Retrieves the version monitor entry from the Directory Server.
1902   *
1903   * @param  connection  The connection to use to communicate with the Directory
1904   *                     Server.
1905   *
1906   * @return  The version monitor entry from the Directory Server, or
1907   *          {@code null} if it is not available.
1908   *
1909   * @throws  LDAPSearchException  If a problem occurs while communicating with
1910   *                               the Directory Server.
1911   */
1912  @Nullable()
1913  public static VersionMonitorEntry getVersionMonitorEntry(
1914              @NotNull final LDAPConnection connection)
1915         throws LDAPSearchException
1916  {
1917    return getVersionMonitorEntry((LDAPInterface) connection);
1918  }
1919
1920
1921
1922  /**
1923   * Retrieves the version monitor entry from the Directory Server.
1924   *
1925   * @param  connection  The connection to use to communicate with the Directory
1926   *                     Server.
1927   *
1928   * @return  The version monitor entry from the Directory Server, or
1929   *          {@code null} if it is not available.
1930   *
1931   * @throws  LDAPSearchException  If a problem occurs while communicating with
1932   *                               the Directory Server.
1933   */
1934  @Nullable()
1935  public static VersionMonitorEntry getVersionMonitorEntry(
1936              @NotNull final LDAPInterface connection)
1937         throws LDAPSearchException
1938  {
1939    final Filter filter = Filter.createEqualityFilter("objectClass",
1940         VersionMonitorEntry.VERSION_MONITOR_OC);
1941
1942    final SearchResult searchResult =
1943         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
1944                           filter);
1945
1946    final int numEntries = searchResult.getEntryCount();
1947    if (numEntries == 0)
1948    {
1949      Debug.debug(Level.FINE, DebugType.MONITOR,
1950           "No entries returned in getVersionMonitorEntry");
1951
1952      return null;
1953    }
1954    else if (numEntries != 1)
1955    {
1956      Debug.debug(Level.FINE, DebugType.MONITOR,
1957           "Multiple entries returned in getVersionMonitorEntry");
1958    }
1959
1960    return new VersionMonitorEntry(searchResult.getSearchEntries().get(0));
1961  }
1962
1963
1964
1965  /**
1966   * Retrieves a list of all X.509 certificate monitor entries available in the
1967   * Directory Server.
1968   *
1969   * @param  connection  The connection to use to communicate with the Directory
1970   *                     Server.
1971   *
1972   * @return  A list of all X.509 certificate monitor entries available in the
1973   *          Directory Server.
1974   *
1975   * @throws  LDAPSearchException  If a problem occurs while communicating with
1976   *                               the Directory Server.
1977   */
1978  @NotNull()
1979  public static List<X509CertificateMonitorEntry>
1980              getX509CertificateMonitorEntries(
1981                   @NotNull final LDAPConnection connection)
1982         throws LDAPSearchException
1983  {
1984    return getX509CertificateMonitorEntries((LDAPInterface) connection);
1985  }
1986
1987
1988
1989  /**
1990   * Retrieves a list of all X.509 certificate monitor entries available in the
1991   * Directory Server.
1992   *
1993   * @param  connection  The connection to use to communicate with the Directory
1994   *                     Server.
1995   *
1996   * @return  A list of all X.509 certificate monitor entries available in the
1997   *          Directory Server.
1998   *
1999   * @throws  LDAPSearchException  If a problem occurs while communicating with
2000   *                               the Directory Server.
2001   */
2002  @NotNull()
2003  public static List<X509CertificateMonitorEntry>
2004              getX509CertificateMonitorEntries(
2005                   @NotNull final LDAPInterface connection)
2006         throws LDAPSearchException
2007  {
2008    final Filter filter = Filter.createEqualityFilter("objectClass",
2009         X509CertificateMonitorEntry.X509_CERTIFICATE_MONITOR_OC);
2010
2011    final SearchResult searchResult =
2012         connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB,
2013                           filter);
2014
2015    final ArrayList<X509CertificateMonitorEntry> monitorEntries =
2016         new ArrayList<>(searchResult.getEntryCount());
2017    for (final SearchResultEntry e : searchResult.getSearchEntries())
2018    {
2019      monitorEntries.add(new X509CertificateMonitorEntry(e));
2020    }
2021
2022    return Collections.unmodifiableList(monitorEntries);
2023  }
2024}