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