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