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