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