001 /*
002 * Copyright 2008-2015 UnboundID Corp.
003 * All Rights Reserved.
004 */
005 /*
006 * Copyright (C) 2015 UnboundID Corp.
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 */
021 package com.unboundid.ldap.sdk.unboundidds.monitors;
022
023
024
025 import java.util.ArrayList;
026 import java.util.Collections;
027 import java.util.Date;
028 import java.util.LinkedHashMap;
029 import java.util.Map;
030
031 import com.unboundid.ldap.sdk.Attribute;
032 import com.unboundid.ldap.sdk.Entry;
033 import com.unboundid.util.NotMutable;
034 import com.unboundid.util.ThreadSafety;
035 import com.unboundid.util.ThreadSafetyLevel;
036
037 import static com.unboundid.ldap.sdk.unboundidds.monitors.MonitorMessages.*;
038 import static com.unboundid.util.StaticUtils.*;
039
040
041
042 /**
043 * <BLOCKQUOTE>
044 * <B>NOTE:</B> This class is part of the Commercial Edition of the UnboundID
045 * LDAP SDK for Java. It is not available for use in applications that
046 * include only the Standard Edition of the LDAP SDK, and is not supported for
047 * use in conjunction with non-UnboundID products.
048 * </BLOCKQUOTE>
049 * This class defines a monitor entry that provides basic information about the
050 * Berkeley DB Java Edition environment in use for a backend. The information
051 * that is provided includes:
052 * <UL>
053 * <LI>The backend ID for the associated backend.</LI>
054 * <LI>The version string for the Berkeley DB Java Edition library.</LI>
055 * <LI>The path to the directory containing the database environment
056 * files.</LI>
057 * <LI>The amount of space consumed by the database files.</LI>
058 * <LI>The amount of memory currently consumed by the database cache.</LI>
059 * <LI>The maximum amount of memory that may be consumed by the database
060 * cache.</LI>
061 * <LI>The percent of the total memory allowed for the database cache that is
062 * currently in use.</LI>
063 * <LI>Whether a checkpoint is currently in progress.</LI>
064 * <LI>The total number of checkpoints that have been completed.</LI>
065 * <LI>The time that the last completed checkpoint began.</LI>
066 * <LI>The time that the last completed checkpoint ended.</LI>
067 * <LI>The total duration of all checkpoints completed.</LI>
068 * <LI>The average duration of all checkpoints completed.</LI>
069 * <LI>The duration of the last checkpoint completed.</LI>
070 * <LI>The length of time since the last checkpoint.</LI>
071 * <LI>The number of log files that the cleaner needs to examine.</LI>
072 * <LI>The number of nodes evicted from the database cache.</LI>
073 * <LI>The number of random-access disk reads performed.</LI>
074 * <LI>The number of random-access disk writes performed.</LI>
075 * <LI>The number of sequential disk reads performed.</LI>
076 * <LI>The number of sequential disk writes performed.</LI>
077 * <LI>The number of active transactions in the database environment.</LI>
078 * <LI>The number of read locks held in the database environment.</LI>
079 * <LI>The number of write locks held in the database environment.</LI>
080 * <LI>The number of transactions waiting on locks.</LI>
081 * <LI>A set of generic statistics about the database environment.</LI>
082 * <LI>A set of generic statistics about the lock subsystem for the database
083 * environment.</LI>
084 * <LI>A set of generic statistics about the transaction subsystem for the
085 * database environment.</LI>
086 * </UL>
087 * The JE environment monitor entries provided by the server can be
088 * retrieved using the {@link MonitorManager#getJEEnvironmentMonitorEntries}
089 * method. These entries provide specific methods for accessing information
090 * about the JE environment (e.g., the
091 * {@link JEEnvironmentMonitorEntry#getJEVersion} method can be used to retrieve
092 * the Berkeley DB JE version). Alternately, this information may be accessed
093 * using the generic API. See the {@link MonitorManager} class documentation
094 * for an example that demonstrates the use of the generic API for accessing
095 * monitor data.
096 */
097 @NotMutable()
098 @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
099 public final class JEEnvironmentMonitorEntry
100 extends MonitorEntry
101 {
102 /**
103 * The structural object class used in JE environment monitor entries.
104 */
105 static final String JE_ENVIRONMENT_MONITOR_OC =
106 "ds-je-environment-monitor-entry";
107
108
109
110 /**
111 * The name of the attribute that contains the number of active transactions.
112 */
113 private static final String ATTR_ACTIVE_TXNS = "active-transaction-count";
114
115
116
117 /**
118 * The name of the attribute that contains the average duration of the all
119 * checkpoints in milliseconds.
120 */
121 private static final String ATTR_AVERAGE_CHECKPOINT_DURATION_MILLIS =
122 "average-checkpoint-duration-millis";
123
124
125
126 /**
127 * The name of the attribute that contains the backend ID for the associated
128 * backend.
129 */
130 private static final String ATTR_BACKEND_ID = "backend-id";
131
132
133
134 /**
135 * The name of the attribute that contains the DB cache percent full.
136 */
137 private static final String ATTR_CACHE_PCT_FULL = "db-cache-percent-full";
138
139
140
141 /**
142 * The name of the attribute that indicates whether a checkpoint is currently
143 * in progress.
144 */
145 private static final String ATTR_CHECKPOINT_IN_PROGRESS =
146 "checkpoint-in-progress";
147
148
149
150 /**
151 * The name of the attribute that contains the cleaner backlog.
152 */
153 private static final String ATTR_CLEANER_BACKLOG = "cleaner-backlog";
154
155
156
157 /**
158 * The name of the attribute that contains the current DB cache size.
159 */
160 private static final String ATTR_CURRENT_CACHE_SIZE = "current-db-cache-size";
161
162
163
164 /**
165 * The name of the attribute that contains the path to the DB directory.
166 */
167 private static final String ATTR_DB_DIRECTORY = "db-directory";
168
169
170
171 /**
172 * The name of the attribute that contains the DB on-disk size.
173 */
174 private static final String ATTR_DB_ON_DISK_SIZE = "db-on-disk-size";
175
176
177
178 /**
179 * The name of the attribute that contains the Berkeley DB JE version string.
180 */
181 private static final String ATTR_JE_VERSION = "je-version";
182
183
184
185 /**
186 * The name of the attribute that contains the duration of the last checkpoint
187 * in milliseconds.
188 */
189 private static final String ATTR_LAST_CHECKPOINT_DURATION_MILLIS =
190 "last-checkpoint-duration-millis";
191
192
193
194 /**
195 * The name of the attribute that contains the time the last checkpoint began.
196 */
197 private static final String ATTR_LAST_CHECKPOINT_START_TIME =
198 "last-checkpoint-start-time";
199
200
201
202 /**
203 * The name of the attribute that contains the time the last checkpoint ended.
204 */
205 private static final String ATTR_LAST_CHECKPOINT_STOP_TIME =
206 "last-checkpoint-stop-time";
207
208
209
210 /**
211 * The name of the attribute that contains the time of the last checkpoint.
212 *
213 * @deprecated Use {@link #ATTR_LAST_CHECKPOINT_STOP_TIME} instead.
214 */
215 @Deprecated()
216 private static final String ATTR_LAST_CHECKPOINT_TIME =
217 "last-checkpoint-time";
218
219
220
221 /**
222 * The name of the attribute that contains the maximum cache size.
223 */
224 private static final String ATTR_MAX_CACHE_SIZE = "max-db-cache-size";
225
226
227
228 /**
229 * The name of the attribute that contains the length of time in milliseconds
230 * since the last checkpoint.
231 */
232 private static final String ATTR_MILLIS_SINCE_LAST_CHECKPOINT =
233 "millis-since-last-checkpoint";
234
235
236
237 /**
238 * The name of the attribute that contains the number of nodes evicted from
239 * the cache.
240 */
241 private static final String ATTR_NODES_EVICTED = "nodes-evicted";
242
243
244
245 /**
246 * The name of the attribute that contains the number of checkpoints
247 * processed.
248 */
249 private static final String ATTR_NUM_CHECKPOINTS = "num-checkpoints";
250
251
252
253 /**
254 * The name of the attribute that contains the number of read locks held.
255 */
256 private static final String ATTR_NUM_READ_LOCKS = "read-locks-held";
257
258
259
260 /**
261 * The name of the attribute that contains the total duration of the all
262 * checkpoints in milliseconds.
263 */
264 private static final String ATTR_TOTAL_CHECKPOINT_DURATION_MILLIS =
265 "total-checkpoint-duration-millis";
266
267
268
269 /**
270 * The name of the attribute that contains the number of transactions waiting
271 * on locks.
272 */
273 private static final String ATTR_NUM_WAITING_TXNS =
274 "transactions-waiting-on-locks";
275
276
277
278 /**
279 * The name of the attribute that contains the number of write locks held.
280 */
281 private static final String ATTR_NUM_WRITE_LOCKS = "write-locks-held";
282
283
284
285 /**
286 * The name of the attribute that contains the number of random reads.
287 */
288 private static final String ATTR_RANDOM_READS = "random-read-count";
289
290
291
292 /**
293 * The name of the attribute that contains the number of random writes.
294 */
295 private static final String ATTR_RANDOM_WRITES = "random-write-count";
296
297
298
299 /**
300 * The name of the attribute that contains the number of sequential reads.
301 */
302 private static final String ATTR_SEQUENTIAL_READS = "sequential-read-count";
303
304
305
306 /**
307 * The name of the attribute that contains the number of sequential writes.
308 */
309 private static final String ATTR_SEQUENTIAL_WRITES = "sequential-write-count";
310
311
312
313 /**
314 * The prefix that will be used for attribute names that contain generic
315 * environment statistics.
316 */
317 private static final String ATTR_PREFIX_ENV_STAT = "je-env-stat-";
318
319
320
321 /**
322 * The prefix that will be used for attribute names that contain generic lock
323 * statistics.
324 */
325 private static final String ATTR_PREFIX_LOCK_STAT = "je-lock-stat-";
326
327
328
329 /**
330 * The prefix that will be used for attribute names that contain generic
331 * transaction statistics.
332 */
333 private static final String ATTR_PREFIX_TXN_STAT = "je-txn-stat-";
334
335
336
337 /**
338 * The name that will be used for the property that contains generic
339 * environment statistics.
340 */
341 private static final String PROPERTY_ENV_STATS = "je-env-stats";
342
343
344
345 /**
346 * The name that will be used for the property that contains generic lock
347 * statistics.
348 */
349 private static final String PROPERTY_LOCK_STATS = "je-lock-stats";
350
351
352
353 /**
354 * The name that will be used for the property that contains generic
355 * transaction statistics.
356 */
357 private static final String PROPERTY_TXN_STATS = "je-txn-stats";
358
359
360
361 /**
362 * The serial version UID for this serializable class.
363 */
364 private static final long serialVersionUID = 2557783119454069632L;
365
366
367
368 // Indicates whether a checkpoint is currently in progress.
369 private final Boolean checkpointInProgress;
370
371 // The time the last checkpoint began.
372 private final Date lastCheckpointStartTime;
373
374 // The time the last checkpoint ended.
375 private final Date lastCheckpointStopTime;
376
377 // The time the last checkpoint ended.
378 @Deprecated
379 private final Date lastCheckpointTime;
380
381 // The number of active transactions.
382 private final Long activeTransactionCount;
383
384 // The average duration for all checkpoints.
385 private final Long averageCheckpointDurationMillis;
386
387 // The current cleaner backlog.
388 private final Long cleanerBacklog;
389
390 // The current DB cache size.
391 private final Long currentDBCacheSize;
392
393 // The current DB cache percent full.
394 private final Long dbCachePercentFull;
395
396 // The current DB on-disk size.
397 private final Long dbOnDiskSize;
398
399 // The duration for the last checkpoint.
400 private final Long lastCheckpointDurationMillis;
401
402 // The maximum allowed DB cache size.
403 private final Long maxDBCacheSize;
404
405 // The length of time since the last checkpoint.
406 private final Long millisSinceLastCheckpoint;
407
408 // The number of nodes evicted from the DB cache.
409 private final Long nodesEvicted;
410
411 // The number of checkpoints completed.
412 private final Long numCheckpoints;
413
414 // The number of random reads performed.
415 private final Long randomReads;
416
417 // The number of random writes performed.
418 private final Long randomWrites;
419
420 // The number of read locks held.
421 private final Long readLocksHeld;
422
423 // The number of sequential reads performed.
424 private final Long sequentialReads;
425
426 // The number of sequential writes performed.
427 private final Long sequentialWrites;
428
429 // The total duration for all checkpoints.
430 private final Long totalCheckpointDurationMillis;
431
432 // The number of transactions waiting on locks.
433 private final Long transactionsWaitingOnLocks;
434
435 // The number of write locks held.
436 private final Long writeLocksHeld;
437
438 // The set of generic environment statistics.
439 private final Map<String,String> envStats;
440
441 // The set of generic lock statistics.
442 private final Map<String,String> lockStats;
443
444 // The set of generic transaction statistics.
445 private final Map<String,String> txnStats;
446
447 // The backend ID for the associated backend.
448 private final String backendID;
449
450 // The path to the directory containing the database files.
451 private final String dbDirectory;
452
453 // The Berkeley DB JE version string.
454 private final String jeVersion;
455
456
457
458 /**
459 * Creates a new JE environment monitor entry from the provided entry.
460 *
461 * @param entry The entry to be parsed as a JE environment monitor entry.
462 * It must not be {@code null}.
463 */
464 @SuppressWarnings("deprecation")
465 public JEEnvironmentMonitorEntry(final Entry entry)
466 {
467 super(entry);
468
469 activeTransactionCount = getLong(ATTR_ACTIVE_TXNS);
470 cleanerBacklog = getLong(ATTR_CLEANER_BACKLOG);
471 currentDBCacheSize = getLong(ATTR_CURRENT_CACHE_SIZE);
472 dbCachePercentFull = getLong(ATTR_CACHE_PCT_FULL);
473 dbOnDiskSize = getLong(ATTR_DB_ON_DISK_SIZE);
474 maxDBCacheSize = getLong(ATTR_MAX_CACHE_SIZE);
475 nodesEvicted = getLong(ATTR_NODES_EVICTED);
476 randomReads = getLong(ATTR_RANDOM_READS);
477 randomWrites = getLong(ATTR_RANDOM_WRITES);
478 readLocksHeld = getLong(ATTR_NUM_READ_LOCKS);
479 sequentialReads = getLong(ATTR_SEQUENTIAL_READS);
480 sequentialWrites = getLong(ATTR_SEQUENTIAL_WRITES);
481 transactionsWaitingOnLocks = getLong(ATTR_NUM_WAITING_TXNS);
482 writeLocksHeld = getLong(ATTR_NUM_WRITE_LOCKS);
483 backendID = getString(ATTR_BACKEND_ID);
484 dbDirectory = getString(ATTR_DB_DIRECTORY);
485 jeVersion = getString(ATTR_JE_VERSION);
486
487 checkpointInProgress = getBoolean(ATTR_CHECKPOINT_IN_PROGRESS);
488 lastCheckpointStartTime = getDate(ATTR_LAST_CHECKPOINT_START_TIME);
489 lastCheckpointStopTime = getDate(ATTR_LAST_CHECKPOINT_STOP_TIME);
490 lastCheckpointTime = getDate(ATTR_LAST_CHECKPOINT_TIME);
491 averageCheckpointDurationMillis =
492 getLong(ATTR_AVERAGE_CHECKPOINT_DURATION_MILLIS);
493 lastCheckpointDurationMillis =
494 getLong(ATTR_LAST_CHECKPOINT_DURATION_MILLIS);
495 millisSinceLastCheckpoint = getLong(ATTR_MILLIS_SINCE_LAST_CHECKPOINT);
496 numCheckpoints = getLong(ATTR_NUM_CHECKPOINTS);
497 totalCheckpointDurationMillis =
498 getLong(ATTR_TOTAL_CHECKPOINT_DURATION_MILLIS);
499
500 final LinkedHashMap<String,String> tmpEnvStats =
501 new LinkedHashMap<String,String>();
502 final LinkedHashMap<String,String> tmpLockStats =
503 new LinkedHashMap<String,String>();
504 final LinkedHashMap<String,String> tmpTxnStats =
505 new LinkedHashMap<String,String>();
506 for (final Attribute a : entry.getAttributes())
507 {
508 final String name = toLowerCase(a.getName());
509 if (name.startsWith(ATTR_PREFIX_ENV_STAT))
510 {
511 tmpEnvStats.put(
512 toLowerCase(name.substring(ATTR_PREFIX_ENV_STAT.length())),
513 a.getValue());
514 }
515 else if (name.startsWith(ATTR_PREFIX_LOCK_STAT))
516 {
517 tmpLockStats.put(
518 toLowerCase(name.substring(ATTR_PREFIX_LOCK_STAT.length())),
519 a.getValue());
520 }
521 else if (name.startsWith(ATTR_PREFIX_TXN_STAT))
522 {
523 tmpTxnStats.put(
524 toLowerCase(name.substring(ATTR_PREFIX_TXN_STAT.length())),
525 a.getValue());
526 }
527 }
528
529 envStats = Collections.unmodifiableMap(tmpEnvStats);
530 lockStats = Collections.unmodifiableMap(tmpLockStats);
531 txnStats = Collections.unmodifiableMap(tmpTxnStats);
532 }
533
534
535
536 /**
537 * Retrieves the backend ID for the backend with which the Berkeley DB JE
538 * database is associated.
539 *
540 * @return The backend ID for the backend with which the Berkeley DB JE
541 * database is associated.
542 */
543 public String getBackendID()
544 {
545 return backendID;
546 }
547
548
549
550 /**
551 * Retrieves the Berkeley DB JE version string for the database environment
552 * of the associated backend.
553 *
554 * @return The Berkeley DB JE version string for the database environment of
555 * the associated backend, or {@code null} if it was not included in
556 * the monitor entry.
557 */
558 public String getJEVersion()
559 {
560 return jeVersion;
561 }
562
563
564
565 /**
566 * Retrieves the path to the directory containing the database files.
567 *
568 * @return The path to the directory containing the database files, or
569 * {@code null} if it was not included in the monitor entry.
570 */
571 public String getDBDirectory()
572 {
573 return dbDirectory;
574 }
575
576
577
578 /**
579 * Retrieves the amount of disk space in bytes consumed by the database files.
580 *
581 * @return The amount of disk space in bytes consumed by the database files,
582 * or {@code null} if it was not included in the monitor entry.
583 */
584 public Long getDBOnDiskSize()
585 {
586 return dbOnDiskSize;
587 }
588
589
590
591 /**
592 * Retrieves the amount of memory in bytes currently consumed by the database
593 * cache.
594 *
595 * @return The amount of memory in bytes currently consumed by the database
596 * cache, or {@code null} if it was not included in the monitor
597 * entry.
598 */
599 public Long getCurrentDBCacheSize()
600 {
601 return currentDBCacheSize;
602 }
603
604
605
606 /**
607 * Retrieves the maximum amount of memory in bytes that may be consumed by the
608 * database cache.
609 *
610 * @return The maximum of memory in bytes that may be consumed by the
611 * database cache, or {@code null} if it was not included in the
612 * monitor entry.
613 */
614 public Long getMaxDBCacheSize()
615 {
616 return maxDBCacheSize;
617 }
618
619
620
621 /**
622 * Retrieves the percentage of the maximum database cache size that is
623 * currently in use.
624 *
625 * @return The percentage of the maximum database cache size that is
626 * currently in use, or {@code null} if it was not included in the
627 * monitor entry.
628 */
629 public Long getDBCachePercentFull()
630 {
631 return dbCachePercentFull;
632 }
633
634
635
636 /**
637 * Indicates whether a checkpoint is currently in progress in the associated
638 * backend.
639 *
640 * @return A {@code Boolean} value indicating whether a checkpoint is
641 * currently in progress in the associated backend, or {@code null}
642 * if it was not included in the monitor entry.
643 */
644 public Boolean checkpointInProgress()
645 {
646 return checkpointInProgress;
647 }
648
649
650
651 /**
652 * Retrieves the number of checkpoints completed in the associated backend.
653 *
654 * @return The number of checkpoints completed in the associated backend, or
655 * {@code null} if it was not included in the monitor entry.
656 */
657 public Long getNumCheckpoints()
658 {
659 return numCheckpoints;
660 }
661
662
663
664 /**
665 * Retrieves the total duration in milliseconds of all checkpoints completed
666 * in the associated backend.
667 *
668 * @return The total duration in milliseconds of all checkpoints completed in
669 * the associated backend, or {@code null} if it was not included in
670 * the monitor entry.
671 */
672 public Long getTotalCheckpointDurationMillis()
673 {
674 return totalCheckpointDurationMillis;
675 }
676
677
678
679 /**
680 * Retrieves the average duration in milliseconds of all checkpoints completed
681 * in the associated backend.
682 *
683 * @return The average duration in milliseconds of all checkpoints completed
684 * in the associated backend, or {@code null} if it was not included
685 * in the monitor entry.
686 */
687 public Long getAverageCheckpointDurationMillis()
688 {
689 return averageCheckpointDurationMillis;
690 }
691
692
693
694 /**
695 * Retrieves the duration in milliseconds of the last checkpoint completed in
696 * the associated backend.
697 *
698 * @return The duration in milliseconds of the last checkpoint completed in
699 * the associated backend, or {@code null} if it was not included
700 * in the monitor entry.
701 */
702 public Long getLastCheckpointDurationMillis()
703 {
704 return lastCheckpointDurationMillis;
705 }
706
707
708
709 /**
710 * Retrieves the time that the last completed checkpoint began.
711 *
712 * @return The time that the last completed checkpoint began, or {@code null}
713 * if it was not included in the monitor entry.
714 */
715 public Date getLastCheckpointStartTime()
716 {
717 return lastCheckpointStartTime;
718 }
719
720
721
722 /**
723 * Retrieves the time that the last completed checkpoint ended.
724 *
725 * @return The time that the last completed checkpoint ended, or {@code null}
726 * if it was not included in the monitor entry.
727 */
728 public Date getLastCheckpointStopTime()
729 {
730 return lastCheckpointStopTime;
731 }
732
733
734
735 /**
736 * Retrieves the time that the last checkpoint occurred.
737 *
738 * @return The time that the last checkpoint occurred, or {@code null} if it
739 * was not included in the monitor entry.
740 *
741 * @deprecated Use {@link #getLastCheckpointStopTime()} instead.
742 */
743 @Deprecated()
744 @SuppressWarnings("deprecation")
745 public Date getLastCheckpointTime()
746 {
747 return lastCheckpointTime;
748 }
749
750
751
752 /**
753 * Retrieves the length of time in milliseconds since the last completed
754 * checkpoint.
755 *
756 * @return The length of time in milliseconds since the last completed
757 * checkpoint, or {@code null} if it was not included in the monitor
758 * entry.
759 */
760 public Long getMillisSinceLastCheckpoint()
761 {
762 return millisSinceLastCheckpoint;
763 }
764
765
766
767 /**
768 * Retrieves the number of log files that the cleaner needs to examine.
769 *
770 * @return The number of log files that the cleaner needs to examine, or
771 * {@code null} if it was not included in the monitor entry.
772 */
773 public Long getCleanerBacklog()
774 {
775 return cleanerBacklog;
776 }
777
778
779
780 /**
781 * Retrieves the number of nodes that have been evicted from the database
782 * cache since the backend was started.
783 *
784 * @return The number of nodes that have been evicted from the database cache
785 * since the backend was started, or {@code null} if it was not
786 * included in the monitor entry.
787 */
788 public Long getNodesEvicted()
789 {
790 return nodesEvicted;
791 }
792
793
794
795 /**
796 * Retrieves the number of random-access disk reads performed since the
797 * backend was started.
798 *
799 * @return The number of random-access disk reads performed since the backend
800 * was started, or {@code null} if it was not included in the monitor
801 * entry.
802 */
803 public Long getRandomReads()
804 {
805 return randomReads;
806 }
807
808
809
810 /**
811 * Retrieves the number of random-access disk writes performed since the
812 * backend was started.
813 *
814 * @return The number of random-access disk writes performed since the
815 * backend was started, or {@code null} if it was not included in the
816 * monitor entry.
817 */
818 public Long getRandomWrites()
819 {
820 return randomWrites;
821 }
822
823
824
825 /**
826 * Retrieves the number of sequential disk reads performed since the backend
827 * was started.
828 *
829 * @return The number of sequential disk reads performed since the backend
830 * was started, or {@code null} if it was not included in the monitor
831 * entry.
832 */
833 public Long getSequentialReads()
834 {
835 return sequentialReads;
836 }
837
838
839
840 /**
841 * Retrieves the number of sequential disk writes performed since the backend
842 * was started.
843 *
844 * @return The number of sequential disk writes performed since the backend
845 * was started, or {@code null} if it was not included in the monitor
846 * entry.
847 */
848 public Long getSequentialWrites()
849 {
850 return sequentialWrites;
851 }
852
853
854
855 /**
856 * Retrieves the number of active transactions in the JE database environment.
857 *
858 * @return The number of active transactions in the JE database environment,
859 * or {@code null} if it was not included in the monitor entry.
860 */
861 public Long getActiveTransactionCount()
862 {
863 return activeTransactionCount;
864 }
865
866
867
868 /**
869 * Retrieves the number of read locks held in the JE database environment.
870 *
871 * @return The number of read locks held in the JE database environment, or
872 * {@code null} if it was not included in the monitor entry.
873 */
874 public Long getReadLocksHeld()
875 {
876 return readLocksHeld;
877 }
878
879
880
881 /**
882 * Retrieves the number of write locks held in the JE database environment.
883 *
884 * @return The number of write locks held in the JE database environment, or
885 * {@code null} if it was not included in the monitor entry.
886 */
887 public Long getWriteLocksHeld()
888 {
889 return writeLocksHeld;
890 }
891
892
893
894 /**
895 * Retrieves the number of transactions currently waiting on a lock in the
896 * database environment.
897 *
898 * @return The number of transactions currently waiting on a lock in the
899 * database environment, or {@code null} if it was not included in
900 * the monitor entry.
901 */
902 public Long getTransactionsWaitingOnLocks()
903 {
904 return transactionsWaitingOnLocks;
905 }
906
907
908
909 /**
910 * Retrieves a set of general environment statistics for the database
911 * environment, mapped from the statistic name to the string representation of
912 * its value. The statistic names will be formatted in all lowercase
913 * characters.
914 *
915 * @return A set of general environment statistics for the database
916 * environment, mapped from the statistic name to the string
917 * representation of its value.
918 */
919 public Map<String,String> getEnvironmentStats()
920 {
921 return envStats;
922 }
923
924
925
926 /**
927 * Retrieves the string representation of the value for a database environment
928 * statistic.
929 *
930 * @param statName The name of the statistic to retrieve. It will be
931 * treated in a case-insensitive manner.
932 *
933 * @return The value of the requested database environment statistic, or
934 * {@code null} if no such statistic was provided.
935 */
936 public String getEnvironmentStat(final String statName)
937 {
938 return envStats.get(toLowerCase(statName));
939 }
940
941
942
943 /**
944 * Retrieves a set of lock statistics for the database environment, mapped
945 * from the statistic name to the string representation of its value. The
946 * statistic names will be formatted in all lowercase characters.
947 *
948 * @return A set of lock statistics for the database environment, mapped from
949 * the statistic name to the string representation of its value.
950 */
951 public Map<String,String> getLockStats()
952 {
953 return lockStats;
954 }
955
956
957
958 /**
959 * Retrieves the string representation of the value for a database environment
960 * lock statistic.
961 *
962 * @param statName The name of the statistic to retrieve. It will be
963 * treated in a case-insensitive manner.
964 *
965 * @return The value of the requested database environment lock statistic, or
966 * {@code null} if no such statistic was provided.
967 */
968 public String getLockStat(final String statName)
969 {
970 return lockStats.get(toLowerCase(statName));
971 }
972
973
974
975 /**
976 * Retrieves a set of transaction statistics for the database environment,
977 * mapped from the statistic name to the string representation of its value.
978 * The statistic names will be formatted in all lowercase characters.
979 *
980 * @return A set of transaction statistics for the database environment,
981 * mapped from the statistic name to the string representation of its
982 * value.
983 */
984 public Map<String,String> getTransactionStats()
985 {
986 return txnStats;
987 }
988
989
990
991 /**
992 * Retrieves the string representation of the value for a database environment
993 * transaction statistic.
994 *
995 * @param statName The name of the statistic to retrieve. It will be
996 * treated in a case-insensitive manner.
997 *
998 * @return The value of the requested database environment transaction
999 * statistic, or {@code null} if no such statistic was provided.
1000 */
1001 public String getTransactionStat(final String statName)
1002 {
1003 return txnStats.get(toLowerCase(statName));
1004 }
1005
1006
1007
1008 /**
1009 * {@inheritDoc}
1010 */
1011 @Override()
1012 public String getMonitorDisplayName()
1013 {
1014 return INFO_JE_ENVIRONMENT_MONITOR_DISPNAME.get();
1015 }
1016
1017
1018
1019 /**
1020 * {@inheritDoc}
1021 */
1022 @Override()
1023 public String getMonitorDescription()
1024 {
1025 return INFO_JE_ENVIRONMENT_MONITOR_DESC.get();
1026 }
1027
1028
1029
1030 /**
1031 * {@inheritDoc}
1032 */
1033 @Override()
1034 public Map<String,MonitorAttribute> getMonitorAttributes()
1035 {
1036 final LinkedHashMap<String,MonitorAttribute> attrs =
1037 new LinkedHashMap<String,MonitorAttribute>();
1038
1039 if (backendID != null)
1040 {
1041 addMonitorAttribute(attrs,
1042 ATTR_BACKEND_ID,
1043 INFO_JE_ENVIRONMENT_DISPNAME_BACKEND_ID.get(),
1044 INFO_JE_ENVIRONMENT_DESC_BACKEND_ID.get(),
1045 backendID);
1046 }
1047
1048 if (jeVersion != null)
1049 {
1050 addMonitorAttribute(attrs,
1051 ATTR_JE_VERSION,
1052 INFO_JE_ENVIRONMENT_DISPNAME_JE_VERSION.get(),
1053 INFO_JE_ENVIRONMENT_DESC_JE_VERSION.get(),
1054 jeVersion);
1055 }
1056
1057 if (dbDirectory != null)
1058 {
1059 addMonitorAttribute(attrs,
1060 ATTR_DB_DIRECTORY,
1061 INFO_JE_ENVIRONMENT_DISPNAME_DB_DIRECTORY.get(),
1062 INFO_JE_ENVIRONMENT_DESC_DB_DIRECTORY.get(),
1063 dbDirectory);
1064 }
1065
1066 if (dbOnDiskSize != null)
1067 {
1068 addMonitorAttribute(attrs,
1069 ATTR_DB_ON_DISK_SIZE,
1070 INFO_JE_ENVIRONMENT_DISPNAME_DB_ON_DISK_SIZE.get(),
1071 INFO_JE_ENVIRONMENT_DESC_DB_ON_DISK_SIZE.get(),
1072 dbOnDiskSize);
1073 }
1074
1075 if (currentDBCacheSize != null)
1076 {
1077 addMonitorAttribute(attrs,
1078 ATTR_CURRENT_CACHE_SIZE,
1079 INFO_JE_ENVIRONMENT_DISPNAME_CURRENT_CACHE_SIZE.get(),
1080 INFO_JE_ENVIRONMENT_DESC_CURRENT_CACHE_SIZE.get(),
1081 currentDBCacheSize);
1082 }
1083
1084 if (maxDBCacheSize != null)
1085 {
1086 addMonitorAttribute(attrs,
1087 ATTR_MAX_CACHE_SIZE,
1088 INFO_JE_ENVIRONMENT_DISPNAME_MAX_CACHE_SIZE.get(),
1089 INFO_JE_ENVIRONMENT_DESC_MAX_CACHE_SIZE.get(),
1090 maxDBCacheSize);
1091 }
1092
1093 if (dbCachePercentFull != null)
1094 {
1095 addMonitorAttribute(attrs,
1096 ATTR_CACHE_PCT_FULL,
1097 INFO_JE_ENVIRONMENT_DISPNAME_CACHE_PCT_FULL.get(),
1098 INFO_JE_ENVIRONMENT_DESC_CACHE_PCT_FULL.get(),
1099 dbCachePercentFull);
1100 }
1101
1102 if (checkpointInProgress != null)
1103 {
1104 addMonitorAttribute(attrs,
1105 ATTR_CHECKPOINT_IN_PROGRESS,
1106 INFO_JE_ENVIRONMENT_DISPNAME_CP_IN_PROGRESS.get(),
1107 INFO_JE_ENVIRONMENT_DESC_CP_IN_PROGRESS.get(),
1108 checkpointInProgress);
1109 }
1110
1111 if (numCheckpoints != null)
1112 {
1113 addMonitorAttribute(attrs,
1114 ATTR_NUM_CHECKPOINTS,
1115 INFO_JE_ENVIRONMENT_DISPNAME_NUM_CP.get(),
1116 INFO_JE_ENVIRONMENT_DESC_NUM_CP.get(),
1117 numCheckpoints);
1118 }
1119
1120 if (totalCheckpointDurationMillis != null)
1121 {
1122 addMonitorAttribute(attrs,
1123 ATTR_TOTAL_CHECKPOINT_DURATION_MILLIS,
1124 INFO_JE_ENVIRONMENT_DISPNAME_TOTAL_CP_DURATION.get(),
1125 INFO_JE_ENVIRONMENT_DESC_TOTAL_CP_DURATION.get(),
1126 totalCheckpointDurationMillis);
1127 }
1128
1129 if (averageCheckpointDurationMillis != null)
1130 {
1131 addMonitorAttribute(attrs,
1132 ATTR_AVERAGE_CHECKPOINT_DURATION_MILLIS,
1133 INFO_JE_ENVIRONMENT_DISPNAME_AVG_CP_DURATION.get(),
1134 INFO_JE_ENVIRONMENT_DESC_AVG_CP_DURATION.get(),
1135 averageCheckpointDurationMillis);
1136 }
1137
1138 if (lastCheckpointDurationMillis != null)
1139 {
1140 addMonitorAttribute(attrs,
1141 ATTR_LAST_CHECKPOINT_DURATION_MILLIS,
1142 INFO_JE_ENVIRONMENT_DISPNAME_LAST_CP_DURATION.get(),
1143 INFO_JE_ENVIRONMENT_DESC_LAST_CP_DURATION.get(),
1144 lastCheckpointDurationMillis);
1145 }
1146
1147 if (lastCheckpointStartTime != null)
1148 {
1149 addMonitorAttribute(attrs,
1150 ATTR_LAST_CHECKPOINT_START_TIME,
1151 INFO_JE_ENVIRONMENT_DISPNAME_LAST_CP_START_TIME.get(),
1152 INFO_JE_ENVIRONMENT_DESC_LAST_CP_START_TIME.get(),
1153 lastCheckpointStartTime);
1154 }
1155
1156 if (lastCheckpointStopTime != null)
1157 {
1158 addMonitorAttribute(attrs,
1159 ATTR_LAST_CHECKPOINT_STOP_TIME,
1160 INFO_JE_ENVIRONMENT_DISPNAME_LAST_CP_STOP_TIME.get(),
1161 INFO_JE_ENVIRONMENT_DESC_LAST_CP_STOP_TIME.get(),
1162 lastCheckpointStopTime);
1163 }
1164
1165 if (millisSinceLastCheckpoint != null)
1166 {
1167 addMonitorAttribute(attrs,
1168 ATTR_MILLIS_SINCE_LAST_CHECKPOINT,
1169 INFO_JE_ENVIRONMENT_DISPNAME_MILLIS_SINCE_CP.get(),
1170 INFO_JE_ENVIRONMENT_DESC_MILLIS_SINCE_CP.get(),
1171 millisSinceLastCheckpoint);
1172 }
1173
1174 if (cleanerBacklog != null)
1175 {
1176 addMonitorAttribute(attrs,
1177 ATTR_CLEANER_BACKLOG,
1178 INFO_JE_ENVIRONMENT_DISPNAME_CLEANER_BACKLOG.get(),
1179 INFO_JE_ENVIRONMENT_DESC_CLEANER_BACKLOG.get(),
1180 cleanerBacklog);
1181 }
1182
1183 if (nodesEvicted != null)
1184 {
1185 addMonitorAttribute(attrs,
1186 ATTR_NODES_EVICTED,
1187 INFO_JE_ENVIRONMENT_DISPNAME_NODES_EVICTED.get(),
1188 INFO_JE_ENVIRONMENT_DESC_NODES_EVICTED.get(),
1189 nodesEvicted);
1190 }
1191
1192 if (randomReads != null)
1193 {
1194 addMonitorAttribute(attrs,
1195 ATTR_RANDOM_READS,
1196 INFO_JE_ENVIRONMENT_DISPNAME_RANDOM_READS.get(),
1197 INFO_JE_ENVIRONMENT_DESC_RANDOM_READS.get(),
1198 randomReads);
1199 }
1200
1201 if (randomWrites != null)
1202 {
1203 addMonitorAttribute(attrs,
1204 ATTR_RANDOM_WRITES,
1205 INFO_JE_ENVIRONMENT_DISPNAME_RANDOM_WRITES.get(),
1206 INFO_JE_ENVIRONMENT_DESC_RANDOM_WRITES.get(),
1207 randomWrites);
1208 }
1209
1210 if (sequentialReads != null)
1211 {
1212 addMonitorAttribute(attrs,
1213 ATTR_SEQUENTIAL_READS,
1214 INFO_JE_ENVIRONMENT_DISPNAME_SEQUENTIAL_READS.get(),
1215 INFO_JE_ENVIRONMENT_DESC_SEQUENTIAL_READS.get(),
1216 sequentialReads);
1217 }
1218
1219 if (sequentialWrites != null)
1220 {
1221 addMonitorAttribute(attrs,
1222 ATTR_SEQUENTIAL_WRITES,
1223 INFO_JE_ENVIRONMENT_DISPNAME_SEQUENTIAL_WRITES.get(),
1224 INFO_JE_ENVIRONMENT_DESC_SEQUENTIAL_WRITES.get(),
1225 sequentialWrites);
1226 }
1227
1228 if (activeTransactionCount != null)
1229 {
1230 addMonitorAttribute(attrs,
1231 ATTR_ACTIVE_TXNS,
1232 INFO_JE_ENVIRONMENT_DISPNAME_ACTIVE_TXNS.get(),
1233 INFO_JE_ENVIRONMENT_DESC_ACTIVE_TXNS.get(),
1234 activeTransactionCount);
1235 }
1236
1237 if (readLocksHeld != null)
1238 {
1239 addMonitorAttribute(attrs,
1240 ATTR_NUM_READ_LOCKS,
1241 INFO_JE_ENVIRONMENT_DISPNAME_READ_LOCKS.get(),
1242 INFO_JE_ENVIRONMENT_DESC_READ_LOCKS.get(),
1243 readLocksHeld);
1244 }
1245
1246 if (writeLocksHeld != null)
1247 {
1248 addMonitorAttribute(attrs,
1249 ATTR_NUM_WRITE_LOCKS,
1250 INFO_JE_ENVIRONMENT_DISPNAME_WRITE_LOCKS.get(),
1251 INFO_JE_ENVIRONMENT_DESC_WRITE_LOCKS.get(),
1252 writeLocksHeld);
1253 }
1254
1255 if (transactionsWaitingOnLocks != null)
1256 {
1257 addMonitorAttribute(attrs,
1258 ATTR_NUM_WAITING_TXNS,
1259 INFO_JE_ENVIRONMENT_DISPNAME_TXNS_WAITING_ON_LOCKS.get(),
1260 INFO_JE_ENVIRONMENT_DESC_TXNS_WAITING_ON_LOCKS.get(),
1261 transactionsWaitingOnLocks);
1262 }
1263
1264 if (! envStats.isEmpty())
1265 {
1266 final ArrayList<String> values = new ArrayList<String>(envStats.size());
1267 for (final Map.Entry<String,String> e : envStats.entrySet())
1268 {
1269 values.add(e.getKey() + '=' + e.getValue());
1270 }
1271
1272 addMonitorAttribute(attrs,
1273 PROPERTY_ENV_STATS,
1274 INFO_JE_ENVIRONMENT_DISPNAME_ENV_STATS.get(),
1275 INFO_JE_ENVIRONMENT_DESC_ENV_STATS.get(),
1276 values);
1277 }
1278
1279 if (! lockStats.isEmpty())
1280 {
1281 final ArrayList<String> values = new ArrayList<String>(lockStats.size());
1282 for (final Map.Entry<String,String> e : lockStats.entrySet())
1283 {
1284 values.add(e.getKey() + '=' + e.getValue());
1285 }
1286
1287 addMonitorAttribute(attrs,
1288 PROPERTY_LOCK_STATS,
1289 INFO_JE_ENVIRONMENT_DISPNAME_LOCK_STATS.get(),
1290 INFO_JE_ENVIRONMENT_DESC_LOCK_STATS.get(),
1291 values);
1292 }
1293
1294 if (! txnStats.isEmpty())
1295 {
1296 final ArrayList<String> values = new ArrayList<String>(txnStats.size());
1297 for (final Map.Entry<String,String> e : txnStats.entrySet())
1298 {
1299 values.add(e.getKey() + '=' + e.getValue());
1300 }
1301
1302 addMonitorAttribute(attrs,
1303 PROPERTY_TXN_STATS,
1304 INFO_JE_ENVIRONMENT_DISPNAME_TXN_STATS.get(),
1305 INFO_JE_ENVIRONMENT_DESC_TXN_STATS.get(),
1306 values);
1307 }
1308
1309 return Collections.unmodifiableMap(attrs);
1310 }
1311 }