| | |
| | | |
| | | |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | |
| | | objectClass: ds-cfg-access-logger |
| | | objectClass: ds-cfg-file-based-access-logger |
| | | cn: File-Based Access Logger |
| | | ds-cfg-logger-class: org.opends.server.loggers.DirectoryAccessLogger |
| | | ds-cfg-logger-class: org.opends.server.loggers.TextAccessLogPublisher |
| | | ds-cfg-logger-enabled: true |
| | | ds-cfg-log-file: logs/access |
| | | ds-cfg-log-file-mode: 640 |
| | | ds-cfg-suppress-internal-operations: true |
| | | ds-cfg-rotation-policy: Size |
| | | ds-cfg-rotation-policy: FixedTime |
| | | ds-cfg-size-limit: 104857600 |
| | | ds-cfg-fixed-time-limit: 86400000 |
| | | ds-cfg-asynchronous-writes: true |
| | | ds-cfg-rotation-policy-dn: cn=24 Hours Time Limit Rotation Policy,cn=Log Rotation Policies,cn=config |
| | | ds-cfg-rotation-policy-dn: cn=Size Limit Rotation Policy,cn=Log Rotation Policies,cn=config |
| | | ds-cfg-retention-policy-dn: cn=File Count Retention Policy,cn=Log Retention Policies,cn=config |
| | | |
| | | dn: cn=File-Based Audit Logger,cn=Loggers,cn=config |
| | | objectClass: top |
| | |
| | | objectClass: ds-cfg-access-logger |
| | | objectClass: ds-cfg-file-based-access-logger |
| | | cn: File-Based Audit Logger |
| | | ds-cfg-logger-class: org.opends.server.loggers.DirectoryAuditLogger |
| | | ds-cfg-logger-enabled: false |
| | | ds-cfg-log-file: logs/audit |
| | | ds-cfg-suppress-internal-operations: true |
| | | ds-cfg-rotation-policy: Size |
| | | ds-cfg-rotation-policy: FixedTime |
| | | ds-cfg-size-limit: 104857600 |
| | | ds-cfg-fixed-time-limit: 86400000 |
| | | |
| | | dn: cn=File-Based Debug Logger,cn=Loggers,cn=config |
| | | objectClass: top |
| | | objectClass: ds-cfg-logger |
| | | objectClass: ds-cfg-debug-logger |
| | | objectClass: ds-cfg-file-based-debug-logger |
| | | cn: File-Based Debug Logger |
| | | ds-cfg-logger-class: org.opends.server.loggers.DirectoryDebugLogger |
| | | ds-cfg-logger-class: org.opends.server.loggers.TextAuditLogPublisher |
| | | ds-cfg-logger-enabled: true |
| | | ds-cfg-log-file: logs/debug |
| | | ds-cfg-default-severity: ERROR |
| | | ds-cfg-default-severity: WARNING |
| | | ds-cfg-log-file: logs/audit |
| | | ds-cfg-log-file-mode: 640 |
| | | ds-cfg-suppress-internal-operations: true |
| | | ds-cfg-asynchronous-writes: true |
| | | ds-cfg-rotation-policy-dn: cn=24 Hours Time Limit Rotation Policy,cn=Log Rotation Policies,cn=config |
| | | ds-cfg-rotation-policy-dn: cn=Size Limit Rotation Policy,cn=Log Rotation Policies,cn=config |
| | | ds-cfg-retention-policy-dn: cn=File Count Retention Policy,cn=Log Retention Policies,cn=config |
| | | |
| | | dn: cn=File-Based Error Logger,cn=Loggers,cn=config |
| | | objectClass: top |
| | |
| | | objectClass: ds-cfg-error-logger |
| | | objectClass: ds-cfg-file-based-error-logger |
| | | cn: File-Based Error Logger |
| | | ds-cfg-logger-class: org.opends.server.loggers.DirectoryErrorLogger |
| | | ds-cfg-logger-class: org.opends.server.loggers.TextErrorLogPublisher |
| | | ds-cfg-logger-enabled: true |
| | | ds-cfg-log-file: logs/errors |
| | | ds-cfg-default-severity: FATAL_ERROR |
| | | ds-cfg-default-severity: NOTICE |
| | | ds-cfg-default-severity: SEVERE_ERROR |
| | | ds-cfg-default-severity: SEVERE_WARNING |
| | | ds-cfg-rotation-policy: Size |
| | | ds-cfg-rotation-policy: FixedTime |
| | | ds-cfg-size-limit: 104857600 |
| | | ds-cfg-fixed-time-limit: 86400000 |
| | | ds-cfg-log-file: logs/error |
| | | ds-cfg-log-file-mode: 640 |
| | | ds-cfg-default-severity: severe-warning |
| | | ds-cfg-default-severity: severe-error |
| | | ds-cfg-default-severity: fatal-error |
| | | ds-cfg-default-severity: notice |
| | | ds-cfg-asynchronous-writes: false |
| | | ds-cfg-rotation-policy-dn: cn=7 Days Time Limit Rotation Policy,cn=Log Rotation Policies,cn=config |
| | | ds-cfg-rotation-policy-dn: cn=Size Limit Rotation Policy,cn=Log Rotation Policies,cn=config |
| | | ds-cfg-retention-policy-dn: cn=File Count Retention Policy,cn=Log Retention Policies,cn=config |
| | | |
| | | dn: cn=File-Based Debug Logger,cn=Loggers,cn=config |
| | | objectClass: top |
| | | objectClass: ds-cfg-logger |
| | | objectClass: ds-cfg-debug-logger |
| | | objectClass: ds-cfg-file-based-debug-logger |
| | | cn: File-Based Debug Logger |
| | | ds-cfg-logger-class: org.opends.server.loggers.debug.TextDebugLogPublisher |
| | | ds-cfg-logger-enabled: false |
| | | ds-cfg-log-file: logs/debug |
| | | ds-cfg-log-file-mode: 640 |
| | | ds-cfg-default-debug-level: error |
| | | ds-cfg-asynchronous-writes: false |
| | | |
| | | dn: cn=Log Rotation Policies,cn=config |
| | | objectClass: top |
| | | objectClass: ds-cfg-branch |
| | | cn: Log Rotation Policies |
| | | |
| | | dn: cn=24 Hours Time Limit Rotation Policy,cn=Log Rotation Policies,cn=config |
| | | objectClass: top |
| | | objectClass: ds-cfg-log-rotation-policy |
| | | objectClass: ds-cfg-time-limit-log-rotation-policy |
| | | cn: Time Limit Rotation Policy |
| | | ds-cfg-rotation-policy-class: org.opends.server.loggers.TimeLimitRotationPolicy |
| | | ds-cfg-rotation-interval: 24 hours |
| | | |
| | | dn: cn=7 Days Time Limit Rotation Policy,cn=Log Rotation Policies,cn=config |
| | | objectClass: top |
| | | objectClass: ds-cfg-log-rotation-policy |
| | | objectClass: ds-cfg-time-limit-log-rotation-policy |
| | | cn: Time Limit Rotation Policy |
| | | ds-cfg-rotation-policy-class: org.opends.server.loggers.TimeLimitRotationPolicy |
| | | ds-cfg-rotation-interval: 7 days |
| | | |
| | | dn: cn=Size Limit Rotation Policy,cn=Log Rotation Policies,cn=config |
| | | objectClass: top |
| | | objectClass: ds-cfg-log-rotation-policy |
| | | objectClass: ds-cfg-size-limit-log-rotation-policy |
| | | cn: Size Limit Rotation Policy |
| | | ds-cfg-rotation-policy-class: org.opends.server.loggers.SizeBasedRotationPolicy |
| | | ds-cfg-file-size-limit: 100 megabytes |
| | | |
| | | dn: cn=Fixed Time Rotation Policy,cn=Log Rotation Policies,cn=config |
| | | objectClass: top |
| | | objectClass: ds-cfg-log-rotation-policy |
| | | objectClass: ds-cfg-fixed-time-log-rotation-policy |
| | | cn: Fixed Time Rotation Policy |
| | | ds-cfg-rotation-policy-class: org.opends.server.loggers.FixedTimeRotationPolicy |
| | | ds-cfg-time-of-day: 2359 |
| | | |
| | | dn: cn=Log Retention Policies,cn=config |
| | | objectClass: top |
| | | objectClass: ds-cfg-branch |
| | | cn: Log Retention Policies |
| | | |
| | | dn: cn=File Count Retention Policy,cn=Log Retention Policies,cn=config |
| | | objectClass: top |
| | | objectClass: ds-cfg-log-retention-policy |
| | | objectClass: ds-cfg-file-count-log-retention-policy |
| | | cn: File Count Retention Policy |
| | | ds-cfg-retention-policy-class: org.opends.server.loggers.FileNumberRetentionPolicy |
| | | ds-cfg-number-of-files: 10 |
| | | |
| | | dn: cn=Free Disk Space Retention Policy,cn=Log Retention Policies,cn=config |
| | | objectClass: top |
| | | objectClass: ds-cfg-log-retention-policy |
| | | objectClass: ds-cfg-free-disk-space-log-retention-policy |
| | | cn: Free Disk Space Retention Policy |
| | | ds-cfg-retention-policy-class: org.opends.server.loggers.FreeDiskSpaceRetentionPolicy |
| | | ds-cfg-free-disk-space: 500 megabytes |
| | | |
| | | dn: cn=Size Limit Retention Policy,cn=Log Retention Policies,cn=config |
| | | objectClass: top |
| | | objectClass: ds-cfg-log-retention-policy |
| | | objectClass: ds-cfg-size-limit-log-retention-policy |
| | | cn: Size Limit Retention Policy |
| | | ds-cfg-retention-policy-class: org.opends.server.loggers.SizeBasedRetentionPolicy |
| | | ds-cfg-disk-space-used: 500 megabytes |
| | | |
| | | dn: cn=Matching Rules,cn=config |
| | | objectClass: top |
| | |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.38 NAME 'ds-cfg-exclude-filter' |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.39 |
| | | NAME 'ds-cfg-fixed-time-limit' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 |
| | | NAME 'ds-cfg-rotation-interval' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 |
| | | SINGLE-VALUE X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.320 NAME 'ds-cfg-global-aci' |
| | | SYNTAX 1.3.6.1.4.1.26027.1.3.4 X-ORIGIN 'OpenDS Directory Server' ) |
| | |
| | | NAME 'ds-cfg-rotation-action' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 |
| | | SINGLE-VALUE X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.90 |
| | | NAME 'ds-cfg-rotation-policy' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 |
| | | NAME 'ds-cfg-rotation-policy-dn' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.91 |
| | | NAME 'ds-cfg-retention-policy' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 |
| | | NAME 'ds-cfg-retention-policy-dn' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.92 NAME 'ds-cfg-number-of-files' |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'OpenDS Directory Server' ) |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.93 NAME 'ds-cfg-disk-space-used' |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.94 NAME 'ds-cfg-free-disk-space' |
| | |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.126 NAME 'ds-cfg-time-of-day' |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.36 SINGLE-VALUE |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.36 |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.127 |
| | | NAME 'ds-cfg-trust-manager-provider-class' |
| | |
| | | NAME 'ds-cfg-virtual-attribute-value' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.345 |
| | | NAME 'ds-cfg-default-debug-level' |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.346 |
| | | NAME 'ds-cfg-default-debug-category' |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.347 |
| | | NAME 'ds-cfg-default-omit-method-entry-arguments' |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.348 |
| | | NAME 'ds-cfg-default-omit-method-return-value' |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.349 |
| | | NAME 'ds-cfg-default-include-throwable-cause' |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.350 |
| | | NAME 'ds-cfg-default-throwable-stack-frames' |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.351 |
| | | NAME 'ds-cfg-debug-scope' |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.352 |
| | | NAME 'ds-cfg-debug-level' |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.353 |
| | | NAME 'ds-cfg-debug-category' |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.354 |
| | | NAME 'ds-cfg-omit-method-entry-arguments' |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.355 |
| | | NAME 'ds-cfg-omit-method-return-value' |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.356 |
| | | NAME 'ds-cfg-include-throwable-cause' |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.357 |
| | | NAME 'ds-cfg-throwable-stack-frames' |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.358 |
| | | NAME 'ds-cfg-asynchronous-writes' |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.359 |
| | | NAME 'ds-cfg-log-file-mode' |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.360 |
| | | NAME 'ds-cfg-writer-auto-flush' |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.361 |
| | | NAME 'ds-cfg-writer-append' |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.375 |
| | | NAME 'ds-cfg-allow-retrieving-membership' SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 |
| | | SINGLE-VALUE X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.376 |
| | | NAME 'ds-cfg-rotation-policy-class' |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.377 |
| | | NAME 'ds-cfg-retention-policy-class' |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.378 |
| | | NAME 'ds-cfg-log-queue-size' |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | attributeTypes: ( 1.3.6.1.4.1.26027.1.1.379 |
| | | NAME 'ds-cfg-file-size-limit' |
| | | SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | objectClasses: ( 1.3.6.1.4.1.26027.1.2.1 |
| | | NAME 'ds-cfg-access-control-handler' SUP top STRUCTURAL |
| | | MUST ( cn $ ds-cfg-acl-handler-class $ ds-cfg-acl-handler-enabled ) |
| | |
| | | ds-cfg-key-store-pin-environment-variable $ ds-cfg-key-store-pin-file ) |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | objectClasses: ( 1.3.6.1.4.1.26027.1.2.22 NAME 'ds-cfg-logger' |
| | | SUP top STRUCTURAL MUST ( cn $ ds-cfg-logger-class $ |
| | | ds-cfg-logger-enabled ) X-ORIGIN 'OpenDS Directory Server' ) |
| | | SUP top STRUCTURAL MUST ( cn $ ds-cfg-logger-enabled $ ds-cfg-logger-class ) |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | objectClasses: ( 1.3.6.1.4.1.26027.1.2.23 NAME 'ds-cfg-access-logger' |
| | | SUP ds-cfg-logger STRUCTURAL X-ORIGIN 'OpenDS Directory Server' ) |
| | | SUP ds-cfg-logger |
| | | STRUCTURAL MAY ( ds-cfg-suppress-internal-operations ) |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | objectClasses: ( 1.3.6.1.4.1.26027.1.2.24 NAME 'ds-cfg-error-logger' |
| | | SUP ds-cfg-logger STRUCTURAL X-ORIGIN 'OpenDS Directory Server' ) |
| | | SUP ds-cfg-logger |
| | | STRUCTURAL MAY ( ds-cfg-default-severity $ ds-cfg-override-severity ) |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | objectClasses: ( 1.3.6.1.4.1.26027.1.2.25 NAME 'ds-cfg-debug-logger' |
| | | SUP ds-cfg-logger STRUCTURAL X-ORIGIN 'OpenDS Directory Server' ) |
| | | SUP ds-cfg-logger STRUCTURAL MUST ( ds-cfg-default-debug-level ) |
| | | MAY ( ds-cfg-default-debug-category $ |
| | | ds-cfg-default-omit-method-entry-arguments $ |
| | | ds-cfg-default-omit-method-return-value $ |
| | | ds-cfg-default-include-throwable-cause $ |
| | | ds-cfg-throwable-stack-frames ) |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | objectClasses: ( 1.3.6.1.4.1.26027.1.2.26 |
| | | NAME 'ds-cfg-file-based-access-logger' SUP ds-cfg-access-logger STRUCTURAL |
| | | MUST ds-cfg-log-file MAY ( ds-cfg-rotation-policy $ ds-cfg-size-limit $ |
| | | ds-cfg-fixed-time-limit $ ds-cfg-time-of-day $ ds-cfg-rotation-action $ |
| | | ds-cfg-default-severity $ ds-cfg-override-severity $ |
| | | ds-cfg-retention-policy $ ds-cfg-number-of-files $ ds-cfg-disk-space-used $ |
| | | ds-cfg-thread-time-interval $ ds-cfg-buffer-size $ ds-cfg-free-disk-space $ |
| | | ds-cfg-suppress-internal-operations ) X-ORIGIN 'OpenDS Directory Server' ) |
| | | MUST ( ds-cfg-log-file $ ds-cfg-asynchronous-writes $ ds-cfg-log-file-mode ) |
| | | MAY ( ds-cfg-rotation-policy-dn $ |
| | | ds-cfg-rotation-action $ ds-cfg-retention-policy-dn $ |
| | | ds-cfg-thread-time-interval $ ds-cfg-buffer-size $ ds-cfg-writer-auto-flush $ |
| | | ds-cfg-writer-append ) |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | objectClasses: ( 1.3.6.1.4.1.26027.1.2.27 |
| | | NAME 'ds-cfg-file-based-debug-logger' SUP ds-cfg-debug-logger STRUCTURAL |
| | | MUST ds-cfg-log-file MAY ( ds-cfg-rotation-policy $ ds-cfg-size-limit $ |
| | | ds-cfg-fixed-time-limit $ ds-cfg-time-of-day $ ds-cfg-rotation-action $ |
| | | ds-cfg-retention-policy $ ds-cfg-number-of-files $ ds-cfg-disk-space-used $ |
| | | ds-cfg-thread-time-interval $ ds-cfg-buffer-size $ ds-cfg-free-disk-space $ |
| | | ds-cfg-default-severity $ ds-cfg-override-severity ) |
| | | MUST ( ds-cfg-log-file $ ds-cfg-asynchronous-writes $ ds-cfg-log-file-mode ) |
| | | MAY ( ds-cfg-rotation-policy-dn $ |
| | | ds-cfg-rotation-action $ ds-cfg-retention-policy-dn $ |
| | | ds-cfg-thread-time-interval $ ds-cfg-buffer-size $ ds-cfg-writer-auto-flush $ |
| | | ds-cfg-writer-append ) |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | objectClasses: ( 1.3.6.1.4.1.26027.1.2.28 |
| | | NAME 'ds-cfg-file-based-error-logger' SUP ds-cfg-error-logger STRUCTURAL |
| | | MUST ds-cfg-log-file MAY ( ds-cfg-rotation-policy $ ds-cfg-size-limit $ |
| | | ds-cfg-fixed-time-limit $ ds-cfg-time-of-day $ ds-cfg-rotation-action $ |
| | | ds-cfg-retention-policy $ ds-cfg-number-of-files $ ds-cfg-disk-space-used $ |
| | | ds-cfg-thread-time-interval $ ds-cfg-buffer-size $ ds-cfg-free-disk-space $ |
| | | ds-cfg-default-severity $ ds-cfg-override-severity ) |
| | | MUST ( ds-cfg-log-file $ ds-cfg-asynchronous-writes $ ds-cfg-log-file-mode ) |
| | | MAY ( ds-cfg-rotation-policy-dn $ |
| | | ds-cfg-rotation-action $ ds-cfg-retention-policy-dn $ |
| | | ds-cfg-thread-time-interval $ ds-cfg-buffer-size $ ds-cfg-writer-auto-flush $ |
| | | ds-cfg-writer-append ) |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | objectClasses: ( 1.3.6.1.4.1.26027.1.2.29 NAME 'ds-cfg-matching-rule' |
| | | SUP top STRUCTURAL MUST ( cn $ ds-cfg-matching-rule-class $ |
| | |
| | | ds-cfg-allow-unclassified-characters ) X-ORIGIN 'OpenDS Directory Server' ) |
| | | objectClasses: ( 1.3.6.1.4.1.26027.1.2.98 |
| | | NAME 'ds-task-rebuild' SUP ds-task |
| | | MUST ( ds-task-rebuild-base-dn $ ds-task-rebuild-index ) |
| | | STRUCTURAL MUST ( ds-task-rebuild-base-dn $ ds-task-rebuild-index ) |
| | | MAY ( ds-task-rebuild-max-threads ) |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | objectClasses: ( 1.3.6.1.4.1.26027.1.2.99 NAME 'ds-virtual-static-group' |
| | |
| | | STRUCTURAL MUST ds-cfg-virtual-attribute-value |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | objectClasses: ( 1.3.6.1.4.1.26027.1.2.101 |
| | | NAME 'ds-cfg-debug-target' |
| | | STRUCTURAL MUST ( ds-cfg-debug-scope $ ds-cfg-debug-level ) |
| | | MAY (ds-cfg-debug-category $ ds-cfg-omit-method-entry-arguments $ |
| | | ds-cfg-omit-method-return-value $ ds-cfg-omit-method-return-value $ |
| | | ds-cfg-include-throwable-cause $ ds-cfg-throwable-stack-frames ) |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | objectClasses: ( 1.3.6.1.4.1.26027.1.2.102 |
| | | NAME 'ds-cfg-log-retention-policy' |
| | | STRUCTURAL MUST ( cn $ ds-cfg-retention-policy-class ) |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | objectClasses: ( 1.3.6.1.4.1.26027.1.2.103 |
| | | NAME 'ds-cfg-file-count-log-retention-policy' SUP ds-cfg-log-retention-policy |
| | | STRUCTURAL MUST ( ds-cfg-number-of-files ) |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | objectClasses: ( 1.3.6.1.4.1.26027.1.2.104 |
| | | NAME 'ds-cfg-size-limit-log-retention-policy' SUP ds-cfg-log-retention-policy |
| | | STRUCTURAL MUST ( ds-cfg-disk-space-used ) |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | objectClasses: ( 1.3.6.1.4.1.26027.1.2.105 |
| | | NAME 'ds-cfg-free-disk-space-log-retention-policy' |
| | | SUP ds-cfg-log-retention-policy |
| | | STRUCTURAL MUST ( ds-cfg-free-disk-space ) |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | objectClasses: ( 1.3.6.1.4.1.26027.1.2.106 |
| | | NAME 'ds-cfg-log-rotation-policy' |
| | | STRUCTURAL MUST ( cn $ ds-cfg-rotation-policy-class ) |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | objectClasses: ( 1.3.6.1.4.1.26027.1.2.107 |
| | | NAME 'ds-cfg-size-limit-log-rotation-policy' |
| | | SUP ds-cfg-log-rotation-policy |
| | | STRUCTURAL MUST ( ds-cfg-file-size-limit ) |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | objectClasses: ( 1.3.6.1.4.1.26027.1.2.108 |
| | | NAME 'ds-cfg-time-limit-log-rotation-policy' |
| | | SUP ds-cfg-log-rotation-policy |
| | | STRUCTURAL MUST ( ds-cfg-rotation-interval ) |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | objectClasses: ( 1.3.6.1.4.1.26027.1.2.109 |
| | | NAME 'ds-cfg-fixed-time-log-rotation-policy' |
| | | SUP ds-cfg-log-rotation-policy |
| | | STRUCTURAL MUST ( ds-cfg-time-of-day ) |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| | | objectClasses: ( 1.3.6.1.4.1.26027.1.2.113 |
| | | NAME 'ds-cfg-member-virtual-attribute' SUP ds-cfg-virtual-attribute |
| | | STRUCTURAL MUST ds-cfg-allow-retrieving-membership |
| | | X-ORIGIN 'OpenDS Directory Server' ) |
| New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <adm:managed-object name="access-log-publisher" |
| | | plural-name="access-log-publishers" |
| | | package="org.opends.server.admin.std" |
| | | extends="log-publisher" |
| | | abstract="true" |
| | | xmlns:adm="http://www.opends.org/admin" |
| | | xmlns:ldap="http://www.opends.org/admin-ldap"> |
| | | <adm:synopsis> |
| | | <adm:user-friendly-plural-name /> |
| | | are reponsible for distributing access log messages from the access logger |
| | | to a destination. |
| | | </adm:synopsis> |
| | | <adm:profile name="ldap"> |
| | | <ldap:object-class> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.2.23</ldap:oid> |
| | | <ldap:name>ds-cfg-access-logger</ldap:name> |
| | | <ldap:superior>ds-cfg-logger</ldap:superior> |
| | | </ldap:object-class> |
| | | </adm:profile> |
| | | <adm:property name="java-implementation-class" mandatory="true"> |
| | | <adm:synopsis> |
| | | The fully-qualified name of the Java class that provides the |
| | | <adm:user-friendly-name /> |
| | | implementation. |
| | | </adm:synopsis> |
| | | <adm:syntax> |
| | | <adm:java-class> |
| | | <adm:instance-of> |
| | | org.opends.server.api.AccessLogPublisher |
| | | </adm:instance-of> |
| | | </adm:java-class> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.60</ldap:oid> |
| | | <ldap:name>ds-cfg-logger-class</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="suppress-internal-operations"> |
| | | <adm:synopsis> |
| | | Omit access messages generated by internal operations. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:defined> |
| | | <adm:value> |
| | | true |
| | | </adm:value> |
| | | </adm:defined> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:boolean /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.123</ldap:oid> |
| | | <ldap:name>ds-cfg-suppress-internal-operations</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | </adm:managed-object> |
| New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <adm:managed-object name="debug-log-publisher" |
| | | plural-name="debug-log-publishers" |
| | | package="org.opends.server.admin.std" |
| | | extends="log-publisher" |
| | | abstract="true" |
| | | xmlns:adm="http://www.opends.org/admin" |
| | | xmlns:ldap="http://www.opends.org/admin-ldap"> |
| | | <adm:synopsis> |
| | | <adm:user-friendly-plural-name /> |
| | | are reponsible for distributing debug log messages from the debug logger to |
| | | a destination. |
| | | </adm:synopsis> |
| | | <adm:profile name="ldap"> |
| | | <ldap:object-class> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.2.25</ldap:oid> |
| | | <ldap:name>ds-cfg-debug-logger</ldap:name> |
| | | <ldap:superior>ds-cfg-logger</ldap:superior> |
| | | </ldap:object-class> |
| | | </adm:profile> |
| | | <adm:relation name="debug-target"> |
| | | <adm:one-to-many /> |
| | | <adm:profile name="ldap"> |
| | | <ldap:rdn-sequence> |
| | | cn=Debug Targets |
| | | </ldap:rdn-sequence> |
| | | <ldap:naming-attribute> |
| | | ds-cfg-debug-scope |
| | | </ldap:naming-attribute> |
| | | </adm:profile> |
| | | </adm:relation> |
| | | <adm:property name="java-implementation-class" mandatory="true"> |
| | | <adm:synopsis> |
| | | The fully-qualified name of the Java class that provides the |
| | | <adm:user-friendly-name /> |
| | | implementation. |
| | | </adm:synopsis> |
| | | <adm:syntax> |
| | | <adm:java-class> |
| | | <adm:instance-of> |
| | | org.opends.server.api.DebugLogPublisher |
| | | </adm:instance-of> |
| | | </adm:java-class> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.60</ldap:oid> |
| | | <ldap:name>ds-cfg-logger-class</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="default-debug-level" mandatory="true"> |
| | | <adm:synopsis> |
| | | The lowest severity level of debug messages to log when none of the |
| | | defined targets match the message. |
| | | </adm:synopsis> |
| | | <adm:syntax> |
| | | <adm:enumeration> |
| | | <adm:value name="disabled"> |
| | | <adm:synopsis> |
| | | No messages will be logged. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="error"> |
| | | <adm:synopsis> |
| | | Messages with severity level of ERROR or higher will be logged. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="warning"> |
| | | <adm:synopsis> |
| | | Messages with severity level of WARNING or higher will be logged. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="info"> |
| | | <adm:synopsis> |
| | | Messages with severity level of INFO or higher will be logged. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="verbose"> |
| | | <adm:synopsis> |
| | | Messages with severity level of VERBOSE or higher will be logged. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="all"> |
| | | <adm:synopsis> |
| | | Messages with any severity level will be logged. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | </adm:enumeration> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.345</ldap:oid> |
| | | <ldap:name>ds-cfg-default-debug-level</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="default-debug-category" multi-valued="true"> |
| | | <adm:synopsis> |
| | | The category(ies) of debug messages to log when none of the defined |
| | | targets match the message. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:alias> |
| | | <adm:synopsis> |
| | | Messages with any category will be logged. |
| | | </adm:synopsis> |
| | | </adm:alias> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:enumeration> |
| | | <adm:value name="caught"> |
| | | <adm:synopsis> |
| | | Exception caught. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="constructor"> |
| | | <adm:synopsis> |
| | | Constructor entry. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="data"> |
| | | <adm:synopsis> |
| | | Raw data dump. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="database-access"> |
| | | <adm:synopsis> |
| | | Access to a backend database. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="enter"> |
| | | <adm:synopsis> |
| | | Method entry. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="exit"> |
| | | <adm:synopsis> |
| | | Method exit. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="message"> |
| | | <adm:synopsis> |
| | | Arbitrary debug message. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="protocol"> |
| | | <adm:synopsis> |
| | | Protocol element dump. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="thrown"> |
| | | <adm:synopsis> |
| | | Exception throw from method. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | </adm:enumeration> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.346</ldap:oid> |
| | | <ldap:name>ds-cfg-default-debug-category</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="default-omit-method-entry-arguments"> |
| | | <adm:synopsis> |
| | | Property to indicate whether to include method arguments in debug messages |
| | | logged by default. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:defined> |
| | | <adm:value> |
| | | false |
| | | </adm:value> |
| | | </adm:defined> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:boolean /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.347</ldap:oid> |
| | | <ldap:name>ds-cfg-default-omit-method-entry-arguments</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="default-omit-method-return-value"> |
| | | <adm:synopsis> |
| | | Property to indicate whether to include the return value in debug messages |
| | | logged by default. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:defined> |
| | | <adm:value> |
| | | false |
| | | </adm:value> |
| | | </adm:defined> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:boolean /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.348</ldap:oid> |
| | | <ldap:name>ds-cfg-default-omit-method-return-value</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="default-include-throwable-cause"> |
| | | <adm:synopsis> |
| | | Property to indicate whether to include the cause of exceptions in |
| | | exception thrown and caught messages logged by default. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:defined> |
| | | <adm:value> |
| | | false |
| | | </adm:value> |
| | | </adm:defined> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:boolean /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.349</ldap:oid> |
| | | <ldap:name>ds-cfg-default-include-throwable-cause</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="default-throwable-stack-frames"> |
| | | <adm:synopsis> |
| | | Property to indicate the number of stack frames to include in the stack |
| | | trace for method entry and exception thrown messages. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:defined> |
| | | <adm:value> |
| | | 0 |
| | | </adm:value> |
| | | </adm:defined> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:integer lower-limit="0" /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.350</ldap:oid> |
| | | <ldap:name>ds-cfg-default-throwable-stack-frames</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | </adm:managed-object> |
| New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <adm:managed-object name="debug-target" |
| | | plural-name="debug-targets" |
| | | package="org.opends.server.admin.std" |
| | | xmlns:adm="http://www.opends.org/admin" |
| | | xmlns:ldap="http://www.opends.org/admin-ldap"> |
| | | <adm:synopsis> |
| | | <adm:user-friendly-plural-name /> |
| | | define the types of messages logged by the debug logPublisher. |
| | | </adm:synopsis> |
| | | <adm:profile name="ldap"> |
| | | <ldap:object-class> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.2.101</ldap:oid> |
| | | <ldap:name>ds-cfg-debug-target</ldap:name> |
| | | <ldap:superior>top</ldap:superior> |
| | | </ldap:object-class> |
| | | </adm:profile> |
| | | <adm:property name="debug-scope" mandatory="true"> |
| | | <adm:synopsis> |
| | | The fully-qualified OpenDS Java package, class, or method affected by |
| | | the settings in this target definition. Use the number character (#) to |
| | | seperate the class name and the method name. |
| | | (ie. org.opends.server.core.DirectoryServer#startUp) |
| | | </adm:synopsis> |
| | | <adm:syntax> |
| | | <adm:string> |
| | | <adm:pattern> |
| | | <adm:regex> |
| | | ^([A-Za-z][A-Za-z0-9_]*\\.)*[A-Za-z][A-Za-z0-9_]*(#[A-Za-z][A-Za-z0-9_]*)?$ |
| | | </adm:regex> |
| | | <adm:synopsis> |
| | | A fully-qualified OpenDS Java package, class, or method name. |
| | | </adm:synopsis> |
| | | </adm:pattern> |
| | | </adm:string> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid> |
| | | 1.3.6.1.4.1.26027.1.1.351 |
| | | </ldap:oid> |
| | | <ldap:name> |
| | | ds-cfg-debug-scope |
| | | </ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="debug-level" mandatory="true"> |
| | | <adm:synopsis> |
| | | The lowest severity level of debug messages to log. |
| | | </adm:synopsis> |
| | | <adm:syntax> |
| | | <adm:enumeration> |
| | | <adm:value name="disabled"> |
| | | <adm:synopsis> |
| | | No messages will be logged. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="error"> |
| | | <adm:synopsis> |
| | | Messages with severity level of ERROR or higher will be logged. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="warning"> |
| | | <adm:synopsis> |
| | | Messages with severity level of WARNING or higher will be logged. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="info"> |
| | | <adm:synopsis> |
| | | Messages with severity level of INFO or higher will be logged. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="verbose"> |
| | | <adm:synopsis> |
| | | Messages with severity level of VERBOSE or higher will be logged. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="all"> |
| | | <adm:synopsis> |
| | | Messages with any severity level will be logged. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | </adm:enumeration> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.352</ldap:oid> |
| | | <ldap:name>ds-cfg-debug-level</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="debug-category" multi-valued="true"> |
| | | <adm:synopsis> |
| | | The category(ies) of debug messages to log. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:alias> |
| | | <adm:synopsis> |
| | | Messages with any category will be logged. |
| | | </adm:synopsis> |
| | | </adm:alias> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:enumeration> |
| | | <adm:value name="caught"> |
| | | <adm:synopsis> |
| | | Exception caught. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="constructor"> |
| | | <adm:synopsis> |
| | | Constructor entry. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="data"> |
| | | <adm:synopsis> |
| | | Raw data dump. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="database-access"> |
| | | <adm:synopsis> |
| | | Access to a backend database. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="enter"> |
| | | <adm:synopsis> |
| | | Method entry. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="exit"> |
| | | <adm:synopsis> |
| | | Method exit. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="message"> |
| | | <adm:synopsis> |
| | | Arbitrary debug message. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="protocol"> |
| | | <adm:synopsis> |
| | | Protocol element dump. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="thrown"> |
| | | <adm:synopsis> |
| | | Exception throw from method. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | </adm:enumeration> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.353</ldap:oid> |
| | | <ldap:name>ds-cfg-debug-category</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="omit-method-entry-arguments"> |
| | | <adm:synopsis> |
| | | Property to indicate whether to include method arguments in debug |
| | | messages. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:defined> |
| | | <adm:value> |
| | | false |
| | | </adm:value> |
| | | </adm:defined> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:boolean /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.354</ldap:oid> |
| | | <ldap:name>ds-cfg-omit-method-entry-arguments</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="omit-method-return-value"> |
| | | <adm:synopsis> |
| | | Property to indicate whether to include the return value in debug |
| | | messages. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:defined> |
| | | <adm:value> |
| | | false |
| | | </adm:value> |
| | | </adm:defined> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:boolean /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.355</ldap:oid> |
| | | <ldap:name>ds-cfg-omit-method-return-value</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="include-throwable-cause"> |
| | | <adm:synopsis> |
| | | Property to indicate whether to include the cause of exceptions in |
| | | exception thrown and caught messages. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:defined> |
| | | <adm:value> |
| | | false |
| | | </adm:value> |
| | | </adm:defined> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:boolean /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.356</ldap:oid> |
| | | <ldap:name>ds-cfg-include-throwable-cause</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="throwable-stack-frames"> |
| | | <adm:synopsis> |
| | | Property to indicate the number of stack frames to include in the stack |
| | | trace for method entry and exception thrown messages. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:defined> |
| | | <adm:value> |
| | | 0 |
| | | </adm:value> |
| | | </adm:defined> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:integer lower-limit="0" /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.357</ldap:oid> |
| | | <ldap:name>ds-cfg-throwable-stack-frames</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | </adm:managed-object> |
| New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <adm:managed-object name="error-log-publisher" |
| | | plural-name="error-log-publishers" |
| | | package="org.opends.server.admin.std" |
| | | extends="log-publisher" |
| | | abstract="true" |
| | | xmlns:adm="http://www.opends.org/admin" |
| | | xmlns:ldap="http://www.opends.org/admin-ldap"> |
| | | <adm:synopsis> |
| | | <adm:user-friendly-plural-name /> |
| | | are reponsible for distributing error log messages from the error logger to |
| | | a destination. |
| | | </adm:synopsis> |
| | | <adm:profile name="ldap"> |
| | | <ldap:object-class> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.2.24</ldap:oid> |
| | | <ldap:name>ds-cfg-error-logger</ldap:name> |
| | | <ldap:superior>ds-cfg-logger</ldap:superior> |
| | | </ldap:object-class> |
| | | </adm:profile> |
| | | <adm:property name="java-implementation-class" mandatory="true"> |
| | | <adm:synopsis> |
| | | The fully-qualified name of the Java class that provides the |
| | | <adm:user-friendly-name /> |
| | | implementation. |
| | | </adm:synopsis> |
| | | <adm:syntax> |
| | | <adm:java-class> |
| | | <adm:instance-of> |
| | | org.opends.server.api.ErrorLogPublisher |
| | | </adm:instance-of> |
| | | </adm:java-class> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.60</ldap:oid> |
| | | <ldap:name>ds-cfg-logger-class</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="default-severity" multi-valued="true"> |
| | | <adm:synopsis> |
| | | Property to specify the default severity levels for the logger. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:alias> |
| | | <adm:synopsis> |
| | | Severities fatal-error, severe-warning, and severe-error will |
| | | be used for the logger. |
| | | </adm:synopsis> |
| | | </adm:alias> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:enumeration> |
| | | <adm:value name="fatal-error"> |
| | | <adm:synopsis> |
| | | The error log severity that will be used for messages that |
| | | provide information about fatal errors which may force the server |
| | | to shut down or operate in a significantly degraded state. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="generic-debug"> |
| | | <adm:synopsis> |
| | | The error log severity that will be used for debug messages |
| | | generated during general processing that may be useful enough to |
| | | warrant making them available without restarting the server in |
| | | debug mode. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="informational"> |
| | | <adm:synopsis> |
| | | The error log severity that will be used for messages that |
| | | provide information about significant events within the server |
| | | that are not warnings or errors. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="mild-error"> |
| | | <adm:synopsis> |
| | | The error log severity that will be used for messages that |
| | | provide information about mild (recoverable) errors encountered |
| | | during processing. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="mild-warning"> |
| | | <adm:synopsis> |
| | | The error log severity that will be used for messages that |
| | | provide information about mild warnings triggered during |
| | | processing. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="notice"> |
| | | <adm:synopsis> |
| | | The error log severity that will be used for the most important |
| | | informational messages (i.e., information that should almost |
| | | always be logged but is not associated with a warning or error |
| | | condition). |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="severe-error"> |
| | | <adm:synopsis> |
| | | The error log severity that will be used for messages that |
| | | provide information about severe errors encountered during |
| | | processing. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="severe-warning"> |
| | | <adm:synopsis> |
| | | The error log severity that will be used for messages that |
| | | provide information about severe warnings triggered during |
| | | processing. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="shutdown-debug"> |
| | | <adm:synopsis> |
| | | The error log severity that will be used for debug messages |
| | | generated during server shutdown. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | <adm:value name="startup-debug"> |
| | | <adm:synopsis> |
| | | The error log severity that will be used for debug messages |
| | | generated during server startup. |
| | | </adm:synopsis> |
| | | </adm:value> |
| | | </adm:enumeration> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.31</ldap:oid> |
| | | <ldap:name>ds-cfg-default-severity</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="override-severity" multi-valued="true"> |
| | | <adm:synopsis> |
| | | Property to specify the override severity levels for the logger. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:alias> |
| | | <adm:synopsis> |
| | | Messages will use the default severity levels. |
| | | </adm:synopsis> |
| | | </adm:alias> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:string /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.74</ldap:oid> |
| | | <ldap:name>ds-cfg-override-severity</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | </adm:managed-object> |
| New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <adm:managed-object name="file-based-access-log-publisher" |
| | | plural-name="file-based-access-log-publishers" |
| | | package="org.opends.server.admin.std" extends="access-log-publisher" |
| | | xmlns:adm="http://www.opends.org/admin" |
| | | xmlns:ldap="http://www.opends.org/admin-ldap"> |
| | | <adm:synopsis> |
| | | <adm:user-friendly-plural-name /> |
| | | publish access messages to the file system. |
| | | </adm:synopsis> |
| | | <adm:profile name="ldap"> |
| | | <ldap:object-class> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.2.26</ldap:oid> |
| | | <ldap:name>ds-cfg-file-based-access-logger</ldap:name> |
| | | <ldap:superior>ds-cfg-access-logger</ldap:superior> |
| | | </ldap:object-class> |
| | | </adm:profile> |
| | | <adm:property name="asynchronous" mandatory="true"> |
| | | <adm:synopsis> |
| | | Indicate whether the |
| | | <adm:user-friendly-name /> |
| | | will publish records asyncronously. |
| | | </adm:synopsis> |
| | | <adm:syntax> |
| | | <adm:boolean /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.358</ldap:oid> |
| | | <ldap:name>ds-cfg-asynchronous-writes</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="queue-size"> |
| | | <adm:synopsis> |
| | | The maximum number of log records that can be stored in the |
| | | asynchronous queue. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:defined> |
| | | <adm:value> |
| | | 5000 |
| | | </adm:value> |
| | | </adm:defined> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:integer /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.378</ldap:oid> |
| | | <ldap:name>dscfg-log-queue-size</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="log-file" mandatory="true"> |
| | | <adm:synopsis> |
| | | The file name to use for the log files generated by the |
| | | <adm:user-friendly-name />. The path to the file is relative to the server |
| | | root. |
| | | </adm:synopsis> |
| | | <adm:syntax> |
| | | <adm:string /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.59</ldap:oid> |
| | | <ldap:name>ds-cfg-log-file</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="log-file-mode" mandatory="true"> |
| | | <adm:synopsis> |
| | | The UNIX permissions of the log files created by this |
| | | <adm:user-friendly-name />. |
| | | </adm:synopsis> |
| | | <adm:syntax> |
| | | <adm:string> |
| | | <adm:pattern> |
| | | <adm:regex> |
| | | ^([0-7][0-7][0-7])$ |
| | | </adm:regex> |
| | | <adm:synopsis> |
| | | An valid UNIX mode string. The mode string must contain three |
| | | digits between zero and seven. |
| | | </adm:synopsis> |
| | | </adm:pattern> |
| | | </adm:string> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.359</ldap:oid> |
| | | <ldap:name>ds-cfg-log-file-mode</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="time-interval"> |
| | | <adm:synopsis> |
| | | This property specifies the interval to check whether |
| | | the log files need to be rotated. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:defined> |
| | | <adm:value> |
| | | 5s |
| | | </adm:value> |
| | | </adm:defined> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:duration base-unit="ms" lower-limit="1"/> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.109</ldap:oid> |
| | | <ldap:name>ds-cfg-thread-time-interval</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="buffer-size"> |
| | | <adm:synopsis> |
| | | This property specifies the log file buffer size. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:defined> |
| | | <adm:value> |
| | | 64kb |
| | | </adm:value> |
| | | </adm:defined> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:size lower-limit="1" /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.110</ldap:oid> |
| | | <ldap:name>ds-cfg-buffer-size</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="auto-flush"> |
| | | <adm:synopsis> |
| | | This property specifies whether to flush the writer after every log |
| | | record. If the asynchronous writes option is used, the writer will |
| | | be flushed after all the log records in the queue are written. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:defined> |
| | | <adm:value> |
| | | true |
| | | </adm:value> |
| | | </adm:defined> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:boolean /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.360</ldap:oid> |
| | | <ldap:name>ds-cfg-writer-auto-flush</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="append"> |
| | | <adm:synopsis> |
| | | This property specifies whether to append to existing log files. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:defined> |
| | | <adm:value> |
| | | true |
| | | </adm:value> |
| | | </adm:defined> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:boolean /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.361</ldap:oid> |
| | | <ldap:name>ds-cfg-writer-append</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="rotation-policy-dn" multi-valued="true"> |
| | | <adm:synopsis> |
| | | The retention policy to use for the <adm:user-friendly-name />. When |
| | | multiple policies are used, rotation will occur if any policy's conditions |
| | | are met. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:alias> |
| | | <adm:synopsis> |
| | | No rotation policy is used and log rotation will not occur. |
| | | </adm:synopsis> |
| | | </adm:alias> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:dn> |
| | | <adm:base> |
| | | cn=Log Rotation Policies,cn=config |
| | | </adm:base> |
| | | </adm:dn> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.90</ldap:oid> |
| | | <ldap:name>ds-cfg-rotation-policy-dn</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="retention-policy-dn" multi-valued="true"> |
| | | <adm:synopsis> |
| | | The retention policy to use for the <adm:user-friendly-name />. When |
| | | multiple policies are used, log files will be cleaned when any of the |
| | | policy's conditions are met |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:alias> |
| | | <adm:synopsis> |
| | | No rentation policy is used and log files will never be cleaned. |
| | | </adm:synopsis> |
| | | </adm:alias> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:dn> |
| | | <adm:base> |
| | | cn=Log Retention Policies,cn=config |
| | | </adm:base> |
| | | </adm:dn> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.91</ldap:oid> |
| | | <ldap:name>ds-cfg-retention-policy-dn</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | </adm:managed-object> |
| New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <adm:managed-object name="file-based-debug-log-publisher" |
| | | plural-name="file-based-debug-log-publishers" |
| | | package="org.opends.server.admin.std" extends="debug-log-publisher" |
| | | xmlns:adm="http://www.opends.org/admin" |
| | | xmlns:ldap="http://www.opends.org/admin-ldap"> |
| | | <adm:synopsis> |
| | | <adm:user-friendly-plural-name /> |
| | | publish debug messages to the file system. |
| | | </adm:synopsis> |
| | | <adm:profile name="ldap"> |
| | | <ldap:object-class> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.2.27</ldap:oid> |
| | | <ldap:name>ds-cfg-file-based-debug-logger</ldap:name> |
| | | <ldap:superior>ds-cfg-debug-logger</ldap:superior> |
| | | </ldap:object-class> |
| | | </adm:profile> |
| | | <adm:property name="asynchronous" mandatory="true"> |
| | | <adm:synopsis> |
| | | Indicate whether the |
| | | <adm:user-friendly-name /> |
| | | will publish records asyncronously. |
| | | </adm:synopsis> |
| | | <adm:syntax> |
| | | <adm:boolean /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.358</ldap:oid> |
| | | <ldap:name>ds-cfg-asynchronous-writes</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="queue-size"> |
| | | <adm:synopsis> |
| | | The maximum number of log records that can be stored in the |
| | | asynchronous queue. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:defined> |
| | | <adm:value> |
| | | 5000 |
| | | </adm:value> |
| | | </adm:defined> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:integer /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.378</ldap:oid> |
| | | <ldap:name>dscfg-log-queue-size</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="log-file" mandatory="true"> |
| | | <adm:synopsis> |
| | | The file name to use for the log files generated by the |
| | | <adm:user-friendly-name />. The path to the file is relative to the server |
| | | root. |
| | | </adm:synopsis> |
| | | <adm:syntax> |
| | | <adm:string /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.59</ldap:oid> |
| | | <ldap:name>ds-cfg-log-file</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="log-file-mode" mandatory="true"> |
| | | <adm:synopsis> |
| | | The UNIX permissions of the log files created by this |
| | | <adm:user-friendly-name />. |
| | | </adm:synopsis> |
| | | <adm:syntax> |
| | | <adm:string> |
| | | <adm:pattern> |
| | | <adm:regex> |
| | | ^([0-7][0-7][0-7])$ |
| | | </adm:regex> |
| | | <adm:synopsis> |
| | | An valid UNIX mode string. The mode string must contain three |
| | | digits between zero and seven. |
| | | </adm:synopsis> |
| | | </adm:pattern> |
| | | </adm:string> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.359</ldap:oid> |
| | | <ldap:name>ds-cfg-log-file-mode</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="time-interval"> |
| | | <adm:synopsis> |
| | | This property specifies the interval to check whether |
| | | the log files need to be rotated. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:defined> |
| | | <adm:value> |
| | | 5s |
| | | </adm:value> |
| | | </adm:defined> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:duration base-unit="ms" lower-limit="1"/> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.109</ldap:oid> |
| | | <ldap:name>ds-cfg-thread-time-interval</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="buffer-size"> |
| | | <adm:synopsis> |
| | | This property specifies the log file buffer size. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:defined> |
| | | <adm:value> |
| | | 64kb |
| | | </adm:value> |
| | | </adm:defined> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:size lower-limit="1" /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.110</ldap:oid> |
| | | <ldap:name>ds-cfg-buffer-size</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="auto-flush"> |
| | | <adm:synopsis> |
| | | This property specifies whether to flush the writer after every log |
| | | record. If the asynchronous writes option is used, the writer will |
| | | be flushed after all the log records in the queue are written. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:defined> |
| | | <adm:value> |
| | | true |
| | | </adm:value> |
| | | </adm:defined> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:boolean /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.360</ldap:oid> |
| | | <ldap:name>ds-cfg-writer-auto-flush</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="append"> |
| | | <adm:synopsis> |
| | | This property specifies whether to append to existing log files. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:defined> |
| | | <adm:value> |
| | | true |
| | | </adm:value> |
| | | </adm:defined> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:boolean /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.361</ldap:oid> |
| | | <ldap:name>ds-cfg-writer-append</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="rotation-policy-dn" multi-valued="true"> |
| | | <adm:synopsis> |
| | | The retention policy to use for the <adm:user-friendly-name />. When |
| | | multiple policies are used, rotation will occur if any policy's conditions |
| | | are met. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:alias> |
| | | <adm:synopsis> |
| | | No rotation policy is used and log rotation will not occur. |
| | | </adm:synopsis> |
| | | </adm:alias> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:dn> |
| | | <adm:base> |
| | | cn=Log Rotation Policies,cn=config |
| | | </adm:base> |
| | | </adm:dn> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.90</ldap:oid> |
| | | <ldap:name>ds-cfg-rotation-policy-dn</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="retention-policy-dn" multi-valued="true"> |
| | | <adm:synopsis> |
| | | The retention policy to use for the <adm:user-friendly-name />. When |
| | | multiple policies are used, log files will be cleaned when any of the |
| | | policy's conditions are met |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:alias> |
| | | <adm:synopsis> |
| | | No rentation policy is used and log files will never be cleaned. |
| | | </adm:synopsis> |
| | | </adm:alias> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:dn> |
| | | <adm:base> |
| | | cn=Log Retention Policies,cn=config |
| | | </adm:base> |
| | | </adm:dn> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.91</ldap:oid> |
| | | <ldap:name>ds-cfg-retention-policy-dn</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | </adm:managed-object> |
| New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <adm:managed-object name="file-based-error-log-publisher" |
| | | plural-name="file-based-error-log-publishers" |
| | | package="org.opends.server.admin.std" extends="error-log-publisher" |
| | | xmlns:adm="http://www.opends.org/admin" |
| | | xmlns:ldap="http://www.opends.org/admin-ldap"> |
| | | <adm:synopsis> |
| | | <adm:user-friendly-plural-name /> |
| | | publish error messages to the file system. |
| | | </adm:synopsis> |
| | | <adm:profile name="ldap"> |
| | | <ldap:object-class> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.2.28</ldap:oid> |
| | | <ldap:name>ds-cfg-file-based-error-logger</ldap:name> |
| | | <ldap:superior>ds-cfg-error-logger</ldap:superior> |
| | | </ldap:object-class> |
| | | </adm:profile> |
| | | <adm:property name="asynchronous" mandatory="true"> |
| | | <adm:synopsis> |
| | | Indicate whether the |
| | | <adm:user-friendly-name /> |
| | | will publish records asyncronously. |
| | | </adm:synopsis> |
| | | <adm:syntax> |
| | | <adm:boolean /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.358</ldap:oid> |
| | | <ldap:name>ds-cfg-asynchronous-writes</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="queue-size"> |
| | | <adm:synopsis> |
| | | The maximum number of log records that can be stored in the |
| | | asynchronous queue. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:defined> |
| | | <adm:value> |
| | | 5000 |
| | | </adm:value> |
| | | </adm:defined> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:integer /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.378</ldap:oid> |
| | | <ldap:name>dscfg-log-queue-size</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="log-file" mandatory="true"> |
| | | <adm:synopsis> |
| | | The file name to use for the log files generated by the |
| | | <adm:user-friendly-name />. The path to the file is relative to the server |
| | | root. |
| | | </adm:synopsis> |
| | | <adm:syntax> |
| | | <adm:string /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.59</ldap:oid> |
| | | <ldap:name>ds-cfg-log-file</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="log-file-mode" mandatory="true"> |
| | | <adm:synopsis> |
| | | The UNIX permissions of the log files created by this |
| | | <adm:user-friendly-name />. |
| | | </adm:synopsis> |
| | | <adm:syntax> |
| | | <adm:string> |
| | | <adm:pattern> |
| | | <adm:regex> |
| | | ^([0-7][0-7][0-7])$ |
| | | </adm:regex> |
| | | <adm:synopsis> |
| | | An valid UNIX mode string. The mode string must contain three |
| | | digits between zero and seven. |
| | | </adm:synopsis> |
| | | </adm:pattern> |
| | | </adm:string> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.359</ldap:oid> |
| | | <ldap:name>ds-cfg-log-file-mode</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="time-interval"> |
| | | <adm:synopsis> |
| | | This property specifies the interval to check whether |
| | | the log files need to be rotated. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:defined> |
| | | <adm:value> |
| | | 5s |
| | | </adm:value> |
| | | </adm:defined> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:duration base-unit="ms" lower-limit="1"/> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.109</ldap:oid> |
| | | <ldap:name>ds-cfg-thread-time-interval</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="buffer-size"> |
| | | <adm:synopsis> |
| | | This property specifies the log file buffer size. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:defined> |
| | | <adm:value> |
| | | 64kb |
| | | </adm:value> |
| | | </adm:defined> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:size lower-limit="1" /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.110</ldap:oid> |
| | | <ldap:name>ds-cfg-buffer-size</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="auto-flush"> |
| | | <adm:synopsis> |
| | | This property specifies whether to flush the writer after every log |
| | | record. If the asynchronous writes option is used, the writer will |
| | | be flushed after all the log records in the queue are written. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:defined> |
| | | <adm:value> |
| | | true |
| | | </adm:value> |
| | | </adm:defined> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:boolean /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.360</ldap:oid> |
| | | <ldap:name>ds-cfg-writer-auto-flush</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="append"> |
| | | <adm:synopsis> |
| | | This property specifies whether to append to existing log files. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:defined> |
| | | <adm:value> |
| | | true |
| | | </adm:value> |
| | | </adm:defined> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:boolean /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.361</ldap:oid> |
| | | <ldap:name>ds-cfg-writer-append</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="rotation-policy-dn" multi-valued="true"> |
| | | <adm:synopsis> |
| | | The retention policy to use for the <adm:user-friendly-name />. When |
| | | multiple policies are used, rotation will occur if any policy's conditions |
| | | are met. |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:alias> |
| | | <adm:synopsis> |
| | | No rotation policy is used and log rotation will not occur. |
| | | </adm:synopsis> |
| | | </adm:alias> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:dn> |
| | | <adm:base> |
| | | cn=Log Rotation Policies,cn=config |
| | | </adm:base> |
| | | </adm:dn> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.90</ldap:oid> |
| | | <ldap:name>ds-cfg-rotation-policy-dn</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | <adm:property name="retention-policy-dn" multi-valued="true"> |
| | | <adm:synopsis> |
| | | The retention policy to use for the <adm:user-friendly-name />. When |
| | | multiple policies are used, log files will be cleaned when any of the |
| | | policy's conditions are met |
| | | </adm:synopsis> |
| | | <adm:default-behavior> |
| | | <adm:alias> |
| | | <adm:synopsis> |
| | | No rentation policy is used and log files will never be cleaned. |
| | | </adm:synopsis> |
| | | </adm:alias> |
| | | </adm:default-behavior> |
| | | <adm:syntax> |
| | | <adm:dn> |
| | | <adm:base> |
| | | cn=Log Retention Policies,cn=config |
| | | </adm:base> |
| | | </adm:dn> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.91</ldap:oid> |
| | | <ldap:name>ds-cfg-retention-policy-dn</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | </adm:managed-object> |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <adm:managed-object |
| | | name="file-count-log-retention-policy" |
| | | plural-name="file-count-log-retention-policies" |
| | | package="org.opends.server.admin.std" |
| | | extends="log-retention-policy" |
| | | xmlns:adm="http://www.opends.org/admin" |
| | | xmlns:ldap="http://www.opends.org/admin-ldap"> |
| | | <adm:synopsis> |
| | | Retention policy based on the number of rotated log files on disk. |
| | | </adm:synopsis> |
| | | <adm:profile name="ldap"> |
| | | <ldap:object-class> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.2.103</ldap:oid> |
| | | <ldap:name>ds-cfg-file-count-log-retention-policy</ldap:name> |
| | | <ldap:superior>ds-cfg-log-retention-policy</ldap:superior> |
| | | </ldap:object-class> |
| | | </adm:profile> |
| | | <adm:property name="number-of-files" mandatory="true"> |
| | | <adm:synopsis> |
| | | Number of log files to retain before the oldest ones will be cleaned. |
| | | </adm:synopsis> |
| | | <adm:syntax> |
| | | <adm:integer lower-limit="1" /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.92</ldap:oid> |
| | | <ldap:name>ds-cfg-number-of-files</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | </adm:managed-object> |
| | | |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <adm:managed-object |
| | | name="fixed-time-log-rotation-policy" |
| | | plural-name="fixed-time-log-rotation-policies" |
| | | package="org.opends.server.admin.std" |
| | | extends="log-rotation-policy" |
| | | xmlns:adm="http://www.opends.org/admin" |
| | | xmlns:ldap="http://www.opends.org/admin-ldap"> |
| | | <adm:synopsis> |
| | | Rotation policy based on fixed time of day. |
| | | </adm:synopsis> |
| | | <adm:profile name="ldap"> |
| | | <ldap:object-class> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.2.109</ldap:oid> |
| | | <ldap:name>ds-cfg-fixed-time-log-rotation-policy</ldap:name> |
| | | <ldap:superior>ds-cfg-log-rotation-policy</ldap:superior> |
| | | </ldap:object-class> |
| | | </adm:profile> |
| | | <adm:property name="time-of-day" multi-valued="true" mandatory="true"> |
| | | <adm:synopsis> |
| | | The time of day which log rotation should occur. |
| | | </adm:synopsis> |
| | | <adm:syntax> |
| | | <adm:string> |
| | | <adm:pattern> |
| | | <adm:regex> |
| | | ^(([0-1][0-9])|([2][0-3]))([0-5][0-9])$ |
| | | </adm:regex> |
| | | <adm:synopsis> |
| | | 24 hour time of day in HHmm format. |
| | | </adm:synopsis> |
| | | </adm:pattern> |
| | | </adm:string> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.126</ldap:oid> |
| | | <ldap:name>ds-cfg-time-of-day</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | </adm:managed-object> |
| | | |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <adm:managed-object |
| | | name="free-disk-space-log-retention-policy" |
| | | plural-name="free-disk-space-log-retention-policies" |
| | | package="org.opends.server.admin.std" |
| | | extends="log-retention-policy" |
| | | xmlns:adm="http://www.opends.org/admin" |
| | | xmlns:ldap="http://www.opends.org/admin-ldap"> |
| | | <adm:synopsis> |
| | | Retention policy based on the free disk space available. |
| | | This policy is only available on Java 6. |
| | | </adm:synopsis> |
| | | <adm:profile name="ldap"> |
| | | <ldap:object-class> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.2.105</ldap:oid> |
| | | <ldap:name>ds-cfg-free-disk-space-log-retention-policy</ldap:name> |
| | | <ldap:superior>ds-cfg-log-retention-policy</ldap:superior> |
| | | </ldap:object-class> |
| | | </adm:profile> |
| | | <adm:property name="free-disk-space" mandatory="true"> |
| | | <adm:synopsis> |
| | | The size of free disk space needed. |
| | | </adm:synopsis> |
| | | <adm:syntax> |
| | | <adm:size lower-limit="1" /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.94</ldap:oid> |
| | | <ldap:name>ds-cfg-free-disk-space</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | </adm:managed-object> |
| | | |
| New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <adm:managed-object name="log-publisher" |
| | | plural-name="log-publishers" |
| | | package="org.opends.server.admin.std" abstract="true" |
| | | xmlns:adm="http://www.opends.org/admin" |
| | | xmlns:ldap="http://www.opends.org/admin-ldap"> |
| | | <adm:synopsis> |
| | | <adm:user-friendly-plural-name /> |
| | | are reponsible for distributing log messages from different loggers to |
| | | a destination. |
| | | </adm:synopsis> |
| | | <adm:profile name="ldap"> |
| | | <ldap:object-class> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.2.22</ldap:oid> |
| | | <ldap:name>ds-cfg-logger</ldap:name> |
| | | <ldap:superior>top</ldap:superior> |
| | | </ldap:object-class> |
| | | </adm:profile> |
| | | <adm:property name="enabled" mandatory="true"> |
| | | <adm:synopsis> |
| | | Indicate whether the |
| | | <adm:user-friendly-name /> |
| | | is enabled for use. |
| | | </adm:synopsis> |
| | | <adm:syntax> |
| | | <adm:boolean /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.61</ldap:oid> |
| | | <ldap:name>ds-cfg-logger-enabled</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | </adm:managed-object> |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <adm:managed-object |
| | | name="log-retention-policy" |
| | | plural-name="log-retention-policies" |
| | | package="org.opends.server.admin.std" |
| | | abstract="true" |
| | | xmlns:adm="http://www.opends.org/admin" |
| | | xmlns:ldap="http://www.opends.org/admin-ldap"> |
| | | <adm:synopsis> |
| | | <adm:user-friendly-plural-name /> are used to specify when log files should |
| | | be cleaned. |
| | | </adm:synopsis> |
| | | <adm:profile name="ldap"> |
| | | <ldap:object-class> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.2.102</ldap:oid> |
| | | <ldap:name>ds-cfg-log-retention-policy</ldap:name> |
| | | <ldap:superior>top</ldap:superior> |
| | | </ldap:object-class> |
| | | </adm:profile> |
| | | <adm:property name="java-implementation-class" mandatory="true"> |
| | | <adm:synopsis> |
| | | The fully-qualified name of the Java class that provides the |
| | | <adm:user-friendly-name /> |
| | | implementation. |
| | | </adm:synopsis> |
| | | <adm:syntax> |
| | | <adm:java-class> |
| | | <adm:instance-of> |
| | | org.opends.server.loggers.RetentionPolicy |
| | | </adm:instance-of> |
| | | </adm:java-class> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.362</ldap:oid> |
| | | <ldap:name>ds-cfg-retention-policy-class</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | </adm:managed-object> |
| | | |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <adm:managed-object |
| | | name="log-rotation-policy" |
| | | plural-name="log-rotation-policies" |
| | | package="org.opends.server.admin.std" |
| | | abstract="true" |
| | | xmlns:adm="http://www.opends.org/admin" |
| | | xmlns:ldap="http://www.opends.org/admin-ldap"> |
| | | <adm:synopsis> |
| | | <adm:user-friendly-plural-name /> are used to specify when log files should |
| | | be rotated. |
| | | </adm:synopsis> |
| | | <adm:profile name="ldap"> |
| | | <ldap:object-class> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.2.106</ldap:oid> |
| | | <ldap:name>ds-cfg-log-rotation-policy</ldap:name> |
| | | <ldap:superior>top</ldap:superior> |
| | | </ldap:object-class> |
| | | </adm:profile> |
| | | <adm:property name="java-implementation-class" mandatory="true"> |
| | | <adm:synopsis> |
| | | The fully-qualified name of the Java class that provides the |
| | | <adm:user-friendly-name /> |
| | | implementation. |
| | | </adm:synopsis> |
| | | <adm:syntax> |
| | | <adm:java-class> |
| | | <adm:instance-of> |
| | | org.opends.server.loggers.RotationPolicy |
| | | </adm:instance-of> |
| | | </adm:java-class> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.363</ldap:oid> |
| | | <ldap:name>ds-cfg-rotation-policy-class</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | </adm:managed-object> |
| | | |
| | |
| | | </ldap:rdn-sequence> |
| | | </adm:profile> |
| | | </adm:relation> |
| | | <adm:relation name="log-publisher"> |
| | | <adm:one-to-many /> |
| | | <adm:profile name="ldap"> |
| | | <ldap:rdn-sequence> |
| | | cn=Loggers,cn=config |
| | | </ldap:rdn-sequence> |
| | | </adm:profile> |
| | | </adm:relation> |
| | | <adm:relation name="log-rotation-policy"> |
| | | <adm:one-to-many /> |
| | | <adm:profile name="ldap"> |
| | | <ldap:rdn-sequence> |
| | | cn=Log Rotation Policies,cn=config |
| | | </ldap:rdn-sequence> |
| | | </adm:profile> |
| | | </adm:relation> |
| | | <adm:relation name="log-retention-policy"> |
| | | <adm:one-to-many /> |
| | | <adm:profile name="ldap"> |
| | | <ldap:rdn-sequence> |
| | | cn=Log Retention Policies,cn=config |
| | | </ldap:rdn-sequence> |
| | | </adm:profile> |
| | | </adm:relation> |
| | | <adm:product-name>OpenDS Directory Server</adm:product-name> |
| | | </adm:root-managed-object> |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <adm:managed-object |
| | | name="size-limit-log-retention-policy" |
| | | plural-name="size-limit-log-retention-policies" |
| | | package="org.opends.server.admin.std" |
| | | extends="log-retention-policy" |
| | | xmlns:adm="http://www.opends.org/admin" |
| | | xmlns:ldap="http://www.opends.org/admin-ldap"> |
| | | <adm:synopsis> |
| | | Retention policy based on the amount of space taken by the log |
| | | files on disk. |
| | | </adm:synopsis> |
| | | <adm:profile name="ldap"> |
| | | <ldap:object-class> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.2.104</ldap:oid> |
| | | <ldap:name>ds-cfg-size-limit-log-retention-policy</ldap:name> |
| | | <ldap:superior>ds-cfg-log-retention-policy</ldap:superior> |
| | | </ldap:object-class> |
| | | </adm:profile> |
| | | <adm:property name="disk-space-used" mandatory="true"> |
| | | <adm:synopsis> |
| | | The maximum total disk space used by the log files. |
| | | </adm:synopsis> |
| | | <adm:syntax> |
| | | <adm:size lower-limit="1" /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.93</ldap:oid> |
| | | <ldap:name>ds-cfg-disk-space-used</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | </adm:managed-object> |
| | | |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <adm:managed-object |
| | | name="size-limit-log-rotation-policy" |
| | | plural-name="size-limit-log-rotation-policies" |
| | | package="org.opends.server.admin.std" |
| | | extends="log-rotation-policy" |
| | | xmlns:adm="http://www.opends.org/admin" |
| | | xmlns:ldap="http://www.opends.org/admin-ldap"> |
| | | <adm:synopsis> |
| | | Rotation policy based on the size of the log file. |
| | | </adm:synopsis> |
| | | <adm:profile name="ldap"> |
| | | <ldap:object-class> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.2.107</ldap:oid> |
| | | <ldap:name>ds-cfg-size-limit-log-rotation-policy</ldap:name> |
| | | <ldap:superior>ds-cfg-log-rotation-policy</ldap:superior> |
| | | </ldap:object-class> |
| | | </adm:profile> |
| | | <adm:property name="file-size-limit" mandatory="true"> |
| | | <adm:synopsis> |
| | | The size of the file when rotation takes place. |
| | | </adm:synopsis> |
| | | <adm:syntax> |
| | | <adm:size lower-limit="1" /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.379</ldap:oid> |
| | | <ldap:name>ds-cfg-file-size-limit</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | </adm:managed-object> |
| | | |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <adm:managed-object |
| | | name="time-limit-log-rotation-policy" |
| | | plural-name="time-limit-log-rotation-policies" |
| | | package="org.opends.server.admin.std" |
| | | extends="log-rotation-policy" |
| | | xmlns:adm="http://www.opends.org/admin" |
| | | xmlns:ldap="http://www.opends.org/admin-ldap"> |
| | | <adm:synopsis> |
| | | Rotation policy based on the time since last rotation. |
| | | </adm:synopsis> |
| | | <adm:profile name="ldap"> |
| | | <ldap:object-class> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.2.108</ldap:oid> |
| | | <ldap:name>ds-cfg-time-limit-log-rotation-policy</ldap:name> |
| | | <ldap:superior>ds-cfg-log-rotation-policy</ldap:superior> |
| | | </ldap:object-class> |
| | | </adm:profile> |
| | | <adm:property name="rotation-interval" mandatory="true"> |
| | | <adm:synopsis> |
| | | The time interval between rotations. |
| | | </adm:synopsis> |
| | | <adm:syntax> |
| | | <adm:duration base-unit="ms" lower-limit="1" /> |
| | | </adm:syntax> |
| | | <adm:profile name="ldap"> |
| | | <ldap:attribute> |
| | | <ldap:oid>1.3.6.1.4.1.26027.1.1.39</ldap:oid> |
| | | <ldap:name>ds-cfg-rotation-interval</ldap:name> |
| | | </ldap:attribute> |
| | | </adm:profile> |
| | | </adm:property> |
| | | </adm:managed-object> |
| | | |
| | |
| | | |
| | | |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.messages.AdminMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | |
| | | |
| | | |
| | | |
| | | import static org.opends.server.loggers.Error.removeAllErrorLoggers; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.util.ServerConstants.PROPERTY_SERVER_ROOT; |
| | | |
| | | import java.io.File; |
| | |
| | | // generator. |
| | | DirectoryServer.initializeJMX(); |
| | | |
| | | removeAllErrorLoggers(true); |
| | | removeAllErrorLogPublishers(); |
| | | |
| | | // Initialize the configuration. |
| | | File instanceRoot = new File("build/package/OpenDS-0.1"); |
| | |
| | | |
| | | |
| | | |
| | | import static org.opends.server.loggers.Error.removeAllErrorLoggers; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.util.ServerConstants.PROPERTY_SERVER_ROOT; |
| | | |
| | | import java.io.File; |
| | |
| | | // generator. |
| | | DirectoryServer.initializeJMX(); |
| | | |
| | | removeAllErrorLoggers(true); |
| | | removeAllErrorLogPublishers(); |
| | | |
| | | // Initialize the configuration. |
| | | File instanceRoot = new File("build/package/OpenDS-0.1"); |
| File was renamed from opendj-sdk/opends/src/server/org/opends/server/api/AccessLogger.java |
| | |
| | | */ |
| | | package org.opends.server.api; |
| | | |
| | | |
| | | |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.admin.std.server.AccessLogPublisherCfg; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.AbandonOperation; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.BindOperation; |
| | | import org.opends.server.core.CompareOperation; |
| | | import org.opends.server.core.DeleteOperation; |
| | | import org.opends.server.core.ExtendedOperation; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.core.ModifyDNOperation; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.UnbindOperation; |
| | | import org.opends.server.types.DisconnectReason; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.DisconnectReason; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.opends.server.types.SearchResultReference; |
| | | |
| | | |
| | | import org.opends.server.core.*; |
| | | |
| | | /** |
| | | * This class defines the set of methods and structures that must be |
| | | * implemented for a Directory Server access logger. |
| | | * implemented for a Directory Server access log publisher. |
| | | * |
| | | * @param <T> The type of access log publisher configuration handled |
| | | * by this log publisher implementation. |
| | | */ |
| | | public abstract class AccessLogger |
| | | public abstract class AccessLogPublisher |
| | | <T extends AccessLogPublisherCfg> |
| | | { |
| | | /** |
| | | * Initializes this access logger based on the information in the |
| | | * provided configuration entry. |
| | | * |
| | | * @param configEntry The configuration entry that contains the |
| | | * information to use to initialize this access |
| | | * logger. |
| | | * |
| | | * @throws ConfigException If an unrecoverable problem arises in |
| | | * the process of performing the |
| | | * initialization. |
| | | * |
| | | * @throws InitializationException If a problem occurs during |
| | | * initialization that is not |
| | | * related to the server |
| | | * configuration. |
| | | * Indicates if internal operations should be omited in the messages |
| | | * logged by this publisher. |
| | | */ |
| | | public abstract void initializeAccessLogger(ConfigEntry configEntry) |
| | | throws ConfigException, InitializationException; |
| | | |
| | | |
| | | protected boolean suppressInternalOperations = true; |
| | | |
| | | /** |
| | | * Closes this access logger and releases any resources it might |
| | | * have held. |
| | | * Initializes this access publisher provider based on the |
| | | * information in the provided debug publisher configuration. |
| | | * |
| | | * @param config |
| | | * The access publisher configuration that contains the |
| | | * information to use to initialize this access publisher. |
| | | * @throws org.opends.server.config.ConfigException |
| | | * If an unrecoverable problem arises in the process of |
| | | * performing the initialization as a result of the server |
| | | * configuration. |
| | | * @throws org.opends.server.types.InitializationException |
| | | * If a problem occurs during initialization that is not |
| | | * related to the server configuration. |
| | | */ |
| | | public abstract void closeAccessLogger(); |
| | | public abstract void initializeAccessLogPublisher(T config) |
| | | throws ConfigException, InitializationException; |
| | | |
| | | |
| | | /** |
| | | * Close this publisher. |
| | | */ |
| | | public abstract void close(); |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about a |
| | |
| | | * the disconnect. |
| | | */ |
| | | public abstract void |
| | | logDisconnect(ClientConnection clientConnection, |
| | | DisconnectReason disconnectReason, |
| | | String message); |
| | | logDisconnect(ClientConnection clientConnection, |
| | | DisconnectReason disconnectReason, |
| | | String message); |
| | | |
| | | |
| | | |
| | |
| | | * request. |
| | | */ |
| | | public abstract void logAbandonRequest(AbandonOperation |
| | | abandonOperation); |
| | | abandonOperation); |
| | | |
| | | |
| | | /** |
| | |
| | | * request. |
| | | */ |
| | | public abstract void logAbandonResult(AbandonOperation |
| | | abandonOperation); |
| | | abandonOperation); |
| | | |
| | | |
| | | |
| | |
| | | * request. |
| | | */ |
| | | public abstract void logCompareRequest(CompareOperation |
| | | compareOperation); |
| | | compareOperation); |
| | | |
| | | |
| | | |
| | |
| | | * response. |
| | | */ |
| | | public abstract void logCompareResponse(CompareOperation |
| | | compareOperation); |
| | | compareOperation); |
| | | |
| | | |
| | | |
| | |
| | | * request. |
| | | */ |
| | | public abstract void logDeleteRequest(DeleteOperation |
| | | deleteOperation); |
| | | deleteOperation); |
| | | |
| | | |
| | | |
| | |
| | | * response. |
| | | */ |
| | | public abstract void logDeleteResponse(DeleteOperation |
| | | deleteOperation); |
| | | deleteOperation); |
| | | |
| | | |
| | | |
| | |
| | | * request. |
| | | */ |
| | | public abstract void logExtendedRequest(ExtendedOperation |
| | | extendedOperation); |
| | | extendedOperation); |
| | | |
| | | |
| | | |
| | |
| | | * response. |
| | | */ |
| | | public abstract void logExtendedResponse(ExtendedOperation |
| | | extendedOperation); |
| | | extendedOperation); |
| | | |
| | | |
| | | |
| | |
| | | * request. |
| | | */ |
| | | public abstract void logModifyRequest(ModifyOperation |
| | | modifyOperation); |
| | | modifyOperation); |
| | | |
| | | |
| | | |
| | |
| | | * response. |
| | | */ |
| | | public abstract void logModifyResponse(ModifyOperation |
| | | modifyOperation); |
| | | modifyOperation); |
| | | |
| | | |
| | | |
| | |
| | | * DN request. |
| | | */ |
| | | public abstract void logModifyDNRequest(ModifyDNOperation |
| | | modifyDNOperation); |
| | | modifyDNOperation); |
| | | |
| | | |
| | | |
| | |
| | | * DN response. |
| | | */ |
| | | public abstract void logModifyDNResponse(ModifyDNOperation |
| | | modifyDNOperation); |
| | | modifyDNOperation); |
| | | |
| | | |
| | | |
| | |
| | | * request. |
| | | */ |
| | | public abstract void logSearchRequest(SearchOperation |
| | | searchOperation); |
| | | searchOperation); |
| | | |
| | | |
| | | |
| | |
| | | * @param searchEntry The search result entry to be logged. |
| | | */ |
| | | public abstract void logSearchResultEntry( |
| | | SearchOperation searchOperation, |
| | | SearchResultEntry searchEntry); |
| | | SearchOperation searchOperation, |
| | | SearchResultEntry searchEntry); |
| | | |
| | | |
| | | |
| | |
| | | * logged. |
| | | */ |
| | | public abstract void logSearchResultReference( |
| | | SearchOperation searchOperation, |
| | | SearchResultReference searchReference); |
| | | SearchOperation searchOperation, |
| | | SearchResultReference searchReference); |
| | | |
| | | |
| | | |
| | |
| | | * result done message. |
| | | */ |
| | | public abstract void logSearchResultDone(SearchOperation |
| | | searchOperation); |
| | | searchOperation); |
| | | |
| | | |
| | | |
| | |
| | | * request. |
| | | */ |
| | | public abstract void logUnbind(UnbindOperation unbindOperation); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether the provided object is equal to this access |
| | | * logger. |
| | | * |
| | | * @param o The object for which to make the determination. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided object is determined |
| | | * to be equal to this access logger, or <CODE>false</CODE> |
| | | * if not. |
| | | */ |
| | | public abstract boolean equals(Object o); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the hash code for this access logger. |
| | | * |
| | | * @return The hash code for this access logger. |
| | | */ |
| | | public abstract int hashCode(); |
| | | } |
| | | |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.api; |
| | | |
| | | import org.opends.server.loggers.LogLevel; |
| | | import org.opends.server.loggers.debug.TraceSettings; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.admin.std.server.DebugLogPublisherCfg; |
| | | import org.opends.server.config.ConfigException; |
| | | import com.sleepycat.je.Transaction; |
| | | import com.sleepycat.je.Database; |
| | | import com.sleepycat.je.DatabaseEntry; |
| | | import com.sleepycat.je.OperationStatus; |
| | | |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * This class defines the set of methods and structures that must be |
| | | * implemented for a Directory Server debug log publisher. |
| | | * |
| | | * @param <T> The type of debug log publisher configuration handled |
| | | * by this log publisher implementation. |
| | | */ |
| | | public abstract class DebugLogPublisher |
| | | <T extends DebugLogPublisherCfg> |
| | | { |
| | | //The default global settings key. |
| | | private static final String GLOBAL= "_global"; |
| | | |
| | | //The map of class names to their trace settings. |
| | | private Map<String, TraceSettings> classTraceSettings; |
| | | |
| | | //The map of class names to their method trace settings. |
| | | private Map<String, Map<String, TraceSettings>> methodTraceSettings; |
| | | |
| | | /** |
| | | * Construct a default configuration where the global scope will |
| | | * only log at the ERROR level. |
| | | */ |
| | | protected DebugLogPublisher() |
| | | { |
| | | classTraceSettings = null; |
| | | methodTraceSettings = null; |
| | | |
| | | //Set the global settings so that only errors are logged. |
| | | addTraceSettings(null, new TraceSettings(DebugLogLevel.ERROR)); |
| | | } |
| | | |
| | | /** |
| | | * Initializes this debug publisher provider based on the |
| | | * information in the provided debug publisher configuration. |
| | | * |
| | | * @param config |
| | | * The debug publisher configuration that contains the |
| | | * information to use to initialize this debug publisher. |
| | | * @throws org.opends.server.config.ConfigException |
| | | * If an unrecoverable problem arises in the process of |
| | | * performing the initialization as a result of the server |
| | | * configuration. |
| | | * @throws org.opends.server.types.InitializationException |
| | | * If a problem occurs during initialization that is not |
| | | * related to the server configuration. |
| | | */ |
| | | public abstract void initializeDebugLogPublisher(T config) |
| | | throws ConfigException, InitializationException; |
| | | |
| | | /** |
| | | * Gets the method trace levels for a specified class. |
| | | * @param className - a fully qualified class name to get method |
| | | * trace levels for |
| | | * @return an unmodifiable map of trace levels keyed by method name. |
| | | * If no method level tracing is configured for the scope, |
| | | * <b>null</b> is returned. |
| | | */ |
| | | public Map<String, TraceSettings> getMethodSettings( |
| | | String className) |
| | | { |
| | | /*if (methodTraceSettings != null) { |
| | | // Method levels are always at leaves in the |
| | | // hierarchy, so don't bother searching up. |
| | | return methodTraceSettings.get(className); |
| | | } |
| | | return null;*/ |
| | | return new HashMap<String, TraceSettings>(); |
| | | } |
| | | |
| | | /** |
| | | * Get the trace settings for a specified class. |
| | | * @param className - a fully qualified class name to get the |
| | | * trace level for |
| | | * @return the current trace settings for the class. |
| | | */ |
| | | public TraceSettings getClassSettings(String className) |
| | | { |
| | | TraceSettings settings = TraceSettings.DISABLED; |
| | | |
| | | // If we're not enabled, trace level is DISABLED. |
| | | if (classTraceSettings != null) { |
| | | // Find most specific trace setting which covers this |
| | | // fully qualified class name |
| | | // Search up the hierarchy for a match. |
| | | String searchName= className; |
| | | Object value= null; |
| | | value= classTraceSettings.get(searchName); |
| | | while (value == null && searchName != null) { |
| | | int clipPoint= searchName.lastIndexOf('$'); |
| | | if (clipPoint == -1) clipPoint= searchName.lastIndexOf('.'); |
| | | if (clipPoint != -1) { |
| | | searchName= searchName.substring(0, clipPoint); |
| | | value= classTraceSettings.get(searchName); |
| | | } |
| | | else { |
| | | searchName= null; |
| | | } |
| | | } |
| | | |
| | | // Use global settings, if nothing more specific was found. |
| | | if (value == null) value= classTraceSettings.get(GLOBAL); |
| | | |
| | | if (value != null) { |
| | | settings= (TraceSettings)value; |
| | | } |
| | | } |
| | | return settings; |
| | | } |
| | | |
| | | /** |
| | | * Adds a trace settings to the current set for a specified scope. |
| | | * If a scope is not specified, the settings will be set for the |
| | | * global scope. The global scope settings are used when no other |
| | | * scope matches. |
| | | * |
| | | * @param scope - the scope to set trace settings for; this is a |
| | | * fully qualified class name or null to set the trace settings for |
| | | * the global scope. |
| | | * @param settings - the trace settings for the scope |
| | | */ |
| | | public void addTraceSettings(String scope, TraceSettings settings) |
| | | { |
| | | if (scope == null) { |
| | | setClassSettings(GLOBAL, settings); |
| | | } |
| | | else { |
| | | int methodPt= scope.lastIndexOf('#'); |
| | | if (methodPt != -1) { |
| | | String methodName= scope.substring(methodPt+1); |
| | | scope= scope.substring(0, methodPt); |
| | | setMethodSettings(scope, methodName, settings); |
| | | } |
| | | else { |
| | | setClassSettings(scope, settings); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * See if a trace setting is alreadly defined for a particular |
| | | * scope. |
| | | * |
| | | * @param scope - the scope to test; this is a fully |
| | | * qualified class name or null to set the trace settings for the |
| | | * globalscope. |
| | | * @return The trace settings for that scope or null if it doesn't |
| | | * exist. |
| | | */ |
| | | public TraceSettings getTraceSettings(String scope) |
| | | { |
| | | if (scope == null) { |
| | | if(classTraceSettings != null) |
| | | { |
| | | return classTraceSettings.get(GLOBAL); |
| | | } |
| | | return null; |
| | | } |
| | | else { |
| | | int methodPt= scope.lastIndexOf('#'); |
| | | if (methodPt != -1) { |
| | | String methodName= scope.substring(methodPt+1); |
| | | scope= scope.substring(0, methodPt); |
| | | if(methodTraceSettings != null) |
| | | { |
| | | Map<String, TraceSettings> methodLevels = |
| | | methodTraceSettings.get(scope); |
| | | if(methodLevels != null) |
| | | { |
| | | return methodLevels.get(methodName); |
| | | } |
| | | return null; |
| | | } |
| | | return null; |
| | | } |
| | | else { |
| | | if(classTraceSettings != null) |
| | | { |
| | | return classTraceSettings.get(scope); |
| | | } |
| | | return null; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Remove a trace setting by scope. |
| | | * |
| | | * @param scope - the scope to remove; this is a fully |
| | | * qualified class name or null to set the trace settings for the |
| | | * global scope. |
| | | * @return The trace settings for that scope or null if it doesn't |
| | | * exist. |
| | | */ |
| | | public TraceSettings removeTraceSettings(String scope) |
| | | { |
| | | TraceSettings removedSettings = null; |
| | | if (scope == null) { |
| | | if(classTraceSettings != null) |
| | | { |
| | | removedSettings = classTraceSettings.remove(GLOBAL); |
| | | } |
| | | } |
| | | else { |
| | | int methodPt= scope.lastIndexOf('#'); |
| | | if (methodPt != -1) { |
| | | String methodName= scope.substring(methodPt+1); |
| | | scope= scope.substring(0, methodPt); |
| | | if(methodTraceSettings != null) |
| | | { |
| | | Map<String, TraceSettings> methodLevels = |
| | | methodTraceSettings.get(scope); |
| | | if(methodLevels != null) |
| | | { |
| | | removedSettings = methodLevels.remove(methodName); |
| | | if(methodLevels.isEmpty()) |
| | | { |
| | | methodTraceSettings.remove(scope); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else { |
| | | if(classTraceSettings != null) |
| | | { |
| | | removedSettings = classTraceSettings.remove(scope); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return removedSettings; |
| | | } |
| | | |
| | | /** |
| | | * Set the trace settings for a class. |
| | | * |
| | | * @param className The class name. |
| | | * @param settings The trace settings for the class. |
| | | */ |
| | | private synchronized void setClassSettings(String className, |
| | | TraceSettings settings) |
| | | { |
| | | if(classTraceSettings == null) classTraceSettings = |
| | | new HashMap<String, TraceSettings>(); |
| | | |
| | | classTraceSettings.put(className, settings); |
| | | } |
| | | |
| | | /** |
| | | * Set the method settings for a particular method in a class. |
| | | * |
| | | * @param className The class name. |
| | | * @param methodName The method name. |
| | | * @param settings The trace settings for the method. |
| | | */ |
| | | private synchronized void setMethodSettings(String className, |
| | | String methodName, |
| | | TraceSettings settings) |
| | | { |
| | | if (methodTraceSettings == null) methodTraceSettings = |
| | | new HashMap<String, Map<String, TraceSettings>>(); |
| | | Map<String, TraceSettings> methodLevels= |
| | | methodTraceSettings.get(className); |
| | | if (methodLevels == null) { |
| | | methodLevels= new TreeMap<String, TraceSettings>(); |
| | | methodTraceSettings.put(className, methodLevels); |
| | | } |
| | | |
| | | methodLevels.put(methodName, settings); |
| | | } |
| | | |
| | | /** |
| | | * Log a constructor entry. |
| | | * |
| | | * @param level The level of the log message. |
| | | * @param settings The current trace settings in effect. |
| | | * @param signature The constuctor method signature. |
| | | * @param sourceLocation The location of the method in the source. |
| | | * @param args The parameters provided to the constructor call. |
| | | */ |
| | | public abstract void traceConstructor(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, |
| | | Object[] args); |
| | | |
| | | /** |
| | | * Log a non static method entry. |
| | | * |
| | | * @param level The level of the log message. |
| | | * @param settings The current trace settings in effect. |
| | | * @param signature The constuctor method signature. |
| | | * @param sourceLocation The location of the method in the source. |
| | | * @param obj the object this method operations on. |
| | | * @param args The parameters provided to the constructor call |
| | | */ |
| | | public abstract void traceNonStaticMethodEntry(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, |
| | | Object obj, |
| | | Object[] args); |
| | | |
| | | /** |
| | | * Log a static method entry. |
| | | * |
| | | * @param level The level of the log message. |
| | | * @param settings The current trace settings in effect. |
| | | * @param signature The constuctor method signature. |
| | | * @param sourceLocation The location of the method in the source. |
| | | * @param args The parameters provided to the constructor call |
| | | */ |
| | | public abstract void traceStaticMethodEntry(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, |
| | | Object[] args); |
| | | |
| | | /** |
| | | * Log a method return. |
| | | * |
| | | * @param level The level of the log message. |
| | | * @param settings The current trace settings in effect. |
| | | * @param signature The constuctor method signature. |
| | | * @param sourceLocation The location of the method in the source. |
| | | * @param ret the return value of the method. |
| | | */ |
| | | public abstract void traceReturn(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, |
| | | Object ret); |
| | | |
| | | /** |
| | | * Log an arbitrary event in a method. |
| | | * |
| | | * @param level The level of the log message. |
| | | * @param settings The current trace settings in effect. |
| | | * @param signature The constuctor method signature. |
| | | * @param sourceLocation The location of the method in the source. |
| | | * @param msg message to format and log. |
| | | */ |
| | | public abstract void traceMessage(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, |
| | | String msg); |
| | | |
| | | /** |
| | | * Log a thrown exception in a method. |
| | | * |
| | | * @param level The level of the log message. |
| | | * @param settings The current trace settings in effect. |
| | | * @param signature The constuctor method signature. |
| | | * @param sourceLocation The location of the method in the source. |
| | | * @param ex the exception thrown. |
| | | */ |
| | | public abstract void traceThrown(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, |
| | | Throwable ex); |
| | | |
| | | /** |
| | | * Log a caught exception in a method. |
| | | * |
| | | * @param level The level of the log message. |
| | | * @param settings The current trace settings in effect. |
| | | * @param signature The constuctor method signature. |
| | | * @param sourceLocation The location of the method in the source. |
| | | * @param ex the exception caught. |
| | | */ |
| | | public abstract void traceCaught(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, |
| | | Throwable ex); |
| | | |
| | | /** |
| | | * Log an JE database access in a method. |
| | | * |
| | | * @param level The level of the log message. |
| | | * @param settings The current trace settings in effect. |
| | | * @param signature The constuctor method signature. |
| | | * @param sourceLocation The location of the method in the source. |
| | | * @param status status of the JE operation. |
| | | * @param database the database handle. |
| | | * @param txn transaction handle (may be null). |
| | | * @param key the key to dump. |
| | | * @param data the data to dump. |
| | | */ |
| | | public abstract void traceJEAccess(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, |
| | | OperationStatus status, |
| | | Database database, |
| | | Transaction txn, |
| | | DatabaseEntry key, |
| | | DatabaseEntry data); |
| | | |
| | | /** |
| | | * Log raw data in a method. |
| | | * |
| | | * @param level The level of the log message. |
| | | * @param settings The current trace settings in effect. |
| | | * @param signature The constuctor method signature. |
| | | * @param sourceLocation The location of the method in the source. |
| | | * @param data the data to dump. |
| | | */ |
| | | public abstract void traceData(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, |
| | | byte[] data); |
| | | |
| | | /** |
| | | * Log a protocol element in a method. |
| | | * |
| | | * @param level The level of the log message. |
| | | * @param settings The current trace settings in effect. |
| | | * @param signature The constuctor method signature. |
| | | * @param sourceLocation The location of the method in the source. |
| | | * @param element the protocol element to dump. |
| | | */ |
| | | public abstract void traceProtocolElement(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, |
| | | ProtocolElement element); |
| | | |
| | | /** |
| | | * Close this publisher. |
| | | */ |
| | | public abstract void close(); |
| | | } |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.api; |
| | | |
| | | import org.opends.server.admin.std.server.ErrorLogPublisherCfg; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import java.util.HashSet; |
| | | import java.util.HashMap; |
| | | |
| | | /** |
| | | * This class defines the set of methods and structures that must be |
| | | * implemented for a Directory Server error log publisher. |
| | | * |
| | | * @param <T> The type of error log publisher configuration handled |
| | | * by this log publisher implementation. |
| | | */ |
| | | public abstract class ErrorLogPublisher |
| | | <T extends ErrorLogPublisherCfg> |
| | | { |
| | | /** |
| | | * The hash map that will be used to define specific log severities |
| | | * for the various categories. |
| | | */ |
| | | protected HashMap<ErrorLogCategory,HashSet<ErrorLogSeverity>> |
| | | definedSeverities = |
| | | new HashMap<ErrorLogCategory, HashSet<ErrorLogSeverity>>(); |
| | | |
| | | /** |
| | | * The set of default log severities that will be used if no custom |
| | | * severities have been defined for the associated category. |
| | | */ |
| | | protected HashSet<ErrorLogSeverity> defaultSeverities = |
| | | new HashSet<ErrorLogSeverity>(); |
| | | /** |
| | | * Initializes this access publisher provider based on the |
| | | * information in the provided debug publisher configuration. |
| | | * |
| | | * @param config |
| | | * The error publisher configuration that contains the |
| | | * information to use to initialize this error publisher. |
| | | * @throws org.opends.server.config.ConfigException |
| | | * If an unrecoverable problem arises in the process of |
| | | * performing the initialization as a result of the server |
| | | * configuration. |
| | | * @throws org.opends.server.types.InitializationException |
| | | * If a problem occurs during initialization that is not |
| | | * related to the server configuration. |
| | | */ |
| | | public abstract void initializeErrorLogPublisher(T config) |
| | | throws ConfigException, InitializationException; |
| | | |
| | | /** |
| | | * Close this publisher. |
| | | */ |
| | | public abstract void close(); |
| | | |
| | | /** |
| | | * Writes a message to the error log using the provided information. |
| | | * |
| | | * @param category The category that may be used to determine |
| | | * whether to actually log this message. |
| | | * @param severity The severity that may be used to determine |
| | | * whether to actually log this message. |
| | | * @param message The message to be logged. |
| | | * @param errorID The error ID that uniquely identifies the |
| | | * format string used to generate the provided |
| | | * message. |
| | | */ |
| | | public abstract void logError(ErrorLogCategory category, |
| | | ErrorLogSeverity severity, |
| | | String message, int errorID); |
| | | |
| | | } |
| | |
| | | import static org.opends.server.messages.AciMessages.*; |
| | | import static org.opends.server.authorization.dseecompat.Aci.*; |
| | | import org.opends.server.core.*; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import org.opends.server.types.*; |
| | | import static org.opends.server.util.StaticUtils.toLowerCase; |
| | |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | | import static org.opends.server.messages.AciMessages.*; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | |
| | | import java.util.*; |
| | |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import org.opends.server.types.*; |
| | | import static org.opends.server.messages.AciMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | |
| | | import static org.opends.server.messages.AciMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | |
| | | |
| | | import static org.opends.server.messages.AciMessages.*; |
| | | import static org.opends.server.authorization.dseecompat.Aci.*; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.BackendMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.ConfigMessages. |
| | |
| | | import org.opends.server.types.DebugLogLevel; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.messages.BackendMessages.*; |
| | |
| | | import static org.opends.server.messages.BackendMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.JebMessages.*; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.*; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.JebMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | import static org.opends.server.messages.ConfigMessages. |
| | | MSGID_CONFIG_BACKEND_INSANE_MODE; |
| | | import static org.opends.server.messages.JebMessages.*; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.util.StaticUtils.getFileForPath; |
| | | |
| | | import org.opends.server.config.ConfigConstants; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugError; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.messages.JebMessages.*; |
| | | |
| | | /** |
| | |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.JebMessages. |
| | | MSGID_JEB_IMPORT_PARENT_NOT_FOUND; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.messages.JebMessages.*; |
| | | |
| | | /** |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.messages.JebMessages.*; |
| | | |
| | | /** |
| | |
| | | import static org.opends.server.messages.JebMessages. |
| | | MSGID_JEB_REBUILD_INSERT_ENTRY_FAILED; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | | |
| | | |
| | |
| | | import com.sleepycat.je.EnvironmentStats; |
| | | |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import static org.opends.server.messages.JebMessages. |
| | | MSGID_JEB_ATTRIBUTE_INDEX_NOT_CONFIGURED; |
| | |
| | | import org.opends.server.types.FilePermission; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.ResultCode; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugInfo; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | |
| | | */ |
| | | package org.opends.server.backends.jeb; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | |
| | | import com.sleepycat.je.Cursor; |
| | | import com.sleepycat.je.CursorConfig; |
| | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.loggers.ErrorLogger; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.messages.BackendMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | |
| | | String message = MessageHandler.getMessage(errorID); |
| | | |
| | | addLogMessage(severity, errorID, message); |
| | | org.opends.server.loggers.Error.logError(category, severity, errorID); |
| | | ErrorLogger.logError(category, severity, errorID); |
| | | } |
| | | |
| | | |
| | |
| | | String message = MessageHandler.getMessage(errorID); |
| | | |
| | | addLogMessage(severity, errorID, message); |
| | | org.opends.server.loggers.Error.logError(category, severity, errorID, args); |
| | | ErrorLogger.logError(category, severity, errorID,args); |
| | | } |
| | | |
| | | |
| | |
| | | int errorID) |
| | | { |
| | | addLogMessage(severity, errorID, message); |
| | | org.opends.server.loggers.Error.logError(category, severity, message, |
| | | ErrorLogger.logError(category, severity, message, |
| | | errorID); |
| | | } |
| | | |
| | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.messages.BackendMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | |
| | | import org.opends.server.types.DebugLogLevel; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | import org.opends.server.types.DebugLogLevel; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | import org.opends.server.types.AttributeValue; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | |
| | |
| | | import org.opends.server.types.operation.PreParseAbandonOperation; |
| | | |
| | | import static org.opends.server.core.CoreConstants.*; |
| | | import static org.opends.server.loggers.Access.*; |
| | | import static org.opends.server.loggers.AccessLogger.*; |
| | | import static org.opends.server.messages.CoreMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.core.CoreConstants.*; |
| | | import static org.opends.server.loggers.Access.*; |
| | | import static org.opends.server.loggers.AccessLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.CoreMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.*; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.core.CoreConstants.*; |
| | | import static org.opends.server.loggers.Access.*; |
| | | import static org.opends.server.loggers.AccessLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.messages.CoreMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | import org.opends.server.types.operation.PreParseCompareOperation; |
| | | |
| | | import static org.opends.server.core.CoreConstants.*; |
| | | import static org.opends.server.loggers.Access.*; |
| | | import static org.opends.server.loggers.AccessLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | import org.opends.server.types.operation.PreParseDeleteOperation; |
| | | |
| | | import static org.opends.server.core.CoreConstants.*; |
| | | import static org.opends.server.loggers.Access.*; |
| | | import static org.opends.server.loggers.AccessLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.CoreMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | import org.opends.server.config.JMXMBean; |
| | | import org.opends.server.extensions.ConfigFileHandler; |
| | | import org.opends.server.extensions.JMXAlertHandler; |
| | | import org.opends.server.loggers.StartupErrorLogger; |
| | | import org.opends.server.loggers.TextErrorLogPublisher; |
| | | import org.opends.server.loggers.TextWriter; |
| | | import org.opends.server.loggers.RetentionPolicy; |
| | | import org.opends.server.loggers.RotationPolicy; |
| | | import org.opends.server.monitors.BackendMonitor; |
| | | import org.opends.server.monitors.ConnectionHandlerMonitor; |
| | | import org.opends.server.schema.*; |
| | |
| | | import org.opends.server.util.args.StringArgument; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.Access.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.AccessLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.CoreMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | // The set of trust manager providers registered with the server. |
| | | private ConcurrentHashMap<DN,TrustManagerProvider> trustManagerProviders; |
| | | |
| | | // The set of log rotation policies registered with the Directory Server, as |
| | | // a mapping between the DN of the associated configuration entry and the |
| | | // policy implementation. |
| | | private ConcurrentHashMap<DN, RotationPolicy> rotationPolicies; |
| | | |
| | | // The set of log retention policies registered with the Directory Server, as |
| | | // a mapping between the DN of the associated configuration entry and the |
| | | // policy implementation. |
| | | private ConcurrentHashMap<DN, RetentionPolicy> retentionPolicies; |
| | | |
| | | // The set of extended operation handlers registered with the server (mapped |
| | | // between the OID of the extended operation and the handler). |
| | | private ConcurrentHashMap<String,ExtendedOperationHandler> |
| | |
| | | // with the server offline. |
| | | private List<Modification> offlineSchemaChanges; |
| | | |
| | | // The log rotation policy config manager for the Directory Server. |
| | | private LogRotationPolicyConfigManager rotationPolicyConfigManager; |
| | | |
| | | // The log retention policy config manager for the Directory Server. |
| | | private LogRetentionPolicyConfigManager retentionPolicyConfigManager; |
| | | |
| | | // The logger configuration manager for the Directory Server. |
| | | private LoggerConfigManager loggerConfigManager; |
| | | |
| | |
| | | |
| | | |
| | | // The error logger that will be used during the Directory Server startup. |
| | | private StartupErrorLogger startupErrorLogger; |
| | | private TextErrorLogPublisher startupErrorLogPublisher; |
| | | |
| | | // The fully-qualified name of the configuration handler class. |
| | | private String configClass; |
| | |
| | | new ConcurrentHashMap<DN,KeyManagerProvider>(); |
| | | directoryServer.trustManagerProviders = |
| | | new ConcurrentHashMap<DN,TrustManagerProvider>(); |
| | | directoryServer.rotationPolicies = |
| | | new ConcurrentHashMap<DN, RotationPolicy>(); |
| | | directoryServer.retentionPolicies = |
| | | new ConcurrentHashMap<DN, RetentionPolicy>(); |
| | | directoryServer.certificateMappers = |
| | | new ConcurrentHashMap<DN,CertificateMapper>(); |
| | | directoryServer.passwordPolicies = |
| | |
| | | // Install default debug and error loggers for use until enough of the |
| | | // configuration has been read to allow the real loggers to be installed. |
| | | |
| | | removeAllErrorLoggers(true); |
| | | startupErrorLogger = new StartupErrorLogger(); |
| | | startupErrorLogger.initializeErrorLogger(null); |
| | | addErrorLogger(startupErrorLogger); |
| | | |
| | | startupErrorLogPublisher = |
| | | TextErrorLogPublisher.getStartupTextErrorPublisher( |
| | | new TextWriter.STDOUT()); |
| | | addErrorLogPublisher(DN.NULL_DN, startupErrorLogPublisher); |
| | | |
| | | // Create the MBean server that we will use for JMX interaction. |
| | | initializeJMX(); |
| | |
| | | initializeCryptoManager(); |
| | | |
| | | |
| | | // Initialize the log rotation policies. |
| | | rotationPolicyConfigManager = new LogRotationPolicyConfigManager(); |
| | | rotationPolicyConfigManager.initializeLogRotationPolicyConfig(); |
| | | |
| | | // Initialize the log retention policies. |
| | | retentionPolicyConfigManager = new LogRetentionPolicyConfigManager(); |
| | | retentionPolicyConfigManager.initializeLogRetentionPolicyConfig(); |
| | | |
| | | // Initialize the server loggers. |
| | | loggerConfigManager = new LoggerConfigManager(); |
| | | loggerConfigManager.initializeLoggers(); |
| | | loggerConfigManager.initializeLoggerConfig(); |
| | | |
| | | |
| | | |
| | |
| | | sendAlertNotification(this, ALERT_TYPE_SERVER_STARTED, msgID, message); |
| | | |
| | | |
| | | removeErrorLogger(startupErrorLogger); |
| | | removeDebugLogPublisher(DN.NULL_DN); |
| | | removeErrorLogPublisher(DN.NULL_DN); |
| | | |
| | | |
| | | // If a server.starting file exists, then remove it. |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Retrieves the log rotation policy registered for the provided configuration |
| | | * entry. |
| | | * |
| | | * @param configEntryDN The DN of the configuration entry for which to |
| | | * retrieve the associated rotation policy. |
| | | * |
| | | * @return The rotation policy registered for the provided configuration |
| | | * entry, or <CODE>null</CODE> if there is no such policy. |
| | | */ |
| | | public static RotationPolicy getRotationPolicy(DN configEntryDN) |
| | | { |
| | | Validator.ensureNotNull(configEntryDN); |
| | | |
| | | return directoryServer.rotationPolicies.get(configEntryDN); |
| | | } |
| | | |
| | | /** |
| | | * Registers the provided log rotation policy with the Directory Server. If a |
| | | * policy is already registered for the provided configuration entry DN, then |
| | | * it will be replaced. |
| | | * |
| | | * @param configEntryDN The DN of the configuration entry that defines the |
| | | * password policy. |
| | | * @param policy The rotation policy to register with the server. |
| | | */ |
| | | public static void registerRotationPolicy(DN configEntryDN, |
| | | RotationPolicy policy) |
| | | { |
| | | Validator.ensureNotNull(configEntryDN, policy); |
| | | |
| | | directoryServer.rotationPolicies.put(configEntryDN, policy); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Deregisters the provided log rotation policy with the Directory Server. |
| | | * If no such policy is registered, then no action will be taken. |
| | | * |
| | | * @param configEntryDN The DN of the configuration entry that defines the |
| | | * rotation policy to deregister. |
| | | */ |
| | | public static void deregisterRotationPolicy(DN configEntryDN) |
| | | { |
| | | Validator.ensureNotNull(configEntryDN); |
| | | |
| | | directoryServer.rotationPolicies.remove(configEntryDN); |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the log retention policy registered for the provided |
| | | * configuration entry. |
| | | * |
| | | * @param configEntryDN The DN of the configuration entry for which to |
| | | * retrieve the associated retention policy. |
| | | * |
| | | * @return The retention policy registered for the provided configuration |
| | | * entry, or <CODE>null</CODE> if there is no such policy. |
| | | */ |
| | | public static RetentionPolicy getRetentionPolicy(DN configEntryDN) |
| | | { |
| | | Validator.ensureNotNull(configEntryDN); |
| | | |
| | | return directoryServer.retentionPolicies.get(configEntryDN); |
| | | } |
| | | |
| | | /** |
| | | * Registers the provided log retention policy with the Directory Server. |
| | | * If a policy is already registered for the provided configuration entry DN, |
| | | * then it will be replaced. |
| | | * |
| | | * @param configEntryDN The DN of the configuration entry that defines the |
| | | * password policy. |
| | | * @param policy The retention policy to register with the server. |
| | | */ |
| | | public static void registerRetentionPolicy(DN configEntryDN, |
| | | RetentionPolicy policy) |
| | | { |
| | | Validator.ensureNotNull(configEntryDN, policy); |
| | | |
| | | directoryServer.retentionPolicies.put(configEntryDN, policy); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Deregisters the provided log retention policy with the Directory Server. |
| | | * If no such policy is registered, then no action will be taken. |
| | | * |
| | | * @param configEntryDN The DN of the configuration entry that defines the |
| | | * retention policy to deregister. |
| | | */ |
| | | public static void deregisterRetentionPolicy(DN configEntryDN) |
| | | { |
| | | Validator.ensureNotNull(configEntryDN); |
| | | |
| | | directoryServer.retentionPolicies.remove(configEntryDN); |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the set of monitor providers that have been registered with the |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // Shut down all the access loggers. |
| | | try |
| | | { |
| | | removeAllAccessLoggers(true); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | |
| | | |
| | | // Release the exclusive lock for the Directory Server process. |
| | | String lockFile = LockFileManager.getServerLockFileName(); |
| | | try |
| | |
| | | logError(ErrorLogCategory.CORE_SERVER, ErrorLogSeverity.NOTICE, |
| | | MSGID_SERVER_STOPPED); |
| | | |
| | | try |
| | | { |
| | | removeAllErrorLoggers(true); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | |
| | | |
| | | // The JDK logger doesn't allow you to deregister things, so we have to |
| | | // reset it. This is necessary to avoid exceptions if you perform an |
| | | // in-core restart or stop the server and start a new instance in the same |
| | | // JVM (which currently isn't possible through any means other than an |
| | | // in-core restart but might be exposed at some point). |
| | | // |
| | | // FIXME -- This could cause problems with an application that's embedding |
| | | // OpenDS and also using the JDK logger. The solution for this |
| | | // will come once we have rewritten the loggers so that we no |
| | | // longer use the JDK logging framework. |
| | | java.util.logging.LogManager.getLogManager().reset(); |
| | | |
| | | removeAllAccessLogPublishers(); |
| | | removeAllErrorLogPublishers(); |
| | | removeAllDebugLogPublishers(); |
| | | |
| | | // Just in case there's something that isn't shut down properly, wait for |
| | | // the monitor to give the OK to stop. |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | import org.opends.server.types.operation.PreParseExtendedOperation; |
| | | |
| | | import static org.opends.server.core.CoreConstants.*; |
| | | import static org.opends.server.loggers.Access.*; |
| | | import static org.opends.server.loggers.AccessLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | import org.opends.server.admin.std.server.LogRetentionPolicyCfg; |
| | | import org.opends.server.admin.std.server.RootCfg; |
| | | import org.opends.server.admin.std.meta.LogRetentionPolicyCfgDefn; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.admin.server.ServerManagementContext; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.server.ConfigurationDeleteListener; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import org.opends.server.loggers.RetentionPolicy; |
| | | import org.opends.server.config.ConfigException; |
| | | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.ArrayList; |
| | | import java.lang.reflect.Method; |
| | | import java.lang.reflect.InvocationTargetException; |
| | | |
| | | /** |
| | | * This class defines a utility that will be used to manage the set of |
| | | * log retention policies used in the Directory Server. It will perform the |
| | | * initialization when the server is starting, and then will manage any |
| | | * additions, and removals of policies while the server is running. |
| | | */ |
| | | public class LogRetentionPolicyConfigManager implements |
| | | ConfigurationAddListener<LogRetentionPolicyCfg>, |
| | | ConfigurationDeleteListener<LogRetentionPolicyCfg>, |
| | | ConfigurationChangeListener<LogRetentionPolicyCfg> |
| | | { |
| | | |
| | | /** |
| | | * Initializes all the log retention policies. |
| | | * |
| | | * @throws ConfigException |
| | | * If an unrecoverable problem arises in the process of |
| | | * performing the initialization as a result of the server |
| | | * configuration. |
| | | * @throws InitializationException |
| | | * If a problem occurs during initialization that is not |
| | | * related to the server configuration. |
| | | */ |
| | | public void initializeLogRetentionPolicyConfig() |
| | | throws ConfigException, InitializationException |
| | | { |
| | | ServerManagementContext context = ServerManagementContext.getInstance(); |
| | | RootCfg root = context.getRootConfiguration(); |
| | | |
| | | root.addLogRetentionPolicyAddListener(this); |
| | | root.addLogRetentionPolicyDeleteListener(this); |
| | | |
| | | for(String name : root.listLogRetentionPolicies()) |
| | | { |
| | | LogRetentionPolicyCfg config = root.getLogRetentionPolicy(name); |
| | | |
| | | RetentionPolicy RetentionPolicy = getRetentionPolicy(config); |
| | | |
| | | DirectoryServer.registerRetentionPolicy(config.dn(), RetentionPolicy); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationAddAcceptable( |
| | | LogRetentionPolicyCfg configuration, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | return isJavaClassAcceptable(configuration, unacceptableReasons); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationDeleteAcceptable( |
| | | LogRetentionPolicyCfg configuration, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | // TODO: Make sure nothing is using this policy before deleting it. |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationAdd(LogRetentionPolicyCfg config) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | try |
| | | { |
| | | RetentionPolicy RetentionPolicy = getRetentionPolicy(config); |
| | | |
| | | DirectoryServer.registerRetentionPolicy(config.dn(), RetentionPolicy); |
| | | } |
| | | catch (ConfigException e) { |
| | | if (debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | messages.add(e.getMessage()); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | } catch (Exception e) { |
| | | if (debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | int msgID = MSGID_CONFIG_RETENTION_POLICY_CANNOT_CREATE_POLICY; |
| | | messages.add(getMessage(msgID, String.valueOf(config.dn().toString()), |
| | | stackTraceToSingleLineString(e))); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | } |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationDelete( |
| | | LogRetentionPolicyCfg config) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | RetentionPolicy policy = DirectoryServer.getRetentionPolicy(config.dn()); |
| | | if(policy != null) |
| | | { |
| | | DirectoryServer.deregisterRetentionPolicy(config.dn()); |
| | | } |
| | | else |
| | | { |
| | | // TODO: Add message and check for usage |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | } |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationChangeAcceptable( |
| | | LogRetentionPolicyCfg configuration, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | return isJavaClassAcceptable(configuration, unacceptableReasons); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | LogRetentionPolicyCfg configuration) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | RetentionPolicy policy = |
| | | DirectoryServer.getRetentionPolicy(configuration.dn()); |
| | | String className = configuration.getJavaImplementationClass(); |
| | | if(!className.equals(policy.getClass().getName())) |
| | | { |
| | | adminActionRequired = true; |
| | | } |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | private boolean isJavaClassAcceptable(LogRetentionPolicyCfg config, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | String className = config.getJavaImplementationClass(); |
| | | LogRetentionPolicyCfgDefn d = LogRetentionPolicyCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = |
| | | d.getJavaImplementationClassPropertyDefinition(); |
| | | // Load the class and cast it to a RetentionPolicy. |
| | | Class<? extends RetentionPolicy> theClass; |
| | | try { |
| | | theClass = pd.loadClass(className, RetentionPolicy.class); |
| | | theClass.newInstance(); |
| | | } catch (Exception e) { |
| | | int msgID = MSGID_CONFIG_RETENTION_POLICY_INVALID_CLASS; |
| | | String message = getMessage(msgID, className, |
| | | config.dn().toString(), |
| | | String.valueOf(e)); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | // Check that the implementation class implements the correct interface. |
| | | try { |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | theClass.getMethod("initializeLogRetentionPolicy", config.definition() |
| | | .getServerConfigurationClass()); |
| | | } catch (Exception e) { |
| | | int msgID = MSGID_CONFIG_RETENTION_POLICY_INVALID_CLASS; |
| | | String message = getMessage(msgID, className, |
| | | config.dn().toString(), |
| | | String.valueOf(e)); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | // The class is valid as far as we can tell. |
| | | return true; |
| | | } |
| | | |
| | | private RetentionPolicy getRetentionPolicy(LogRetentionPolicyCfg config) |
| | | throws ConfigException { |
| | | String className = config.getJavaImplementationClass(); |
| | | LogRetentionPolicyCfgDefn d = LogRetentionPolicyCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = |
| | | d.getJavaImplementationClassPropertyDefinition(); |
| | | // Load the class and cast it to a RetentionPolicy. |
| | | Class<? extends RetentionPolicy> theClass; |
| | | RetentionPolicy RetentionPolicy; |
| | | try { |
| | | theClass = pd.loadClass(className, RetentionPolicy.class); |
| | | RetentionPolicy = theClass.newInstance(); |
| | | |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | Method method = theClass.getMethod("initializeLogRetentionPolicy", |
| | | config.definition().getServerConfigurationClass()); |
| | | method.invoke(RetentionPolicy, config); |
| | | } |
| | | catch (InvocationTargetException ite) |
| | | { |
| | | // Rethrow the exceptions thrown be the invoked method. |
| | | Throwable e = ite.getTargetException(); |
| | | int msgID = MSGID_CONFIG_RETENTION_POLICY_INVALID_CLASS; |
| | | String message = getMessage(msgID, className, |
| | | config.dn().toString(), |
| | | stackTraceToSingleLineString(e)); |
| | | throw new ConfigException(msgID, message, e); |
| | | } catch (Exception e) { |
| | | int msgID = MSGID_CONFIG_RETENTION_POLICY_INVALID_CLASS; |
| | | String message = getMessage(msgID, className, |
| | | config.dn().toString(), |
| | | String.valueOf(e)); |
| | | throw new ConfigException(msgID, message, e); |
| | | } |
| | | |
| | | // The connection handler has been successfully initialized. |
| | | return RetentionPolicy; |
| | | } |
| | | } |
| | | |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | import org.opends.server.loggers.RotationPolicy; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.admin.server.ConfigurationDeleteListener; |
| | | import org.opends.server.admin.server.ServerManagementContext; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.LogRotationPolicyCfg; |
| | | import org.opends.server.admin.std.server.RootCfg; |
| | | import org.opends.server.admin.std.meta.LogRotationPolicyCfgDefn; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import org.opends.server.config.ConfigException; |
| | | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.ArrayList; |
| | | import java.lang.reflect.Method; |
| | | import java.lang.reflect.InvocationTargetException; |
| | | |
| | | /** |
| | | * This class defines a utility that will be used to manage the set of |
| | | * log rotation policies used in the Directory Server. It will perform the |
| | | * initialization when the server is starting, and then will manage any |
| | | * additions, and removals of policies while the server is running. |
| | | */ |
| | | public class LogRotationPolicyConfigManager implements |
| | | ConfigurationAddListener<LogRotationPolicyCfg>, |
| | | ConfigurationDeleteListener<LogRotationPolicyCfg>, |
| | | ConfigurationChangeListener<LogRotationPolicyCfg> |
| | | { |
| | | |
| | | /** |
| | | * Initializes all the log rotation policies. |
| | | * |
| | | * @throws ConfigException |
| | | * If an unrecoverable problem arises in the process of |
| | | * performing the initialization as a result of the server |
| | | * configuration. |
| | | * @throws InitializationException |
| | | * If a problem occurs during initialization that is not |
| | | * related to the server configuration. |
| | | */ |
| | | public void initializeLogRotationPolicyConfig() |
| | | throws ConfigException, InitializationException |
| | | { |
| | | ServerManagementContext context = ServerManagementContext.getInstance(); |
| | | RootCfg root = context.getRootConfiguration(); |
| | | |
| | | root.addLogRotationPolicyAddListener(this); |
| | | root.addLogRotationPolicyDeleteListener(this); |
| | | |
| | | for(String name : root.listLogRotationPolicies()) |
| | | { |
| | | LogRotationPolicyCfg config = root.getLogRotationPolicy(name); |
| | | |
| | | RotationPolicy rotationPolicy = getRotationPolicy(config); |
| | | |
| | | DirectoryServer.registerRotationPolicy(config.dn(), rotationPolicy); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationAddAcceptable( |
| | | LogRotationPolicyCfg configuration, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | return isJavaClassAcceptable(configuration, unacceptableReasons); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationDeleteAcceptable( |
| | | LogRotationPolicyCfg configuration, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | // TODO: Make sure nothing is using this policy before deleting it. |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationAdd(LogRotationPolicyCfg config) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | try |
| | | { |
| | | RotationPolicy rotationPolicy = getRotationPolicy(config); |
| | | |
| | | DirectoryServer.registerRotationPolicy(config.dn(), rotationPolicy); |
| | | } |
| | | catch (ConfigException e) { |
| | | if (debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | messages.add(e.getMessage()); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | } catch (Exception e) { |
| | | if (debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | int msgID = MSGID_CONFIG_ROTATION_POLICY_CANNOT_CREATE_POLICY; |
| | | messages.add(getMessage(msgID, String.valueOf(config.dn().toString()), |
| | | stackTraceToSingleLineString(e))); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | } |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationDelete( |
| | | LogRotationPolicyCfg config) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | RotationPolicy policy = DirectoryServer.getRotationPolicy(config.dn()); |
| | | if(policy != null) |
| | | { |
| | | DirectoryServer.deregisterRotationPolicy(config.dn()); |
| | | } |
| | | else |
| | | { |
| | | // TODO: Add message and check for usage |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | } |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationChangeAcceptable( |
| | | LogRotationPolicyCfg configuration, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | return isJavaClassAcceptable(configuration, unacceptableReasons); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | LogRotationPolicyCfg configuration) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | RotationPolicy policy = |
| | | DirectoryServer.getRotationPolicy(configuration.dn()); |
| | | String className = configuration.getJavaImplementationClass(); |
| | | if(!className.equals(policy.getClass().getName())) |
| | | { |
| | | adminActionRequired = true; |
| | | } |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | private boolean isJavaClassAcceptable(LogRotationPolicyCfg config, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | String className = config.getJavaImplementationClass(); |
| | | LogRotationPolicyCfgDefn d = LogRotationPolicyCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = |
| | | d.getJavaImplementationClassPropertyDefinition(); |
| | | // Load the class and cast it to a RotationPolicy. |
| | | Class<? extends RotationPolicy> theClass; |
| | | try { |
| | | theClass = pd.loadClass(className, RotationPolicy.class); |
| | | theClass.newInstance(); |
| | | } catch (Exception e) { |
| | | int msgID = MSGID_CONFIG_ROTATION_POLICY_INVALID_CLASS; |
| | | String message = getMessage(msgID, className, |
| | | config.dn().toString(), |
| | | String.valueOf(e)); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | // Check that the implementation class implements the correct interface. |
| | | try { |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | theClass.getMethod("initializeLogRotationPolicy", config.definition() |
| | | .getServerConfigurationClass()); |
| | | } catch (Exception e) { |
| | | int msgID = MSGID_CONFIG_ROTATION_POLICY_INVALID_CLASS; |
| | | String message = getMessage(msgID, className, |
| | | config.dn().toString(), |
| | | String.valueOf(e)); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | // The class is valid as far as we can tell. |
| | | return true; |
| | | } |
| | | |
| | | private RotationPolicy getRotationPolicy(LogRotationPolicyCfg config) |
| | | throws ConfigException { |
| | | String className = config.getJavaImplementationClass(); |
| | | LogRotationPolicyCfgDefn d = LogRotationPolicyCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = |
| | | d.getJavaImplementationClassPropertyDefinition(); |
| | | // Load the class and cast it to a RotationPolicy. |
| | | Class<? extends RotationPolicy> theClass; |
| | | RotationPolicy rotationPolicy; |
| | | try { |
| | | theClass = pd.loadClass(className, RotationPolicy.class); |
| | | rotationPolicy = theClass.newInstance(); |
| | | |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | Method method = theClass.getMethod("initializeLogRotationPolicy", |
| | | config.definition().getServerConfigurationClass()); |
| | | method.invoke(rotationPolicy, config); |
| | | } |
| | | catch (InvocationTargetException ite) |
| | | { |
| | | // Rethrow the exceptions thrown be the invoked method. |
| | | Throwable e = ite.getTargetException(); |
| | | int msgID = MSGID_CONFIG_ROTATION_POLICY_INVALID_CLASS; |
| | | String message = getMessage(msgID, className, |
| | | config.dn().toString(), |
| | | stackTraceToSingleLineString(e)); |
| | | throw new ConfigException(msgID, message, e); |
| | | } catch (Exception e) { |
| | | int msgID = MSGID_CONFIG_ROTATION_POLICY_INVALID_CLASS; |
| | | String message = getMessage(msgID, className, |
| | | config.dn().toString(), |
| | | String.valueOf(e)); |
| | | throw new ConfigException(msgID, message, e); |
| | | } |
| | | |
| | | // The connection handler has been successfully initialized. |
| | | return rotationPolicy; |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.*; |
| | | |
| | | import org.opends.server.api.AccessLogger; |
| | | import org.opends.server.api.ConfigAddListener; |
| | | import org.opends.server.api.ConfigChangeListener; |
| | | import org.opends.server.api.ConfigDeleteListener; |
| | | import org.opends.server.api.ConfigHandler; |
| | | import org.opends.server.api.ConfigurableComponent; |
| | | import org.opends.server.api.ErrorLogger; |
| | | import org.opends.server.config.BooleanConfigAttribute; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.config.StringConfigAttribute; |
| | | import org.opends.server.loggers.StartupErrorLogger; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.Access.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import org.opends.server.loggers.debug.DebugLogger; |
| | | import org.opends.server.loggers.ErrorLogger; |
| | | import org.opends.server.loggers.AccessLogger; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | import org.opends.server.admin.std.server.*; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.admin.server.ConfigurationDeleteListener; |
| | | import org.opends.server.admin.server.ServerManagementContext; |
| | | |
| | | |
| | | /** |
| | |
| | | * the server is starting, and then will manage any additions, removals, or |
| | | * modifications of any loggers while the server is running. |
| | | */ |
| | | public class LoggerConfigManager |
| | | implements ConfigChangeListener, ConfigAddListener, ConfigDeleteListener |
| | | public class LoggerConfigManager implements |
| | | ConfigurationAddListener<LogPublisherCfg>, |
| | | ConfigurationDeleteListener<LogPublisherCfg> |
| | | { |
| | | /** |
| | | * The fully-qualified name of this class for debugging purposes. |
| | | */ |
| | | private static final String CLASS_NAME = |
| | | "org.opends.server.core.LoggerConfigManager"; |
| | | |
| | | |
| | | |
| | | // A mapping between the DNs of the logger configuration entries and the |
| | | // associated active access loggers. |
| | | private ConcurrentHashMap<DN,AccessLogger> activeAccessLoggers; |
| | | |
| | | // A mapping between the DNs of the logger configuration entries and the |
| | | // associated active error loggers. |
| | | private ConcurrentHashMap<DN,ErrorLogger> activeErrorLoggers; |
| | | |
| | | // The configuration handler for the Directory Server. |
| | | private ConfigHandler configHandler; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new instance of this logger config manager. |
| | | */ |
| | | public LoggerConfigManager() |
| | | { |
| | | configHandler = DirectoryServer.getConfigHandler(); |
| | | |
| | | activeAccessLoggers = new ConcurrentHashMap<DN,AccessLogger>(); |
| | | activeErrorLoggers = new ConcurrentHashMap<DN,ErrorLogger>(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Initializes all loggers currently defined in the Directory Server |
| | | * configuration. This should only be called at Directory Server startup. |
| | | * Initializes all the log publishers. |
| | | * |
| | | * @throws ConfigException If a configuration problem causes the monitor |
| | | * initialization process to fail. |
| | | * |
| | | * @throws InitializationException If a problem occurs while initializing |
| | | * the monitors that is not related to the |
| | | * server configuration. |
| | | * @throws ConfigException |
| | | * If an unrecoverable problem arises in the process of |
| | | * performing the initialization as a result of the server |
| | | * configuration. |
| | | * @throws InitializationException |
| | | * If a problem occurs during initialization that is not |
| | | * related to the server configuration. |
| | | */ |
| | | public void initializeLoggers() |
| | | throws ConfigException, InitializationException |
| | | public void initializeLoggerConfig() |
| | | throws ConfigException, InitializationException |
| | | { |
| | | // First, get the logger configuration base entry. |
| | | ConfigEntry loggerBaseEntry; |
| | | try |
| | | // Create an internal server management context and retrieve |
| | | // the root configuration which has the log publisher relation. |
| | | ServerManagementContext context = ServerManagementContext.getInstance(); |
| | | RootCfg root = context.getRootConfiguration(); |
| | | |
| | | root.addLogPublisherAddListener(this); |
| | | root.addLogPublisherAddListener(this); |
| | | |
| | | List<DebugLogPublisherCfg> debugPublisherCfgs = |
| | | new ArrayList<DebugLogPublisherCfg>(); |
| | | |
| | | List<AccessLogPublisherCfg> accessPublisherCfgs = |
| | | new ArrayList<AccessLogPublisherCfg>(); |
| | | |
| | | List<ErrorLogPublisherCfg> errorPublisherCfgs = |
| | | new ArrayList<ErrorLogPublisherCfg>(); |
| | | |
| | | for (String name : root.listLogPublishers()) |
| | | { |
| | | DN loggerBaseDN = DN.decode(DN_LOGGER_BASE); |
| | | loggerBaseEntry = configHandler.getConfigEntry(loggerBaseDN); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if(debugEnabled()) |
| | | LogPublisherCfg config = root.getLogPublisher(name); |
| | | |
| | | if(config instanceof DebugLogPublisherCfg) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | debugPublisherCfgs.add((DebugLogPublisherCfg)config); |
| | | } |
| | | |
| | | int msgID = MSGID_CONFIG_LOGGER_CANNOT_GET_BASE; |
| | | String message = getMessage(msgID, String.valueOf(e)); |
| | | throw new ConfigException(msgID, message, e); |
| | | } |
| | | |
| | | if (loggerBaseEntry == null) |
| | | { |
| | | // The logger base entry does not exist. This is not acceptable, so throw |
| | | // an exception. |
| | | int msgID = MSGID_CONFIG_LOGGER_BASE_DOES_NOT_EXIST; |
| | | String message = getMessage(msgID); |
| | | throw new ConfigException(msgID, message); |
| | | } |
| | | |
| | | |
| | | // Register add and delete listeners with the logger base entry. We don't |
| | | // care about modifications to it. |
| | | loggerBaseEntry.registerAddListener(this); |
| | | loggerBaseEntry.registerDeleteListener(this); |
| | | |
| | | |
| | | // See if the logger base has any children. If not, then log a warning. |
| | | if (! loggerBaseEntry.hasChildren()) |
| | | { |
| | | logError(ErrorLogCategory.CONFIGURATION, ErrorLogSeverity.SEVERE_WARNING, |
| | | MSGID_CONFIG_LOGGER_NO_ACTIVE_ACCESS_LOGGERS); |
| | | logError(ErrorLogCategory.CONFIGURATION, ErrorLogSeverity.SEVERE_WARNING, |
| | | MSGID_CONFIG_LOGGER_NO_ACTIVE_ERROR_LOGGERS); |
| | | logError(ErrorLogCategory.CONFIGURATION, ErrorLogSeverity.MILD_WARNING, |
| | | MSGID_CONFIG_LOGGER_NO_ACTIVE_DEBUG_LOGGERS); |
| | | return; |
| | | } |
| | | |
| | | |
| | | // Iterate through the child entries and process them as logger |
| | | // configuration entries. |
| | | for (ConfigEntry childEntry : loggerBaseEntry.getChildren().values()) |
| | | { |
| | | if(!childEntry.hasObjectClass(OC_DEBUG_LOGGER)) |
| | | else if(config instanceof AccessLogPublisherCfg) |
| | | { |
| | | childEntry.registerChangeListener(this); |
| | | |
| | | StringBuilder unacceptableReason = new StringBuilder(); |
| | | if (! configAddIsAcceptable(childEntry, unacceptableReason)) |
| | | { |
| | | logError(ErrorLogCategory.CONFIGURATION, |
| | | ErrorLogSeverity.SEVERE_ERROR, |
| | | MSGID_CONFIG_LOGGER_ENTRY_UNACCEPTABLE, |
| | | childEntry.getDN().toString(), |
| | | unacceptableReason.toString()); |
| | | continue; |
| | | } |
| | | |
| | | try |
| | | { |
| | | ConfigChangeResult result = applyConfigurationAdd(childEntry); |
| | | if (result.getResultCode() != ResultCode.SUCCESS) |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | |
| | | List<String> resultMessages = result.getMessages(); |
| | | if ((resultMessages == null) || (resultMessages.isEmpty())) |
| | | { |
| | | buffer.append( |
| | | getMessage(MSGID_CONFIG_UNKNOWN_UNACCEPTABLE_REASON)); |
| | | } |
| | | else |
| | | { |
| | | Iterator<String> iterator = resultMessages.iterator(); |
| | | |
| | | buffer.append(iterator.next()); |
| | | while (iterator.hasNext()) |
| | | { |
| | | buffer.append(EOL); |
| | | buffer.append(iterator.next()); |
| | | } |
| | | } |
| | | |
| | | logError(ErrorLogCategory.CONFIGURATION, |
| | | ErrorLogSeverity.SEVERE_ERROR, |
| | | MSGID_CONFIG_LOGGER_CANNOT_CREATE_LOGGER, |
| | | childEntry.getDN().toString(), buffer.toString()); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logError(ErrorLogCategory.CONFIGURATION, |
| | | ErrorLogSeverity.SEVERE_ERROR, |
| | | MSGID_CONFIG_LOGGER_CANNOT_CREATE_LOGGER, |
| | | childEntry.getDN().toString(), String.valueOf(e)); |
| | | } |
| | | accessPublisherCfgs.add((AccessLogPublisherCfg)config); |
| | | } |
| | | else if(config instanceof ErrorLogPublisherCfg) |
| | | { |
| | | errorPublisherCfgs.add((ErrorLogPublisherCfg)config); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_OBJECTCLASS; |
| | | String message = getMessage(msgID, String.valueOf(config.dn())); |
| | | throw new ConfigException(msgID, message); |
| | | } |
| | | } |
| | | |
| | | |
| | | // See if there are active loggers in all categories. If not, then log a |
| | | // message. |
| | | if (activeAccessLoggers.isEmpty()) |
| | | if (accessPublisherCfgs.isEmpty()) |
| | | { |
| | | logError(ErrorLogCategory.CONFIGURATION, ErrorLogSeverity.SEVERE_WARNING, |
| | | MSGID_CONFIG_LOGGER_NO_ACTIVE_ACCESS_LOGGERS); |
| | | ErrorLogger.logError(ErrorLogCategory.CONFIGURATION, |
| | | ErrorLogSeverity.SEVERE_WARNING, |
| | | MSGID_CONFIG_LOGGER_NO_ACTIVE_ACCESS_LOGGERS); |
| | | } |
| | | if (errorPublisherCfgs.isEmpty()) |
| | | { |
| | | ErrorLogger.logError(ErrorLogCategory.CONFIGURATION, |
| | | ErrorLogSeverity.SEVERE_WARNING, |
| | | MSGID_CONFIG_LOGGER_NO_ACTIVE_ERROR_LOGGERS); |
| | | } |
| | | |
| | | if (activeErrorLoggers.isEmpty()) |
| | | { |
| | | logError(ErrorLogCategory.CONFIGURATION, ErrorLogSeverity.SEVERE_WARNING, |
| | | MSGID_CONFIG_LOGGER_NO_ACTIVE_ERROR_LOGGERS); |
| | | } |
| | | DebugLogger.getInstance().initializeDebugLogger(debugPublisherCfgs); |
| | | AccessLogger.getInstance().initializeAccessLogger(accessPublisherCfgs); |
| | | ErrorLogger.getInstance().initializeErrorLogger(errorPublisherCfgs); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Stops and closes all loggers associated with the Directory Server. It will |
| | | * replace them with startup error and debug loggers so that any final |
| | | * messages logged by the server after this call may still be captured on |
| | | * standard error. |
| | | * {@inheritDoc} |
| | | */ |
| | | public void stopLoggers() |
| | | public boolean isConfigurationAddAcceptable(LogPublisherCfg config, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | StartupErrorLogger errorLogger = new StartupErrorLogger(); |
| | | errorLogger.initializeErrorLogger(null); |
| | | |
| | | removeAllErrorLoggers(true); |
| | | addErrorLogger(errorLogger); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether the configuration entry that will result from a proposed |
| | | * modification is acceptable to this change listener. |
| | | * |
| | | * @param configEntry The configuration entry that will result from |
| | | * the requested update. |
| | | * @param unacceptableReason A buffer to which this method can append a |
| | | * human-readable message explaining why the |
| | | * proposed change is not acceptable. |
| | | * |
| | | * @return <CODE>true</CODE> if the proposed entry contains an acceptable |
| | | * configuration, or <CODE>false</CODE> if it does not. |
| | | */ |
| | | public boolean configChangeIsAcceptable(ConfigEntry configEntry, |
| | | StringBuilder unacceptableReason) |
| | | { |
| | | // Make sure that the entry has an appropriate objectclass for an access, |
| | | // error, or debug logger. |
| | | boolean isAccessLogger = false; |
| | | boolean isErrorLogger = false; |
| | | boolean isDebugLogger = false; |
| | | if (configEntry.hasObjectClass(OC_ACCESS_LOGGER)) |
| | | if(config instanceof DebugLogPublisherCfg) |
| | | { |
| | | isAccessLogger = true; |
| | | return DebugLogger.getInstance().isConfigurationAddAcceptable( |
| | | (DebugLogPublisherCfg)config, unacceptableReasons); |
| | | } |
| | | else if (configEntry.hasObjectClass(OC_ERROR_LOGGER)) |
| | | { |
| | | isErrorLogger = true; |
| | | } |
| | | else if (configEntry.hasObjectClass(OC_DEBUG_LOGGER)) |
| | | { |
| | | isDebugLogger = true; |
| | | } |
| | | else if(config instanceof AccessLogPublisherCfg) |
| | | { |
| | | return AccessLogger.getInstance().isConfigurationAddAcceptable( |
| | | (AccessLogPublisherCfg)config, unacceptableReasons); |
| | | } |
| | | else if(config instanceof ErrorLogPublisherCfg) |
| | | { |
| | | return ErrorLogger.getInstance().isConfigurationAddAcceptable( |
| | | (ErrorLogPublisherCfg)config, unacceptableReasons); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_OBJECTCLASS; |
| | | String message = getMessage(msgID, configEntry.getDN().toString()); |
| | | unacceptableReason.append(message); |
| | | unacceptableReasons.add(getMessage(msgID, String.valueOf(config.dn()))); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // Make sure that the entry specifies the logger class name. |
| | | StringConfigAttribute classNameAttr; |
| | | try |
| | | { |
| | | StringConfigAttribute classStub = |
| | | new StringConfigAttribute(ATTR_LOGGER_CLASS, |
| | | getMessage(MSGID_CONFIG_LOGGER_DESCRIPTION_CLASS_NAME), |
| | | true, false, true); |
| | | classNameAttr = (StringConfigAttribute) |
| | | configEntry.getConfigAttribute(classStub); |
| | | |
| | | if (classNameAttr == null) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_NO_CLASS_NAME; |
| | | String message = getMessage(msgID, configEntry.getDN().toString()); |
| | | unacceptableReason.append(message); |
| | | return false; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if(debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_CLASS_NAME; |
| | | String message = getMessage(msgID, configEntry.getDN().toString(), |
| | | String.valueOf(e)); |
| | | unacceptableReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | Class loggerClass; |
| | | try |
| | | { |
| | | loggerClass = DirectoryServer.loadClass(classNameAttr.pendingValue()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if(debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_CLASS_NAME; |
| | | String message = getMessage(msgID, configEntry.getDN().toString(), |
| | | String.valueOf(e)); |
| | | unacceptableReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | if (isAccessLogger) |
| | | { |
| | | try |
| | | { |
| | | AccessLogger logger = (AccessLogger) loggerClass.newInstance(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if(debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ACCESS_LOGGER_CLASS; |
| | | String message = getMessage(msgID, loggerClass.getName(), |
| | | configEntry.getDN().toString(), |
| | | String.valueOf(e)); |
| | | unacceptableReason.append(message); |
| | | return false; |
| | | } |
| | | } |
| | | else if (isErrorLogger) |
| | | { |
| | | try |
| | | { |
| | | ErrorLogger logger = (ErrorLogger) loggerClass.newInstance(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if(debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ERROR_LOGGER_CLASS; |
| | | String message = getMessage(msgID, loggerClass.getName(), |
| | | configEntry.getDN().toString(), |
| | | String.valueOf(e)); |
| | | unacceptableReason.append(message); |
| | | return false; |
| | | } |
| | | } |
| | | else if (isDebugLogger) |
| | | { |
| | | } |
| | | |
| | | |
| | | // See if this logger entry should be enabled. |
| | | BooleanConfigAttribute enabledAttr; |
| | | try |
| | | { |
| | | BooleanConfigAttribute enabledStub = |
| | | new BooleanConfigAttribute(ATTR_LOGGER_ENABLED, |
| | | getMessage(MSGID_CONFIG_LOGGER_DESCRIPTION_ENABLED), false); |
| | | enabledAttr = (BooleanConfigAttribute) |
| | | configEntry.getConfigAttribute(enabledStub); |
| | | |
| | | if (enabledAttr == null) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_NO_ENABLED_ATTR; |
| | | String message = getMessage(msgID, configEntry.getDN().toString()); |
| | | unacceptableReason.append(message); |
| | | return false; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if(debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ENABLED_VALUE; |
| | | String message = getMessage(msgID, configEntry.getDN().toString(), |
| | | String.valueOf(e)); |
| | | unacceptableReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // If we've gotten here then the logger entry appears to be acceptable. |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Attempts to apply a new configuration to this Directory Server component |
| | | * based on the provided changed entry. |
| | | * |
| | | * @param configEntry The configuration entry that containing the updated |
| | | * configuration for this component. |
| | | * |
| | | * @return Information about the result of processing the configuration |
| | | * change. |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationChange(ConfigEntry configEntry) |
| | | public ConfigChangeResult applyConfigurationAdd(LogPublisherCfg config) |
| | | { |
| | | DN configEntryDN = configEntry.getDN(); |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | |
| | | // Make sure that the entry has an appropriate objectclass for an access, |
| | | // error, or debug logger. |
| | | boolean isAccessLogger = false; |
| | | boolean isErrorLogger = false; |
| | | boolean isDebugLogger = false; |
| | | if (configEntry.hasObjectClass(OC_ACCESS_LOGGER)) |
| | | if(config instanceof DebugLogPublisherCfg) |
| | | { |
| | | isAccessLogger = true; |
| | | return DebugLogger.getInstance().applyConfigurationAdd( |
| | | (DebugLogPublisherCfg)config); |
| | | } |
| | | else if (configEntry.hasObjectClass(OC_ERROR_LOGGER)) |
| | | { |
| | | isErrorLogger = true; |
| | | } |
| | | else if (configEntry.hasObjectClass(OC_DEBUG_LOGGER)) |
| | | { |
| | | isDebugLogger = true; |
| | | } |
| | | else if(config instanceof AccessLogPublisherCfg) |
| | | { |
| | | return AccessLogger.getInstance().applyConfigurationAdd( |
| | | (AccessLogPublisherCfg)config); |
| | | } |
| | | else if(config instanceof ErrorLogPublisherCfg) |
| | | { |
| | | return ErrorLogger.getInstance().applyConfigurationAdd( |
| | | (ErrorLogPublisherCfg)config); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_OBJECTCLASS; |
| | | messages.add(getMessage(msgID, String.valueOf(configEntryDN))); |
| | | resultCode = ResultCode.UNWILLING_TO_PERFORM; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | boolean adminActionRequired = false; |
| | | messages.add(getMessage(msgID, String.valueOf(config.dn()))); |
| | | ResultCode resultCode = ResultCode.UNWILLING_TO_PERFORM; |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | |
| | | // Get the corresponding logger if it is active. |
| | | boolean isActive = false; |
| | | AccessLogger accessLogger = null; |
| | | ErrorLogger errorLogger = null; |
| | | if (isAccessLogger) |
| | | { |
| | | accessLogger = activeAccessLoggers.get(configEntryDN); |
| | | isActive = (accessLogger != null); |
| | | } |
| | | else if (isErrorLogger) |
| | | { |
| | | errorLogger = activeErrorLoggers.get(configEntryDN); |
| | | isActive = (errorLogger != null); |
| | | } |
| | | |
| | | |
| | | // See if this logger should be enabled or disabled. |
| | | boolean needsEnabled = false; |
| | | BooleanConfigAttribute enabledAttr; |
| | | try |
| | | { |
| | | BooleanConfigAttribute enabledStub = |
| | | new BooleanConfigAttribute(ATTR_LOGGER_ENABLED, |
| | | getMessage(MSGID_CONFIG_LOGGER_DESCRIPTION_ENABLED), false); |
| | | enabledAttr = (BooleanConfigAttribute) |
| | | configEntry.getConfigAttribute(enabledStub); |
| | | |
| | | if (enabledAttr == null) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_NO_ENABLED_ATTR; |
| | | messages.add(getMessage(msgID, String.valueOf(configEntryDN))); |
| | | resultCode = ResultCode.UNWILLING_TO_PERFORM; |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, |
| | | messages); |
| | | } |
| | | |
| | | if (enabledAttr.activeValue()) |
| | | { |
| | | if (isActive) |
| | | { |
| | | // The logger is already active, so no action is required. |
| | | } |
| | | else |
| | | { |
| | | needsEnabled = true; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (isActive) |
| | | { |
| | | // The logger is active, so it needs to be disabled. Do this and |
| | | // return that we were successful. |
| | | if (isAccessLogger) |
| | | { |
| | | activeAccessLoggers.remove(configEntryDN); |
| | | accessLogger.closeAccessLogger(); |
| | | } |
| | | else if (isErrorLogger) |
| | | { |
| | | activeErrorLoggers.remove(configEntryDN); |
| | | errorLogger.closeErrorLogger(); |
| | | } |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, |
| | | messages); |
| | | } |
| | | else |
| | | { |
| | | // The logger is already disabled, so no action is required and we |
| | | // can short-circuit out of this processing. |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, |
| | | messages); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if(debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ENABLED_VALUE; |
| | | messages.add(getMessage(msgID, String.valueOf(configEntryDN), |
| | | String.valueOf(e))); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | |
| | | // Make sure that the entry specifies the logger class name. If it has |
| | | // changed, then we will not try to dynamically apply it. |
| | | String className; |
| | | try |
| | | { |
| | | StringConfigAttribute classStub = |
| | | new StringConfigAttribute(ATTR_LOGGER_CLASS, |
| | | getMessage(MSGID_CONFIG_LOGGER_DESCRIPTION_CLASS_NAME), |
| | | true, false, true); |
| | | StringConfigAttribute classNameAttr = |
| | | (StringConfigAttribute) configEntry.getConfigAttribute(classStub); |
| | | |
| | | if (classNameAttr == null) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_NO_CLASS_NAME; |
| | | messages.add(getMessage(msgID, String.valueOf(configEntryDN))); |
| | | resultCode = ResultCode.OBJECTCLASS_VIOLATION; |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, |
| | | messages); |
| | | } |
| | | |
| | | className = classNameAttr.pendingValue(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if(debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_CLASS_NAME; |
| | | messages.add(getMessage(msgID, String.valueOf(configEntryDN), |
| | | String.valueOf(e))); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | |
| | | boolean classChanged = false; |
| | | String oldClassName = null; |
| | | if (! (needsEnabled || (accessLogger == null) && (errorLogger == null) )) |
| | | { |
| | | if (isAccessLogger) |
| | | { |
| | | oldClassName = accessLogger.getClass().getName(); |
| | | classChanged = (! className.equals(oldClassName)); |
| | | } |
| | | else if (isErrorLogger) |
| | | { |
| | | oldClassName = errorLogger.getClass().getName(); |
| | | classChanged = (! className.equals(oldClassName)); |
| | | } |
| | | } |
| | | |
| | | |
| | | if (classChanged) |
| | | { |
| | | // This will not be applied dynamically. Add a message to the response |
| | | // and indicate that admin action is required. |
| | | adminActionRequired = true; |
| | | messages.add(getMessage(MSGID_CONFIG_LOGGER_CLASS_ACTION_REQUIRED, |
| | | String.valueOf(oldClassName), |
| | | String.valueOf(className), |
| | | String.valueOf(configEntryDN))); |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | |
| | | // If the monitor needs to be enabled, then create it and register it with |
| | | // the Directory Server. |
| | | if (needsEnabled) |
| | | { |
| | | if (isAccessLogger) |
| | | { |
| | | try |
| | | { |
| | | Class loggerClass = DirectoryServer.loadClass(className); |
| | | accessLogger = (AccessLogger) loggerClass.newInstance(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if(debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ACCESS_LOGGER_CLASS; |
| | | messages.add(getMessage(msgID, className, |
| | | String.valueOf(configEntryDN), |
| | | String.valueOf(e))); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, |
| | | messages); |
| | | } |
| | | |
| | | try |
| | | { |
| | | accessLogger.initializeAccessLogger(configEntry); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if(debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_CONFIG_LOGGER_ACCESS_INITIALIZATION_FAILED; |
| | | messages.add(getMessage(msgID, className, |
| | | String.valueOf(configEntryDN), |
| | | String.valueOf(e))); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, |
| | | messages); |
| | | } |
| | | |
| | | addAccessLogger(accessLogger); |
| | | activeAccessLoggers.put(configEntryDN, accessLogger); |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, |
| | | messages); |
| | | } |
| | | else if (isErrorLogger) |
| | | { |
| | | try |
| | | { |
| | | Class loggerClass = DirectoryServer.loadClass(className); |
| | | errorLogger = (ErrorLogger) loggerClass.newInstance(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if(debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ERROR_LOGGER_CLASS; |
| | | messages.add(getMessage(msgID, className, |
| | | String.valueOf(configEntryDN), |
| | | String.valueOf(e))); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, |
| | | messages); |
| | | } |
| | | |
| | | try |
| | | { |
| | | errorLogger.initializeErrorLogger(configEntry); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if(debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_CONFIG_LOGGER_ERROR_INITIALIZATION_FAILED; |
| | | messages.add(getMessage(msgID, className, |
| | | String.valueOf(configEntryDN), |
| | | String.valueOf(e))); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, |
| | | messages); |
| | | } |
| | | |
| | | addErrorLogger(errorLogger); |
| | | activeErrorLoggers.put(configEntryDN, errorLogger); |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, |
| | | messages); |
| | | } |
| | | else |
| | | { |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, |
| | | messages); |
| | | } |
| | | } |
| | | |
| | | |
| | | // If we've gotten here, then there haven't been any changes to anything |
| | | // that we care about. |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether the configuration entry that will result from a proposed |
| | | * add is acceptable to this add listener. |
| | | * |
| | | * @param configEntry The configuration entry that will result from |
| | | * the requested add. |
| | | * @param unacceptableReason A buffer to which this method can append a |
| | | * human-readable message explaining why the |
| | | * proposed entry is not acceptable. |
| | | * |
| | | * @return <CODE>true</CODE> if the proposed entry contains an acceptable |
| | | * configuration, or <CODE>false</CODE> if it does not. |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean configAddIsAcceptable(ConfigEntry configEntry, |
| | | StringBuilder unacceptableReason) |
| | | public boolean isConfigurationDeleteAcceptable(LogPublisherCfg config, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | // Make sure that no entry already exists with the specified DN. |
| | | DN configEntryDN = configEntry.getDN(); |
| | | if (activeAccessLoggers.containsKey(configEntryDN) || |
| | | activeErrorLoggers.containsKey(configEntryDN) ) |
| | | if(config instanceof DebugLogPublisherCfg) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_EXISTS; |
| | | String message = getMessage(msgID, String.valueOf(configEntryDN)); |
| | | unacceptableReason.append(message); |
| | | return false; |
| | | return DebugLogger.getInstance().isConfigurationDeleteAcceptable( |
| | | (DebugLogPublisherCfg)config, unacceptableReasons); |
| | | } |
| | | |
| | | |
| | | // Make sure that the entry has an appropriate objectclass for an access, |
| | | // error, or debug logger. |
| | | boolean isAccessLogger = false; |
| | | boolean isErrorLogger = false; |
| | | boolean isDebugLogger = false; |
| | | if (configEntry.hasObjectClass(OC_ACCESS_LOGGER)) |
| | | { |
| | | isAccessLogger = true; |
| | | } |
| | | else if (configEntry.hasObjectClass(OC_ERROR_LOGGER)) |
| | | { |
| | | isErrorLogger = true; |
| | | } |
| | | else if (configEntry.hasObjectClass(OC_DEBUG_LOGGER)) |
| | | { |
| | | isDebugLogger = true; |
| | | } |
| | | else if(config instanceof AccessLogPublisherCfg) |
| | | { |
| | | return AccessLogger.getInstance().isConfigurationDeleteAcceptable( |
| | | (AccessLogPublisherCfg)config, unacceptableReasons); |
| | | } |
| | | else if(config instanceof ErrorLogPublisherCfg) |
| | | { |
| | | return ErrorLogger.getInstance().isConfigurationDeleteAcceptable( |
| | | (ErrorLogPublisherCfg)config, unacceptableReasons); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_OBJECTCLASS; |
| | | String message = getMessage(msgID, configEntry.getDN().toString()); |
| | | unacceptableReason.append(message); |
| | | unacceptableReasons.add(getMessage(msgID, String.valueOf(config.dn()))); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // Make sure that the entry specifies the logger class name. |
| | | StringConfigAttribute classNameAttr; |
| | | try |
| | | { |
| | | StringConfigAttribute classStub = |
| | | new StringConfigAttribute(ATTR_LOGGER_CLASS, |
| | | getMessage(MSGID_CONFIG_LOGGER_DESCRIPTION_CLASS_NAME), |
| | | true, false, true); |
| | | classNameAttr = (StringConfigAttribute) |
| | | configEntry.getConfigAttribute(classStub); |
| | | |
| | | if (classNameAttr == null) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_NO_CLASS_NAME; |
| | | String message = getMessage(msgID, configEntry.getDN().toString()); |
| | | unacceptableReason.append(message); |
| | | return false; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if(debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_CLASS_NAME; |
| | | String message = getMessage(msgID, configEntry.getDN().toString(), |
| | | String.valueOf(e)); |
| | | unacceptableReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | Class loggerClass; |
| | | try |
| | | { |
| | | loggerClass = DirectoryServer.loadClass(classNameAttr.pendingValue()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if(debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_CLASS_NAME; |
| | | String message = getMessage(msgID, configEntry.getDN().toString(), |
| | | String.valueOf(e)); |
| | | unacceptableReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | Object logger = null; |
| | | if (isAccessLogger) |
| | | { |
| | | try |
| | | { |
| | | logger = (AccessLogger) loggerClass.newInstance(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if(debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ACCESS_LOGGER_CLASS; |
| | | String message = getMessage(msgID, loggerClass.getName(), |
| | | configEntry.getDN().toString(), |
| | | String.valueOf(e)); |
| | | unacceptableReason.append(message); |
| | | return false; |
| | | } |
| | | } |
| | | else if (isErrorLogger) |
| | | { |
| | | try |
| | | { |
| | | logger = (ErrorLogger) loggerClass.newInstance(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if(debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ERROR_LOGGER_CLASS; |
| | | String message = getMessage(msgID, loggerClass.getName(), |
| | | configEntry.getDN().toString(), |
| | | String.valueOf(e)); |
| | | unacceptableReason.append(message); |
| | | return false; |
| | | } |
| | | } |
| | | else if (isDebugLogger) |
| | | { |
| | | } |
| | | |
| | | |
| | | // If the logger is a configurable component, then make sure that its |
| | | // configuration is valid. |
| | | if (logger instanceof ConfigurableComponent) |
| | | { |
| | | ConfigurableComponent cc = (ConfigurableComponent) logger; |
| | | LinkedList<String> errorMessages = new LinkedList<String>(); |
| | | if (! cc.hasAcceptableConfiguration(configEntry, errorMessages)) |
| | | { |
| | | if (errorMessages.isEmpty()) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_UNACCEPTABLE_CONFIG; |
| | | unacceptableReason.append(getMessage(msgID, |
| | | String.valueOf(configEntryDN))); |
| | | } |
| | | else |
| | | { |
| | | Iterator<String> iterator = errorMessages.iterator(); |
| | | unacceptableReason.append(iterator.next()); |
| | | while (iterator.hasNext()) |
| | | { |
| | | unacceptableReason.append(" "); |
| | | unacceptableReason.append(iterator.next()); |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | // See if this logger entry should be enabled. |
| | | BooleanConfigAttribute enabledAttr; |
| | | try |
| | | { |
| | | BooleanConfigAttribute enabledStub = |
| | | new BooleanConfigAttribute(ATTR_LOGGER_ENABLED, |
| | | getMessage(MSGID_CONFIG_LOGGER_DESCRIPTION_ENABLED), false); |
| | | enabledAttr = (BooleanConfigAttribute) |
| | | configEntry.getConfigAttribute(enabledStub); |
| | | |
| | | if (enabledAttr == null) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_NO_ENABLED_ATTR; |
| | | String message = getMessage(msgID, configEntry.getDN().toString()); |
| | | unacceptableReason.append(message); |
| | | return false; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if(debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ENABLED_VALUE; |
| | | String message = getMessage(msgID, configEntry.getDN().toString(), |
| | | String.valueOf(e)); |
| | | unacceptableReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // If we've gotten here then the logger entry appears to be acceptable. |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Attempts to apply a new configuration based on the provided added entry. |
| | | * |
| | | * @param configEntry The new configuration entry that contains the |
| | | * configuration to apply. |
| | | * |
| | | * @return Information about the result of processing the configuration |
| | | * change. |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationAdd(ConfigEntry configEntry) |
| | | public ConfigChangeResult applyConfigurationDelete(LogPublisherCfg config) |
| | | { |
| | | DN configEntryDN = configEntry.getDN(); |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | |
| | | // Make sure that the entry has an appropriate objectclass for an access, |
| | | // error, or debug logger. |
| | | boolean isAccessLogger = false; |
| | | boolean isErrorLogger = false; |
| | | boolean isDebugLogger = false; |
| | | if (configEntry.hasObjectClass(OC_ACCESS_LOGGER)) |
| | | if(config instanceof DebugLogPublisherCfg) |
| | | { |
| | | isAccessLogger = true; |
| | | return DebugLogger.getInstance().applyConfigurationDelete( |
| | | (DebugLogPublisherCfg)config); |
| | | } |
| | | else if (configEntry.hasObjectClass(OC_ERROR_LOGGER)) |
| | | { |
| | | isErrorLogger = true; |
| | | } |
| | | else if (configEntry.hasObjectClass(OC_DEBUG_LOGGER)) |
| | | { |
| | | isDebugLogger = true; |
| | | } |
| | | else if(config instanceof AccessLogPublisherCfg) |
| | | { |
| | | return AccessLogger.getInstance().applyConfigurationDelete( |
| | | (AccessLogPublisherCfg)config); |
| | | } |
| | | else if(config instanceof ErrorLogPublisherCfg) |
| | | { |
| | | return ErrorLogger.getInstance().applyConfigurationDelete( |
| | | (ErrorLogPublisherCfg)config); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_OBJECTCLASS; |
| | | messages.add(getMessage(msgID, String.valueOf(configEntryDN))); |
| | | resultCode = ResultCode.UNWILLING_TO_PERFORM; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | boolean adminActionRequired = false; |
| | | messages.add(getMessage(msgID, String.valueOf(config.dn()))); |
| | | ResultCode resultCode = ResultCode.UNWILLING_TO_PERFORM; |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | |
| | | // See if this logger should be enabled or disabled. |
| | | BooleanConfigAttribute enabledAttr; |
| | | try |
| | | { |
| | | BooleanConfigAttribute enabledStub = |
| | | new BooleanConfigAttribute(ATTR_LOGGER_ENABLED, |
| | | getMessage(MSGID_CONFIG_LOGGER_DESCRIPTION_ENABLED), false); |
| | | enabledAttr = (BooleanConfigAttribute) |
| | | configEntry.getConfigAttribute(enabledStub); |
| | | |
| | | if (enabledAttr == null) |
| | | { |
| | | // The attribute doesn't exist, so it will be disabled by default. |
| | | int msgID = MSGID_CONFIG_LOGGER_NO_ENABLED_ATTR; |
| | | messages.add(getMessage(msgID, String.valueOf(configEntryDN))); |
| | | resultCode = ResultCode.SUCCESS; |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, |
| | | messages); |
| | | } |
| | | else if (! enabledAttr.activeValue()) |
| | | { |
| | | // It is explicitly configured as disabled, so we don't need to do |
| | | // anything. |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, |
| | | messages); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if(debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ENABLED_VALUE; |
| | | messages.add(getMessage(msgID, String.valueOf(configEntryDN), |
| | | String.valueOf(e))); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | |
| | | // Make sure that the entry specifies the logger class name. |
| | | String className; |
| | | try |
| | | { |
| | | StringConfigAttribute classStub = |
| | | new StringConfigAttribute(ATTR_LOGGER_CLASS, |
| | | getMessage(MSGID_CONFIG_LOGGER_DESCRIPTION_CLASS_NAME), |
| | | true, false, true); |
| | | StringConfigAttribute classNameAttr = |
| | | (StringConfigAttribute) configEntry.getConfigAttribute(classStub); |
| | | |
| | | if (classNameAttr == null) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_NO_CLASS_NAME; |
| | | messages.add(getMessage(msgID, String.valueOf(configEntryDN))); |
| | | resultCode = ResultCode.OBJECTCLASS_VIOLATION; |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, |
| | | messages); |
| | | } |
| | | |
| | | className = classNameAttr.pendingValue(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if(debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_CLASS_NAME; |
| | | messages.add(getMessage(msgID, String.valueOf(configEntryDN), |
| | | String.valueOf(e))); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | |
| | | // If this is supposed to be an access logger, then load and initialize the |
| | | // class, and register it with the Directory Server. |
| | | if (isAccessLogger) |
| | | { |
| | | AccessLogger accessLogger; |
| | | |
| | | try |
| | | { |
| | | Class loggerClass = DirectoryServer.loadClass(className); |
| | | accessLogger = (AccessLogger) loggerClass.newInstance(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if(debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ACCESS_LOGGER_CLASS; |
| | | messages.add(getMessage(msgID, className, String.valueOf(configEntryDN), |
| | | String.valueOf(e))); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, |
| | | messages); |
| | | } |
| | | |
| | | |
| | | try |
| | | { |
| | | accessLogger.initializeAccessLogger(configEntry); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if(debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_CONFIG_LOGGER_ACCESS_INITIALIZATION_FAILED; |
| | | messages.add(getMessage(msgID, className, String.valueOf(configEntryDN), |
| | | String.valueOf(e))); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, |
| | | messages); |
| | | } |
| | | |
| | | |
| | | addAccessLogger(accessLogger); |
| | | activeAccessLoggers.put(configEntryDN, accessLogger); |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | |
| | | // If this is supposed to be an error logger, then load and initialize the |
| | | // class, and register it with the Directory Server. |
| | | else if (isErrorLogger) |
| | | { |
| | | ErrorLogger errorLogger; |
| | | |
| | | try |
| | | { |
| | | Class loggerClass = DirectoryServer.loadClass(className); |
| | | errorLogger = (ErrorLogger) loggerClass.newInstance(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if(debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ERROR_LOGGER_CLASS; |
| | | messages.add(getMessage(msgID, className, String.valueOf(configEntryDN), |
| | | String.valueOf(e))); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, |
| | | messages); |
| | | } |
| | | |
| | | |
| | | try |
| | | { |
| | | errorLogger.initializeErrorLogger(configEntry); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if(debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_CONFIG_LOGGER_ERROR_INITIALIZATION_FAILED; |
| | | messages.add(getMessage(msgID, className, String.valueOf(configEntryDN), |
| | | String.valueOf(e))); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, |
| | | messages); |
| | | } |
| | | |
| | | |
| | | addErrorLogger(errorLogger); |
| | | activeErrorLoggers.put(configEntryDN, errorLogger); |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | |
| | | // If this is supposed to be a debug logger, then load and initialize the |
| | | // class, and register it with the Directory Server. |
| | | else |
| | | { |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether it is acceptable to remove the provided configuration |
| | | * entry. |
| | | * |
| | | * @param configEntry The configuration entry that will be removed |
| | | * from the configuration. |
| | | * @param unacceptableReason A buffer to which this method can append a |
| | | * human-readable message explaining why the |
| | | * proposed delete is not acceptable. |
| | | * |
| | | * @return <CODE>true</CODE> if the proposed entry may be removed from the |
| | | * configuration, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean configDeleteIsAcceptable(ConfigEntry configEntry, |
| | | StringBuilder unacceptableReason) |
| | | { |
| | | // A delete should always be acceptable, so just return true. |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Attempts to apply a new configuration based on the provided deleted entry. |
| | | * |
| | | * @param configEntry The new configuration entry that has been deleted. |
| | | * |
| | | * @return Information about the result of processing the configuration |
| | | * change. |
| | | */ |
| | | public ConfigChangeResult applyConfigurationDelete(ConfigEntry configEntry) |
| | | { |
| | | DN configEntryDN = configEntry.getDN(); |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | |
| | | |
| | | // See if the entry is registered as an access logger. If so, deregister it |
| | | // and stop the logger. |
| | | AccessLogger accessLogger = activeAccessLoggers.remove(configEntryDN); |
| | | if (accessLogger != null) |
| | | { |
| | | removeAccessLogger(accessLogger); |
| | | accessLogger.closeAccessLogger(); |
| | | return new ConfigChangeResult(resultCode, adminActionRequired); |
| | | } |
| | | |
| | | |
| | | // See if the entry is registered as an error logger. If so, deregister it |
| | | // and stop the logger. |
| | | ErrorLogger errorLogger = activeErrorLoggers.remove(configEntryDN); |
| | | if (errorLogger != null) |
| | | { |
| | | removeErrorLogger(errorLogger); |
| | | errorLogger.closeErrorLogger(); |
| | | return new ConfigChangeResult(resultCode, adminActionRequired); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | // If we've gotten here, then it wasn't an active logger so we can just |
| | | // return without doing anything. |
| | | return new ConfigChangeResult(resultCode, adminActionRequired); |
| | | } |
| | | } |
| | | |
| | |
| | | import org.opends.server.types.operation.PreParseModifyDNOperation; |
| | | |
| | | import static org.opends.server.core.CoreConstants.*; |
| | | import static org.opends.server.loggers.Access.*; |
| | | import static org.opends.server.loggers.AccessLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.CoreMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.core.CoreConstants.*; |
| | | import static org.opends.server.loggers.Access.*; |
| | | import static org.opends.server.loggers.AccessLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.CoreMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.PluginMessages.*; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.util.TimeThread; |
| | | |
| | | import static org.opends.server.core.CoreConstants.*; |
| | | import static org.opends.server.loggers.Access.*; |
| | | import static org.opends.server.loggers.AccessLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.messages.CoreMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | import org.opends.server.types.operation.PostOperationUnbindOperation; |
| | | import org.opends.server.types.operation.PreParseUnbindOperation; |
| | | |
| | | import static org.opends.server.loggers.Access.*; |
| | | import static org.opends.server.loggers.AccessLogger.*; |
| | | import static org.opends.server.messages.CoreMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | |
| | |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.types.VirtualAttributeRule; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ExtensionsMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.extensions.ExtensionsConstants.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ExtensionsMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | import org.opends.server.types.SearchScope; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.messages.ExtensionsMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | |
| | | import org.opends.server.types.SearchResultReference; |
| | | import org.opends.server.types.SearchScope; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ExtensionsMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | | |
| | |
| | | |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.messages.ExtensionsMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ExtensionsMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ExtensionsMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ExtensionsMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ExtensionsMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ExtensionsMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ExtensionsMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | import static org.opends.server.extensions.ExtensionsConstants.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.messages.ExtensionsMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | |
| | | import org.opends.server.admin.std.server.SimilarityBasedPasswordValidatorCfg; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.messages.ExtensionsMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ExtensionsMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ExtensionsMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.CoreMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | |
| | | import org.opends.server.types.Operation; |
| | | |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.CoreMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | | |
| | | |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.List; |
| | | import java.util.ArrayList; |
| | | import java.lang.reflect.Method; |
| | | import java.lang.reflect.InvocationTargetException; |
| | | |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.api.AccessLogPublisher; |
| | | import org.opends.server.core.*; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.admin.std.server.AccessLogPublisherCfg; |
| | | import org.opends.server.admin.std.meta.AccessLogPublisherCfgDefn; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.server.ConfigurationDeleteListener; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.config.ConfigException; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.messages.ConfigMessages. |
| | | MSGID_CONFIG_LOGGER_CANNOT_CREATE_LOGGER; |
| | | import static org.opends.server.messages.ConfigMessages. |
| | | MSGID_CONFIG_LOGGER_INVALID_ACCESS_LOGGER_CLASS; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | | |
| | | |
| | | /** |
| | | * This class defines the wrapper that will invoke all registered access loggers |
| | | * for each type of request received or response sent. |
| | | */ |
| | | public class AccessLogger implements |
| | | ConfigurationAddListener<AccessLogPublisherCfg>, |
| | | ConfigurationDeleteListener<AccessLogPublisherCfg>, |
| | | ConfigurationChangeListener<AccessLogPublisherCfg> |
| | | { |
| | | // The set of access loggers that have been registered with the server. It |
| | | // will initially be empty. |
| | | static ConcurrentHashMap<DN, AccessLogPublisher> accessPublishers = |
| | | new ConcurrentHashMap<DN, AccessLogPublisher>(); |
| | | |
| | | // The singleton instance of this class for configuration purposes. |
| | | static final AccessLogger instance = new AccessLogger(); |
| | | |
| | | |
| | | /** |
| | | * Retrieve the singleton instance of this class. |
| | | * |
| | | * @return The singleton instance of this logger. |
| | | */ |
| | | public static AccessLogger getInstance() |
| | | { |
| | | return instance; |
| | | } |
| | | |
| | | /** |
| | | * Add an access log publisher to the access logger. |
| | | * |
| | | * @param dn The DN of the configuration entry for the publisher. |
| | | * @param publisher The access log publisher to add. |
| | | */ |
| | | public synchronized static void addAccessLogPublisher(DN dn, |
| | | AccessLogPublisher publisher) |
| | | { |
| | | accessPublishers.put(dn, publisher); |
| | | } |
| | | |
| | | /** |
| | | * Remove an access log publisher from the access logger. |
| | | * |
| | | * @param dn The DN of the publisher to remove. |
| | | * @return The publisher that was removed or null if it was not found. |
| | | */ |
| | | public synchronized static AccessLogPublisher removeAccessLogPublisher(DN dn) |
| | | { |
| | | AccessLogPublisher AccessLogPublisher = accessPublishers.get(dn); |
| | | if(AccessLogPublisher != null) |
| | | { |
| | | AccessLogPublisher.close(); |
| | | } |
| | | |
| | | return AccessLogPublisher; |
| | | } |
| | | |
| | | /** |
| | | * Removes all existing access log publishers from the logger. |
| | | */ |
| | | public synchronized static void removeAllAccessLogPublishers() |
| | | { |
| | | for(AccessLogPublisher publisher : accessPublishers.values()) |
| | | { |
| | | publisher.close(); |
| | | } |
| | | |
| | | accessPublishers.clear(); |
| | | } |
| | | |
| | | /** |
| | | * Initializes all the access log publishers. |
| | | * |
| | | * @param configs The access log publisher configurations. |
| | | * @throws ConfigException |
| | | * If an unrecoverable problem arises in the process of |
| | | * performing the initialization as a result of the server |
| | | * configuration. |
| | | * @throws InitializationException |
| | | * If a problem occurs during initialization that is not |
| | | * related to the server configuration. |
| | | */ |
| | | public void initializeAccessLogger(List<AccessLogPublisherCfg> configs) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | for(AccessLogPublisherCfg config : configs) |
| | | { |
| | | config.addAccessChangeListener(this); |
| | | |
| | | if(config.isEnabled()) |
| | | { |
| | | AccessLogPublisher AccessLogPublisher = getAccessPublisher(config); |
| | | |
| | | addAccessLogPublisher(config.dn(), AccessLogPublisher); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationAddAcceptable(AccessLogPublisherCfg config, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | return !config.isEnabled() || |
| | | isJavaClassAcceptable(config, unacceptableReasons); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationChangeAcceptable(AccessLogPublisherCfg config, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | return !config.isEnabled() || |
| | | isJavaClassAcceptable(config, unacceptableReasons); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationAdd(AccessLogPublisherCfg config) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | config.addAccessChangeListener(this); |
| | | |
| | | if(config.isEnabled()) |
| | | { |
| | | try |
| | | { |
| | | AccessLogPublisher AccessLogPublisher = getAccessPublisher(config); |
| | | |
| | | addAccessLogPublisher(config.dn(), AccessLogPublisher); |
| | | } |
| | | catch(ConfigException e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | messages.add(e.getMessage()); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | int msgID = MSGID_CONFIG_LOGGER_CANNOT_CREATE_LOGGER; |
| | | messages.add(getMessage(msgID, String.valueOf(config.dn().toString()), |
| | | stackTraceToSingleLineString(e))); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | } |
| | | } |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | AccessLogPublisherCfg config) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | DN dn = config.dn(); |
| | | AccessLogPublisher AccessLogPublisher = accessPublishers.get(dn); |
| | | |
| | | if(AccessLogPublisher == null) |
| | | { |
| | | if(config.isEnabled()) |
| | | { |
| | | // Needs to be added and enabled. |
| | | return applyConfigurationAdd(config); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if(config.isEnabled()) |
| | | { |
| | | // The publisher is currently active, so we don't need to do anything. |
| | | // Changes to the class name cannot be |
| | | // applied dynamically, so if the class name did change then |
| | | // indicate that administrative action is required for that |
| | | // change to take effect. |
| | | String className = config.getJavaImplementationClass(); |
| | | if(!className.equals(AccessLogPublisher.getClass().getName())) |
| | | { |
| | | adminActionRequired = true; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // The publisher is being disabled so shut down and remove. |
| | | removeAccessLogPublisher(config.dn()); |
| | | } |
| | | } |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationDeleteAcceptable(AccessLogPublisherCfg config, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | DN dn = config.dn(); |
| | | AccessLogPublisher AccessLogPublisher = accessPublishers.get(dn); |
| | | return AccessLogPublisher != null; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationDelete( |
| | | AccessLogPublisherCfg config) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | |
| | | removeAccessLogPublisher(config.dn()); |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired); |
| | | } |
| | | |
| | | private boolean isJavaClassAcceptable(AccessLogPublisherCfg config, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | String className = config.getJavaImplementationClass(); |
| | | AccessLogPublisherCfgDefn d = AccessLogPublisherCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = |
| | | d.getJavaImplementationClassPropertyDefinition(); |
| | | // Load the class and cast it to a DebugLogPublisher. |
| | | Class<? extends AccessLogPublisher> theClass; |
| | | try { |
| | | theClass = pd.loadClass(className, AccessLogPublisher.class); |
| | | theClass.newInstance(); |
| | | } catch (Exception e) { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ACCESS_LOGGER_CLASS; |
| | | String message = getMessage(msgID, className, |
| | | config.dn().toString(), |
| | | String.valueOf(e)); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | // Check that the implementation class implements the correct interface. |
| | | try { |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | theClass.getMethod("initializeAccessLogPublisher", config.definition() |
| | | .getServerConfigurationClass()); |
| | | } catch (Exception e) { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ACCESS_LOGGER_CLASS; |
| | | String message = getMessage(msgID, className, |
| | | config.dn().toString(), |
| | | String.valueOf(e)); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | // The class is valid as far as we can tell. |
| | | return true; |
| | | } |
| | | |
| | | private AccessLogPublisher getAccessPublisher(AccessLogPublisherCfg config) |
| | | throws ConfigException { |
| | | String className = config.getJavaImplementationClass(); |
| | | AccessLogPublisherCfgDefn d = AccessLogPublisherCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = |
| | | d.getJavaImplementationClassPropertyDefinition(); |
| | | // Load the class and cast it to a AccessLogPublisher. |
| | | Class<? extends AccessLogPublisher> theClass; |
| | | AccessLogPublisher AccessLogPublisher; |
| | | try { |
| | | theClass = pd.loadClass(className, AccessLogPublisher.class); |
| | | AccessLogPublisher = theClass.newInstance(); |
| | | |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | Method method = theClass.getMethod("initializeAccessLogPublisher", |
| | | config.definition().getServerConfigurationClass()); |
| | | method.invoke(AccessLogPublisher, config); |
| | | } |
| | | catch (InvocationTargetException ite) |
| | | { |
| | | // Rethrow the exceptions thrown be the invoked method. |
| | | Throwable e = ite.getTargetException(); |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ACCESS_LOGGER_CLASS; |
| | | String message = getMessage(msgID, className, |
| | | config.dn().toString(), |
| | | stackTraceToSingleLineString(e)); |
| | | throw new ConfigException(msgID, message, e); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ACCESS_LOGGER_CLASS; |
| | | String message = getMessage(msgID, className, |
| | | config.dn().toString(), |
| | | String.valueOf(e)); |
| | | throw new ConfigException(msgID, message, e); |
| | | } |
| | | |
| | | // The access publisher has been successfully initialized. |
| | | return AccessLogPublisher; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about a new client |
| | | * connection that has been established, regardless of whether it will be |
| | | * immediately terminated. |
| | | * |
| | | * @param clientConnection The client connection that has been established. |
| | | */ |
| | | public static void logConnect(ClientConnection clientConnection) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers.values()) |
| | | { |
| | | publisher.logConnect(clientConnection); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the |
| | | * termination of an existing client connection. |
| | | * |
| | | * @param clientConnection The client connection that has been terminated. |
| | | * @param disconnectReason A generic disconnect reason for the connection |
| | | * termination. |
| | | * @param message A human-readable message that can provide |
| | | * additional information about the disconnect. |
| | | */ |
| | | public static void logDisconnect(ClientConnection clientConnection, |
| | | DisconnectReason disconnectReason, |
| | | String message) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers.values()) |
| | | { |
| | | publisher.logDisconnect(clientConnection, disconnectReason, message); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the abandon |
| | | * request associated with the provided abandon operation. |
| | | * |
| | | * @param abandonOperation The abandon operation containing the information |
| | | * to use to log the abandon request. |
| | | */ |
| | | public static void logAbandonRequest(AbandonOperation abandonOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers.values()) |
| | | { |
| | | publisher.logAbandonRequest(abandonOperation); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the result of |
| | | * the provided abandon operation. |
| | | * |
| | | * @param abandonOperation The abandon operation containing the information |
| | | * to use to log the abandon result. |
| | | */ |
| | | public static void logAbandonResult(AbandonOperation abandonOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers.values()) |
| | | { |
| | | publisher.logAbandonResult(abandonOperation); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the add |
| | | * request associated with the provided add operation. |
| | | * |
| | | * @param addOperation The add operation containing the information to use |
| | | * to log the add request. |
| | | */ |
| | | public static void logAddRequest(AddOperation addOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers.values()) |
| | | { |
| | | publisher.logAddRequest(addOperation); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the add |
| | | * response associated with the provided add operation. |
| | | * |
| | | * @param addOperation The add operation containing the information to use |
| | | * to log the add response. |
| | | */ |
| | | public static void logAddResponse(AddOperation addOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers.values()) |
| | | { |
| | | publisher.logAddResponse(addOperation); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the bind |
| | | * request associated with the provided bind operation. |
| | | * |
| | | * @param bindOperation The bind operation containing the information to use |
| | | * to log the bind request. |
| | | */ |
| | | public static void logBindRequest(BindOperation bindOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers.values()) |
| | | { |
| | | publisher.logBindRequest(bindOperation); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the bind |
| | | * response associated with the provided bind operation. |
| | | * |
| | | * @param bindOperation The bind operation containing the information to use |
| | | * to log the bind response. |
| | | */ |
| | | public static void logBindResponse(BindOperation bindOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers.values()) |
| | | { |
| | | publisher.logBindResponse(bindOperation); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the compare |
| | | * request associated with the provided compare operation. |
| | | * |
| | | * @param compareOperation The compare operation containing the information |
| | | * to use to log the compare request. |
| | | */ |
| | | public static void logCompareRequest(CompareOperation compareOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers.values()) |
| | | { |
| | | publisher.logCompareRequest(compareOperation); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the compare |
| | | * response associated with the provided compare operation. |
| | | * |
| | | * @param compareOperation The compare operation containing the information |
| | | * to use to log the compare response. |
| | | */ |
| | | public static void logCompareResponse(CompareOperation compareOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers.values()) |
| | | { |
| | | publisher.logCompareResponse(compareOperation); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the delete |
| | | * request associated with the provided delete operation. |
| | | * |
| | | * @param deleteOperation The delete operation containing the information to |
| | | * use to log the delete request. |
| | | */ |
| | | public static void logDeleteRequest(DeleteOperation deleteOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers.values()) |
| | | { |
| | | publisher.logDeleteRequest(deleteOperation); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the delete |
| | | * response associated with the provided delete operation. |
| | | * |
| | | * @param deleteOperation The delete operation containing the information to |
| | | * use to log the delete response. |
| | | */ |
| | | public static void logDeleteResponse(DeleteOperation deleteOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers.values()) |
| | | { |
| | | publisher.logDeleteResponse(deleteOperation); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the extended |
| | | * request associated with the provided extended operation. |
| | | * |
| | | * @param extendedOperation The extended operation containing the |
| | | * information to use to log the extended request. |
| | | */ |
| | | public static void logExtendedRequest(ExtendedOperation extendedOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers.values()) |
| | | { |
| | | publisher.logExtendedRequest(extendedOperation); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the extended |
| | | * response associated with the provided extended operation. |
| | | * |
| | | * @param extendedOperation The extended operation containing the |
| | | * information to use to log the extended response. |
| | | */ |
| | | public static void logExtendedResponse(ExtendedOperation extendedOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers.values()) |
| | | { |
| | | publisher.logExtendedResponse(extendedOperation); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the modify |
| | | * request associated with the provided modify operation. |
| | | * |
| | | * @param modifyOperation The modify operation containing the information to |
| | | * use to log the modify request. |
| | | */ |
| | | public static void logModifyRequest(ModifyOperation modifyOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers.values()) |
| | | { |
| | | publisher.logModifyRequest(modifyOperation); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the modify |
| | | * response associated with the provided modify operation. |
| | | * |
| | | * @param modifyOperation The modify operation containing the information to |
| | | * use to log the modify response. |
| | | */ |
| | | public static void logModifyResponse(ModifyOperation modifyOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers.values()) |
| | | { |
| | | publisher.logModifyResponse(modifyOperation); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the modify DN |
| | | * request associated with the provided modify DN operation. |
| | | * |
| | | * @param modifyDNOperation The modify DN operation containing the |
| | | * information to use to log the modify DN request. |
| | | */ |
| | | public static void logModifyDNRequest(ModifyDNOperation modifyDNOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers.values()) |
| | | { |
| | | publisher.logModifyDNRequest(modifyDNOperation); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the modify DN |
| | | * response associated with the provided modify DN operation. |
| | | * |
| | | * @param modifyDNOperation The modify DN operation containing the |
| | | * information to use to log the modify DN |
| | | * response. |
| | | */ |
| | | public static void logModifyDNResponse(ModifyDNOperation modifyDNOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers.values()) |
| | | { |
| | | publisher.logModifyDNResponse(modifyDNOperation); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the search |
| | | * request associated with the provided search operation. |
| | | * |
| | | * @param searchOperation The search operation containing the information to |
| | | * use to log the search request. |
| | | */ |
| | | public static void logSearchRequest(SearchOperation searchOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers.values()) |
| | | { |
| | | publisher.logSearchRequest(searchOperation); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the search |
| | | * result entry that matches the criteria associated with the provided search |
| | | * operation. |
| | | * |
| | | * @param searchOperation The search operation with which the search result |
| | | * entry is associated. |
| | | * @param searchEntry The search result entry to be logged. |
| | | */ |
| | | public static void logSearchResultEntry(SearchOperation searchOperation, |
| | | SearchResultEntry searchEntry) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers.values()) |
| | | { |
| | | publisher.logSearchResultEntry(searchOperation, searchEntry); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the search |
| | | * result reference returned while processing the associated search operation. |
| | | * |
| | | * @param searchOperation The search operation with which the search result |
| | | * reference is associated. |
| | | * @param searchReference The search result reference to be logged. |
| | | */ |
| | | public static void logSearchResultReference(SearchOperation searchOperation, |
| | | SearchResultReference searchReference) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers.values()) |
| | | { |
| | | publisher.logSearchResultReference(searchOperation, searchReference); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the completion |
| | | * of the provided search operation. |
| | | * |
| | | * @param searchOperation The search operation containing the information |
| | | * to use to log the search result done message. |
| | | */ |
| | | public static void logSearchResultDone(SearchOperation searchOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers.values()) |
| | | { |
| | | publisher.logSearchResultDone(searchOperation); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the unbind |
| | | * request associated with the provided unbind operation. |
| | | * |
| | | * @param unbindOperation The unbind operation containing the information to |
| | | * use to log the unbind request. |
| | | */ |
| | | public static void logUnbind(UnbindOperation unbindOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers.values()) |
| | | { |
| | | publisher.logUnbind(unbindOperation); |
| | | } |
| | | } |
| | | } |
| | | |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | | import org.opends.server.api.DirectoryThread; |
| | | import org.opends.server.api.ServerShutdownListener; |
| | | import org.opends.server.core.DirectoryServer; |
| | | |
| | | import java.util.concurrent.LinkedBlockingQueue; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * A Text Writer which writes log records asynchronously to |
| | | * character-based stream. |
| | | */ |
| | | public class AsyncronousTextWriter |
| | | implements ServerShutdownListener, TextWriter |
| | | { |
| | | /** |
| | | * The wrapped Text Writer. |
| | | */ |
| | | private final TextWriter writer; |
| | | |
| | | /** Queue to store unpublished records. */ |
| | | private final LinkedBlockingQueue<String> queue; |
| | | |
| | | private String name; |
| | | private boolean stopRequested; |
| | | private WriterThread writerThread; |
| | | |
| | | private boolean autoFlush; |
| | | |
| | | /** |
| | | * Construct a new AsyncronousTextWriter wrapper. |
| | | * |
| | | * @param name the name of the thread. |
| | | * @param capacity the size of the queue before it gets flushed. |
| | | * @param autoFlush indicates if the underlying writer should be flushed |
| | | * after the queue is flushed. |
| | | * @param writer a character stream used for output. |
| | | */ |
| | | public AsyncronousTextWriter(String name, int capacity, boolean autoFlush, |
| | | TextWriter writer) |
| | | { |
| | | this.name = name; |
| | | this.autoFlush = autoFlush; |
| | | this.writer = writer; |
| | | |
| | | this.queue = new LinkedBlockingQueue<String>(capacity); |
| | | this.writerThread = null; |
| | | this.stopRequested = false; |
| | | |
| | | writerThread = new WriterThread(); |
| | | writerThread.start(); |
| | | |
| | | DirectoryServer.registerShutdownListener(this); |
| | | } |
| | | |
| | | /** |
| | | * The publisher thread is responsible for emptying the queue of log records |
| | | * waiting to published. |
| | | */ |
| | | private class WriterThread extends DirectoryThread |
| | | { |
| | | public WriterThread() |
| | | { |
| | | super(name); |
| | | } |
| | | /** |
| | | * the run method of the writerThread. Run until queue is empty |
| | | * AND we've been asked to terminate |
| | | */ |
| | | public void run() |
| | | { |
| | | String message = null; |
| | | while (!isShuttingDown() || !queue.isEmpty()) { |
| | | try |
| | | { |
| | | message = queue.poll(10, TimeUnit.SECONDS); |
| | | if(message != null) |
| | | { |
| | | do |
| | | { |
| | | writer.writeRecord(message); |
| | | message = queue.poll(); |
| | | } |
| | | while(message != null); |
| | | |
| | | if(autoFlush) |
| | | { |
| | | flush(); |
| | | } |
| | | } |
| | | } |
| | | catch (InterruptedException ex) { |
| | | // Ignore. We'll rerun the loop |
| | | // and presumably fall out. |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // Method needs to be synchronized with _shutdown mutator, as we don't |
| | | // want shutdown to start after we check for it, but before we queue |
| | | // request. |
| | | private synchronized void writeAsynchronously(String record) |
| | | { |
| | | // If shutting down reject, otherwise publish (if we have a publisher!) |
| | | while (!isShuttingDown()) |
| | | { |
| | | // Put request on queue for writer |
| | | try |
| | | { |
| | | queue.put(record); |
| | | break; |
| | | } |
| | | catch(InterruptedException e) |
| | | { |
| | | // We expect this to happen. Just ignore it and hopefully |
| | | // drop out in the next try. |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Write the log record asyncronously. |
| | | * |
| | | * @param record the log record to write. |
| | | */ |
| | | public void writeRecord(String record) |
| | | { |
| | | // No writer? Off to the bit bucket. |
| | | if (writer != null) { |
| | | writeAsynchronously(record); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void flush() |
| | | { |
| | | writer.flush(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public long getBytesWritten() |
| | | { |
| | | return writer.getBytesWritten(); |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the wrapped writer. |
| | | * |
| | | * @return The wrapped writer used by this asyncronous writer. |
| | | */ |
| | | public TextWriter getWrappedWriter() |
| | | { |
| | | return writer; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public String getShutdownListenerName() |
| | | { |
| | | return "AsyncronousTextWriter Thread " + name; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void processServerShutdown(String reason) |
| | | { |
| | | // Don't shutdown the wrapped writer on server shutdown as it |
| | | // might get more write requests before the log publishers are |
| | | // manually shutdown just before the server process exists. |
| | | shutdown(false); |
| | | } |
| | | |
| | | /** |
| | | * Queries whether the publisher is in shutdown mode. |
| | | */ |
| | | private boolean isShuttingDown() |
| | | { |
| | | return stopRequested; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void shutdown() |
| | | { |
| | | shutdown(true); |
| | | } |
| | | |
| | | /** |
| | | * Releases any resources held by the writer. |
| | | * |
| | | * @param shutdownWrapped If the wrapped writer should be closed as well. |
| | | */ |
| | | public void shutdown(boolean shutdownWrapped) |
| | | { |
| | | stopRequested = true; |
| | | |
| | | // Wait for publisher thread to terminate |
| | | while (writerThread != null && writerThread.isAlive()) { |
| | | try { |
| | | // Interrupt the thread if its blocking |
| | | writerThread.interrupt(); |
| | | writerThread.join(); |
| | | } |
| | | catch (InterruptedException ex) { |
| | | // Ignore; we gotta wait.. |
| | | } |
| | | } |
| | | |
| | | // The writer writerThread SHOULD have drained the queue. |
| | | // If not, handle outstanding requests ourselves, |
| | | // and push them to the writer. |
| | | while (!queue.isEmpty()) { |
| | | String message = queue.poll(); |
| | | writer.writeRecord(message); |
| | | } |
| | | |
| | | // Shutdown the wrapped writer. |
| | | if (shutdownWrapped && writer != null) writer.shutdown(); |
| | | |
| | | DirectoryServer.deregisterShutdownListener(this); |
| | | } |
| | | |
| | | /** |
| | | * Set the auto flush setting for this writer. |
| | | * |
| | | * @param autoFlush If the writer should flush the buffer after every line. |
| | | */ |
| | | public void setAutoFlush(boolean autoFlush) |
| | | { |
| | | this.autoFlush = autoFlush; |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | | |
| | | |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.List; |
| | | import java.util.ArrayList; |
| | | import java.lang.reflect.Method; |
| | | import java.lang.reflect.InvocationTargetException; |
| | | |
| | | import org.opends.server.api.ErrorLogPublisher; |
| | | import org.opends.server.messages.MessageHandler; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.admin.std.server.ErrorLogPublisherCfg; |
| | | import org.opends.server.admin.std.meta.ErrorLogPublisherCfgDefn; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.admin.server.ConfigurationDeleteListener; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | |
| | | /** |
| | | * This class defines the wrapper that will invoke all registered error loggers |
| | | * for each type of request received or response sent. If no error log |
| | | * publishers are registered, messages will be directed to standard out. |
| | | */ |
| | | public class ErrorLogger implements |
| | | ConfigurationAddListener<ErrorLogPublisherCfg>, |
| | | ConfigurationDeleteListener<ErrorLogPublisherCfg>, |
| | | ConfigurationChangeListener<ErrorLogPublisherCfg> |
| | | { |
| | | // The set of error loggers that have been registered with the server. It |
| | | // will initially be empty. |
| | | private static ConcurrentHashMap<DN, ErrorLogPublisher> errorPublishers = |
| | | new ConcurrentHashMap<DN, ErrorLogPublisher>(); |
| | | |
| | | // The singleton instance of this class for configuration purposes. |
| | | private static final ErrorLogger instance = new ErrorLogger(); |
| | | |
| | | /** |
| | | * Retrieve the singleton instance of this class. |
| | | * |
| | | * @return The singleton instance of this logger. |
| | | */ |
| | | public static ErrorLogger getInstance() |
| | | { |
| | | return instance; |
| | | } |
| | | |
| | | /** |
| | | * Add an error log publisher to the error logger. |
| | | * |
| | | * @param dn The DN of the configuration entry for the publisher. |
| | | * @param publisher The error log publisher to add. |
| | | */ |
| | | public synchronized static void addErrorLogPublisher(DN dn, |
| | | ErrorLogPublisher publisher) |
| | | { |
| | | errorPublishers.put(dn, publisher); |
| | | } |
| | | |
| | | /** |
| | | * Remove an error log publisher from the error logger. |
| | | * |
| | | * @param dn The DN of the publisher to remove. |
| | | * @return The publisher that was removed or null if it was not found. |
| | | */ |
| | | public synchronized static ErrorLogPublisher removeErrorLogPublisher(DN dn) |
| | | { |
| | | ErrorLogPublisher errorLogPublisher = errorPublishers.remove(dn); |
| | | if(errorLogPublisher != null) |
| | | { |
| | | errorLogPublisher.close(); |
| | | } |
| | | |
| | | return errorLogPublisher; |
| | | } |
| | | |
| | | /** |
| | | * Removes all existing error log publishers from the logger. |
| | | */ |
| | | public synchronized static void removeAllErrorLogPublishers() |
| | | { |
| | | for(ErrorLogPublisher publisher : errorPublishers.values()) |
| | | { |
| | | publisher.close(); |
| | | } |
| | | |
| | | errorPublishers.clear(); |
| | | } |
| | | |
| | | /** |
| | | * Initializes all the error log publishers. |
| | | * |
| | | * @param configs The error log publisher configurations. |
| | | * @throws ConfigException |
| | | * If an unrecoverable problem arises in the process of |
| | | * performing the initialization as a result of the server |
| | | * configuration. |
| | | * @throws InitializationException |
| | | * If a problem occurs during initialization that is not |
| | | * related to the server configuration. |
| | | */ |
| | | public void initializeErrorLogger(List<ErrorLogPublisherCfg> configs) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | for(ErrorLogPublisherCfg config : configs) |
| | | { |
| | | config.addErrorChangeListener(this); |
| | | |
| | | if(config.isEnabled()) |
| | | { |
| | | ErrorLogPublisher errorLogPublisher = getErrorPublisher(config); |
| | | |
| | | addErrorLogPublisher(config.dn(), errorLogPublisher); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationAddAcceptable(ErrorLogPublisherCfg config, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | return !config.isEnabled() || |
| | | isJavaClassAcceptable(config, unacceptableReasons); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationChangeAcceptable(ErrorLogPublisherCfg config, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | return !config.isEnabled() || |
| | | isJavaClassAcceptable(config, unacceptableReasons); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationAdd(ErrorLogPublisherCfg config) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | config.addErrorChangeListener(this); |
| | | |
| | | if(config.isEnabled()) |
| | | { |
| | | try |
| | | { |
| | | ErrorLogPublisher errorLogPublisher = getErrorPublisher(config); |
| | | |
| | | addErrorLogPublisher(config.dn(), errorLogPublisher); |
| | | } |
| | | catch(ConfigException e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | messages.add(e.getMessage()); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | int msgID = MSGID_CONFIG_LOGGER_CANNOT_CREATE_LOGGER; |
| | | messages.add(getMessage(msgID, String.valueOf(config.dn().toString()), |
| | | stackTraceToSingleLineString(e))); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | } |
| | | } |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | ErrorLogPublisherCfg config) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | DN dn = config.dn(); |
| | | ErrorLogPublisher errorLogPublisher = errorPublishers.get(dn); |
| | | |
| | | if(errorLogPublisher == null) |
| | | { |
| | | if(config.isEnabled()) |
| | | { |
| | | // Needs to be added and enabled. |
| | | return applyConfigurationAdd(config); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if(config.isEnabled()) |
| | | { |
| | | // The publisher is currently active, so we don't need to do anything. |
| | | // Changes to the class name cannot be |
| | | // applied dynamically, so if the class name did change then |
| | | // indicate that administrative action is required for that |
| | | // change to take effect. |
| | | String className = config.getJavaImplementationClass(); |
| | | if(!className.equals(errorLogPublisher.getClass().getName())) |
| | | { |
| | | adminActionRequired = true; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // The publisher is being disabled so shut down and remove. |
| | | removeErrorLogPublisher(config.dn()); |
| | | } |
| | | } |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationDeleteAcceptable(ErrorLogPublisherCfg config, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | DN dn = config.dn(); |
| | | ErrorLogPublisher errorLogPublisher = errorPublishers.get(dn); |
| | | return errorLogPublisher != null; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationDelete( |
| | | ErrorLogPublisherCfg config) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | |
| | | removeErrorLogPublisher(config.dn()); |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired); |
| | | } |
| | | |
| | | private boolean isJavaClassAcceptable(ErrorLogPublisherCfg config, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | String className = config.getJavaImplementationClass(); |
| | | ErrorLogPublisherCfgDefn d = ErrorLogPublisherCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = |
| | | d.getJavaImplementationClassPropertyDefinition(); |
| | | // Load the class and cast it to a DebugLogPublisher. |
| | | Class<? extends ErrorLogPublisher> theClass; |
| | | try { |
| | | theClass = pd.loadClass(className, ErrorLogPublisher.class); |
| | | theClass.newInstance(); |
| | | } catch (Exception e) { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ERROR_LOGGER_CLASS; |
| | | String message = getMessage(msgID, className, |
| | | config.dn().toString(), |
| | | String.valueOf(e)); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | // Check that the implementation class implements the correct interface. |
| | | try { |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | theClass.getMethod("initializeErrorLogPublisher", config.definition() |
| | | .getServerConfigurationClass()); |
| | | } catch (Exception e) { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ERROR_LOGGER_CLASS; |
| | | String message = getMessage(msgID, className, |
| | | config.dn().toString(), |
| | | String.valueOf(e)); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | // The class is valid as far as we can tell. |
| | | return true; |
| | | } |
| | | |
| | | private ErrorLogPublisher getErrorPublisher(ErrorLogPublisherCfg config) |
| | | throws ConfigException { |
| | | String className = config.getJavaImplementationClass(); |
| | | ErrorLogPublisherCfgDefn d = ErrorLogPublisherCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = |
| | | d.getJavaImplementationClassPropertyDefinition(); |
| | | // Load the class and cast it to a ErrorLogPublisher. |
| | | Class<? extends ErrorLogPublisher> theClass; |
| | | ErrorLogPublisher errorLogPublisher; |
| | | try { |
| | | theClass = pd.loadClass(className, ErrorLogPublisher.class); |
| | | errorLogPublisher = theClass.newInstance(); |
| | | |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | Method method = theClass.getMethod("initializeErrorLogPublisher", |
| | | config.definition().getServerConfigurationClass()); |
| | | method.invoke(errorLogPublisher, config); |
| | | } |
| | | catch (InvocationTargetException ite) |
| | | { |
| | | // Rethrow the exceptions thrown be the invoked method. |
| | | Throwable e = ite.getTargetException(); |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ERROR_LOGGER_CLASS; |
| | | String message = getMessage(msgID, className, |
| | | config.dn().toString(), |
| | | stackTraceToSingleLineString(e)); |
| | | throw new ConfigException(msgID, message, e); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ERROR_LOGGER_CLASS; |
| | | String message = getMessage(msgID, className, |
| | | config.dn().toString(), |
| | | String.valueOf(e)); |
| | | throw new ConfigException(msgID, message, e); |
| | | } |
| | | |
| | | // The error publisher has been successfully initialized. |
| | | return errorLogPublisher; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the error log using the provided information. |
| | | * |
| | | * @param category The category that may be used to determine whether to |
| | | * actually log this message. |
| | | * @param severity The severity that may be used to determine whether to |
| | | * actually log this message. |
| | | * @param errorID The error ID that uniquely identifies the provided format |
| | | * string. |
| | | */ |
| | | public static void logError(ErrorLogCategory category, |
| | | ErrorLogSeverity severity, int errorID) |
| | | { |
| | | String message = MessageHandler.getMessage(errorID); |
| | | |
| | | for (ErrorLogPublisher publisher : errorPublishers.values()) |
| | | { |
| | | publisher.logError(category, severity, message, errorID); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the error log using the provided information. |
| | | * |
| | | * @param category The category that may be used to determine whether to |
| | | * actually log this message. |
| | | * @param severity The severity that may be used to determine whether to |
| | | * actually log this message. |
| | | * @param errorID The error ID that uniquely identifies the provided format |
| | | * string. |
| | | * @param args The set of arguments to use for the provided format |
| | | * string. |
| | | */ |
| | | public static void logError(ErrorLogCategory category, |
| | | ErrorLogSeverity severity, int errorID, |
| | | Object... args) |
| | | { |
| | | String message = MessageHandler.getMessage(errorID, args); |
| | | |
| | | for (ErrorLogPublisher publisher : errorPublishers.values()) |
| | | { |
| | | publisher.logError(category, severity, message, errorID); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the error log using the provided information. |
| | | * |
| | | * @param category The category that may be used to determine whether to |
| | | * actually log this message. |
| | | * @param severity The severity that may be used to determine whether to |
| | | * actually log this message. |
| | | * @param message The message to be logged. |
| | | * @param errorID The error ID that uniquely identifies the format string |
| | | * used to generate the provided message. |
| | | */ |
| | | public static void logError(ErrorLogCategory category, |
| | | ErrorLogSeverity severity, String message, |
| | | int errorID) |
| | | { |
| | | for (ErrorLogPublisher publisher : errorPublishers.values()) |
| | | { |
| | | publisher.logError(category, severity, message, errorID); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | package org.opends.server.loggers; |
| | | |
| | | import java.io.File; |
| | | import java.io.FilenameFilter; |
| | | |
| | | /** |
| | | * A FileNamingPolicy is used by a MultiFileWriter to generate the |
| | |
| | | * @return the next file. |
| | | */ |
| | | public File getNextName(); |
| | | |
| | | /** |
| | | * Gets the filename filter that can be used to filter files named by this |
| | | * policy. |
| | | * |
| | | * @return The FilenameFilter that can filter files named by this policy. |
| | | */ |
| | | public FilenameFilter getFilenameFilter(); |
| | | |
| | | /** |
| | | * Gets all the existing files named by this policy. |
| | | * |
| | | * @return The files named by this policy. |
| | | */ |
| | | public File[] listFiles(); |
| | | |
| | | |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | | import org.opends.server.admin.std.server.FileCountLogRetentionPolicyCfg; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | |
| | | import java.io.File; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.ArrayList; |
| | | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugInfo; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | /** |
| | | * This class implements a retention policy based on the number of files. |
| | | * Files will be cleaned up based on the number of files on disk. |
| | | */ |
| | | public class FileNumberRetentionPolicy implements RetentionPolicy |
| | | public class FileNumberRetentionPolicy implements |
| | | RetentionPolicy<FileCountLogRetentionPolicyCfg>, |
| | | ConfigurationChangeListener<FileCountLogRetentionPolicyCfg> |
| | | { |
| | | |
| | | private int numFiles = 0; |
| | | private File directory = null; |
| | | private String prefix = null; |
| | | |
| | | /** |
| | | * Create the retention policy based on the number of files. |
| | | * |
| | | * @param dir The directory in which the log files reside. |
| | | * @param prefix The prefix for the log file names. |
| | | * @param numFiles The number of files on disk. |
| | | * {@inheritDoc} |
| | | */ |
| | | public FileNumberRetentionPolicy(String dir, String prefix, int numFiles) |
| | | public void initializeLogRetentionPolicy( |
| | | FileCountLogRetentionPolicyCfg config) |
| | | { |
| | | this.numFiles = numFiles; |
| | | this.directory = new File(dir); |
| | | this.prefix = prefix; |
| | | numFiles = config.getNumberOfFiles(); |
| | | |
| | | config.addFileCountChangeListener(this); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationChangeAcceptable( |
| | | FileCountLogRetentionPolicyCfg config, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | // Changes should always be OK |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * This method deletes files based on the policy. |
| | | * |
| | | * @return number of files deleted. |
| | | * {@inheritDoc} |
| | | */ |
| | | public int deleteFiles() |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | FileCountLogRetentionPolicyCfg config) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | numFiles = config.getNumberOfFiles(); |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public int deleteFiles(MultifileTextWriter writer) |
| | | { |
| | | int count = 0; |
| | | File[] files = writer.getNamingPolicy().listFiles(); |
| | | |
| | | File[] selectedFiles = directory.listFiles(new LogFileFilter(prefix)); |
| | | if (selectedFiles.length <= numFiles) |
| | | if (files.length <= numFiles) |
| | | { |
| | | return 0; |
| | | } |
| | | |
| | | // Sort files based on last modified time. |
| | | Arrays.sort(selectedFiles, new FileComparator()); |
| | | Arrays.sort(files, new FileComparator()); |
| | | |
| | | for (int j = numFiles; j < selectedFiles.length; j++) |
| | | for (int j = numFiles; j < files.length; j++) |
| | | { |
| | | // System.out.println("Deleting log file:" + selectedFiles[j]); |
| | | selectedFiles[j].delete(); |
| | | if(debugEnabled()) |
| | | { |
| | | debugInfo("Deleting log file:", files[j]); |
| | | } |
| | | files[j].delete(); |
| | | count++; |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | | import java.util.Calendar; |
| | | import java.util.GregorianCalendar; |
| | | import java.util.*; |
| | | |
| | | import org.opends.server.util.TimeThread; |
| | | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugInfo; |
| | | import org.opends.server.admin.std.server.FixedTimeLogRotationPolicyCfg; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | /** |
| | | * This class implements a rotation policy based on fixed |
| | | * day/time of day. |
| | | */ |
| | | public class FixedTimeRotationPolicy implements RotationPolicy |
| | | public class FixedTimeRotationPolicy implements |
| | | RotationPolicy<FixedTimeLogRotationPolicyCfg>, |
| | | ConfigurationChangeListener<FixedTimeLogRotationPolicyCfg> |
| | | { |
| | | |
| | | private static final long NEXT_DAY = 24 * 3600 * 1000; |
| | | private static final long MS_IN_DAY = 24 * 3600 * 1000; |
| | | |
| | | // The scheduled rotation times as ms offsets from the beginnging of the day. |
| | | private long[] rotationTimes; |
| | | private long nextRotationTime = 0; |
| | | |
| | | /** |
| | | * Time in HHmm format. Will be calculated as (hourOfDay*100) + |
| | | * minuteOfHour. |
| | | * |
| | | * @param timeOfDays The times at which log rotation should occur. |
| | | */ |
| | | |
| | | public FixedTimeRotationPolicy(int[] timeOfDays) |
| | | * {@inheritDoc} |
| | | */ |
| | | public void initializeLogRotationPolicy(FixedTimeLogRotationPolicyCfg config) |
| | | { |
| | | Calendar cal = new GregorianCalendar(); |
| | | cal.set( Calendar.MILLISECOND, 0 ); |
| | | cal.set( Calendar.SECOND, 0 ); |
| | | cal.set( Calendar.MINUTE, 0 ); |
| | | cal.set( Calendar.HOUR_OF_DAY, 0 ); |
| | | long timeFromStartOfDay = cal.getTime().getTime(); |
| | | rotationTimes = new long[config.getTimeOfDay().size()]; |
| | | |
| | | rotationTimes = new long[timeOfDays.length]; |
| | | |
| | | for(int i = 0; i < timeOfDays.length; i++) |
| | | int i = 0; |
| | | for(String time : config.getTimeOfDay()) |
| | | { |
| | | int hour = timeOfDays[i]/100; |
| | | int min = timeOfDays[i] - hour*100; |
| | | int hour = Integer.valueOf(time)/100; |
| | | int min = Integer.valueOf(time) - hour*100; |
| | | |
| | | rotationTimes[i] = timeFromStartOfDay + hour*3600*1000 + min*60*1000; |
| | | rotationTimes[i++] = hour*3600*1000 + min*60*1000; |
| | | } |
| | | |
| | | long currTime = TimeThread.getTime(); |
| | | Arrays.sort(rotationTimes); |
| | | |
| | | nextRotationTime = getNextRotationTime(currTime, 0); |
| | | |
| | | config.addFixedTimeChangeListener(this); |
| | | } |
| | | |
| | | /** |
| | | * This method indicates if the log file should be |
| | | * rotated or not. |
| | | * |
| | | * @return true if the file needs to be rotated, false otherwise. |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean rotateFile() |
| | | public boolean isConfigurationChangeAcceptable( |
| | | FixedTimeLogRotationPolicyCfg config, List<String> unacceptableReasons) |
| | | { |
| | | long currTime = TimeThread.getTime(); |
| | | if (debugEnabled()) |
| | | { |
| | | debugInfo("Rotation at fixed time: %d nextRotationTime: %d", |
| | | currTime, nextRotationTime); |
| | | } |
| | | |
| | | if(currTime > nextRotationTime) |
| | | { |
| | | nextRotationTime = getNextRotationTime(currTime, nextRotationTime); |
| | | if (debugEnabled()) |
| | | { |
| | | debugInfo("Setting next rotation to : %d", nextRotationTime); |
| | | } |
| | | return true; |
| | | } |
| | | return false; |
| | | // Changes should always be OK |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * Get the next rotation time. |
| | | * |
| | | * @param currTime The current time. |
| | | * @param currRotationTime The time we currently believe should be the next |
| | | * rotation time. |
| | | * |
| | | * @return The time that should be used for the next log file rotation. |
| | | * {@inheritDoc} |
| | | */ |
| | | private long getNextRotationTime(long currTime, long currRotationTime) |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | FixedTimeLogRotationPolicyCfg config) |
| | | { |
| | | long prevRotationTime = currRotationTime; |
| | | for(int j = 0; j < rotationTimes.length; j++) |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | rotationTimes = new long[config.getTimeOfDay().size()]; |
| | | |
| | | int i = 0; |
| | | for(String time : config.getTimeOfDay()) |
| | | { |
| | | if (currTime < rotationTimes[j]) |
| | | int hour = Integer.valueOf(time)/100; |
| | | int min = Integer.valueOf(time) - hour*100; |
| | | |
| | | rotationTimes[i++] = hour*3600*1000 + min*60*1000; |
| | | } |
| | | |
| | | Arrays.sort(rotationTimes); |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean rotateFile(MultifileTextWriter writer) |
| | | { |
| | | long currTime = TimeThread.getTime(); |
| | | long lastRotationTime = writer.getLastRotationTime(); |
| | | long dayOfLastRotation = MS_IN_DAY * (lastRotationTime / MS_IN_DAY); |
| | | long hourOfLastRotation = lastRotationTime - dayOfLastRotation; |
| | | |
| | | // Find a scheduled rotation time thats right after the last rotation time. |
| | | long hourOfNextRotation = 0; |
| | | for(long time : rotationTimes) |
| | | { |
| | | if(time > hourOfLastRotation) |
| | | { |
| | | currRotationTime = rotationTimes[j]; |
| | | hourOfNextRotation = time; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if(currRotationTime == prevRotationTime) |
| | | if(hourOfNextRotation <= 0) |
| | | { |
| | | for(int k = 0; k < rotationTimes.length; k++) |
| | | { |
| | | rotationTimes[k] += NEXT_DAY; |
| | | } |
| | | currRotationTime = rotationTimes[0]; |
| | | // Rotation alrealy happened after the latest fixed time for that day. |
| | | // Set it the first rotation time for the next day. |
| | | hourOfNextRotation = rotationTimes[0] + MS_IN_DAY; |
| | | } |
| | | |
| | | return currRotationTime; |
| | | } |
| | | long nextRotationTime = dayOfLastRotation + hourOfNextRotation; |
| | | |
| | | if (debugEnabled()) |
| | | { |
| | | debugInfo("As of %d, the next rotation at fixed time is: %d", |
| | | currTime, nextRotationTime); |
| | | } |
| | | |
| | | return currTime > nextRotationTime; |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | import java.io.File; |
| | | import java.lang.reflect.Method; |
| | | import java.util.Arrays; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugInfo; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.admin.std.server.FreeDiskSpaceLogRetentionPolicyCfg; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | |
| | | /** |
| | | * This class implements a retention policy based on the free disk |
| | | * space available expressed as a percentage. This policy is only |
| | | * available on Java 6. |
| | | */ |
| | | public class FreeDiskSpaceRetentionPolicy implements RetentionPolicy |
| | | public class FreeDiskSpaceRetentionPolicy implements |
| | | RetentionPolicy<FreeDiskSpaceLogRetentionPolicyCfg>, |
| | | ConfigurationChangeListener<FreeDiskSpaceLogRetentionPolicyCfg> |
| | | { |
| | | |
| | | private long freeDiskSpace = 0; |
| | | private File directory = null; |
| | | private String prefix = null; |
| | | |
| | | /** |
| | | * Create the retention policy based on the free disk space available. |
| | | * |
| | | * @param dir The directory in which the log files reside. |
| | | * @param prefix The prefix for the log file names. |
| | | * @param freeDiskSpace The free disk space needed. |
| | | * {@inheritDoc} |
| | | */ |
| | | public FreeDiskSpaceRetentionPolicy(String dir, String prefix, |
| | | long freeDiskSpace) |
| | | public void initializeLogRetentionPolicy( |
| | | FreeDiskSpaceLogRetentionPolicyCfg config) |
| | | { |
| | | this.directory = new File(dir); |
| | | this.freeDiskSpace = freeDiskSpace; |
| | | this.prefix = prefix; |
| | | freeDiskSpace = config.getFreeDiskSpace(); |
| | | |
| | | config.addFreeDiskSpaceChangeListener(this); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationChangeAcceptable( |
| | | FreeDiskSpaceLogRetentionPolicyCfg config, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | // Changes should always be OK |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | FreeDiskSpaceLogRetentionPolicyCfg config) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | freeDiskSpace = config.getFreeDiskSpace(); |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | /** |
| | | * This method deletes files based on the policy. |
| | | * |
| | | * @param writer the multi file text writer writing the log files. |
| | | * @return number of files deleted. |
| | | */ |
| | | public int deleteFiles() |
| | | public int deleteFiles(MultifileTextWriter writer) |
| | | { |
| | | File[] files = writer.getNamingPolicy().listFiles(); |
| | | |
| | | if(files.length <= 0) |
| | | { |
| | | return 0; |
| | | } |
| | | |
| | | int count = 0; |
| | | long freeSpace = 0; |
| | | |
| | | try |
| | | { |
| | | // Use reflection to see use the getFreeSpace method if available. |
| | | // this method is only available on Java 6. |
| | | Method meth = File.class.getMethod("getFreeSpace", new Class[0]); |
| | | Object value = meth.invoke(this.directory); |
| | | Object value = meth.invoke(files[0]); |
| | | freeSpace = ((Long) value).longValue(); |
| | | } |
| | | catch (Exception e) |
| | |
| | | return 0; |
| | | } |
| | | |
| | | if(debugEnabled()) |
| | | { |
| | | debugInfo("Current free disk space: %d, Required: %d", freeSpace, |
| | | freeDiskSpace); |
| | | } |
| | | |
| | | if (freeSpace > freeDiskSpace) |
| | | { |
| | | // No cleaning needed. |
| | |
| | | } |
| | | |
| | | long freeSpaceNeeded = freeDiskSpace - freeSpace; |
| | | File[] selectedFiles = directory.listFiles(new LogFileFilter(prefix)); |
| | | |
| | | // Sort files based on last modified time. |
| | | Arrays.sort(selectedFiles, new FileComparator()); |
| | | Arrays.sort(files, new FileComparator()); |
| | | |
| | | long freedSpace = 0; |
| | | for (int j = selectedFiles.length - 1; j < 1; j--) |
| | | for (int j = files.length - 1; j < 1; j--) |
| | | { |
| | | freedSpace += selectedFiles[j].length(); |
| | | // System.out.println("Deleting log file:" + selectedFiles[j]); |
| | | selectedFiles[j].delete(); |
| | | freedSpace += files[j].length(); |
| | | if(debugEnabled()) |
| | | { |
| | | debugInfo("Deleting log file:", files[j]); |
| | | } |
| | | files[j].delete(); |
| | | if (freedSpace >= freeSpaceNeeded) |
| | | { |
| | | break; |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | | import org.opends.server.types.DN; |
| | | |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.LoggerMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.io.File; |
| | | |
| | | /** |
| | | * A LogPublisherErrorHandler is used for notification of exceptions which |
| | | * occur during the publishing of a record. |
| | | * |
| | | * The advantage of using a handler is that we can handle exceptions |
| | | * asynchronously (useful when dealing with an AsynchronousPublisher). |
| | | */ |
| | | public class LogPublisherErrorHandler |
| | | { |
| | | private DN publisherConfigDN; |
| | | private boolean writeErrorOccured = false; |
| | | |
| | | /** |
| | | * Construct a new log publisher error handler for a log publisher |
| | | * with the provided configuration DN. |
| | | * |
| | | * @param publisherConfigDN The DN of the managed object for the |
| | | * log publisher. |
| | | */ |
| | | public LogPublisherErrorHandler(DN publisherConfigDN) |
| | | { |
| | | this.publisherConfigDN = publisherConfigDN; |
| | | } |
| | | |
| | | /** |
| | | * Handle an exception which occurred during the publishing |
| | | * of a log record. |
| | | * @param record - the record which was being published. |
| | | * @param ex - the exception occurred. |
| | | */ |
| | | public void handleWriteError(String record, Throwable ex) |
| | | { |
| | | if(!writeErrorOccured) |
| | | { |
| | | int msgID = MSGID_LOGGER_ERROR_WRITING_RECORD; |
| | | String msg = getMessage(msgID, publisherConfigDN.toString(), |
| | | stackTraceToSingleLineString(ex)); |
| | | System.err.println(msg); |
| | | writeErrorOccured = true; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Handle an exception which occured while trying to open a log |
| | | * file. |
| | | * @param file - the file which was being opened. |
| | | * @param ex - the exception occured. |
| | | */ |
| | | public void handleOpenError(File file, Throwable ex) |
| | | { |
| | | int msgID = MSGID_LOGGER_ERROR_OPENING_FILE; |
| | | String msg = getMessage(msgID, file.toString(), |
| | | publisherConfigDN.toString(), |
| | | stackTraceToSingleLineString(ex)); |
| | | System.err.println(msg); |
| | | } |
| | | |
| | | /** |
| | | * Handle an exception which occured while trying to close a log |
| | | * file. |
| | | * @param ex - the exception occured. |
| | | */ |
| | | public void handleCloseError(Throwable ex) |
| | | { |
| | | int msgID = MSGID_LOGGER_ERROR_CLOSING_FILE; |
| | | String msg = getMessage(msgID, publisherConfigDN.toString(), |
| | | stackTraceToSingleLineString(ex)); |
| | | System.err.println(msg); |
| | | } |
| | | |
| | | /** |
| | | * Handle an exception which occured while trying to flush the |
| | | * writer buffer. |
| | | * @param ex - the exception occured. |
| | | */ |
| | | public void handleFlushError(Throwable ex) |
| | | { |
| | | int msgID = MSGID_LOGGER_ERROR_FLUSHING_BUFFER; |
| | | String msg = getMessage(msgID, publisherConfigDN.toString(), |
| | | stackTraceToSingleLineString(ex)); |
| | | System.err.println(msg); |
| | | } |
| | | } |
| | |
| | | import org.opends.server.api.DirectoryThread; |
| | | import org.opends.server.api.ServerShutdownListener; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import org.opends.server.config.ConfigAttribute; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.InvokableMethod; |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.FilePermission; |
| | | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugVerbose; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import org.opends.server.admin.std.server.SizeLimitLogRotationPolicyCfg; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.util.TimeThread; |
| | | |
| | | import java.io.*; |
| | | import java.util.concurrent.CopyOnWriteArrayList; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * A MultiFileTextWriter is a specialized TextWriter which supports publishing |
| | |
| | | * When a switch is required, the writer closes the current file and opens a |
| | | * new one named in accordance with a specified FileNamingPolicy. |
| | | */ |
| | | public class MultifileTextWriter extends TextWriter |
| | | implements ServerShutdownListener |
| | | public class MultifileTextWriter |
| | | implements ServerShutdownListener, TextWriter, |
| | | ConfigurationChangeListener<SizeLimitLogRotationPolicyCfg> |
| | | { |
| | | private static final String UTF8_ENCODING= "UTF-8"; |
| | | private static final int BUFFER_SIZE= 65536; |
| | | |
| | | private CopyOnWriteArrayList<RotationPolicy> rotationPolicies; |
| | | private CopyOnWriteArrayList<RetentionPolicy> retentionPolicies; |
| | | private CopyOnWriteArrayList<RotationPolicy> rotationPolicies = |
| | | new CopyOnWriteArrayList<RotationPolicy>(); |
| | | private CopyOnWriteArrayList<RetentionPolicy> retentionPolicies = |
| | | new CopyOnWriteArrayList<RetentionPolicy>(); |
| | | |
| | | private FileNamingPolicy namingPolicy; |
| | | private FilePermission filePermissions; |
| | | private LogPublisherErrorHandler errorHandler; |
| | | //TODO: Implement actions. |
| | | private ArrayList<ActionType> actions; |
| | | |
| | |
| | | private int bufferSize; |
| | | private boolean autoFlush; |
| | | private boolean append; |
| | | private int interval; |
| | | private long interval; |
| | | private boolean stopRequested; |
| | | private long sizeLimit = 0; |
| | | |
| | | private Thread rotaterThread; |
| | | |
| | | /** |
| | | * Get the writer for the initial log file and initialize the |
| | | * rotation policy. |
| | | * @param naming - the file naming policy in use |
| | | * @param encoding - the encoding to use when writing log records. |
| | | * @param autoFlush - indicates whether the file should be flushed |
| | | * after every record written. |
| | | * @param append - indicates whether to append to the existing file or to |
| | | * overwrite it. |
| | | * @param bufferSize - the buffer size to use for the writer. |
| | | * @return a PrintWriter for the initial log file |
| | | * @throws IOException if the initial log file could not be opened |
| | | */ |
| | | private static PrintWriter getInitialWriter(FileNamingPolicy naming, |
| | | String encoding, |
| | | boolean autoFlush, |
| | | boolean append, |
| | | int bufferSize) |
| | | throws IOException |
| | | { |
| | | File file = naming.getInitialName(); |
| | | return constructWriter(file, encoding, autoFlush, append, bufferSize); |
| | | } |
| | | private long lastRotationTime = TimeThread.getTime(); |
| | | private long lastCleanTime = TimeThread.getTime(); |
| | | private long lastCleanCount = 0; |
| | | private long totalFilesRotated = 0; |
| | | private long totalFilesCleaned = 0; |
| | | |
| | | /** |
| | | * Construct a PrintWriter for a file. |
| | | * @param file - the file to open for writing |
| | | * @param encoding - the encoding to use when writing log records. |
| | | * @param autoFlush - indicates whether the file should be flushed |
| | | * after every record written. |
| | | * @param append - indicates whether the file should be appended to or |
| | | * truncated. |
| | | * @param bufferSize - the buffer size to use for the writer. |
| | | * @return a PrintWriter for the specified file. |
| | | * @throws IOException if the PrintWriter could not be constructed |
| | | * or if the file already exists and it was indicated this should be |
| | | * an error. |
| | | */ |
| | | private static PrintWriter constructWriter(File file, String encoding, |
| | | boolean autoFlush, boolean append, |
| | | int bufferSize) |
| | | throws IOException |
| | | { |
| | | FileOutputStream fos= new FileOutputStream(file, append); |
| | | OutputStreamWriter osw= new OutputStreamWriter(fos, encoding); |
| | | BufferedWriter bw = null; |
| | | if(bufferSize <= 0) |
| | | { |
| | | bw= new BufferedWriter(osw); |
| | | } |
| | | else |
| | | { |
| | | bw= new BufferedWriter(osw, bufferSize); |
| | | } |
| | | return new PrintWriter(bw, autoFlush); |
| | | } |
| | | |
| | | /** |
| | | * Creates a new instance of MultiFileTextWriter with the supplied policies. |
| | | * |
| | | * @param name the name of the log rotation thread. |
| | | * @param namingPolicy the file naming policy to use to name rotated log |
| | | * files. |
| | | * @throws IOException if an error occurs while creating the log file. |
| | | */ |
| | | public MultifileTextWriter(String name, FileNamingPolicy namingPolicy) |
| | | throws IOException |
| | | { |
| | | this(name, 5000, namingPolicy, UTF8_ENCODING, |
| | | true, true, BUFFER_SIZE, null, null); |
| | | } |
| | | /** The underlying output stream. */ |
| | | private MeteredStream outputStream; |
| | | /** The underlaying buffered writer using the output steram. */ |
| | | private BufferedWriter writer; |
| | | |
| | | /** |
| | | * Creates a new instance of MultiFileTextWriter with the supplied policies. |
| | |
| | | * @param interval the interval to check whether the logs need to be rotated. |
| | | * @param namingPolicy the file naming policy to use to name rotated log. |
| | | * files. |
| | | * @param filePermissions the file permissions to set on the log files. |
| | | * @param errorHandler the log publisher error handler to notify when |
| | | * an error occurs. |
| | | * @param encoding the encoding to use to write the log files. |
| | | * @param autoFlush whether to flush the writer on every println. |
| | | * @param append whether to append to an existing log file. |
| | | * @param bufferSize the bufferSize to use for the writer. |
| | | * @param rotationPolicies the rotation policy to use for log rotation. |
| | | * @param retentionPolicies the retention policy to use for log rotation. |
| | | * @throws IOException if an error occurs while creating the log file. |
| | | * @throws DirectoryException if an error occurs while preping the new log |
| | | * file. |
| | | */ |
| | | public MultifileTextWriter(String name, int interval, |
| | | FileNamingPolicy namingPolicy, String encoding, |
| | | boolean autoFlush, boolean append, int bufferSize, |
| | | CopyOnWriteArrayList<RotationPolicy> rotationPolicies, |
| | | CopyOnWriteArrayList<RetentionPolicy> retentionPolicies) |
| | | throws IOException |
| | | public MultifileTextWriter(String name, long interval, |
| | | FileNamingPolicy namingPolicy, |
| | | FilePermission filePermissions, |
| | | LogPublisherErrorHandler errorHandler, |
| | | String encoding, |
| | | boolean autoFlush, |
| | | boolean append, |
| | | int bufferSize) |
| | | throws IOException, DirectoryException |
| | | { |
| | | super(getInitialWriter(namingPolicy, encoding, |
| | | autoFlush, append, bufferSize), true); |
| | | File file = namingPolicy.getInitialName(); |
| | | constructWriter(file, filePermissions, encoding, append, |
| | | bufferSize); |
| | | |
| | | this.name = name; |
| | | this.interval = interval; |
| | | this.namingPolicy = namingPolicy; |
| | | this.rotationPolicies = rotationPolicies; |
| | | this.retentionPolicies = retentionPolicies; |
| | | this.filePermissions = filePermissions; |
| | | this.errorHandler = errorHandler; |
| | | |
| | | this.encoding = encoding; |
| | | this.encoding = UTF8_ENCODING; |
| | | this.autoFlush = autoFlush; |
| | | this.append = append; |
| | | this.bufferSize = bufferSize; |
| | | |
| | | this.stopRequested = false; |
| | | |
| | | // We will lazily launch the rotaterThread |
| | | // to ensure initialization safety. |
| | | rotaterThread = new RotaterThread(this); |
| | | rotaterThread.start(); |
| | | |
| | | DirectoryServer.registerShutdownListener(this); |
| | | } |
| | | |
| | | /** |
| | | * Construct a PrintWriter for a file. |
| | | * @param file - the file to open for writing |
| | | * @param filePermissions - the file permissions to set on the file. |
| | | * @param encoding - the encoding to use when writing log records. |
| | | * @param append - indicates whether the file should be appended to or |
| | | * truncated. |
| | | * @param bufferSize - the buffer size to use for the writer. |
| | | * @throws IOException if the PrintWriter could not be constructed |
| | | * or if the file already exists and it was indicated this should be |
| | | * an error. |
| | | * @throws DirectoryException if there was a problem setting permissions on |
| | | * the file. |
| | | */ |
| | | private void constructWriter(File file, FilePermission filePermissions, |
| | | String encoding, boolean append, |
| | | int bufferSize) |
| | | throws IOException, DirectoryException |
| | | { |
| | | // Create new file if it doesn't exist |
| | | if(!file.exists()) |
| | | { |
| | | file.createNewFile(); |
| | | } |
| | | |
| | | FileOutputStream stream = new FileOutputStream(file, append); |
| | | outputStream = new MeteredStream(stream, 0); |
| | | |
| | | OutputStreamWriter osw = new OutputStreamWriter(outputStream, encoding); |
| | | BufferedWriter bw = null; |
| | | if(bufferSize <= 0) |
| | | { |
| | | writer = new BufferedWriter(osw); |
| | | } |
| | | else |
| | | { |
| | | writer = new BufferedWriter(osw, bufferSize); |
| | | } |
| | | |
| | | if(FilePermission.canSetPermissions()) |
| | | { |
| | | FilePermission.setPermissions(file, filePermissions); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Add a rotation policy to enforce on the files written by this writer. |
| | | * |
| | | * @param policy The rotation policy to add. |
| | | */ |
| | | public void addRotationPolicy(RotationPolicy policy) |
| | | { |
| | | this.rotationPolicies.add(policy); |
| | | |
| | | if(policy instanceof SizeBasedRotationPolicy) |
| | | { |
| | | SizeBasedRotationPolicy sizePolicy = ((SizeBasedRotationPolicy)policy); |
| | | if(sizeLimit == 0 || |
| | | sizeLimit > sizePolicy.currentConfig.getFileSizeLimit()) |
| | | { |
| | | sizeLimit = sizePolicy.currentConfig.getFileSizeLimit(); |
| | | } |
| | | // Add this as a change listener so we can update the size limit. |
| | | sizePolicy.currentConfig.addSizeLimitChangeListener(this); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Add a retention policy to enforce on the files written by this writer. |
| | | * |
| | | * @param policy The retention policy to add. |
| | | */ |
| | | public void addRetentionPolicy(RetentionPolicy policy) |
| | | { |
| | | this.retentionPolicies.add(policy); |
| | | } |
| | | |
| | | /** |
| | | * Removes all the rotation policies currently enforced by this writer. |
| | | */ |
| | | public void removeAllRotationPolicies() |
| | | { |
| | | for(RotationPolicy policy : rotationPolicies) |
| | | { |
| | | if(policy instanceof SizeBasedRotationPolicy) |
| | | { |
| | | sizeLimit = 0; |
| | | |
| | | // Remove this as a change listener. |
| | | SizeBasedRotationPolicy sizePolicy = ((SizeBasedRotationPolicy)policy); |
| | | sizePolicy.currentConfig.removeSizeLimitChangeListener(this); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Removes all retention policies being enforced by this writer. |
| | | */ |
| | | public void removeAllRetentionPolicies() |
| | | { |
| | | this.retentionPolicies.clear(); |
| | | } |
| | | |
| | | /** |
| | | * Set the auto flush setting for this writer. |
| | | * |
| | | * @param autoFlush If the writer should flush the buffer after every line. |
| | | */ |
| | | public void setAutoFlush(boolean autoFlush) |
| | | { |
| | | this.autoFlush = autoFlush; |
| | | } |
| | | |
| | | /** |
| | | * Set the append setting for this writter. |
| | | * |
| | | * @param append If the writer should append to an existing file. |
| | | */ |
| | | public void setAppend(boolean append) |
| | | { |
| | | this.append = append; |
| | | } |
| | | |
| | | /** |
| | | * Set the buffer size for this writter. |
| | | * |
| | | * @param bufferSize The size of the underlying output stream buffer. |
| | | */ |
| | | public void setBufferSize(int bufferSize) |
| | | { |
| | | this.bufferSize = bufferSize; |
| | | } |
| | | |
| | | /** |
| | | * Set the file permission to set for newly created log files. |
| | | * |
| | | * @param filePermissions The file permission to set for new log files. |
| | | */ |
| | | public void setFilePermissions(FilePermission filePermissions) |
| | | { |
| | | this.filePermissions = filePermissions; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the current naming policy used to generate log file names. |
| | | * |
| | | * @return The current naming policy in use. |
| | | */ |
| | | public FileNamingPolicy getNamingPolicy() |
| | | { |
| | | return namingPolicy; |
| | | } |
| | | |
| | | /** |
| | | * Set the naming policy to use when generating new log files. |
| | | * |
| | | * @param namingPolicy the naming policy to use to name log files. |
| | | */ |
| | | public void setNamingPolicy(FileNamingPolicy namingPolicy) |
| | | { |
| | | this.namingPolicy = namingPolicy; |
| | | } |
| | | |
| | | /** |
| | | * Set the internval in which the rotator thread checks to see if the log |
| | | * file should be rotated. |
| | | * |
| | | * @param interval The interval to check if the log file needs to be rotated. |
| | | */ |
| | | public void setInterval(long interval) |
| | | { |
| | | this.interval = interval; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationChangeAcceptable( |
| | | SizeLimitLogRotationPolicyCfg config, List<String> unacceptableReasons) |
| | | { |
| | | // This should always be ok |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | SizeLimitLogRotationPolicyCfg config) |
| | | { |
| | | if(sizeLimit == 0 || sizeLimit > config.getFileSizeLimit()) |
| | | { |
| | | sizeLimit = config.getFileSizeLimit(); |
| | | } |
| | | |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false, |
| | | new ArrayList<String>()); |
| | | } |
| | | |
| | | /** |
| | | * A rotater thread is responsible for checking if the log files need to be |
| | | * rotated based on the policies. It will do so if necessary. |
| | | */ |
| | | private class RotaterThread extends DirectoryThread |
| | | { |
| | | MultifileTextWriter writer; |
| | | /** |
| | | * Create a new rotater thread. |
| | | */ |
| | | public RotaterThread() |
| | | public RotaterThread(MultifileTextWriter writer) |
| | | { |
| | | super(name); |
| | | this.writer = writer; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | |
| | | if(rotationPolicies != null) |
| | | for(RotationPolicy rotationPolicy : rotationPolicies) |
| | | { |
| | | for(RotationPolicy rotationPolicy : rotationPolicies) |
| | | if(rotationPolicy.rotateFile(writer)) |
| | | { |
| | | if(rotationPolicy.rotateFile()) |
| | | { |
| | | try |
| | | { |
| | | rotate(); |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | //TODO: Comment this after AOP logging is complete. |
| | | //int msgID = MSGID_CONFIG_LOGGER_ROTATE_FAILED; |
| | | //Error.logError(ErrorLogCategory.CORE_SERVER, |
| | | // ErrorLogSeverity.SEVERE_ERROR, msgID, ioe); |
| | | } |
| | | } |
| | | rotate(); |
| | | } |
| | | } |
| | | |
| | | if(retentionPolicies != null) |
| | | for(RetentionPolicy retentionPolicy : retentionPolicies) |
| | | { |
| | | for(RetentionPolicy retentionPolicy : retentionPolicies) |
| | | int numFilesDeleted = |
| | | retentionPolicy.deleteFiles(writer); |
| | | if(numFilesDeleted > 0) |
| | | { |
| | | int numFilesDeleted = retentionPolicy.deleteFiles(); |
| | | if (debugEnabled()) |
| | | { |
| | | debugVerbose("%d files deleted by rentention policy", |
| | | numFilesDeleted); |
| | | } |
| | | lastCleanTime = TimeThread.getTime(); |
| | | lastCleanCount = numFilesDeleted; |
| | | totalFilesCleaned++; |
| | | } |
| | | if (debugEnabled()) |
| | | { |
| | | debugVerbose("%d files deleted by rentention policy", |
| | | numFilesDeleted); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | public void processServerShutdown(String reason) |
| | | { |
| | | startShutDown(); |
| | | stopRequested = true; |
| | | |
| | | // Wait for rotater to terminate |
| | | while (rotaterThread != null && rotaterThread.isAlive()) { |
| | | try { |
| | | // Interrupt if its sleeping |
| | | rotaterThread.interrupt(); |
| | | rotaterThread.join(); |
| | | } |
| | | catch (InterruptedException ex) { |
| | |
| | | } |
| | | } |
| | | |
| | | writer.flush(); |
| | | writer.close(); |
| | | writer = null; |
| | | DirectoryServer.deregisterShutdownListener(this); |
| | | |
| | | removeAllRotationPolicies(); |
| | | removeAllRetentionPolicies(); |
| | | |
| | | // Don't close the writer as there might still be message to be |
| | | // written. manually shutdown just before the server process |
| | | // exists. |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return if the publish is in shutdown mode. |
| | | */ |
| | | private synchronized boolean isShuttingDown() |
| | | private boolean isShuttingDown() |
| | | { |
| | | return stopRequested; |
| | | } |
| | | |
| | | /** |
| | | * Tell the writer to start shutting down. |
| | | */ |
| | | private synchronized void startShutDown() |
| | | { |
| | | stopRequested = true; |
| | | } |
| | | |
| | | /** |
| | | * Shutdown the text writer. |
| | | */ |
| | | public void shutdown() |
| | | { |
| | | processServerShutdown(null); |
| | | |
| | | DirectoryServer.deregisterShutdownListener(this); |
| | | try |
| | | { |
| | | writer.flush(); |
| | | writer.close(); |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | errorHandler.handleCloseError(e); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | * |
| | | * @param record the log record to write. |
| | | */ |
| | | public synchronized void writeRecord(String record) |
| | | public void writeRecord(String record) |
| | | { |
| | | // Launch writer rotaterThread if not running |
| | | if (rotaterThread == null) { |
| | | rotaterThread = new RotaterThread(); |
| | | rotaterThread.start(); |
| | | synchronized(this) |
| | | { |
| | | try |
| | | { |
| | | writer.write(record); |
| | | writer.newLine(); |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | errorHandler.handleWriteError(record, e); |
| | | } |
| | | |
| | | if(autoFlush) |
| | | { |
| | | flush(); |
| | | } |
| | | } |
| | | |
| | | writer.println(record); |
| | | if(sizeLimit > 0 && outputStream.written >= sizeLimit) |
| | | { |
| | | rotate(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void flush() |
| | | { |
| | | try |
| | | { |
| | | writer.flush(); |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | errorHandler.handleFlushError(e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Tries to rotate the log files. If the new log file alreadly exists, it |
| | | * tries to rename the file. On failure, all subsequent log write requests |
| | | * will throw exceptions. |
| | | * |
| | | * @throws IOException if an error occurs while rotation the log files. |
| | | */ |
| | | public void rotate() throws IOException |
| | | public synchronized void rotate() |
| | | { |
| | | writer.flush(); |
| | | writer.close(); |
| | | writer = null; |
| | | try |
| | | { |
| | | writer.flush(); |
| | | writer.close(); |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | errorHandler.handleCloseError(e); |
| | | } |
| | | |
| | | File currentFile = namingPolicy.getInitialName(); |
| | | File newFile = namingPolicy.getNextName(); |
| | | currentFile.renameTo(newFile); |
| | | |
| | | writer = constructWriter(currentFile, encoding, |
| | | autoFlush, append, bufferSize); |
| | | try |
| | | { |
| | | constructWriter(currentFile, filePermissions, encoding, append, |
| | | bufferSize); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | errorHandler.handleOpenError(currentFile, e); |
| | | } |
| | | |
| | | //RotationActionThread rotThread = |
| | | // new RotationActionThread(newFile, actions, configEntry); |
| | | //rotThread.start(); |
| | | } |
| | | |
| | | /** |
| | | * Invokes the specified method with the provided arguments. |
| | | * |
| | | * @param methodName The name of the method to invoke. |
| | | * @param arguments The set of configuration attributes holding the |
| | | * arguments to use for the method. |
| | | * |
| | | * @return The return value for the method, or <CODE>null</CODE> if it did |
| | | * not return a value. |
| | | * |
| | | * @throws org.opends.server.types.DirectoryException |
| | | * If there was no such method, or if an error occurred while attempting |
| | | * to invoke it. |
| | | */ |
| | | public Object invokeMethod(String methodName, ConfigAttribute[] arguments) |
| | | throws DirectoryException |
| | | { |
| | | if(!methodName.equals("rotateNow")) |
| | | { |
| | | int msgID = MSGID_CONFIG_JMX_NO_METHOD; |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, |
| | | getMessage(msgID), msgID); |
| | | } |
| | | |
| | | try |
| | | { |
| | | rotate(); |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | //TODO: Comment when AOP logging framework is complete. |
| | | //int msgID = MSGID_CONFIG_LOGGER_ROTATE_FAILED; |
| | | //throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, |
| | | // getMessage(msgID, e), msgID); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves a list of the methods that may be invoked for this component. |
| | | * |
| | | * @return A list of the methods that may be invoked for this component. |
| | | */ |
| | | public InvokableMethod[] getOperationSignatures() |
| | | { |
| | | InvokableMethod[] methods = new InvokableMethod[1]; |
| | | methods[0] = new InvokableMethod("rotateNow", |
| | | "Rotate the log file immediately", |
| | | null, "void", true, true); |
| | | return methods; |
| | | totalFilesRotated++; |
| | | lastRotationTime = TimeThread.getTime(); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | this.actions = actions; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the number of bytes written to the current log file. |
| | | * |
| | | * @return The number of bytes written to the current log file. |
| | | */ |
| | | public long getBytesWritten() |
| | | { |
| | | return outputStream.written; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the last time one or more log files are cleaned in this instance |
| | | * of the Directory Server. If log files have never been cleaned, this value |
| | | * will be the time the server started. |
| | | * |
| | | * @return The last time log files are cleaned. |
| | | */ |
| | | public long getLastCleanTime() |
| | | { |
| | | return lastCleanTime; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the number of files cleaned in the last cleanup run. |
| | | * |
| | | * @return The number of files cleaned int he last cleanup run. |
| | | */ |
| | | public long getLastCleanCount() |
| | | { |
| | | return lastCleanCount; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the last time a log file was rotated in this instance of |
| | | * Directory Server. If a log rotation never |
| | | * occured, this value will be the time the server started. |
| | | * |
| | | * @return The last time log rotation occured. |
| | | */ |
| | | public long getLastRotationTime() |
| | | { |
| | | return lastRotationTime; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the total number file rotations occured in this instance of the |
| | | * Directory Server. |
| | | * |
| | | * @return The total number of file rotations. |
| | | */ |
| | | public long getTotalFilesRotated() |
| | | { |
| | | return totalFilesRotated; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves teh total number of files cleaned in this instance of the |
| | | * Directory Server. |
| | | * |
| | | * @return The total number of files cleaned. |
| | | */ |
| | | public long getTotalFilesCleaned() |
| | | { |
| | | return totalFilesCleaned; |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | | import org.opends.server.admin.std.server.LogRetentionPolicyCfg; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.types.InitializationException; |
| | | |
| | | |
| | | /** |
| | | * This interface describes the retention policy that should be used |
| | | * for the logger. Supported policies include number of files and |
| | | * disk utilization (for Java 6). |
| | | * |
| | | * @param <T> The type of retention policy configuration handled by |
| | | * this retention policy implementation. |
| | | */ |
| | | public interface RetentionPolicy |
| | | public interface RetentionPolicy<T extends LogRetentionPolicyCfg> |
| | | { |
| | | /** |
| | | * Initializes this log retention policy based on the |
| | | * information in the provided retention policy configuration. |
| | | * |
| | | * @param config |
| | | * The retention policy configuration that contains the |
| | | * information to use to initialize this policy. |
| | | * @throws ConfigException |
| | | * If an unrecoverable problem arises in the process of |
| | | * performing the initialization as a result of the server |
| | | * configuration. |
| | | * @throws InitializationException |
| | | * If a problem occurs during initialization that is not |
| | | * related to the server configuration. |
| | | */ |
| | | public abstract void initializeLogRetentionPolicy(T config) |
| | | throws ConfigException, InitializationException; |
| | | |
| | | /** |
| | | * This method checks for whether files should be deleted or not. |
| | | * |
| | | * @return number of files deleted. |
| | | * @param writer The multi file writer writing the files to be |
| | | * checked. |
| | | * |
| | | * @return number of files deleted, if any. |
| | | */ |
| | | public int deleteFiles(); |
| | | public int deleteFiles(MultifileTextWriter writer); |
| | | |
| | | } |
| | | |
| | |
| | | action = new ZIPAction(filename, zipFile, true); |
| | | break; |
| | | case SIGN: |
| | | String alias = RotationConfigUtil.getCertificateAlias(configEntry); |
| | | action = new SignatureAction(filename, alias); |
| | | //String alias = RotationConfigUtil.getCertificateAlias(configEntry); |
| | | //action = new SignatureAction(filename, alias); |
| | | break; |
| | | case ENCRYPT: |
| | | String encFile = filename + ".enc"; |
| | | String certAlias = |
| | | RotationConfigUtil.getCertificateAlias(configEntry); |
| | | //String certAlias = |
| | | // RotationConfigUtil.getCertificateAlias(configEntry); |
| | | // FIXME - make the encryption algorithm configurable. |
| | | action = new EncryptAction(filename, encFile, false, certAlias, |
| | | "RSA"); |
| | | //action = new EncryptAction(filename, encFile, false, certAlias, |
| | | // "RSA"); |
| | | break; |
| | | default: |
| | | System.err.println("Invalid post rollover action:" + at); |
| | |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | | import org.opends.server.admin.std.server.LogRotationPolicyCfg; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.config.ConfigException; |
| | | |
| | | |
| | | /** |
| | | * This interface describes the rotation policy that should be used |
| | | * for the logger. Supported policies include size based and time |
| | | * based. |
| | | * |
| | | * @param <T> The type of rotation policy configuration handled by |
| | | * this retention policy implementation. |
| | | */ |
| | | public interface RotationPolicy |
| | | public interface RotationPolicy<T extends LogRotationPolicyCfg> |
| | | { |
| | | /** |
| | | * Initializes this log rotation policy based on the |
| | | * information in the provided rotation policy configuration. |
| | | * |
| | | * @param config |
| | | * The rotation policy configuration that contains the |
| | | * information to use to initialize this policy. |
| | | * @throws ConfigException |
| | | * If an unrecoverable problem arises in the process of |
| | | * performing the initialization as a result of the server |
| | | * configuration. |
| | | * @throws InitializationException |
| | | * If a problem occurs during initialization that is not |
| | | * related to the server configuration. |
| | | */ |
| | | public abstract void initializeLogRotationPolicy(T config) |
| | | throws ConfigException, InitializationException; |
| | | |
| | | |
| | | /** |
| | | * This method indicates if the log file should be |
| | | * rotated or not. |
| | | * |
| | | * @param writer The multi file writer writing the file to be |
| | | * checked. |
| | | * @return true if the log file should be rotated, false otherwise. |
| | | */ |
| | | public boolean rotateFile(); |
| | | public boolean rotateFile(MultifileTextWriter writer); |
| | | |
| | | |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | | import org.opends.server.admin.std.server.SizeLimitLogRetentionPolicyCfg; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugInfo; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import java.io.File; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.ArrayList; |
| | | |
| | | /** |
| | | * This class implements a retention policy based on the amount of |
| | | * space taken by the log files. |
| | | */ |
| | | public class SizeBasedRetentionPolicy implements RetentionPolicy |
| | | public class SizeBasedRetentionPolicy implements |
| | | RetentionPolicy<SizeLimitLogRetentionPolicyCfg>, |
| | | ConfigurationChangeListener<SizeLimitLogRetentionPolicyCfg> |
| | | { |
| | | |
| | | private long size = 0; |
| | | private File directory = null; |
| | | private String prefix = null; |
| | | |
| | | /** |
| | | * Create the retention policy based on the disk space used by the log files. |
| | | * |
| | | * @param dir The directory in which the log files reside. |
| | | * @param prefix The prefix for the log file names. |
| | | * @param size The total disk space used. |
| | | * {@inheritDoc} |
| | | */ |
| | | public SizeBasedRetentionPolicy(String dir, String prefix, long size) |
| | | public void initializeLogRetentionPolicy( |
| | | SizeLimitLogRetentionPolicyCfg config) |
| | | { |
| | | this.size = size; |
| | | this.directory = new File(dir); |
| | | this.prefix = prefix; |
| | | size = config.getDiskSpaceUsed(); |
| | | |
| | | config.addSizeLimitChangeListener(this); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationChangeAcceptable( |
| | | SizeLimitLogRetentionPolicyCfg config, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | // Changes should always be OK |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * This method deletes files based on the policy. |
| | | * |
| | | * @return The number of files deleted. |
| | | * {@inheritDoc} |
| | | */ |
| | | public int deleteFiles() |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | SizeLimitLogRetentionPolicyCfg config) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | size = config.getDiskSpaceUsed(); |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public int deleteFiles(MultifileTextWriter writer) |
| | | { |
| | | File[] files = writer.getNamingPolicy().listFiles(); |
| | | int count = 0; |
| | | |
| | | File[] selectedFiles = directory.listFiles(new LogFileFilter(prefix)); |
| | | long totalLength = 0; |
| | | for (int i = 0; i < selectedFiles.length; i++) |
| | | for (File file : files) |
| | | { |
| | | totalLength += selectedFiles[i].length(); |
| | | totalLength += file.length(); |
| | | } |
| | | |
| | | if(debugEnabled()) |
| | | { |
| | | debugInfo("Total size of files: %d, Max: %d", totalLength, size); |
| | | } |
| | | |
| | | if (totalLength <= size) |
| | | { |
| | | return 0; |
| | |
| | | long freeSpaceNeeded = totalLength - size; |
| | | |
| | | // Sort files based on last modified time. |
| | | Arrays.sort(selectedFiles, new FileComparator()); |
| | | Arrays.sort(files, new FileComparator()); |
| | | |
| | | long freedSpace = 0; |
| | | for (int j = selectedFiles.length - 1; j < 1; j--) |
| | | for (int j = files.length - 1; j < 1; j--) |
| | | { |
| | | freedSpace += selectedFiles[j].length(); |
| | | // System.out.println("Deleting log file:" + selectedFiles[j]); |
| | | selectedFiles[j].delete(); |
| | | freedSpace += files[j].length(); |
| | | if(debugEnabled()) |
| | | { |
| | | debugInfo("Deleting log file:", files[j]); |
| | | } |
| | | files[j].delete(); |
| | | if (freedSpace >= freeSpaceNeeded) |
| | | { |
| | | break; |
| | |
| | | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugInfo; |
| | | import org.opends.server.admin.std.server.SizeLimitLogRotationPolicyCfg; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.config.ConfigException; |
| | | |
| | | import java.util.List; |
| | | import java.util.ArrayList; |
| | | |
| | | /** |
| | | * This class implements a rotation policy based on the size of the |
| | | * file. |
| | | */ |
| | | public class SizeBasedRotationPolicy implements RotationPolicy |
| | | public class SizeBasedRotationPolicy implements |
| | | RotationPolicy<SizeLimitLogRotationPolicyCfg>, |
| | | ConfigurationChangeListener<SizeLimitLogRotationPolicyCfg> |
| | | { |
| | | |
| | | private long sizeLimit; |
| | | private DirectoryFileHandler fileHandler; |
| | | |
| | | SizeLimitLogRotationPolicyCfg currentConfig; |
| | | |
| | | /** |
| | | * Create the size based policy. |
| | | * |
| | | * @param size The size of the file when rotation takes place. |
| | | * {@inheritDoc} |
| | | */ |
| | | public SizeBasedRotationPolicy(long size) |
| | | public void initializeLogRotationPolicy(SizeLimitLogRotationPolicyCfg config) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | sizeLimit = size; |
| | | sizeLimit = config.getFileSizeLimit(); |
| | | |
| | | config.addSizeLimitChangeListener(this); |
| | | currentConfig = config; |
| | | } |
| | | |
| | | /** |
| | | * Set the file handler instance. |
| | | * |
| | | * @param handler The file handler which manages the file to be rotated. |
| | | * {@inheritDoc} |
| | | */ |
| | | public void setFileHandler(DirectoryFileHandler handler) |
| | | public boolean isConfigurationChangeAcceptable( |
| | | SizeLimitLogRotationPolicyCfg config, List<String> unacceptableReasons) |
| | | { |
| | | this.fileHandler = handler; |
| | | // Changes should always be OK |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * Get the maximum allowable file size. |
| | | * |
| | | * @return The maximum allowable file size. |
| | | * {@inheritDoc} |
| | | */ |
| | | public long getMaxFileSize() |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | SizeLimitLogRotationPolicyCfg config) |
| | | { |
| | | return sizeLimit; |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | sizeLimit = config.getFileSizeLimit(); |
| | | |
| | | currentConfig = config; |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | /** |
| | | * This method indicates if the log file should be |
| | | * rotated or not. |
| | | * |
| | | * @param writer The multi file text writer writing the log file. |
| | | * @return true if the file needs to be rotated, false otherwise. |
| | | */ |
| | | public boolean rotateFile() |
| | | public boolean rotateFile(MultifileTextWriter writer) |
| | | { |
| | | if (fileHandler.getFileSize() >= sizeLimit) |
| | | if (writer.getBytesWritten() >= sizeLimit) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | debugInfo("File Length: %d", fileHandler.getFileSize()); |
| | | debugInfo("%d bytes written in current file", writer.getBytesWritten()); |
| | | } |
| | | return true; |
| | | } |
| File was renamed from opendj-sdk/opends/src/server/org/opends/server/loggers/DirectoryAccessLogger.java |
| | |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | import java.util.concurrent.CopyOnWriteArrayList; |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | import java.util.*; |
| | | |
| | | import org.opends.server.api.AccessLogger; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.api.ConfigurableComponent; |
| | | import org.opends.server.config.BooleanConfigAttribute; |
| | | import org.opends.server.config.ConfigAttribute; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.api.*; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.config.StringConfigAttribute; |
| | | import org.opends.server.core.AbandonOperation; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.BindOperation; |
| | |
| | | import org.opends.server.core.ModifyDNOperation; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.UnbindOperation; |
| | | import org.opends.server.types.ByteString; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.DisconnectReason; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.opends.server.types.SearchResultReference; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.messages.LoggerMessages.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import org.opends.server.admin.std.server.FileBasedAccessLogPublisherCfg; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import static org.opends.server.util.StaticUtils.getFileForPath; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | | import org.opends.server.util.TimeThread; |
| | | |
| | | |
| | | /** |
| | | * This class provides the implementation of the access logger used by |
| | | * the directory server. |
| | | */ |
| | | public class DirectoryAccessLogger extends AccessLogger |
| | | implements ConfigurableComponent |
| | | public class TextAccessLogPublisher |
| | | extends AccessLogPublisher<FileBasedAccessLogPublisherCfg> |
| | | implements ConfigurationChangeListener<FileBasedAccessLogPublisherCfg> |
| | | { |
| | | private static final int DEFAULT_TIME_INTERVAL = 30000; |
| | | private static final int DEFAULT_BUFFER_SIZE = 65536; |
| | | private boolean suppressInternalOps = true; |
| | | private Logger accessLogger = null; |
| | | private String changedLogFileName = null; |
| | | private DirectoryFileHandler fileHandler = null; |
| | | private TextWriter writer; |
| | | |
| | | // The DN of the config entry this component is associated with. |
| | | private DN configDN; |
| | | |
| | | private FileBasedAccessLogPublisherCfg currentConfig; |
| | | |
| | | /** |
| | | * Initializes this access logger based on the information in the provided |
| | | * configuration entry. |
| | | * Returns an instance of the text access log publisher that will print |
| | | * all messages to the provided writer. This is used to print the messages |
| | | * to the console when the server starts up. |
| | | * |
| | | * @param configEntry The configuration entry that contains the information |
| | | * to use to initialize this access logger. |
| | | * |
| | | * @throws ConfigException If an unrecoverable problem arises in the |
| | | * process of performing the initialization. |
| | | */ |
| | | public void initializeAccessLogger(ConfigEntry configEntry) |
| | | throws ConfigException |
| | | * @param writer The text writer where the message will be written to. |
| | | * @return The instance of the text error log publisher that will print |
| | | * all messages to standard out. |
| | | */ |
| | | public static TextAccessLogPublisher |
| | | getStartupTextAccessPublisher(TextWriter writer) |
| | | { |
| | | configDN = configEntry.getDN(); |
| | | TextAccessLogPublisher startupPublisher = new TextAccessLogPublisher(); |
| | | startupPublisher.writer = writer; |
| | | |
| | | // FIXME - read the logger name from the config |
| | | StringConfigAttribute logFileStub = |
| | | new StringConfigAttribute(ATTR_LOGGER_FILE, |
| | | getMessage(MSGID_CONFIG_LOGGER_DESCRIPTION_CLASS_NAME), |
| | | true, false, true); |
| | | StringConfigAttribute logFileNameAttr = (StringConfigAttribute) |
| | | configEntry.getConfigAttribute(logFileStub); |
| | | |
| | | if(logFileNameAttr == null) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_NO_FILE_NAME; |
| | | String message = getMessage(msgID, configEntry.getDN().toString()); |
| | | throw new ConfigException(msgID, message); |
| | | } |
| | | initializeAccessLogger(logFileNameAttr.activeValue(), configEntry); |
| | | |
| | | return startupPublisher; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void initializeAccessLogPublisher( |
| | | FileBasedAccessLogPublisherCfg config) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | File logFile = getFileForPath(config.getLogFile()); |
| | | FileNamingPolicy fnPolicy = new TimeStampNaming(logFile); |
| | | |
| | | try |
| | | { |
| | | FilePermission perm = |
| | | FilePermission.decodeUNIXMode(config.getLogFileMode()); |
| | | |
| | | LogPublisherErrorHandler errorHandler = |
| | | new LogPublisherErrorHandler(config.dn()); |
| | | |
| | | boolean writerAutoFlush = |
| | | config.isAutoFlush() && !config.isAsynchronous(); |
| | | |
| | | MultifileTextWriter writer = |
| | | new MultifileTextWriter("Multifile Text Writer for " + |
| | | config.dn().toNormalizedString(), |
| | | config.getTimeInterval(), |
| | | fnPolicy, |
| | | perm, |
| | | errorHandler, |
| | | "UTF-8", |
| | | writerAutoFlush, |
| | | config.isAppend(), |
| | | (int)config.getBufferSize()); |
| | | |
| | | // Validate retention and rotation policies. |
| | | for(DN dn : config.getRotationPolicyDN()) |
| | | { |
| | | RotationPolicy policy = DirectoryServer.getRotationPolicy(dn); |
| | | if(policy != null) |
| | | { |
| | | writer.addRotationPolicy(policy); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ROTATION_POLICY; |
| | | String message = getMessage(msgID, dn.toString(), |
| | | config.dn().toString()); |
| | | throw new ConfigException(msgID, message); |
| | | } |
| | | } |
| | | for(DN dn: config.getRetentionPolicyDN()) |
| | | { |
| | | RetentionPolicy policy = DirectoryServer.getRetentionPolicy(dn); |
| | | if(policy != null) |
| | | { |
| | | writer.addRetentionPolicy(policy); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_RETENTION_POLICY; |
| | | String message = getMessage(msgID, dn.toString(), |
| | | config.dn().toString()); |
| | | throw new ConfigException(msgID, message); |
| | | } |
| | | } |
| | | |
| | | if(config.isAsynchronous()) |
| | | { |
| | | this.writer = new AsyncronousTextWriter("Asyncronous Text Writer for " + |
| | | config.dn().toNormalizedString(), config.getQueueSize(), |
| | | config.isAutoFlush(), |
| | | writer); |
| | | } |
| | | else |
| | | { |
| | | this.writer = writer; |
| | | } |
| | | } |
| | | catch(DirectoryException e) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGING_CANNOT_CREATE_WRITER; |
| | | String message = getMessage(msgID, config.dn().toString(), |
| | | String.valueOf(e)); |
| | | throw new InitializationException(msgID, message, e); |
| | | |
| | | } |
| | | catch(IOException e) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGING_CANNOT_CREATE_WRITER; |
| | | String message = getMessage(msgID, config.dn().toString(), |
| | | String.valueOf(e)); |
| | | throw new InitializationException(msgID, message, e); |
| | | |
| | | } |
| | | |
| | | suppressInternalOperations = config.isSuppressInternalOperations(); |
| | | |
| | | currentConfig = config; |
| | | |
| | | config.addFileBasedAccessChangeListener(this); |
| | | } |
| | | |
| | | /** |
| | | * Closes this access logger and releases any resources it might have held. |
| | | * {@inheritDoc} |
| | | */ |
| | | public void closeAccessLogger() |
| | | public boolean isConfigurationChangeAcceptable( |
| | | FileBasedAccessLogPublisherCfg config, List<String> unacceptableReasons) |
| | | { |
| | | // Make sure the permission is valid. |
| | | try |
| | | { |
| | | if(!currentConfig.getLogFileMode().equalsIgnoreCase( |
| | | config.getLogFileMode())) |
| | | { |
| | | FilePermission.decodeUNIXMode(config.getLogFileMode()); |
| | | } |
| | | if(!currentConfig.getLogFile().equalsIgnoreCase(config.getLogFile())) |
| | | { |
| | | File logFile = getFileForPath(config.getLogFile()); |
| | | if(logFile.createNewFile()) |
| | | { |
| | | logFile.delete(); |
| | | } |
| | | } |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGING_CANNOT_CREATE_WRITER; |
| | | String message = getMessage(msgID, config.dn().toString(), |
| | | stackTraceToSingleLineString(e)); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | |
| | | // Validate retention and rotation policies. |
| | | for(DN dn : config.getRotationPolicyDN()) |
| | | { |
| | | RotationPolicy policy = DirectoryServer.getRotationPolicy(dn); |
| | | if(policy == null) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ROTATION_POLICY; |
| | | String message = getMessage(msgID, dn.toString(), |
| | | config.dn().toString()); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | } |
| | | for(DN dn: config.getRetentionPolicyDN()) |
| | | { |
| | | RetentionPolicy policy = DirectoryServer.getRetentionPolicy(dn); |
| | | if(policy == null) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_RETENTION_POLICY; |
| | | String message = getMessage(msgID, dn.toString(), |
| | | config.dn().toString()); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | FileBasedAccessLogPublisherCfg config) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | suppressInternalOperations = config.isSuppressInternalOperations(); |
| | | |
| | | File logFile = getFileForPath(config.getLogFile()); |
| | | FileNamingPolicy fnPolicy = new TimeStampNaming(logFile); |
| | | |
| | | try |
| | | { |
| | | FilePermission perm = |
| | | FilePermission.decodeUNIXMode(config.getLogFileMode()); |
| | | |
| | | boolean writerAutoFlush = |
| | | config.isAutoFlush() && !config.isAsynchronous(); |
| | | |
| | | TextWriter currentWriter; |
| | | // Determine the writer we are using. If we were writing asyncronously, |
| | | // we need to modify the underlaying writer. |
| | | if(writer instanceof AsyncronousTextWriter) |
| | | { |
| | | currentWriter = ((AsyncronousTextWriter)writer).getWrappedWriter(); |
| | | } |
| | | else |
| | | { |
| | | currentWriter = writer; |
| | | } |
| | | |
| | | if(currentWriter instanceof MultifileTextWriter) |
| | | { |
| | | MultifileTextWriter mfWriter = (MultifileTextWriter)currentWriter; |
| | | |
| | | mfWriter.setNamingPolicy(fnPolicy); |
| | | mfWriter.setFilePermissions(perm); |
| | | mfWriter.setAppend(config.isAppend()); |
| | | mfWriter.setAutoFlush(writerAutoFlush); |
| | | mfWriter.setBufferSize((int)config.getBufferSize()); |
| | | mfWriter.setInterval(config.getTimeInterval()); |
| | | |
| | | mfWriter.removeAllRetentionPolicies(); |
| | | mfWriter.removeAllRotationPolicies(); |
| | | |
| | | for(DN dn : config.getRotationPolicyDN()) |
| | | { |
| | | RotationPolicy policy = DirectoryServer.getRotationPolicy(dn); |
| | | if(policy != null) |
| | | { |
| | | mfWriter.addRotationPolicy(policy); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ROTATION_POLICY; |
| | | String message = getMessage(msgID, dn.toString(), |
| | | config.dn().toString()); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | messages.add(message); |
| | | } |
| | | } |
| | | for(DN dn: config.getRetentionPolicyDN()) |
| | | { |
| | | RetentionPolicy policy = DirectoryServer.getRetentionPolicy(dn); |
| | | if(policy != null) |
| | | { |
| | | mfWriter.addRetentionPolicy(policy); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_RETENTION_POLICY; |
| | | String message = getMessage(msgID, dn.toString(), |
| | | config.dn().toString()); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | messages.add(message); |
| | | } |
| | | } |
| | | |
| | | |
| | | if(writer instanceof AsyncronousTextWriter && !config.isAsynchronous()) |
| | | { |
| | | // The asynronous setting is being turned off. |
| | | AsyncronousTextWriter asyncWriter = ((AsyncronousTextWriter)writer); |
| | | writer = mfWriter; |
| | | asyncWriter.shutdown(false); |
| | | } |
| | | |
| | | if(!(writer instanceof AsyncronousTextWriter) && |
| | | config.isAsynchronous()) |
| | | { |
| | | // The asynronous setting is being turned on. |
| | | AsyncronousTextWriter asyncWriter = |
| | | new AsyncronousTextWriter("Asyncronous Text Writer for " + |
| | | config.dn().toNormalizedString(), config.getQueueSize(), |
| | | config.isAutoFlush(), |
| | | mfWriter); |
| | | writer = asyncWriter; |
| | | } |
| | | |
| | | if((currentConfig.isAsynchronous() && config.isAsynchronous()) && |
| | | (currentConfig.getQueueSize() != config.getQueueSize())) |
| | | { |
| | | adminActionRequired = true; |
| | | } |
| | | |
| | | currentConfig = config; |
| | | } |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGING_CANNOT_CREATE_WRITER; |
| | | String message = getMessage(msgID, config.dn().toString(), |
| | | stackTraceToSingleLineString(e)); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | messages.add(message); |
| | | |
| | | } |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void close() |
| | | { |
| | | fileHandler.close(); |
| | | writer.shutdown(); |
| | | |
| | | if(currentConfig != null) |
| | | { |
| | | currentConfig.removeFileBasedAccessChangeListener(this); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | public void logConnect(ClientConnection clientConnection) |
| | | { |
| | | long connectionID = clientConnection.getConnectionID(); |
| | | if(connectionID < 0 && suppressInternalOps) |
| | | if (connectionID < 0 && suppressInternalOperations) |
| | | { |
| | | return; |
| | | } |
| | | StringBuilder buffer = new StringBuilder(50); |
| | | buffer.append("CONNECT conn="); |
| | | buffer.append("["); |
| | | buffer.append(TimeThread.getLocalTime()); |
| | | buffer.append("]"); |
| | | buffer.append(" CONNECT conn="); |
| | | buffer.append(connectionID); |
| | | buffer.append(" from="); |
| | | buffer.append(clientConnection.getClientAddress()); |
| | |
| | | buffer.append(" protocol="); |
| | | buffer.append(clientConnection.getProtocol()); |
| | | |
| | | accessLogger.log(DirectoryLogLevel.INFORMATIONAL, buffer.toString()); |
| | | writer.writeRecord(buffer.toString()); |
| | | |
| | | } |
| | | |
| | |
| | | String message) |
| | | { |
| | | long connectionID = clientConnection.getConnectionID(); |
| | | if(connectionID < 0 && suppressInternalOps) |
| | | if (connectionID < 0 && suppressInternalOperations) |
| | | { |
| | | return; |
| | | } |
| | | StringBuilder buffer = new StringBuilder(50); |
| | | |
| | | buffer.append("DISCONNECT conn="); |
| | | buffer.append("["); |
| | | buffer.append(TimeThread.getLocalTime()); |
| | | buffer.append("]"); |
| | | buffer.append(" DISCONNECT conn="); |
| | | buffer.append(connectionID); |
| | | buffer.append(" reason=\""); |
| | | buffer.append(disconnectReason); |
| | |
| | | |
| | | buffer.append("\""); |
| | | |
| | | accessLogger.log(DirectoryLogLevel.INFORMATIONAL, buffer.toString()); |
| | | writer.writeRecord(buffer.toString()); |
| | | } |
| | | |
| | | |
| | |
| | | public void logAbandonRequest(AbandonOperation abandonOperation) |
| | | { |
| | | long connectionID = abandonOperation.getConnectionID(); |
| | | if(connectionID < 0 && suppressInternalOps) |
| | | if (connectionID < 0 && suppressInternalOperations) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | StringBuilder buffer = new StringBuilder(50); |
| | | |
| | | buffer.append("ABANDON conn="); |
| | | buffer.append("["); |
| | | buffer.append(TimeThread.getLocalTime()); |
| | | buffer.append("]"); |
| | | buffer.append(" ABANDON conn="); |
| | | buffer.append(connectionID); |
| | | buffer.append(" op="); |
| | | buffer.append(abandonOperation.getOperationID()); |
| | |
| | | buffer.append(" idToAbandon="); |
| | | buffer.append(abandonOperation.getIDToAbandon()); |
| | | |
| | | accessLogger.log(DirectoryLogLevel.INFORMATIONAL, buffer.toString()); |
| | | writer.writeRecord(buffer.toString()); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void logAbandonResult(AbandonOperation abandonOperation) |
| | | { |
| | | long connectionID = abandonOperation.getConnectionID(); |
| | | if(connectionID < 0 && suppressInternalOps) |
| | | if (connectionID < 0 && suppressInternalOperations) |
| | | { |
| | | return; |
| | | } |
| | | StringBuilder buffer = new StringBuilder(50); |
| | | |
| | | buffer.append("ABANDON conn="); |
| | | buffer.append("["); |
| | | buffer.append(TimeThread.getLocalTime()); |
| | | buffer.append("]"); |
| | | buffer.append(" ABANDON conn="); |
| | | buffer.append(connectionID); |
| | | buffer.append(" op="); |
| | | buffer.append(abandonOperation.getOperationID()); |
| | |
| | | buffer.append(" etime="); |
| | | buffer.append(abandonOperation.getProcessingTime()); |
| | | |
| | | accessLogger.log(DirectoryLogLevel.INFORMATIONAL, buffer.toString()); |
| | | writer.writeRecord(buffer.toString()); |
| | | } |
| | | |
| | | |
| | |
| | | public void logAddRequest(AddOperation addOperation) |
| | | { |
| | | long connectionID = addOperation.getConnectionID(); |
| | | if(connectionID < 0 && suppressInternalOps) |
| | | if (connectionID < 0 && suppressInternalOperations) |
| | | { |
| | | return; |
| | | } |
| | | StringBuilder buffer = new StringBuilder(50); |
| | | |
| | | buffer.append("ADD conn="); |
| | | buffer.append("["); |
| | | buffer.append(TimeThread.getLocalTime()); |
| | | buffer.append("]"); |
| | | buffer.append(" ADD conn="); |
| | | buffer.append(connectionID); |
| | | buffer.append(" op="); |
| | | buffer.append(addOperation.getOperationID()); |
| | |
| | | addOperation.getRawEntryDN().toString(buffer); |
| | | buffer.append("\""); |
| | | |
| | | accessLogger.log(DirectoryLogLevel.INFORMATIONAL, buffer.toString()); |
| | | writer.writeRecord(buffer.toString()); |
| | | } |
| | | |
| | | |
| | |
| | | public void logAddResponse(AddOperation addOperation) |
| | | { |
| | | long connectionID = addOperation.getConnectionID(); |
| | | if(connectionID < 0 && suppressInternalOps) |
| | | if (connectionID < 0 && suppressInternalOperations) |
| | | { |
| | | return; |
| | | } |
| | | StringBuilder buffer = new StringBuilder(50); |
| | | |
| | | buffer.append("ADD conn="); |
| | | buffer.append("["); |
| | | buffer.append(TimeThread.getLocalTime()); |
| | | buffer.append("]"); |
| | | buffer.append(" ADD conn="); |
| | | buffer.append(connectionID); |
| | | buffer.append(" op="); |
| | | buffer.append(addOperation.getOperationID()); |
| | |
| | | buffer.append("\" etime="); |
| | | buffer.append(addOperation.getProcessingTime()); |
| | | |
| | | accessLogger.log(DirectoryLogLevel.INFORMATIONAL, buffer.toString()); |
| | | writer.writeRecord(buffer.toString()); |
| | | } |
| | | |
| | | |
| | |
| | | public void logBindRequest(BindOperation bindOperation) |
| | | { |
| | | long connectionID = bindOperation.getConnectionID(); |
| | | if(connectionID < 0 && suppressInternalOps) |
| | | if (connectionID < 0 && suppressInternalOperations) |
| | | { |
| | | return; |
| | | } |
| | | StringBuilder buffer = new StringBuilder(50); |
| | | |
| | | buffer.append("BIND conn="); |
| | | buffer.append("["); |
| | | buffer.append(TimeThread.getLocalTime()); |
| | | buffer.append("]"); |
| | | buffer.append(" BIND conn="); |
| | | buffer.append(connectionID); |
| | | buffer.append(" op="); |
| | | buffer.append(bindOperation.getOperationID()); |
| | |
| | | bindOperation.getRawBindDN().toString(buffer); |
| | | buffer.append("\""); |
| | | |
| | | accessLogger.log(DirectoryLogLevel.INFORMATIONAL, buffer.toString()); |
| | | writer.writeRecord(buffer.toString()); |
| | | } |
| | | |
| | | |
| | |
| | | public void logBindResponse(BindOperation bindOperation) |
| | | { |
| | | long connectionID = bindOperation.getConnectionID(); |
| | | if(connectionID < 0 && suppressInternalOps) |
| | | if (connectionID < 0 && suppressInternalOperations) |
| | | { |
| | | return; |
| | | } |
| | | StringBuilder buffer = new StringBuilder(50); |
| | | |
| | | buffer.append("BIND conn="); |
| | | buffer.append("["); |
| | | buffer.append(TimeThread.getLocalTime()); |
| | | buffer.append("]"); |
| | | buffer.append(" BIND conn="); |
| | | buffer.append(connectionID); |
| | | buffer.append(" op="); |
| | | buffer.append(bindOperation.getOperationID()); |
| | |
| | | buffer.append("\" etime="); |
| | | buffer.append(bindOperation.getProcessingTime()); |
| | | |
| | | accessLogger.log(DirectoryLogLevel.INFORMATIONAL, buffer.toString()); |
| | | writer.writeRecord(buffer.toString()); |
| | | } |
| | | |
| | | |
| | |
| | | public void logCompareRequest(CompareOperation compareOperation) |
| | | { |
| | | long connectionID = compareOperation.getConnectionID(); |
| | | if(connectionID < 0 && suppressInternalOps) |
| | | if (connectionID < 0 && suppressInternalOperations) |
| | | { |
| | | return; |
| | | } |
| | | StringBuilder buffer = new StringBuilder(50); |
| | | |
| | | buffer.append("COMPARE conn="); |
| | | buffer.append("["); |
| | | buffer.append(TimeThread.getLocalTime()); |
| | | buffer.append("]"); |
| | | buffer.append(" COMPARE conn="); |
| | | buffer.append(connectionID); |
| | | buffer.append(" op="); |
| | | buffer.append(compareOperation.getOperationID()); |
| | |
| | | buffer.append("\" attr="); |
| | | buffer.append(compareOperation.getAttributeType()); |
| | | |
| | | accessLogger.log(DirectoryLogLevel.INFORMATIONAL, buffer.toString()); |
| | | writer.writeRecord(buffer.toString()); |
| | | } |
| | | |
| | | |
| | |
| | | public void logCompareResponse(CompareOperation compareOperation) |
| | | { |
| | | long connectionID = compareOperation.getConnectionID(); |
| | | if(connectionID < 0 && suppressInternalOps) |
| | | if (connectionID < 0 && suppressInternalOperations) |
| | | { |
| | | return; |
| | | } |
| | | StringBuilder buffer = new StringBuilder(50); |
| | | |
| | | buffer.append("COMPARE conn="); |
| | | buffer.append("["); |
| | | buffer.append(TimeThread.getLocalTime()); |
| | | buffer.append("]"); |
| | | buffer.append(" COMPARE conn="); |
| | | buffer.append(connectionID); |
| | | buffer.append(" op="); |
| | | buffer.append(compareOperation.getOperationID()); |
| | |
| | | buffer.append("\" etime="); |
| | | buffer.append(compareOperation.getProcessingTime()); |
| | | |
| | | accessLogger.log(DirectoryLogLevel.INFORMATIONAL, buffer.toString()); |
| | | writer.writeRecord(buffer.toString()); |
| | | } |
| | | |
| | | |
| | |
| | | public void logDeleteRequest(DeleteOperation deleteOperation) |
| | | { |
| | | long connectionID = deleteOperation.getConnectionID(); |
| | | if(connectionID < 0 && suppressInternalOps) |
| | | if (connectionID < 0 && suppressInternalOperations) |
| | | { |
| | | return; |
| | | } |
| | | StringBuilder buffer = new StringBuilder(50); |
| | | |
| | | buffer.append("DELETE conn="); |
| | | buffer.append("["); |
| | | buffer.append(TimeThread.getLocalTime()); |
| | | buffer.append("]"); |
| | | buffer.append(" DELETE conn="); |
| | | buffer.append(connectionID); |
| | | buffer.append(" op="); |
| | | buffer.append(deleteOperation.getOperationID()); |
| | |
| | | buffer.append("\""); |
| | | |
| | | |
| | | accessLogger.log(DirectoryLogLevel.INFORMATIONAL, buffer.toString()); |
| | | writer.writeRecord(buffer.toString()); |
| | | } |
| | | |
| | | |
| | |
| | | public void logDeleteResponse(DeleteOperation deleteOperation) |
| | | { |
| | | long connectionID = deleteOperation.getConnectionID(); |
| | | if(connectionID < 0 && suppressInternalOps) |
| | | if (connectionID < 0 && suppressInternalOperations) |
| | | { |
| | | return; |
| | | } |
| | | StringBuilder buffer = new StringBuilder(50); |
| | | |
| | | buffer.append("DELETE conn="); |
| | | buffer.append("["); |
| | | buffer.append(TimeThread.getLocalTime()); |
| | | buffer.append("]"); |
| | | buffer.append(" DELETE conn="); |
| | | buffer.append(connectionID); |
| | | buffer.append(" op="); |
| | | buffer.append(deleteOperation.getOperationID()); |
| | |
| | | buffer.append("\" etime="); |
| | | buffer.append(deleteOperation.getProcessingTime()); |
| | | |
| | | accessLogger.log(DirectoryLogLevel.INFORMATIONAL, buffer.toString()); |
| | | writer.writeRecord(buffer.toString()); |
| | | } |
| | | |
| | | |
| | |
| | | public void logExtendedRequest(ExtendedOperation extendedOperation) |
| | | { |
| | | long connectionID = extendedOperation.getConnectionID(); |
| | | if(connectionID < 0 && suppressInternalOps) |
| | | if (connectionID < 0 && suppressInternalOperations) |
| | | { |
| | | return; |
| | | } |
| | | StringBuilder buffer = new StringBuilder(50); |
| | | |
| | | buffer.append("EXTENDED conn="); |
| | | buffer.append("["); |
| | | buffer.append(TimeThread.getLocalTime()); |
| | | buffer.append("]"); |
| | | buffer.append(" EXTENDED conn="); |
| | | buffer.append(connectionID); |
| | | buffer.append(" op="); |
| | | buffer.append(extendedOperation.getOperationID()); |
| | |
| | | buffer.append(extendedOperation.getRequestOID()); |
| | | buffer.append("\""); |
| | | |
| | | accessLogger.log(DirectoryLogLevel.INFORMATIONAL, buffer.toString()); |
| | | writer.writeRecord(buffer.toString()); |
| | | } |
| | | |
| | | |
| | |
| | | public void logExtendedResponse(ExtendedOperation extendedOperation) |
| | | { |
| | | long connectionID = extendedOperation.getConnectionID(); |
| | | if(connectionID < 0 && suppressInternalOps) |
| | | if (connectionID < 0 && suppressInternalOperations) |
| | | { |
| | | return; |
| | | } |
| | | StringBuilder buffer = new StringBuilder(50); |
| | | |
| | | buffer.append("EXTENDED conn="); |
| | | buffer.append("["); |
| | | buffer.append(TimeThread.getLocalTime()); |
| | | buffer.append("]"); |
| | | buffer.append(" EXTENDED conn="); |
| | | buffer.append(connectionID); |
| | | buffer.append(" op="); |
| | | buffer.append(extendedOperation.getOperationID()); |
| | |
| | | buffer.append("\" etime="); |
| | | buffer.append(extendedOperation.getProcessingTime()); |
| | | |
| | | accessLogger.log(DirectoryLogLevel.INFORMATIONAL, buffer.toString()); |
| | | writer.writeRecord(buffer.toString()); |
| | | } |
| | | |
| | | |
| | |
| | | public void logModifyRequest(ModifyOperation modifyOperation) |
| | | { |
| | | long connectionID = modifyOperation.getConnectionID(); |
| | | if(connectionID < 0 && suppressInternalOps) |
| | | if (connectionID < 0 && suppressInternalOperations) |
| | | { |
| | | return; |
| | | } |
| | | StringBuilder buffer = new StringBuilder(50); |
| | | |
| | | buffer.append("MODIFY conn="); |
| | | buffer.append("["); |
| | | buffer.append(TimeThread.getLocalTime()); |
| | | buffer.append("]"); |
| | | buffer.append(" MODIFY conn="); |
| | | buffer.append(connectionID); |
| | | buffer.append(" op="); |
| | | buffer.append(modifyOperation.getOperationID()); |
| | |
| | | modifyOperation.getRawEntryDN().toString(buffer); |
| | | buffer.append("\""); |
| | | |
| | | accessLogger.log(DirectoryLogLevel.INFORMATIONAL, buffer.toString()); |
| | | writer.writeRecord(buffer.toString()); |
| | | } |
| | | |
| | | |
| | |
| | | public void logModifyResponse(ModifyOperation modifyOperation) |
| | | { |
| | | long connectionID = modifyOperation.getConnectionID(); |
| | | if(connectionID < 0 && suppressInternalOps) |
| | | if (connectionID < 0 && suppressInternalOperations) |
| | | { |
| | | return; |
| | | } |
| | | StringBuilder buffer = new StringBuilder(50); |
| | | |
| | | buffer.append("MODIFY conn="); |
| | | buffer.append("["); |
| | | buffer.append(TimeThread.getLocalTime()); |
| | | buffer.append("]"); |
| | | buffer.append(" MODIFY conn="); |
| | | buffer.append(connectionID); |
| | | buffer.append(" op="); |
| | | buffer.append(modifyOperation.getOperationID()); |
| | |
| | | buffer.append("\" etime="); |
| | | buffer.append(modifyOperation.getProcessingTime()); |
| | | |
| | | accessLogger.log(DirectoryLogLevel.INFORMATIONAL, buffer.toString()); |
| | | writer.writeRecord(buffer.toString()); |
| | | } |
| | | |
| | | |
| | |
| | | public void logModifyDNRequest(ModifyDNOperation modifyDNOperation) |
| | | { |
| | | long connectionID = modifyDNOperation.getConnectionID(); |
| | | if(connectionID < 0 && suppressInternalOps) |
| | | if (connectionID < 0 && suppressInternalOperations) |
| | | { |
| | | return; |
| | | } |
| | | StringBuilder buffer = new StringBuilder(50); |
| | | |
| | | buffer.append("MODIFYDN conn="); |
| | | buffer.append("["); |
| | | buffer.append(TimeThread.getLocalTime()); |
| | | buffer.append("]"); |
| | | buffer.append(" MODIFYDN conn="); |
| | | buffer.append(connectionID); |
| | | buffer.append(" op="); |
| | | buffer.append(modifyDNOperation.getOperationID()); |
| | |
| | | newSuperior.toString(buffer); |
| | | } |
| | | |
| | | accessLogger.log(DirectoryLogLevel.INFORMATIONAL, buffer.toString()); |
| | | writer.writeRecord(buffer.toString()); |
| | | } |
| | | |
| | | |
| | |
| | | public void logModifyDNResponse(ModifyDNOperation modifyDNOperation) |
| | | { |
| | | long connectionID = modifyDNOperation.getConnectionID(); |
| | | if(connectionID < 0 && suppressInternalOps) |
| | | if (connectionID < 0 && suppressInternalOperations) |
| | | { |
| | | return; |
| | | } |
| | | StringBuilder buffer = new StringBuilder(50); |
| | | |
| | | buffer.append("MODIFYDN conn="); |
| | | buffer.append("["); |
| | | buffer.append(TimeThread.getLocalTime()); |
| | | buffer.append("]"); |
| | | buffer.append(" MODIFYDN conn="); |
| | | buffer.append(connectionID); |
| | | buffer.append(" op="); |
| | | buffer.append(modifyDNOperation.getOperationID()); |
| | |
| | | buffer.append("\" etime="); |
| | | buffer.append(modifyDNOperation.getProcessingTime()); |
| | | |
| | | accessLogger.log(DirectoryLogLevel.INFORMATIONAL, buffer.toString()); |
| | | writer.writeRecord(buffer.toString()); |
| | | } |
| | | |
| | | |
| | |
| | | public void logSearchRequest(SearchOperation searchOperation) |
| | | { |
| | | long connectionID = searchOperation.getConnectionID(); |
| | | if(connectionID < 0 && suppressInternalOps) |
| | | if (connectionID < 0 && suppressInternalOperations) |
| | | { |
| | | return; |
| | | } |
| | | StringBuilder buffer = new StringBuilder(50); |
| | | |
| | | buffer.append("SEARCH conn="); |
| | | buffer.append("["); |
| | | buffer.append(TimeThread.getLocalTime()); |
| | | buffer.append("]"); |
| | | buffer.append(" SEARCH conn="); |
| | | buffer.append(connectionID); |
| | | buffer.append(" op="); |
| | | buffer.append(searchOperation.getOperationID()); |
| | |
| | | buffer.append("\""); |
| | | } |
| | | |
| | | accessLogger.log(DirectoryLogLevel.INFORMATIONAL, buffer.toString()); |
| | | writer.writeRecord(buffer.toString()); |
| | | } |
| | | |
| | | |
| | |
| | | public void logSearchResultDone(SearchOperation searchOperation) |
| | | { |
| | | long connectionID = searchOperation.getConnectionID(); |
| | | if(connectionID < 0 && suppressInternalOps) |
| | | if (connectionID < 0 && suppressInternalOperations) |
| | | { |
| | | return; |
| | | } |
| | | StringBuilder buffer = new StringBuilder(50); |
| | | |
| | | buffer.append("SEARCH conn="); |
| | | buffer.append("["); |
| | | buffer.append(TimeThread.getLocalTime()); |
| | | buffer.append("]"); |
| | | buffer.append(" SEARCH conn="); |
| | | buffer.append(connectionID); |
| | | buffer.append(" op="); |
| | | buffer.append(searchOperation.getOperationID()); |
| | |
| | | buffer.append(" etime="); |
| | | buffer.append(searchOperation.getProcessingTime()); |
| | | |
| | | accessLogger.log(DirectoryLogLevel.INFORMATIONAL, buffer.toString()); |
| | | writer.writeRecord(buffer.toString()); |
| | | } |
| | | |
| | | |
| | |
| | | public void logUnbind(UnbindOperation unbindOperation) |
| | | { |
| | | long connectionID = unbindOperation.getConnectionID(); |
| | | if(connectionID < 0 && suppressInternalOps) |
| | | if (connectionID < 0 && suppressInternalOperations) |
| | | { |
| | | return; |
| | | } |
| | | StringBuilder buffer = new StringBuilder(50); |
| | | |
| | | buffer.append("UNBIND conn="); |
| | | buffer.append("["); |
| | | buffer.append(TimeThread.getLocalTime()); |
| | | buffer.append("]"); |
| | | buffer.append(" UNBIND conn="); |
| | | buffer.append(connectionID); |
| | | buffer.append(" op="); |
| | | buffer.append(unbindOperation.getOperationID()); |
| | | buffer.append(" msgID="); |
| | | buffer.append(unbindOperation.getMessageID()); |
| | | |
| | | accessLogger.log(DirectoryLogLevel.INFORMATIONAL, buffer.toString()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether the provided object is equal to this access logger. |
| | | * |
| | | * @param obj The object for which to make the determination. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided object is equal |
| | | * to this access logger, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean equals(Object obj) |
| | | { |
| | | if(this == obj) { |
| | | return true; |
| | | } |
| | | |
| | | if((obj == null) || (obj.getClass() != this.getClass())) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | return accessLogger.equals(obj); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the hash code for this access logger. |
| | | * |
| | | * @return The hash code for this access logger. |
| | | */ |
| | | public int hashCode() |
| | | { |
| | | return accessLogger.hashCode(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the DN of the configuration entry with which this component is |
| | | * associated. |
| | | * |
| | | * @return The DN of the configuration entry with which this component is |
| | | * associated. |
| | | */ |
| | | public DN getConfigurableComponentEntryDN() |
| | | { |
| | | return configDN; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the set of configuration attributes that are associated with this |
| | | * configurable component. |
| | | * |
| | | * @return The set of configuration attributes that are associated with this |
| | | * configurable component. |
| | | */ |
| | | public List<ConfigAttribute> getConfigurationAttributes() |
| | | { |
| | | // NYI |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Indicates whether the configuration entry that will result from a proposed |
| | | * modification is acceptable to this change listener. |
| | | * |
| | | * @param configEntry The configuration entry that will result from |
| | | * the requested update. |
| | | * @param unacceptableReasons A buffer to which this method can append a |
| | | * human-readable message explaining why the |
| | | * proposed change is not acceptable. |
| | | * |
| | | * @return <CODE>true</CODE> if the proposed entry contains an acceptable |
| | | * configuration, or <CODE>false</CODE> if it does not. |
| | | */ |
| | | public boolean hasAcceptableConfiguration(ConfigEntry configEntry, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | try |
| | | { |
| | | StringConfigAttribute logFileStub = |
| | | new StringConfigAttribute(ATTR_LOGGER_FILE, |
| | | getMessage(MSGID_CONFIG_LOGGER_DESCRIPTION_CLASS_NAME), |
| | | true, false, true); |
| | | StringConfigAttribute logFileNameAttr = (StringConfigAttribute) |
| | | configEntry.getConfigAttribute(logFileStub); |
| | | |
| | | if(logFileNameAttr == null) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_NO_FILE_NAME; |
| | | String message = getMessage(msgID, configEntry.getDN().toString()); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | changedLogFileName = logFileNameAttr.pendingValue(); |
| | | } catch (ConfigException ce) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ACCESS_LOGGER_CLASS; |
| | | String message = getMessage(msgID, this.getClass().getName(), |
| | | configEntry.getDN().toString(), |
| | | String.valueOf(ce)); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Attempts to apply a new configuration to this Directory Server component |
| | | * based on the provided changed entry. |
| | | * |
| | | * @param configEntry The configuration entry that containing the |
| | | * updated configuration for this component. |
| | | * @param detailedResults Indicates whether to provide detailed information |
| | | * about any actions performed. |
| | | * |
| | | * @return Information about the result of processing the configuration |
| | | * change. |
| | | */ |
| | | public ConfigChangeResult applyNewConfiguration(ConfigEntry configEntry, |
| | | boolean detailedResults) |
| | | { |
| | | fileHandler.close(); |
| | | // reinitialize the logger. |
| | | try |
| | | { |
| | | initializeAccessLogger(changedLogFileName, configEntry); |
| | | } catch(ConfigException ce) |
| | | { |
| | | // TODO - log the change failure. |
| | | return new ConfigChangeResult(DirectoryServer.getServerErrorResultCode(), |
| | | false); |
| | | } |
| | | |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Initialize the JDK logger an associate a file handler with the |
| | | * specified file name with it. |
| | | * |
| | | * @param logFileName The name of the log file to write to. |
| | | * @param configEntry The configuration entry with the information to use to |
| | | * initialize this logger. |
| | | * |
| | | * @throws ConfigException If an unrecoverable problem arises in the |
| | | * process of performing the initialization. |
| | | */ |
| | | private void initializeAccessLogger(String logFileName, |
| | | ConfigEntry configEntry) throws ConfigException |
| | | { |
| | | accessLogger = |
| | | Logger.getLogger("org.opends.server.loggers.DirectoryAccessLogger"); |
| | | accessLogger.setLevel(Level.ALL); |
| | | |
| | | File logFile = new File(logFileName); |
| | | if(!logFile.isAbsolute()) |
| | | { |
| | | logFile = new File (DirectoryServer.getServerRoot() + File.separator + |
| | | logFileName); |
| | | } |
| | | |
| | | BooleanConfigAttribute enabledAttr; |
| | | try |
| | | { |
| | | BooleanConfigAttribute enabledStub = |
| | | new BooleanConfigAttribute(ATTR_LOGGER_SUPPRESS_INTERNAL_OPERATIONS, |
| | | getMessage(MSGID_CONFIG_LOGGER_SUPPRESS_INTERNAL_OPERATIONS), |
| | | false); |
| | | enabledAttr = (BooleanConfigAttribute) |
| | | configEntry.getConfigAttribute(enabledStub); |
| | | |
| | | if (enabledAttr != null) |
| | | { |
| | | suppressInternalOps = enabledAttr.pendingValue(); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_SUPPRESS_INT_OPERATION_VALUE; |
| | | String message = getMessage(msgID, configEntry.getDN().toString(), |
| | | String.valueOf(e)); |
| | | throw new ConfigException(msgID, message); |
| | | } |
| | | |
| | | |
| | | try |
| | | { |
| | | int bufferSize = RotationConfigUtil.getIntegerAttribute(configEntry, |
| | | ATTR_LOGGER_BUFFER_SIZE, MSGID_LOGGER_BUFFER_SIZE); |
| | | if(bufferSize == -1) |
| | | { |
| | | bufferSize = DEFAULT_BUFFER_SIZE; |
| | | } |
| | | CopyOnWriteArrayList<RotationPolicy> rp = |
| | | RotationConfigUtil.getRotationPolicies(configEntry); |
| | | fileHandler = new DirectoryFileHandler(configEntry, |
| | | logFile.getAbsolutePath(), |
| | | bufferSize); |
| | | fileHandler.setFormatter(new DirectoryFileFormatter(false)); |
| | | accessLogger.addHandler(fileHandler); |
| | | |
| | | if(rp != null) |
| | | { |
| | | ArrayList<ActionType> actions = |
| | | RotationConfigUtil.getPostRotationActions(configEntry); |
| | | fileHandler.setPostRotationActions(actions); |
| | | for(RotationPolicy rotationPolicy : rp) |
| | | { |
| | | if(rotationPolicy instanceof SizeBasedRotationPolicy) |
| | | { |
| | | long fileSize = |
| | | ((SizeBasedRotationPolicy) rotationPolicy).getMaxFileSize(); |
| | | fileHandler.setFileSize(fileSize); |
| | | rp.remove(rotationPolicy); |
| | | } |
| | | } |
| | | } |
| | | |
| | | CopyOnWriteArrayList<RetentionPolicy> retentionPolicies = |
| | | RotationConfigUtil.getRetentionPolicies(configEntry); |
| | | |
| | | int threadTimeInterval = RotationConfigUtil.getIntegerAttribute( |
| | | configEntry, ATTR_LOGGER_THREAD_INTERVAL, |
| | | MSGID_LOGGER_THREAD_INTERVAL); |
| | | if(threadTimeInterval == -1) |
| | | { |
| | | threadTimeInterval = DEFAULT_TIME_INTERVAL; |
| | | } |
| | | |
| | | LoggerThread lt = new LoggerThread("AccessLogger Thread", |
| | | threadTimeInterval, fileHandler, rp, |
| | | retentionPolicies); |
| | | lt.start(); |
| | | |
| | | } catch(IOException ioe) { |
| | | int msgID = MSGID_LOG_ACCESS_CANNOT_ADD_FILE_HANDLER; |
| | | String message = getMessage(msgID, String.valueOf(ioe)); |
| | | throw new ConfigException(msgID, message, ioe); |
| | | } |
| | | writer.writeRecord(buffer.toString()); |
| | | } |
| | | } |
| | | |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | |
| | | import org.opends.server.api.*; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.AbandonOperation; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.BindOperation; |
| | | import org.opends.server.core.CompareOperation; |
| | | import org.opends.server.core.DeleteOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ExtendedOperation; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.core.ModifyDNOperation; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.UnbindOperation; |
| | | import org.opends.server.protocols.asn1.ASN1OctetString; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.Base64; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.opends.server.util.TimeThread; |
| | | import static org.opends.server.util.StaticUtils.getFileForPath; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | | |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.types.ResultCode.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import org.opends.server.admin.std.server.FileBasedAccessLogPublisherCfg; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | |
| | | |
| | | /** |
| | | * This class provides the implementation of the audit logger used by |
| | | * the directory server. |
| | | */ |
| | | public class TextAuditLogPublisher |
| | | extends AccessLogPublisher<FileBasedAccessLogPublisherCfg> |
| | | implements ConfigurationChangeListener<FileBasedAccessLogPublisherCfg> |
| | | { |
| | | private TextWriter writer; |
| | | |
| | | private FileBasedAccessLogPublisherCfg currentConfig; |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void initializeAccessLogPublisher( |
| | | FileBasedAccessLogPublisherCfg config) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | File logFile = getFileForPath(config.getLogFile()); |
| | | FileNamingPolicy fnPolicy = new TimeStampNaming(logFile); |
| | | |
| | | try |
| | | { |
| | | FilePermission perm = |
| | | FilePermission.decodeUNIXMode(config.getLogFileMode()); |
| | | |
| | | LogPublisherErrorHandler errorHandler = |
| | | new LogPublisherErrorHandler(config.dn()); |
| | | |
| | | boolean writerAutoFlush = |
| | | config.isAutoFlush() && !config.isAsynchronous(); |
| | | |
| | | MultifileTextWriter writer = |
| | | new MultifileTextWriter("Multifile Text Writer for " + |
| | | config.dn().toNormalizedString(), |
| | | config.getTimeInterval(), |
| | | fnPolicy, |
| | | perm, |
| | | errorHandler, |
| | | "UTF-8", |
| | | writerAutoFlush, |
| | | config.isAppend(), |
| | | (int)config.getBufferSize()); |
| | | |
| | | // Validate retention and rotation policies. |
| | | for(DN dn : config.getRotationPolicyDN()) |
| | | { |
| | | RotationPolicy policy = DirectoryServer.getRotationPolicy(dn); |
| | | if(policy != null) |
| | | { |
| | | writer.addRotationPolicy(policy); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ROTATION_POLICY; |
| | | String message = getMessage(msgID, dn.toString(), |
| | | config.dn().toString()); |
| | | throw new ConfigException(msgID, message); |
| | | } |
| | | } |
| | | for(DN dn: config.getRetentionPolicyDN()) |
| | | { |
| | | RetentionPolicy policy = DirectoryServer.getRetentionPolicy(dn); |
| | | if(policy != null) |
| | | { |
| | | writer.addRetentionPolicy(policy); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_RETENTION_POLICY; |
| | | String message = getMessage(msgID, dn.toString(), |
| | | config.dn().toString()); |
| | | throw new ConfigException(msgID, message); |
| | | } |
| | | } |
| | | |
| | | if(config.isAsynchronous()) |
| | | { |
| | | this.writer = new AsyncronousTextWriter("Asyncronous Text Writer for " + |
| | | config.dn().toNormalizedString(), config.getQueueSize(), |
| | | config.isAutoFlush(), |
| | | writer); |
| | | } |
| | | else |
| | | { |
| | | this.writer = writer; |
| | | } |
| | | } |
| | | catch(DirectoryException e) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGING_CANNOT_CREATE_WRITER; |
| | | String message = getMessage(msgID, config.dn().toString(), |
| | | String.valueOf(e)); |
| | | throw new InitializationException(msgID, message, e); |
| | | |
| | | } |
| | | catch(IOException e) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGING_CANNOT_CREATE_WRITER; |
| | | String message = getMessage(msgID, config.dn().toString(), |
| | | String.valueOf(e)); |
| | | throw new InitializationException(msgID, message, e); |
| | | |
| | | } |
| | | |
| | | suppressInternalOperations = config.isSuppressInternalOperations(); |
| | | |
| | | currentConfig = config; |
| | | |
| | | config.addFileBasedAccessChangeListener(this); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationChangeAcceptable( |
| | | FileBasedAccessLogPublisherCfg config, List<String> unacceptableReasons) |
| | | { |
| | | // Make sure the permission is valid. |
| | | try |
| | | { |
| | | if(!currentConfig.getLogFileMode().equalsIgnoreCase( |
| | | config.getLogFileMode())) |
| | | { |
| | | FilePermission.decodeUNIXMode(config.getLogFileMode()); |
| | | } |
| | | if(!currentConfig.getLogFile().equalsIgnoreCase(config.getLogFile())) |
| | | { |
| | | File logFile = getFileForPath(config.getLogFile()); |
| | | if(logFile.createNewFile()) |
| | | { |
| | | logFile.delete(); |
| | | } |
| | | } |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGING_CANNOT_CREATE_WRITER; |
| | | String message = getMessage(msgID, config.dn().toString(), |
| | | stackTraceToSingleLineString(e)); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | |
| | | // Validate retention and rotation policies. |
| | | for(DN dn : config.getRotationPolicyDN()) |
| | | { |
| | | RotationPolicy policy = DirectoryServer.getRotationPolicy(dn); |
| | | if(policy == null) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ROTATION_POLICY; |
| | | String message = getMessage(msgID, dn.toString(), |
| | | config.dn().toString()); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | } |
| | | for(DN dn: config.getRetentionPolicyDN()) |
| | | { |
| | | RetentionPolicy policy = DirectoryServer.getRetentionPolicy(dn); |
| | | if(policy == null) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_RETENTION_POLICY; |
| | | String message = getMessage(msgID, dn.toString(), |
| | | config.dn().toString()); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | FileBasedAccessLogPublisherCfg config) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | suppressInternalOperations = config.isSuppressInternalOperations(); |
| | | |
| | | File logFile = getFileForPath(config.getLogFile()); |
| | | FileNamingPolicy fnPolicy = new TimeStampNaming(logFile); |
| | | |
| | | try |
| | | { |
| | | FilePermission perm = |
| | | FilePermission.decodeUNIXMode(config.getLogFileMode()); |
| | | |
| | | boolean writerAutoFlush = |
| | | config.isAutoFlush() && !config.isAsynchronous(); |
| | | |
| | | TextWriter currentWriter; |
| | | // Determine the writer we are using. If we were writing asyncronously, |
| | | // we need to modify the underlaying writer. |
| | | if(writer instanceof AsyncronousTextWriter) |
| | | { |
| | | currentWriter = ((AsyncronousTextWriter)writer).getWrappedWriter(); |
| | | } |
| | | else |
| | | { |
| | | currentWriter = writer; |
| | | } |
| | | |
| | | if(currentWriter instanceof MultifileTextWriter) |
| | | { |
| | | MultifileTextWriter mfWriter = (MultifileTextWriter)writer; |
| | | |
| | | mfWriter.setNamingPolicy(fnPolicy); |
| | | mfWriter.setFilePermissions(perm); |
| | | mfWriter.setAppend(config.isAppend()); |
| | | mfWriter.setAutoFlush(writerAutoFlush); |
| | | mfWriter.setBufferSize((int)config.getBufferSize()); |
| | | mfWriter.setInterval(config.getTimeInterval()); |
| | | |
| | | mfWriter.removeAllRetentionPolicies(); |
| | | mfWriter.removeAllRotationPolicies(); |
| | | |
| | | for(DN dn : config.getRotationPolicyDN()) |
| | | { |
| | | RotationPolicy policy = DirectoryServer.getRotationPolicy(dn); |
| | | if(policy != null) |
| | | { |
| | | mfWriter.addRotationPolicy(policy); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ROTATION_POLICY; |
| | | String message = getMessage(msgID, dn.toString(), |
| | | config.dn().toString()); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | messages.add(message); |
| | | } |
| | | } |
| | | for(DN dn: config.getRetentionPolicyDN()) |
| | | { |
| | | RetentionPolicy policy = DirectoryServer.getRetentionPolicy(dn); |
| | | if(policy != null) |
| | | { |
| | | mfWriter.addRetentionPolicy(policy); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_RETENTION_POLICY; |
| | | String message = getMessage(msgID, dn.toString(), |
| | | config.dn().toString()); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | messages.add(message); |
| | | } |
| | | } |
| | | |
| | | |
| | | if(writer instanceof AsyncronousTextWriter && !config.isAsynchronous()) |
| | | { |
| | | // The asynronous setting is being turned off. |
| | | AsyncronousTextWriter asyncWriter = ((AsyncronousTextWriter)writer); |
| | | writer = mfWriter; |
| | | asyncWriter.shutdown(false); |
| | | } |
| | | |
| | | if(!(writer instanceof AsyncronousTextWriter) && |
| | | config.isAsynchronous()) |
| | | { |
| | | // The asynronous setting is being turned on. |
| | | AsyncronousTextWriter asyncWriter = |
| | | new AsyncronousTextWriter("Asyncronous Text Writer for " + |
| | | config.dn().toNormalizedString(), config.getQueueSize(), |
| | | config.isAutoFlush(), |
| | | mfWriter); |
| | | writer = asyncWriter; |
| | | } |
| | | |
| | | if((currentConfig.isAsynchronous() && config.isAsynchronous()) && |
| | | (currentConfig.getQueueSize() != config.getQueueSize())) |
| | | { |
| | | adminActionRequired = true; |
| | | } |
| | | |
| | | currentConfig = config; |
| | | } |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGING_CANNOT_CREATE_WRITER; |
| | | String message = getMessage(msgID, config.dn().toString(), |
| | | stackTraceToSingleLineString(e)); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | messages.add(message); |
| | | |
| | | } |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void close() |
| | | { |
| | | writer.shutdown(); |
| | | currentConfig.removeFileBasedAccessChangeListener(this); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the audit logger with information about a new client |
| | | * connection that has been established, regardless of whether it will be |
| | | * immediately terminated. |
| | | * |
| | | * @param clientConnection The client connection that has been established. |
| | | */ |
| | | public void logConnect(ClientConnection clientConnection) |
| | | { |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the audit logger with information about the |
| | | * termination of an existing client connection. |
| | | * |
| | | * @param clientConnection The client connection that has been terminated. |
| | | * @param disconnectReason A generic disconnect reason for the connection |
| | | * termination. |
| | | * @param message A human-readable message that can provide |
| | | * additional information about the disconnect. |
| | | */ |
| | | public void logDisconnect(ClientConnection clientConnection, |
| | | DisconnectReason disconnectReason, |
| | | String message) |
| | | { |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the audit logger with information about the abandon |
| | | * request associated with the provided abandon operation. |
| | | * |
| | | * @param abandonOperation The abandon operation containing the information |
| | | * to use to log the abandon request. |
| | | */ |
| | | public void logAbandonRequest(AbandonOperation abandonOperation) |
| | | { |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the audit logger with information about the result |
| | | * of the provided abandon operation. |
| | | * |
| | | * @param abandonOperation The abandon operation containing the information |
| | | * to use to log the abandon request. |
| | | */ |
| | | public void logAbandonResult(AbandonOperation abandonOperation) |
| | | { |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the audit logger with information about the add |
| | | * request associated with the provided add operation. |
| | | * |
| | | * @param addOperation The add operation containing the information to use |
| | | * to log the add request. |
| | | */ |
| | | public void logAddRequest(AddOperation addOperation) |
| | | { |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the audit logger with information about the add |
| | | * response associated with the provided add operation. |
| | | * |
| | | * @param addOperation The add operation containing the information to use |
| | | * to log the add response. |
| | | */ |
| | | public void logAddResponse(AddOperation addOperation) |
| | | { |
| | | long connectionID = addOperation.getConnectionID(); |
| | | if(connectionID < 0 && suppressInternalOperations) |
| | | { |
| | | return; |
| | | } |
| | | ResultCode code = addOperation.getResultCode(); |
| | | |
| | | if(code == SUCCESS) |
| | | { |
| | | StringBuilder buffer = new StringBuilder(50); |
| | | buffer.append("["); |
| | | buffer.append(TimeThread.getLocalTime()); |
| | | buffer.append("]"); |
| | | buffer.append("dn:"); |
| | | ByteString dnString = addOperation.getRawEntryDN(); |
| | | encodeValue(dnString, buffer); |
| | | |
| | | buffer.append(EOL); |
| | | buffer.append("changetype: add"); |
| | | buffer.append(EOL); |
| | | List<RawAttribute> rawAttributes = addOperation.getRawAttributes(); |
| | | for (RawAttribute attr : rawAttributes) |
| | | { |
| | | buffer.append(attr.getAttributeType()); |
| | | buffer.append(":"); |
| | | List<ASN1OctetString> values = attr.getValues(); |
| | | if (!values.isEmpty()) |
| | | { |
| | | Iterator<ASN1OctetString> iterator = values.iterator(); |
| | | ASN1OctetString nextString = iterator.next(); |
| | | encodeValue(nextString, buffer); |
| | | while (iterator.hasNext()) |
| | | { |
| | | buffer.append(EOL); |
| | | buffer.append(attr.getAttributeType()); |
| | | buffer.append(":"); |
| | | nextString = iterator.next(); |
| | | encodeValue(nextString, buffer); |
| | | } |
| | | } |
| | | buffer.append(EOL); |
| | | } |
| | | |
| | | writer.writeRecord(buffer.toString()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the audit logger with information about the bind |
| | | * request associated with the provided bind operation. |
| | | * |
| | | * @param bindOperation The bind operation with the information to use |
| | | * to log the bind request. |
| | | */ |
| | | public void logBindRequest(BindOperation bindOperation) |
| | | { |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the audit logger with information about the bind |
| | | * response associated with the provided bind operation. |
| | | * |
| | | * @param bindOperation The bind operation containing the information to use |
| | | * to log the bind response. |
| | | */ |
| | | public void logBindResponse(BindOperation bindOperation) |
| | | { |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the audit logger with information about the compare |
| | | * request associated with the provided compare operation. |
| | | * |
| | | * @param compareOperation The compare operation containing the information |
| | | * to use to log the compare request. |
| | | */ |
| | | public void logCompareRequest(CompareOperation compareOperation) |
| | | { |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the audit logger with information about the compare |
| | | * response associated with the provided compare operation. |
| | | * |
| | | * @param compareOperation The compare operation containing the information |
| | | * to use to log the compare response. |
| | | */ |
| | | public void logCompareResponse(CompareOperation compareOperation) |
| | | { |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the audit logger with information about the delete |
| | | * request associated with the provided delete operation. |
| | | * |
| | | * @param deleteOperation The delete operation with the information to |
| | | * use to log the delete request. |
| | | */ |
| | | public void logDeleteRequest(DeleteOperation deleteOperation) |
| | | { |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the audit logger with information about the delete |
| | | * response associated with the provided delete operation. |
| | | * |
| | | * @param deleteOperation The delete operation containing the information to |
| | | * use to log the delete response. |
| | | */ |
| | | public void logDeleteResponse(DeleteOperation deleteOperation) |
| | | { |
| | | long connectionID = deleteOperation.getConnectionID(); |
| | | if(connectionID < 0 && suppressInternalOperations) |
| | | { |
| | | return; |
| | | } |
| | | ResultCode code = deleteOperation.getResultCode(); |
| | | |
| | | if(code == SUCCESS) |
| | | { |
| | | StringBuilder buffer = new StringBuilder(50); |
| | | buffer.append("["); |
| | | buffer.append(TimeThread.getLocalTime()); |
| | | buffer.append("]"); |
| | | buffer.append("dn:"); |
| | | ByteString dnString = deleteOperation.getRawEntryDN(); |
| | | encodeValue(dnString, buffer); |
| | | buffer.append(EOL); |
| | | buffer.append("changetype: delete"); |
| | | buffer.append(EOL); |
| | | buffer.append(EOL); |
| | | |
| | | writer.writeRecord(buffer.toString()); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the audit logger with information about the extended |
| | | * request associated with the provided extended operation. |
| | | * |
| | | * @param extendedOperation The extended operation containing the |
| | | * information to use to log the extended request. |
| | | */ |
| | | public void logExtendedRequest(ExtendedOperation extendedOperation) |
| | | { |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the audit logger with information about the extended |
| | | * response associated with the provided extended operation. |
| | | * |
| | | * @param extendedOperation The extended operation containing the |
| | | * info to use to log the extended response. |
| | | */ |
| | | public void logExtendedResponse(ExtendedOperation extendedOperation) |
| | | { |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the audit logger with information about the modify |
| | | * request associated with the provided modify operation. |
| | | * |
| | | * @param modifyOperation The modify operation containing the information to |
| | | * use to log the modify request. |
| | | */ |
| | | public void logModifyRequest(ModifyOperation modifyOperation) |
| | | { |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the audit logger with information about the modify |
| | | * response associated with the provided modify operation. |
| | | * |
| | | * @param modifyOperation The modify operation containing the information to |
| | | * use to log the modify response. |
| | | */ |
| | | public void logModifyResponse(ModifyOperation modifyOperation) |
| | | { |
| | | long connectionID = modifyOperation.getConnectionID(); |
| | | if(connectionID < 0 && suppressInternalOperations) |
| | | { |
| | | return; |
| | | } |
| | | ResultCode code = modifyOperation.getResultCode(); |
| | | |
| | | if(code == SUCCESS) |
| | | { |
| | | StringBuilder buffer = new StringBuilder(50); |
| | | buffer.append("["); |
| | | buffer.append(TimeThread.getLocalTime()); |
| | | buffer.append("]"); |
| | | buffer.append("dn:"); |
| | | ByteString dnString = modifyOperation.getRawEntryDN(); |
| | | encodeValue(dnString, buffer); |
| | | buffer.append(EOL); |
| | | buffer.append("changetype: modify"); |
| | | buffer.append(EOL); |
| | | List<RawModification> modifications = |
| | | modifyOperation.getRawModifications(); |
| | | for (RawModification modification : modifications) |
| | | { |
| | | ModificationType modType = modification.getModificationType(); |
| | | RawAttribute attr = modification.getAttribute(); |
| | | switch (modType) |
| | | { |
| | | case ADD: |
| | | buffer.append("add: "); |
| | | break; |
| | | case DELETE: |
| | | buffer.append("delete: "); |
| | | break; |
| | | case REPLACE: |
| | | buffer.append("replace: "); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | buffer.append(attr.getAttributeType()); |
| | | List<ASN1OctetString> values = attr.getValues(); |
| | | if (!values.isEmpty()) |
| | | { |
| | | Iterator<ASN1OctetString> iterator = values.iterator(); |
| | | ASN1OctetString nextString = iterator.next(); |
| | | encodeValue(nextString, buffer); |
| | | while (iterator.hasNext()) |
| | | { |
| | | buffer.append(EOL); |
| | | buffer.append(attr.getAttributeType()); |
| | | buffer.append(":"); |
| | | nextString = iterator.next(); |
| | | encodeValue(nextString, buffer); |
| | | } |
| | | } |
| | | buffer.append(EOL); |
| | | } |
| | | |
| | | buffer.append(EOL); |
| | | |
| | | writer.writeRecord(buffer.toString()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the audit logger with information about the modify DN |
| | | * request associated with the provided modify DN operation. |
| | | * |
| | | * @param modifyDNOperation The modify DN operation containing the |
| | | * info to use to log the modify DN request. |
| | | */ |
| | | public void logModifyDNRequest(ModifyDNOperation modifyDNOperation) |
| | | { |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the audit logger with information about the modify DN |
| | | * response associated with the provided modify DN operation. |
| | | * |
| | | * @param modifyDNOperation The modify DN operation containing the |
| | | * information to use to log the modify DN |
| | | * response. |
| | | */ |
| | | public void logModifyDNResponse(ModifyDNOperation modifyDNOperation) |
| | | { |
| | | long connectionID = modifyDNOperation.getConnectionID(); |
| | | if(connectionID < 0 && suppressInternalOperations) |
| | | { |
| | | return; |
| | | } |
| | | ResultCode code = modifyDNOperation.getResultCode(); |
| | | |
| | | if(code == SUCCESS) |
| | | { |
| | | StringBuilder buffer = new StringBuilder(50); |
| | | buffer.append("["); |
| | | buffer.append(TimeThread.getLocalTime()); |
| | | buffer.append("]"); |
| | | buffer.append("dn:"); |
| | | ByteString dnString = modifyDNOperation.getRawEntryDN(); |
| | | encodeValue(dnString, buffer); |
| | | buffer.append(EOL); |
| | | buffer.append("changetype: moddn"); |
| | | buffer.append(EOL); |
| | | buffer.append("newrdn: "); |
| | | ByteString newrdnString = modifyDNOperation.getRawNewRDN(); |
| | | encodeValue(newrdnString, buffer); |
| | | buffer.append(EOL); |
| | | buffer.append("deleteoldrdn: "); |
| | | if (modifyDNOperation.deleteOldRDN()) |
| | | { |
| | | buffer.append("1"); |
| | | } |
| | | else |
| | | { |
| | | buffer.append("0"); |
| | | } |
| | | buffer.append(EOL); |
| | | if (modifyDNOperation.getRawNewSuperior() != null) |
| | | { |
| | | buffer.append("newsuperior: "); |
| | | ByteString newSuperior = modifyDNOperation.getRawNewSuperior(); |
| | | encodeValue(newSuperior, buffer); |
| | | buffer.append(EOL); |
| | | } |
| | | |
| | | buffer.append(EOL); |
| | | |
| | | writer.writeRecord(buffer.toString()); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the audit logger with information about the search |
| | | * request associated with the provided search operation. |
| | | * |
| | | * @param searchOperation The search operation containing the info to |
| | | * use to log the search request. |
| | | */ |
| | | public void logSearchRequest(SearchOperation searchOperation) |
| | | { |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the audit logger with information about the search |
| | | * result entry that matches the criteria associated with the provided search |
| | | * operation. |
| | | * |
| | | * @param searchOperation The search operation with which the search result |
| | | * entry is associated. |
| | | * @param searchEntry The search result entry to be logged. |
| | | */ |
| | | public void logSearchResultEntry(SearchOperation searchOperation, |
| | | SearchResultEntry searchEntry) |
| | | { |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the audit logger with information about the search |
| | | * result reference returned while processing the associated search |
| | | * operation. |
| | | * |
| | | * @param searchOperation The search operation with which the search result |
| | | * reference is associated. |
| | | * @param searchReference The search result reference to be logged. |
| | | */ |
| | | public void logSearchResultReference(SearchOperation searchOperation, |
| | | SearchResultReference searchReference) |
| | | { |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the audit logger with information about the |
| | | * completion of the provided search operation. |
| | | * |
| | | * @param searchOperation The search operation containing the information |
| | | * to use to log the search result done message. |
| | | */ |
| | | public void logSearchResultDone(SearchOperation searchOperation) |
| | | { |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the audit logger with information about the unbind |
| | | * request associated with the provided unbind operation. |
| | | * |
| | | * @param unbindOperation The unbind operation containing the info to |
| | | * use to log the unbind request. |
| | | */ |
| | | public void logUnbind(UnbindOperation unbindOperation) |
| | | { |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Appends the appropriately-encoded attribute value to the provided buffer. |
| | | * |
| | | * @param str The ASN.1 octet string containing the value to append. |
| | | * @param buffer The buffer to which to append the value. |
| | | */ |
| | | private void encodeValue(ByteString str, StringBuilder buffer) |
| | | { |
| | | byte[] byteVal = str.value(); |
| | | if(StaticUtils.needsBase64Encoding(byteVal)) |
| | | { |
| | | buffer.append(": "); |
| | | buffer.append(Base64.encode(byteVal)); |
| | | } else |
| | | { |
| | | buffer.append(" "); |
| | | str.toString(buffer); |
| | | } |
| | | } |
| | | } |
| | | |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | |
| | | import org.opends.server.api.*; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.LoggerMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import org.opends.server.admin.std.server.FileBasedErrorLogPublisherCfg; |
| | | import org.opends.server.admin.std.meta.ErrorLogPublisherCfgDefn; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import static org.opends.server.util.StaticUtils.getFileForPath; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | | import org.opends.server.util.TimeThread; |
| | | |
| | | |
| | | /** |
| | | * This class provides an implementation of an error log publisher. |
| | | */ |
| | | public class TextErrorLogPublisher |
| | | extends ErrorLogPublisher<FileBasedErrorLogPublisherCfg> |
| | | implements ConfigurationChangeListener<FileBasedErrorLogPublisherCfg> |
| | | { |
| | | private TextWriter writer; |
| | | |
| | | private FileBasedErrorLogPublisherCfg currentConfig; |
| | | |
| | | /** |
| | | * Returns an instance of the text error log publisher that will print |
| | | * all messages to the provided writer. This is used to print the messages |
| | | * to the console when the server starts up. |
| | | * |
| | | * @param writer The text writer where the message will be written to. |
| | | * @return The instance of the text error log publisher that will print |
| | | * all messages to standard out. |
| | | */ |
| | | public static TextErrorLogPublisher |
| | | getStartupTextErrorPublisher(TextWriter writer) |
| | | { |
| | | TextErrorLogPublisher startupPublisher = new TextErrorLogPublisher(); |
| | | startupPublisher.writer = writer; |
| | | |
| | | startupPublisher.defaultSeverities.add(ErrorLogSeverity.FATAL_ERROR); |
| | | startupPublisher.defaultSeverities.add(ErrorLogSeverity.SEVERE_ERROR); |
| | | startupPublisher.defaultSeverities.add(ErrorLogSeverity.SEVERE_WARNING); |
| | | startupPublisher.defaultSeverities.add(ErrorLogSeverity.NOTICE); |
| | | |
| | | return startupPublisher; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void initializeErrorLogPublisher(FileBasedErrorLogPublisherCfg config) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | File logFile = getFileForPath(config.getLogFile()); |
| | | FileNamingPolicy fnPolicy = new TimeStampNaming(logFile); |
| | | |
| | | try |
| | | { |
| | | FilePermission perm = |
| | | FilePermission.decodeUNIXMode(config.getLogFileMode()); |
| | | |
| | | LogPublisherErrorHandler errorHandler = |
| | | new LogPublisherErrorHandler(config.dn()); |
| | | |
| | | boolean writerAutoFlush = |
| | | config.isAutoFlush() && !config.isAsynchronous(); |
| | | |
| | | MultifileTextWriter writer = |
| | | new MultifileTextWriter("Multifile Text Writer for " + |
| | | config.dn().toNormalizedString(), |
| | | config.getTimeInterval(), |
| | | fnPolicy, |
| | | perm, |
| | | errorHandler, |
| | | "UTF-8", |
| | | writerAutoFlush, |
| | | config.isAppend(), |
| | | (int)config.getBufferSize()); |
| | | |
| | | // Validate retention and rotation policies. |
| | | for(DN dn : config.getRotationPolicyDN()) |
| | | { |
| | | RotationPolicy policy = DirectoryServer.getRotationPolicy(dn); |
| | | if(policy != null) |
| | | { |
| | | writer.addRotationPolicy(policy); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ROTATION_POLICY; |
| | | String message = getMessage(msgID, dn.toString(), |
| | | config.dn().toString()); |
| | | throw new ConfigException(msgID, message); |
| | | } |
| | | } |
| | | for(DN dn: config.getRetentionPolicyDN()) |
| | | { |
| | | RetentionPolicy policy = DirectoryServer.getRetentionPolicy(dn); |
| | | if(policy != null) |
| | | { |
| | | writer.addRetentionPolicy(policy); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_RETENTION_POLICY; |
| | | String message = getMessage(msgID, dn.toString(), |
| | | config.dn().toString()); |
| | | throw new ConfigException(msgID, message); |
| | | } |
| | | } |
| | | |
| | | if(config.isAsynchronous()) |
| | | { |
| | | this.writer = new AsyncronousTextWriter("Asyncronous Text Writer for " + |
| | | config.dn().toNormalizedString(), config.getQueueSize(), |
| | | config.isAutoFlush(), |
| | | writer); |
| | | } |
| | | else |
| | | { |
| | | this.writer = writer; |
| | | } |
| | | } |
| | | catch(DirectoryException e) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGING_CANNOT_CREATE_WRITER; |
| | | String message = getMessage(msgID, config.dn().toString(), |
| | | String.valueOf(e)); |
| | | throw new InitializationException(msgID, message, e); |
| | | |
| | | } |
| | | catch(IOException e) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGING_CANNOT_CREATE_WRITER; |
| | | String message = getMessage(msgID, config.dn().toString(), |
| | | String.valueOf(e)); |
| | | throw new InitializationException(msgID, message, e); |
| | | |
| | | } |
| | | |
| | | Set<ErrorLogPublisherCfgDefn.DefaultSeverity> defSevs = |
| | | config.getDefaultSeverity(); |
| | | if(defSevs.isEmpty()) |
| | | { |
| | | defaultSeverities.add(ErrorLogSeverity.FATAL_ERROR); |
| | | defaultSeverities.add(ErrorLogSeverity.SEVERE_ERROR); |
| | | defaultSeverities.add(ErrorLogSeverity.SEVERE_WARNING); |
| | | } else |
| | | { |
| | | for(ErrorLogPublisherCfgDefn.DefaultSeverity defSev : defSevs) |
| | | { |
| | | ErrorLogSeverity errorSeverity = |
| | | ErrorLogSeverity.getByName(defSev.name()); |
| | | if(errorSeverity != null) |
| | | { |
| | | defaultSeverities.add(errorSeverity); |
| | | } |
| | | } |
| | | } |
| | | |
| | | for(String overrideSeverity : config.getOverrideSeverity()) |
| | | { |
| | | if(overrideSeverity != null) |
| | | { |
| | | int equalPos = overrideSeverity.indexOf('='); |
| | | if (equalPos < 0) |
| | | { |
| | | int msgID = MSGID_ERROR_LOGGER_INVALID_OVERRIDE_SEVERITY; |
| | | String msg = getMessage(msgID, overrideSeverity); |
| | | throw new ConfigException(msgID, msg); |
| | | |
| | | } else |
| | | { |
| | | String categoryName = overrideSeverity.substring(0, equalPos); |
| | | ErrorLogCategory category = ErrorLogCategory.getByName(categoryName); |
| | | if (category == null) |
| | | { |
| | | int msgID = MSGID_ERROR_LOGGER_INVALID_CATEGORY; |
| | | String msg = getMessage(msgID, categoryName); |
| | | throw new ConfigException(msgID, msg); |
| | | } else |
| | | { |
| | | HashSet<ErrorLogSeverity> severities = |
| | | new HashSet<ErrorLogSeverity>(); |
| | | StringTokenizer sevTokenizer = |
| | | new StringTokenizer(overrideSeverity.substring(equalPos+1), ","); |
| | | while (sevTokenizer.hasMoreElements()) |
| | | { |
| | | String severityName = sevTokenizer.nextToken(); |
| | | ErrorLogSeverity severity = |
| | | ErrorLogSeverity.getByName(severityName); |
| | | if (severity == null) |
| | | { |
| | | int msgID = MSGID_ERROR_LOGGER_INVALID_SEVERITY; |
| | | String msg = getMessage(msgID, categoryName); |
| | | throw new ConfigException(msgID, msg); |
| | | } else |
| | | { |
| | | severities.add(severity); |
| | | } |
| | | } |
| | | definedSeverities.put(category, severities); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | currentConfig = config; |
| | | |
| | | config.addFileBasedErrorChangeListener(this); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationChangeAcceptable( |
| | | FileBasedErrorLogPublisherCfg config, List<String> unacceptableReasons) |
| | | { |
| | | // Make sure the permission is valid. |
| | | try |
| | | { |
| | | if(!currentConfig.getLogFileMode().equalsIgnoreCase( |
| | | config.getLogFileMode())) |
| | | { |
| | | FilePermission.decodeUNIXMode(config.getLogFileMode()); |
| | | } |
| | | if(!currentConfig.getLogFile().equalsIgnoreCase(config.getLogFile())) |
| | | { |
| | | File logFile = getFileForPath(config.getLogFile()); |
| | | if(logFile.createNewFile()) |
| | | { |
| | | logFile.delete(); |
| | | } |
| | | } |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGING_CANNOT_CREATE_WRITER; |
| | | String message = getMessage(msgID, config.dn().toString(), |
| | | stackTraceToSingleLineString(e)); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | |
| | | // Validate retention and rotation policies. |
| | | for(DN dn : config.getRotationPolicyDN()) |
| | | { |
| | | RotationPolicy policy = DirectoryServer.getRotationPolicy(dn); |
| | | if(policy == null) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ROTATION_POLICY; |
| | | String message = getMessage(msgID, dn.toString(), |
| | | config.dn().toString()); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | } |
| | | for(DN dn: config.getRetentionPolicyDN()) |
| | | { |
| | | RetentionPolicy policy = DirectoryServer.getRetentionPolicy(dn); |
| | | if(policy == null) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_RETENTION_POLICY; |
| | | String message = getMessage(msgID, dn.toString(), |
| | | config.dn().toString()); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | for(String overrideSeverity : config.getOverrideSeverity()) |
| | | { |
| | | if(overrideSeverity != null) |
| | | { |
| | | int equalPos = overrideSeverity.indexOf('='); |
| | | if (equalPos < 0) |
| | | { |
| | | int msgID = MSGID_ERROR_LOGGER_INVALID_OVERRIDE_SEVERITY; |
| | | String msg = getMessage(msgID, overrideSeverity); |
| | | unacceptableReasons.add(msg); |
| | | return false; |
| | | |
| | | } else |
| | | { |
| | | String categoryName = overrideSeverity.substring(0, equalPos); |
| | | ErrorLogCategory category = ErrorLogCategory.getByName(categoryName); |
| | | if (category == null) |
| | | { |
| | | int msgID = MSGID_ERROR_LOGGER_INVALID_CATEGORY; |
| | | String msg = getMessage(msgID, categoryName); |
| | | unacceptableReasons.add(msg); |
| | | return false; |
| | | } else |
| | | { |
| | | StringTokenizer sevTokenizer = |
| | | new StringTokenizer(overrideSeverity.substring(equalPos+1), ","); |
| | | while (sevTokenizer.hasMoreElements()) |
| | | { |
| | | String severityName = sevTokenizer.nextToken(); |
| | | ErrorLogSeverity severity = |
| | | ErrorLogSeverity.getByName(severityName); |
| | | if (severity == null) |
| | | { |
| | | int msgID = MSGID_ERROR_LOGGER_INVALID_SEVERITY; |
| | | String msg = getMessage(msgID, categoryName); |
| | | unacceptableReasons.add(msg); |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | FileBasedErrorLogPublisherCfg config) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | Set<ErrorLogPublisherCfgDefn.DefaultSeverity> defSev = |
| | | config.getDefaultSeverity(); |
| | | defaultSeverities.clear(); |
| | | if(defSev.isEmpty()) |
| | | { |
| | | defaultSeverities.add(ErrorLogSeverity.FATAL_ERROR); |
| | | defaultSeverities.add(ErrorLogSeverity.SEVERE_ERROR); |
| | | defaultSeverities.add(ErrorLogSeverity.SEVERE_WARNING); |
| | | } else |
| | | { |
| | | for(ErrorLogPublisherCfgDefn.DefaultSeverity defStr : defSev) |
| | | { |
| | | ErrorLogSeverity errorSeverity = |
| | | ErrorLogSeverity.getByName(defStr.toString()); |
| | | if(errorSeverity != null) |
| | | { |
| | | defaultSeverities.add(errorSeverity); |
| | | } |
| | | } |
| | | } |
| | | |
| | | definedSeverities.clear(); |
| | | for(String overrideSeverity : config.getOverrideSeverity()) |
| | | { |
| | | if(overrideSeverity != null) |
| | | { |
| | | int equalPos = overrideSeverity.indexOf('='); |
| | | if (equalPos < 0) |
| | | { |
| | | int msgID = MSGID_ERROR_LOGGER_INVALID_OVERRIDE_SEVERITY; |
| | | String msg = getMessage(msgID, overrideSeverity); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | messages.add(msg); |
| | | } else |
| | | { |
| | | String categoryName = overrideSeverity.substring(0, equalPos); |
| | | ErrorLogCategory category = ErrorLogCategory.getByName(categoryName); |
| | | if (category == null) |
| | | { |
| | | int msgID = MSGID_ERROR_LOGGER_INVALID_CATEGORY; |
| | | String msg = getMessage(msgID, categoryName); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | messages.add(msg); |
| | | } else |
| | | { |
| | | HashSet<ErrorLogSeverity> severities = |
| | | new HashSet<ErrorLogSeverity>(); |
| | | StringTokenizer sevTokenizer = |
| | | new StringTokenizer(overrideSeverity.substring(equalPos+1), ","); |
| | | while (sevTokenizer.hasMoreElements()) |
| | | { |
| | | String severityName = sevTokenizer.nextToken(); |
| | | ErrorLogSeverity severity = |
| | | ErrorLogSeverity.getByName(severityName); |
| | | if (severity == null) |
| | | { |
| | | int msgID = MSGID_ERROR_LOGGER_INVALID_SEVERITY; |
| | | String msg = getMessage(msgID, categoryName); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | messages.add(msg); |
| | | } else |
| | | { |
| | | severities.add(severity); |
| | | } |
| | | } |
| | | definedSeverities.put(category, severities); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | File logFile = getFileForPath(config.getLogFile()); |
| | | FileNamingPolicy fnPolicy = new TimeStampNaming(logFile); |
| | | |
| | | try |
| | | { |
| | | FilePermission perm = |
| | | FilePermission.decodeUNIXMode(config.getLogFileMode()); |
| | | |
| | | boolean writerAutoFlush = |
| | | config.isAutoFlush() && !config.isAsynchronous(); |
| | | |
| | | TextWriter currentWriter; |
| | | // Determine the writer we are using. If we were writing asyncronously, |
| | | // we need to modify the underlaying writer. |
| | | if(writer instanceof AsyncronousTextWriter) |
| | | { |
| | | currentWriter = ((AsyncronousTextWriter)writer).getWrappedWriter(); |
| | | } |
| | | else |
| | | { |
| | | currentWriter = writer; |
| | | } |
| | | |
| | | if(currentWriter instanceof MultifileTextWriter) |
| | | { |
| | | MultifileTextWriter mfWriter = (MultifileTextWriter)writer; |
| | | |
| | | mfWriter.setNamingPolicy(fnPolicy); |
| | | mfWriter.setFilePermissions(perm); |
| | | mfWriter.setAppend(config.isAppend()); |
| | | mfWriter.setAutoFlush(writerAutoFlush); |
| | | mfWriter.setBufferSize((int)config.getBufferSize()); |
| | | mfWriter.setInterval(config.getTimeInterval()); |
| | | |
| | | mfWriter.removeAllRetentionPolicies(); |
| | | mfWriter.removeAllRotationPolicies(); |
| | | |
| | | for(DN dn : config.getRotationPolicyDN()) |
| | | { |
| | | RotationPolicy policy = DirectoryServer.getRotationPolicy(dn); |
| | | if(policy != null) |
| | | { |
| | | mfWriter.addRotationPolicy(policy); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ROTATION_POLICY; |
| | | String message = getMessage(msgID, dn.toString(), |
| | | config.dn().toString()); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | messages.add(message); |
| | | } |
| | | } |
| | | for(DN dn: config.getRetentionPolicyDN()) |
| | | { |
| | | RetentionPolicy policy = DirectoryServer.getRetentionPolicy(dn); |
| | | if(policy != null) |
| | | { |
| | | mfWriter.addRetentionPolicy(policy); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_RETENTION_POLICY; |
| | | String message = getMessage(msgID, dn.toString(), |
| | | config.dn().toString()); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | messages.add(message); |
| | | } |
| | | } |
| | | |
| | | |
| | | if(writer instanceof AsyncronousTextWriter && !config.isAsynchronous()) |
| | | { |
| | | // The asynronous setting is being turned off. |
| | | AsyncronousTextWriter asyncWriter = ((AsyncronousTextWriter)writer); |
| | | writer = mfWriter; |
| | | asyncWriter.shutdown(false); |
| | | } |
| | | |
| | | if(!(writer instanceof AsyncronousTextWriter) && |
| | | config.isAsynchronous()) |
| | | { |
| | | // The asynronous setting is being turned on. |
| | | AsyncronousTextWriter asyncWriter = |
| | | new AsyncronousTextWriter("Asyncronous Text Writer for " + |
| | | config.dn().toNormalizedString(), config.getQueueSize(), |
| | | config.isAutoFlush(), |
| | | mfWriter); |
| | | writer = asyncWriter; |
| | | } |
| | | |
| | | if((currentConfig.isAsynchronous() && config.isAsynchronous()) && |
| | | (currentConfig.getQueueSize() != config.getQueueSize())) |
| | | { |
| | | adminActionRequired = true; |
| | | } |
| | | |
| | | currentConfig = config; |
| | | } |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGING_CANNOT_CREATE_WRITER; |
| | | String message = getMessage(msgID, config.dn().toString(), |
| | | stackTraceToSingleLineString(e)); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | messages.add(message); |
| | | |
| | | } |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void close() |
| | | { |
| | | writer.shutdown(); |
| | | |
| | | if(currentConfig != null) |
| | | { |
| | | currentConfig.removeFileBasedErrorChangeListener(this); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void logError(ErrorLogCategory category, |
| | | ErrorLogSeverity severity, String message, |
| | | int errorID) |
| | | { |
| | | HashSet<ErrorLogSeverity> severities = definedSeverities.get(category); |
| | | if(severities == null) |
| | | { |
| | | severities = defaultSeverities; |
| | | } |
| | | |
| | | if(severities.contains(severity)) |
| | | { |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append("["); |
| | | sb.append(TimeThread.getLocalTime()); |
| | | sb.append("] category=").append(category.getCategoryName()). |
| | | append(" severity=").append(severity.getSeverityName()). |
| | | append(" msgID=").append(String.valueOf(errorID)). |
| | | append(" msg=").append(message); |
| | | |
| | | // FIXME - lookup the level based on the severity |
| | | writer.writeRecord(sb.toString()); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * A TextWriter provides a character-based stream used by a |
| | | * TextLogPublisher as a target for outputting log records. |
| | | * Separating this from a LogPublisher implementation allows |
| | | * better sharing of targets such as the console, since a |
| | | * TextWriter imposes no format. |
| | | * Text Publishers as a target for outputting log records. |
| | | */ |
| | | public class TextWriter |
| | | public interface TextWriter |
| | | { |
| | | /** |
| | | * A TextWriter which writes to standard out. |
| | | */ |
| | | public static TextWriter STDOUT= |
| | | new TextWriter(new PrintWriter(System.out, true), false); |
| | | /** |
| | | * A TextWriter which writes to standard error. |
| | | */ |
| | | public static TextWriter STDERR= |
| | | new TextWriter(new PrintWriter(System.err, true), false); |
| | | |
| | | /** The underlying output stream. */ |
| | | protected PrintWriter writer; |
| | | |
| | | /** Indicates whether we should close the stream on shutdown. */ |
| | | private boolean closable; |
| | | |
| | | /** |
| | | * Create a new TextWriter for a specified writer. |
| | | * On shutdown, the writer will be closed. |
| | | * |
| | | * @param writer - a character stream used for output. |
| | | */ |
| | | public TextWriter(PrintWriter writer) |
| | | { |
| | | this(writer, true); |
| | | } |
| | | |
| | | /** |
| | | * Create a new TextWriter for a specified writer. |
| | | * On shutdown, the writer will be closed if requested. |
| | | * |
| | | * @param writer - a character stream used for output. |
| | | * @param closeOnShutdown - indicates whether the provided. |
| | | * stream should be closed when shutdown is invoked. |
| | | */ |
| | | public TextWriter(PrintWriter writer, boolean closeOnShutdown) |
| | | { |
| | | this.writer = writer; |
| | | closable = closeOnShutdown; |
| | | } |
| | | |
| | | /** |
| | | * Writes a text record to the output stream. |
| | | * |
| | | * @param record - the record to write. |
| | | */ |
| | | public void writeRecord(String record) |
| | | { |
| | | writer.println(record); |
| | | } |
| | | public void writeRecord(String record); |
| | | |
| | | /** |
| | | * Flushes any buffered contents of the output stream. |
| | | */ |
| | | public void flush() |
| | | { |
| | | writer.flush(); |
| | | } |
| | | public void flush(); |
| | | |
| | | /** |
| | | * Releases any resources held by the writer. |
| | | * Unless <b>closeOnShutdown</b> was <b>false</b> when the writer |
| | | * was constructed, the wrapped output stream will also be |
| | | * closed. |
| | | */ |
| | | public void shutdown() |
| | | public void shutdown(); |
| | | |
| | | /** |
| | | * Retrieves the number of bytes written by this writer. |
| | | * |
| | | * @return the number of bytes written by this writer. |
| | | */ |
| | | public long getBytesWritten(); |
| | | |
| | | /** |
| | | * A TextWriter implementationwhich writes to standard out. |
| | | */ |
| | | public static class STDOUT implements TextWriter |
| | | { |
| | | // Close only if we were told to |
| | | if (closable) { |
| | | private MeteredStream stream = new MeteredStream(System.out, 0); |
| | | private PrintWriter writer = new PrintWriter(stream, true); |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void writeRecord(String record) |
| | | { |
| | | writer.println(record); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void flush() |
| | | { |
| | | writer.flush(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void shutdown() |
| | | { |
| | | writer.close(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public long getBytesWritten() |
| | | { |
| | | return stream.written; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * A TextWriter implementation which writes to standard error. |
| | | */ |
| | | public static class STDERR implements TextWriter |
| | | { |
| | | private MeteredStream stream = new MeteredStream(System.err, 0); |
| | | private PrintWriter writer = new PrintWriter(stream, true); |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void writeRecord(String record) |
| | | { |
| | | writer.println(record); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void flush() |
| | | { |
| | | writer.flush(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void shutdown() |
| | | { |
| | | writer.close(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public long getBytesWritten() |
| | | { |
| | | return stream.written; |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.admin.std.server.ErrorLogPublisherCfg; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.api.ErrorLogPublisher; |
| | | import org.opends.server.util.TimeThread; |
| | | |
| | | /** |
| | | * This class provides an implementation of an error logger where only messages |
| | | * generated by a specified thread is actually logged. |
| | | */ |
| | | public class ThreadFilterTextErrorLogPublisher |
| | | extends ErrorLogPublisher<ErrorLogPublisherCfg> |
| | | { |
| | | private Thread thread; |
| | | |
| | | private TextWriter writer; |
| | | |
| | | /** |
| | | * Construct a new instance with the provided settings. |
| | | * |
| | | * @param thread The thread to log from. |
| | | * @param writer The writer used to write the messages. |
| | | */ |
| | | public ThreadFilterTextErrorLogPublisher(Thread thread, |
| | | TextWriter writer) |
| | | { |
| | | this.thread = thread; |
| | | this.writer = writer; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void initializeErrorLogPublisher(ErrorLogPublisherCfg config) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | // This class should only be used internally in the server and not be |
| | | // configurable via the admin framework. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void close() |
| | | { |
| | | writer.shutdown(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void logError(ErrorLogCategory category, |
| | | ErrorLogSeverity severity, String message, |
| | | int errorID) |
| | | { |
| | | Thread currentThread = Thread.currentThread(); |
| | | if(this.thread.equals(currentThread) || |
| | | this.thread.getThreadGroup().equals(currentThread.getThreadGroup())) |
| | | { |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append("["); |
| | | sb.append(TimeThread.getLocalTime()); |
| | | sb.append("] category=").append(category.getCategoryName()). |
| | | append(" severity=").append(severity.getSeverityName()). |
| | | append(" msgID=").append(String.valueOf(errorID)). |
| | | append(" msg=").append(message); |
| | | |
| | | this.writer.writeRecord(sb.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | package org.opends.server.loggers; |
| | | |
| | | import org.opends.server.util.TimeThread; |
| | | import org.opends.server.admin.std.server.TimeLimitLogRotationPolicyCfg; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import java.util.List; |
| | | import java.util.ArrayList; |
| | | |
| | | /** |
| | | * This class implements a fixed time based rotation policy. |
| | | * Rotation will happen N seconds since the last rotation. |
| | | */ |
| | | public class TimeLimitRotationPolicy implements RotationPolicy |
| | | public class TimeLimitRotationPolicy implements |
| | | RotationPolicy<TimeLimitLogRotationPolicyCfg>, |
| | | ConfigurationChangeListener<TimeLimitLogRotationPolicyCfg> |
| | | { |
| | | |
| | | private long timeInterval = 0; |
| | | private long lastModifiedTime = 0; |
| | | |
| | | /** |
| | | * Create the time based rotation policy. |
| | | * |
| | | * @param time The time interval between rotations. |
| | | * {@inheritDoc} |
| | | */ |
| | | public TimeLimitRotationPolicy(long time) |
| | | public void initializeLogRotationPolicy(TimeLimitLogRotationPolicyCfg config) |
| | | { |
| | | timeInterval = time; |
| | | lastModifiedTime = TimeThread.getTime(); |
| | | timeInterval = config.getRotationInterval(); |
| | | |
| | | config.addTimeLimitChangeListener(this); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationChangeAcceptable( |
| | | TimeLimitLogRotationPolicyCfg config, List<String> unacceptableReasons) |
| | | { |
| | | // Changes should always be OK |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | TimeLimitLogRotationPolicyCfg config) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | timeInterval = config.getRotationInterval(); |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | |
| | |
| | | * This method indicates if the log file should be |
| | | * rotated or not. |
| | | * |
| | | * @param writer The mutli file text writer written the log file. |
| | | * @return true if the file should be rotated, false otherwise. |
| | | */ |
| | | public boolean rotateFile() |
| | | public boolean rotateFile(MultifileTextWriter writer) |
| | | { |
| | | long currTime = TimeThread.getTime(); |
| | | if (currTime - lastModifiedTime > timeInterval) |
| | | { |
| | | do |
| | | { |
| | | lastModifiedTime += timeInterval; |
| | | } |
| | | while (lastModifiedTime < currTime); |
| | | |
| | | // lastModifiedTime = currTime; |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | return currTime - writer.getLastRotationTime() > timeInterval; |
| | | } |
| | | |
| | | } |
| | |
| | | import org.opends.server.util.TimeThread; |
| | | |
| | | import java.io.File; |
| | | import java.io.FilenameFilter; |
| | | |
| | | /** |
| | | * A file name policy that names files suffixed by the time it was created. |
| | |
| | | File file; |
| | | |
| | | /** |
| | | * The FilenameFilter implementation for this naming policy to filter |
| | | * for all the files named by this policy. |
| | | */ |
| | | private class TimeStampNamingFilter implements FilenameFilter |
| | | { |
| | | /** |
| | | * Select only files that are named by this policy. |
| | | * |
| | | * @param dir The directory to search. |
| | | * @param name The filename to which to apply the filter. |
| | | * |
| | | * @return <CODE>true</CODE> if the given filename matches the filter, or |
| | | * <CODE>false</CODE> if it does not. |
| | | */ |
| | | public boolean accept(File dir, String name) |
| | | { |
| | | if(new File(dir, name).isDirectory()) |
| | | { |
| | | return false; |
| | | } |
| | | name = name.toLowerCase(); |
| | | return name.startsWith(file.getName().toLowerCase()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Create a new instance of the TimeStampNaming policy. Files will be created |
| | | * with the names in the prefix.utctime format. |
| | | * |
| | |
| | | { |
| | | this.file = file; |
| | | } |
| | | |
| | | /** |
| | | * Initializes the policy and returns the current name to use. |
| | | * |
| | | * @return the initial file. |
| | | * {@inheritDoc} |
| | | */ |
| | | public File getInitialName() |
| | | { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets the next name to use. |
| | | * |
| | | * @return the next file. |
| | | * {@inheritDoc} |
| | | */ |
| | | public File getNextName() |
| | | { |
| | | return new File(file + "." + TimeThread.getGMTTime()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public FilenameFilter getFilenameFilter() |
| | | { |
| | | return new TimeStampNamingFilter(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public File[] listFiles() |
| | | { |
| | | File directory = file.getParentFile(); |
| | | return directory.listFiles(getFilenameFilter()); |
| | | } |
| | | |
| | | } |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | * Portions Copyright 2007 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.loggers.debug; |
| | | |
| | | import org.opends.server.api.ProtocolElement; |
| | | import org.opends.server.loggers.Logger; |
| | | import org.opends.server.loggers.LogLevel; |
| | | |
| | | import java.util.Map; |
| | | import java.util.HashMap; |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.concurrent.CopyOnWriteArraySet; |
| | | import java.nio.ByteBuffer; |
| | | import java.lang.reflect.Method; |
| | | import java.lang.reflect.InvocationTargetException; |
| | | |
| | | import com.sleepycat.je.OperationStatus; |
| | | import com.sleepycat.je.Database; |
| | | import com.sleepycat.je.Transaction; |
| | | import com.sleepycat.je.DatabaseEntry; |
| | | import org.opends.server.api.ProtocolElement; |
| | | import org.opends.server.api.DebugLogPublisher; |
| | | import org.opends.server.loggers.*; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.DynamicConstants; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.opends.server.admin.std.server.DebugLogPublisherCfg; |
| | | import org.opends.server.admin.std.meta.DebugLogPublisherCfgDefn; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.server.ConfigurationDeleteListener; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import com.sleepycat.je.*; |
| | | |
| | | /** |
| | | * A logger for debug and trace logging. DebugLogger provides a debugging |
| | |
| | | * |
| | | * DebugLogger is self-initializing. |
| | | */ |
| | | public class DebugLogger extends Logger |
| | | public class DebugLogger implements |
| | | ConfigurationAddListener<DebugLogPublisherCfg>, |
| | | ConfigurationDeleteListener<DebugLogPublisherCfg>, |
| | | ConfigurationChangeListener<DebugLogPublisherCfg> |
| | | { |
| | | private static DebugLogger logger = null; |
| | | static boolean staticEnabled = false; |
| | | //The default level to log constructor exectuions. |
| | | static final LogLevel DEFAULT_CONSTRUCTOR_LEVEL = |
| | | DebugLogLevel.VERBOSE; |
| | | //The default level to log method entry and exit pointcuts. |
| | | static final LogLevel DEFAULT_ENTRY_EXIT_LEVEL = |
| | | DebugLogLevel.VERBOSE; |
| | | //The default level to log method entry and exit pointcuts. |
| | | static final LogLevel DEFAULT_THROWN_LEVEL = |
| | | DebugLogLevel.ERROR; |
| | | |
| | | private Map<String, Tracer> classTracers; |
| | | // The set of all DebugTracer aspect instances. |
| | | static CopyOnWriteArraySet<DebugTracer> classTracers = |
| | | new CopyOnWriteArraySet<DebugTracer>(); |
| | | |
| | | private DebugConfiguration configuration; |
| | | // The set of debug loggers that have been registered with the server. It |
| | | // will initially be empty. |
| | | static ConcurrentHashMap<DN, |
| | | DebugLogPublisher> debugPublishers = |
| | | new ConcurrentHashMap<DN, |
| | | DebugLogPublisher>(); |
| | | |
| | | private DebugLogger(DebugConfiguration config) |
| | | // Trace methods will use this static boolean to determine if debug is |
| | | // enabled so to not incur the cost of calling debugPublishers.isEmtpty(). |
| | | static boolean enabled = false; |
| | | |
| | | // The singleton instance of this class for configuration purposes. |
| | | static final DebugLogger instance = new DebugLogger(); |
| | | |
| | | static |
| | | { |
| | | super(config); |
| | | configuration = config; |
| | | classTracers = new HashMap<String, Tracer>(); |
| | | staticEnabled = enabled; |
| | | // Install the startup publishers if necessary until the config kicks in and |
| | | // adds the real publishers. |
| | | |
| | | if(DynamicConstants.WEAVE_ENABLED) |
| | | { |
| | | try |
| | | { |
| | | TextDebugLogPublisher startupDebugPublisher = |
| | | TextDebugLogPublisher.getStartupTextDebugPublisher( |
| | | new TextWriter.STDOUT()); |
| | | |
| | | debugPublishers.put(DN.NULL_DN, |
| | | startupDebugPublisher); |
| | | enabled = true; |
| | | |
| | | // Update all existing aspect instances |
| | | addTracerSettings(startupDebugPublisher); |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | System.err.println("Error installing the startup debug logger: " + |
| | | StaticUtils.stackTraceToSingleLineString(e)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Add an debug log publisher to the debug logger. |
| | | * |
| | | * @param dn The DN of the configuration entry for the publisher. |
| | | * @param publisher The error log publisher to add. |
| | | */ |
| | | public synchronized static void addDebugLogPublisher(DN dn, |
| | | DebugLogPublisher publisher) |
| | | { |
| | | debugPublishers.put(dn, publisher); |
| | | enabled = DynamicConstants.WEAVE_ENABLED; |
| | | } |
| | | |
| | | /** |
| | | * Obtain the trace logger singleton. |
| | | * @return the trace logger singleton. |
| | | * Remove an debug log publisher from the debug logger. |
| | | * |
| | | * @param dn The DN of the publisher to remove. |
| | | * @return The publisher that was removed or null if it was not found. |
| | | */ |
| | | public static synchronized DebugLogger getLogger() |
| | | public synchronized static DebugLogPublisher removeDebugLogPublisher(DN dn) |
| | | { |
| | | if (logger == null) { |
| | | /** |
| | | * The debug logger is being intialized for the first time. |
| | | * Bootstrap the debug logger when the server first starts up so |
| | | * all debug messages are log from the first initialization of a |
| | | * server class. |
| | | */ |
| | | logger= new DebugLogger(DebugConfiguration.getStartupConfiguration()); |
| | | DebugLogPublisher removed = debugPublishers.remove(dn); |
| | | |
| | | if(removed != null) |
| | | { |
| | | removed.close(); |
| | | } |
| | | |
| | | return logger; |
| | | if(debugPublishers.isEmpty()) |
| | | { |
| | | enabled = false; |
| | | } |
| | | |
| | | return removed; |
| | | } |
| | | |
| | | /** |
| | | * Obtain the status of this logger singleton. |
| | | * Removes all existing debug log publishers from the logger. |
| | | */ |
| | | public synchronized static void removeAllDebugLogPublishers() |
| | | { |
| | | for(DebugLogPublisher publisher : debugPublishers.values()) |
| | | { |
| | | publisher.close(); |
| | | } |
| | | |
| | | debugPublishers.clear(); |
| | | |
| | | enabled = false; |
| | | } |
| | | |
| | | /** |
| | | * Initializes all the debug log publishers. |
| | | * |
| | | * @return the status of this logger. |
| | | * @param configs The debug log publisher configurations. |
| | | * @throws ConfigException |
| | | * If an unrecoverable problem arises in the process of |
| | | * performing the initialization as a result of the server |
| | | * configuration. |
| | | * @throws InitializationException |
| | | * If a problem occurs during initialization that is not |
| | | * related to the server configuration. |
| | | */ |
| | | public void initializeDebugLogger(List<DebugLogPublisherCfg> configs) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | for(DebugLogPublisherCfg config : configs) |
| | | { |
| | | config.addDebugChangeListener(this); |
| | | |
| | | if(config.isEnabled()) |
| | | { |
| | | DebugLogPublisher debugLogPublisher = getDebugPublisher(config); |
| | | |
| | | addDebugLogPublisher(config.dn(), debugLogPublisher); |
| | | |
| | | // Update all existing aspect instances |
| | | addTracerSettings(debugLogPublisher); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationAddAcceptable(DebugLogPublisherCfg config, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | return !config.isEnabled() || |
| | | isJavaClassAcceptable(config, unacceptableReasons); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationChangeAcceptable(DebugLogPublisherCfg config, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | return !config.isEnabled() || |
| | | isJavaClassAcceptable(config, unacceptableReasons); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationAdd(DebugLogPublisherCfg config) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | config.addDebugChangeListener(this); |
| | | |
| | | if(config.isEnabled()) |
| | | { |
| | | try |
| | | { |
| | | DebugLogPublisher debugLogPublisher = |
| | | getDebugPublisher(config); |
| | | |
| | | addDebugLogPublisher(config.dn(), debugLogPublisher); |
| | | |
| | | addTracerSettings(debugLogPublisher); |
| | | } |
| | | catch(ConfigException e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | messages.add(e.getMessage()); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | int msgID = MSGID_CONFIG_LOGGER_CANNOT_CREATE_LOGGER; |
| | | messages.add(getMessage(msgID, String.valueOf(config.dn().toString()), |
| | | stackTraceToSingleLineString(e))); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | } |
| | | } |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | DebugLogPublisherCfg config) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | DN dn = config.dn(); |
| | | DebugLogPublisher debugLogPublisher = debugPublishers.get(dn); |
| | | |
| | | if(debugLogPublisher == null) |
| | | { |
| | | if(config.isEnabled()) |
| | | { |
| | | // Needs to be added and enabled. |
| | | return applyConfigurationAdd(config); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if(config.isEnabled()) |
| | | { |
| | | // The publisher is currently active, so we don't need to do anything. |
| | | // Changes to the class name cannot be |
| | | // applied dynamically, so if the class name did change then |
| | | // indicate that administrative action is required for that |
| | | // change to take effect. |
| | | String className = config.getJavaImplementationClass(); |
| | | if(!className.equals(debugLogPublisher.getClass().getName())) |
| | | { |
| | | adminActionRequired = true; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // The publisher is being disabled so shut down and remove. |
| | | removeTracerSettings(debugLogPublisher); |
| | | removeDebugLogPublisher(config.dn()); |
| | | } |
| | | } |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationDeleteAcceptable(DebugLogPublisherCfg config, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | DN dn = config.dn(); |
| | | DebugLogPublisher debugLogPublisher = debugPublishers.get(dn); |
| | | return debugLogPublisher != null; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult |
| | | applyConfigurationDelete(DebugLogPublisherCfg config) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | |
| | | DebugLogPublisher publisher = removeDebugLogPublisher(config.dn()); |
| | | if(publisher != null) |
| | | { |
| | | removeTracerSettings(publisher); |
| | | } |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired); |
| | | } |
| | | |
| | | private boolean isJavaClassAcceptable(DebugLogPublisherCfg config, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | String className = config.getJavaImplementationClass(); |
| | | DebugLogPublisherCfgDefn d = DebugLogPublisherCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = |
| | | d.getJavaImplementationClassPropertyDefinition(); |
| | | // Load the class and cast it to a DebugLogPublisher. |
| | | Class<? extends DebugLogPublisher> theClass; |
| | | try { |
| | | theClass = pd.loadClass(className, DebugLogPublisher.class); |
| | | theClass.newInstance(); |
| | | } catch (Exception e) { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_DEBUG_LOGGER_CLASS; |
| | | String message = getMessage(msgID, className, |
| | | config.dn().toString(), |
| | | String.valueOf(e)); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | // Check that the implementation class implements the correct interface. |
| | | try { |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | theClass.getMethod("initializeDebugLogPublisher", config.definition() |
| | | .getServerConfigurationClass()); |
| | | } catch (Exception e) { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_DEBUG_LOGGER_CLASS; |
| | | String message = getMessage(msgID, className, |
| | | config.dn().toString(), |
| | | String.valueOf(e)); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | // The class is valid as far as we can tell. |
| | | return true; |
| | | } |
| | | |
| | | private DebugLogPublisher getDebugPublisher(DebugLogPublisherCfg config) |
| | | throws ConfigException { |
| | | String className = config.getJavaImplementationClass(); |
| | | DebugLogPublisherCfgDefn d = DebugLogPublisherCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = |
| | | d.getJavaImplementationClassPropertyDefinition(); |
| | | // Load the class and cast it to a DebugLogPublisher. |
| | | Class<? extends DebugLogPublisher> theClass; |
| | | DebugLogPublisher debugLogPublisher; |
| | | try { |
| | | theClass = pd.loadClass(className, DebugLogPublisher.class); |
| | | debugLogPublisher = theClass.newInstance(); |
| | | |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | Method method = theClass.getMethod("initializeDebugLogPublisher", |
| | | config.definition().getServerConfigurationClass()); |
| | | method.invoke(debugLogPublisher, config); |
| | | } |
| | | catch (InvocationTargetException ite) |
| | | { |
| | | // Rethrow the exceptions thrown be the invoked method. |
| | | Throwable e = ite.getTargetException(); |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_DEBUG_LOGGER_CLASS; |
| | | String message = getMessage(msgID, className, |
| | | config.dn().toString(), |
| | | stackTraceToSingleLineString(e)); |
| | | throw new ConfigException(msgID, message, e); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_DEBUG_LOGGER_CLASS; |
| | | String message = getMessage(msgID, className, |
| | | config.dn().toString(), |
| | | String.valueOf(e)); |
| | | throw new ConfigException(msgID, message, e); |
| | | } |
| | | |
| | | // The debug publisher has been successfully initialized. |
| | | return debugLogPublisher; |
| | | } |
| | | |
| | | /** |
| | | * Adds the settings for the provided publisher in all existing tracers. |
| | | * If existing settings exist for the given publisher, it will be updated |
| | | * with the new settings. |
| | | * |
| | | * @param publisher The debug log publisher with the new settings. |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public static void addTracerSettings(DebugLogPublisher publisher) |
| | | { |
| | | // Make sure this publisher is still registered with us. If not, don't |
| | | // use its settings. |
| | | if(debugPublishers.contains(publisher)) |
| | | { |
| | | for(DebugTracer tracer : classTracers) |
| | | { |
| | | tracer.classSettings.put(publisher, |
| | | publisher.getClassSettings(tracer.className)); |
| | | |
| | | // For some reason, the compiler doesn't see that |
| | | // debugLogPublihser.getMethodSettings returns a parameterized Map. |
| | | // This problem goes away if a parameterized verson of |
| | | // DebugLogPublisher is used. However, we can't not use reflection to |
| | | // instantiate a generic |
| | | // DebugLogPublisher<? extends DebugLogPublisherCfg> type. The only |
| | | // thing we can do is to just suppress the compiler warnings. |
| | | Map<String, TraceSettings> methodSettings = |
| | | publisher.getMethodSettings(tracer.className); |
| | | if(methodSettings != null) |
| | | { |
| | | tracer.methodSettings.put(publisher, methodSettings); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Removes the settings for the provided publisher in all existing tracers. |
| | | * |
| | | * @param publisher The debug log publisher to remove. |
| | | */ |
| | | public static void removeTracerSettings(DebugLogPublisher publisher) |
| | | { |
| | | for(DebugTracer tracer : classTracers) |
| | | { |
| | | tracer.classSettings.remove(publisher); |
| | | tracer.methodSettings.remove(publisher); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Indicates if debug logging is enabled. |
| | | * |
| | | * @return True if debug logging is enabled. False otherwise. |
| | | */ |
| | | public static boolean debugEnabled() |
| | | { |
| | | return staticEnabled; |
| | | return enabled; |
| | | } |
| | | |
| | | /** |
| | | * Register a trace logger for the specified class. |
| | | * @param className - the class for which to register the tracer under. |
| | | * @param tracer - the tracer object to register. |
| | | */ |
| | | public synchronized void registerTracer(String className, |
| | | Tracer tracer) |
| | | { |
| | | Tracer traceLogger = classTracers.get(className); |
| | | if (traceLogger == null) { |
| | | classTracers.put(className, tracer); |
| | | tracer.updateSettings(this.configuration); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Update the tracing configuration of the debug logger with the specified |
| | | * trace configuration. |
| | | * Retrieve the singleton instance of this class. |
| | | * |
| | | * @param config the new configuration to apply. |
| | | * @return The singleton instance of this logger. |
| | | */ |
| | | public synchronized void updateConfiguration(DebugConfiguration config) |
| | | public static DebugLogger getInstance() |
| | | { |
| | | super.updateConfiguration(config); |
| | | staticEnabled = enabled; |
| | | |
| | | for(Tracer tracer : classTracers.values()) |
| | | { |
| | | tracer.updateSettings(config); |
| | | } |
| | | |
| | | this.configuration = config; |
| | | return instance; |
| | | } |
| | | |
| | | /** |
| | |
| | | ProtocolElement element) {} |
| | | |
| | | |
| | | /** |
| | | * Classes and methods annotated with @NoDebugTracing will not be weaved with |
| | | * debug logging statements by AspectJ. |
| | | */ |
| | | public @interface NoDebugTracing {} |
| | | |
| | | /** |
| | | * Methods annotated with @NoEntryDebugTracing will not be weaved with |
| | | * entry debug logging statements by AspectJ. |
| | | */ |
| | | public @interface NoEntryDebugTracing {} |
| | | |
| | | /** |
| | | * Methods annotated with @NoExitDebugTracing will not be weaved with |
| | | * exit debug logging statements by AspectJ. |
| | | */ |
| | | public @interface NoExitDebugTracing {} |
| | | |
| | | /** |
| | | * Methods annotated with @TraceThrown will be weaved by AspectJ with |
| | | * debug logging statements when an exception is thrown from the method. |
| | | */ |
| | | public @interface TraceThrown {} |
| | | |
| | | } |
| | |
| | | public class DebugMessageFormatter |
| | | { |
| | | /** |
| | | * Construct a new debug message formatter. |
| | | */ |
| | | public DebugMessageFormatter() { |
| | | //no implementation needed. |
| | | } |
| | | |
| | | /** |
| | | * Format the message format string with the provided arguments. |
| | | * |
| | | * @param msg the message format string to be formatted. |
| | | * @param msgArgs the arguments to use when replacing tokens in the message. |
| | | * @return the formatted message string. |
| | | */ |
| | | public String format(String msg, Object[] msgArgs) |
| | | public static String format(String msg, Object[] msgArgs) |
| | | { |
| | | StringBuilder buffer= new StringBuilder(); |
| | | Object[] decoratedArgs = decorateMessageArgs(msgArgs); |
| | |
| | | } |
| | | } |
| | | |
| | | private void concatenateArgs(Object[] args, StringBuilder buffer) |
| | | private static void concatenateArgs(Object[] args, StringBuilder buffer) |
| | | { |
| | | for (int i = 0; (args != null) && (i < args.length); i++) { |
| | | buffer.append(" ").append(args[i]); |
| | | } |
| | | } |
| | | |
| | | private Object[] decorateMessageArgs(Object[] undecoratedArgs) |
| | | private static Object[] decorateMessageArgs(Object[] undecoratedArgs) |
| | | { |
| | | Object[] args= null; |
| | | if (undecoratedArgs != null) { |
| | |
| | | return args; |
| | | } |
| | | |
| | | private Object decorateArg(Object arg) |
| | | private static Object decorateArg(Object arg) |
| | | { |
| | | Object decoratedArg= arg; |
| | | |
| | |
| | | return decoratedArg; |
| | | } |
| | | |
| | | private String decorateArrayArg(Object[] array) |
| | | private static String decorateArrayArg(Object[] array) |
| | | { |
| | | return decorateListArg(Arrays.asList(array)); |
| | | } |
| | | |
| | | private String decorateArrayArg(boolean[] array) |
| | | private static String decorateArrayArg(boolean[] array) |
| | | { |
| | | StringBuilder buffer= new StringBuilder(); |
| | | buffer.append("[ "); |
| | |
| | | return buffer.toString(); |
| | | } |
| | | |
| | | private String decorateArrayArg(byte[] array) |
| | | private static String decorateArrayArg(byte[] array) |
| | | { |
| | | StringBuilder buffer= new StringBuilder(); |
| | | buffer.append("[ "); |
| | |
| | | return buffer.toString(); |
| | | } |
| | | |
| | | private String decorateArrayArg(char[] array) |
| | | private static String decorateArrayArg(char[] array) |
| | | { |
| | | StringBuilder buffer= new StringBuilder(); |
| | | buffer.append("[ "); |
| | |
| | | return buffer.toString(); |
| | | } |
| | | |
| | | private String decorateArrayArg(double[] array) |
| | | private static String decorateArrayArg(double[] array) |
| | | { |
| | | StringBuilder buffer= new StringBuilder(); |
| | | buffer.append("[ "); |
| | |
| | | return buffer.toString(); |
| | | } |
| | | |
| | | private String decorateArrayArg(float[] array) |
| | | private static String decorateArrayArg(float[] array) |
| | | { |
| | | StringBuilder buffer= new StringBuilder(); |
| | | buffer.append("[ "); |
| | |
| | | return buffer.toString(); |
| | | } |
| | | |
| | | private String decorateArrayArg(int[] array) |
| | | private static String decorateArrayArg(int[] array) |
| | | { |
| | | StringBuilder buffer= new StringBuilder(); |
| | | buffer.append("[ "); |
| | |
| | | return buffer.toString(); |
| | | } |
| | | |
| | | private String decorateArrayArg(long[] array) |
| | | private static String decorateArrayArg(long[] array) |
| | | { |
| | | StringBuilder buffer= new StringBuilder(); |
| | | buffer.append("[ "); |
| | |
| | | return buffer.toString(); |
| | | } |
| | | |
| | | private String decorateListArg(List list) |
| | | private static String decorateListArg(List list) |
| | | { |
| | | StringBuilder buffer= new StringBuilder(); |
| | | Iterator iter= list.iterator(); |
| | |
| | | return buffer.toString(); |
| | | } |
| | | |
| | | private String decorateMapArg(Map map) |
| | | private static String decorateMapArg(Map map) |
| | | { |
| | | StringBuilder buffer= new StringBuilder(); |
| | | Iterator iter= map.entrySet().iterator(); |
| | |
| | | */ |
| | | package org.opends.server.loggers.debug; |
| | | |
| | | import static org.opends.server.util.ServerConstants.EOL; |
| | | |
| | | /** |
| | | * A DebugStackTraceFormatter converts an exception's stack trace into |
| | | * a String appropriate for tracing, optionally performing filtering |
| | |
| | | /** |
| | | * Filters out all undesired stack frames from the given Throwable's |
| | | * stack trace. |
| | | * @param t - the Throwable for which a stack trace is being generated. |
| | | * @param frames the frames to filter |
| | | * @return an array of StackTraceElements to be used in formatting. |
| | | */ |
| | | public StackTraceElement[] getFilteredStackTrace(Throwable t); |
| | | public StackTraceElement[] getFilteredStackTrace( |
| | | StackTraceElement[] frames); |
| | | } |
| | | |
| | | /** |
| | |
| | | * Return the stack trace of an exception with debug and trailing non |
| | | * OpenDS frames filtered out. |
| | | * |
| | | * @param t the throwable to filter. |
| | | * @param frames the frames to filter |
| | | * @return the filtered stack trace. |
| | | */ |
| | | public StackTraceElement[] getFilteredStackTrace(Throwable t) |
| | | public StackTraceElement[] getFilteredStackTrace( |
| | | StackTraceElement[] frames) |
| | | { |
| | | StackTraceElement[] frames= t.getStackTrace(); |
| | | StackTraceElement[] trimmedStack= null; |
| | | if (frames != null && frames.length > 0) { |
| | | int firstFrame= 0; |
| | |
| | | |
| | | while(t != null) |
| | | { |
| | | StackTraceElement[] frames= filter != null ? |
| | | filter.getFilteredStackTrace(t) : t.getStackTrace(); |
| | | StackTraceElement[] frames = t.getStackTrace(); |
| | | if(filter != null) |
| | | { |
| | | frames = filter.getFilteredStackTrace(frames); |
| | | } |
| | | |
| | | if (frames != null) { |
| | | int frameLimit= Math.min(maxDepth, frames.length); |
| | | if (frameLimit > 0) { |
| | | |
| | | |
| | | for (int i= 0; i < frameLimit; i++) { |
| | | buffer.append(" "); |
| | | buffer.append(frames[i]); |
| | | buffer.append(" / "); |
| | | buffer.append(EOL); |
| | | } |
| | | |
| | | if(frameLimit < frames.length) |
| | | { |
| | | buffer.append("...("); |
| | | buffer.append(" ...("); |
| | | buffer.append(frames.length - frameLimit); |
| | | buffer.append(" more)"); |
| | | buffer.append(EOL); |
| | | } |
| | | } |
| | | } |
| | |
| | | if(includeCause && t.getCause() != null) |
| | | { |
| | | t = t.getCause(); |
| | | buffer.append("; caused by "); |
| | | buffer.append(" caused by "); |
| | | } |
| | | else |
| | | { |
| | |
| | | |
| | | return buffer.toString(); |
| | | } |
| | | |
| | | /** |
| | | * Generate a String representation of the possibly filtered stack trace |
| | | * from the current position in executation. |
| | | * @param filter - a FrameFilter to use to exclude some stack frames from |
| | | * the trace. If null, no filtering is performed. |
| | | * @param maxDepth - the maximum number of stack frames to include in the |
| | | * trace. |
| | | * @return the stack trace. |
| | | */ |
| | | public static String formatStackTrace(FrameFilter filter, int maxDepth) |
| | | { |
| | | StringBuffer buffer= new StringBuffer(); |
| | | |
| | | StackTraceElement[] frames = Thread.currentThread().getStackTrace(); |
| | | if(filter != null) |
| | | { |
| | | frames = filter.getFilteredStackTrace(frames); |
| | | } |
| | | |
| | | if (frames != null) { |
| | | int frameLimit= Math.min(maxDepth, frames.length); |
| | | if (frameLimit > 0) { |
| | | |
| | | |
| | | for (int i= 0; i < frameLimit; i++) { |
| | | buffer.append(" "); |
| | | buffer.append(frames[i]); |
| | | buffer.append(EOL); |
| | | } |
| | | |
| | | if(frameLimit < frames.length) |
| | | { |
| | | buffer.append(" ...("); |
| | | buffer.append(frames.length - frameLimit); |
| | | buffer.append(" more)"); |
| | | buffer.append(EOL); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return buffer.toString(); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.loggers.debug; |
| | | |
| | | import org.aspectj.lang.annotation.*; |
| | | import org.aspectj.lang.JoinPoint; |
| | | import org.opends.server.api.DebugLogPublisher; |
| | | import org.opends.server.api.ProtocolElement; |
| | | import org.opends.server.types.DebugLogCategory; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import org.opends.server.loggers.LogLevel; |
| | | import org.opends.server.loggers.LogCategory; |
| | | |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.nio.ByteBuffer; |
| | | |
| | | import com.sleepycat.je.OperationStatus; |
| | | import com.sleepycat.je.Database; |
| | | import com.sleepycat.je.Transaction; |
| | | import com.sleepycat.je.DatabaseEntry; |
| | | |
| | | import static |
| | | org.opends.server.loggers.debug.DebugLogger.DEFAULT_CONSTRUCTOR_LEVEL; |
| | | import static |
| | | org.opends.server.loggers.debug.DebugLogger.DEFAULT_ENTRY_EXIT_LEVEL; |
| | | import static |
| | | org.opends.server.loggers.debug.DebugLogger.DEFAULT_THROWN_LEVEL; |
| | | import static |
| | | org.opends.server.loggers.debug.DebugLogger.debugPublishers; |
| | | import static |
| | | org.opends.server.loggers.debug.DebugLogger.classTracers; |
| | | |
| | | /** |
| | | * An aspect for source-code tracing at the method level. |
| | | * |
| | | * One DebugLogger aspect instance exists for each Java class using tracing. |
| | | * Tracer must be registered with the DebugLogger. |
| | | * |
| | | * Logging is always done at a level basis, with debug log messages |
| | | * exceeding the trace threshold being traced, others being discarded. |
| | | */ |
| | | @Aspect("pertypewithin(!@DebugLogger.NoDebugTracing org.opends.server..*+ && " + |
| | | "!org.opends.server.loggers.*+ && " + |
| | | "!org.opends.server.loggers.debug..*+ &&" + |
| | | "!org.opends.server.types.DebugLogLevel+ && " + |
| | | "!org.opends.server.types.DebugLogCategory+ && " + |
| | | "!org.opends.server.api.DebugLogPublisher+ &&" + |
| | | "!org.opends.server.util.TimeThread+)") |
| | | public class DebugTracer |
| | | { |
| | | /** |
| | | * Pointcut for matching static context events. |
| | | */ |
| | | @Pointcut("!this(Object)") |
| | | private void staticContext() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching non static context events. |
| | | * @param obj The object being operated on. |
| | | */ |
| | | @Pointcut("this(obj)") |
| | | private void nonStaticContext(Object obj) |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching all toString() methods. |
| | | */ |
| | | @Pointcut("execution(* *..toString(..))") |
| | | private void toStringMethod() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching all getMessage() methods. |
| | | */ |
| | | @Pointcut("execution(String org.opends.server." + |
| | | "messages.MessageHandler.getMessage(..))") |
| | | private void getMessageMethod() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching all getDebugProperties() methods. |
| | | * TODO: Make this less general. Find out if pointcut matches |
| | | * subclass methods. |
| | | */ |
| | | @Pointcut("execution(* *..getDebugProperties(..))") |
| | | private void getDebugPropertiesMethod() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching debugMessage() methods. |
| | | */ |
| | | @Pointcut("call(public static void org.opends.server." + |
| | | "loggers.debug.DebugLogger.debugMessage(..))") |
| | | private void logMessageMethod() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching debugVerbose() methods. |
| | | */ |
| | | @Pointcut("call(public static void org.opends.server." + |
| | | "loggers.debug.DebugLogger.debugVerbose(..))") |
| | | private void logVerboseMethod() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching debugInfo() methods. |
| | | */ |
| | | @Pointcut("call(public static void org.opends.server." + |
| | | "loggers.debug.DebugLogger.debugInfo(..))") |
| | | private void logInfoMethod() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching debugWarning() methods. |
| | | */ |
| | | @Pointcut("call(public static void org.opends.server." + |
| | | "loggers.debug.DebugLogger.debugWarning(..))") |
| | | private void logWarningMethod() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching debugError() methods. |
| | | */ |
| | | @Pointcut("call(public static void org.opends.server." + |
| | | "loggers.debug.DebugLogger.debugError(..))") |
| | | private void logErrorMethod() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching debugThrown() methods. |
| | | */ |
| | | @Pointcut("call(public static void org.opends.server." + |
| | | "loggers.debug.DebugLogger.debugThrown(..))") |
| | | private void logThrownMethod() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching debugCaught() methods. |
| | | */ |
| | | @Pointcut("call(public static void org.opends.server." + |
| | | "loggers.debug.DebugLogger.debugCaught(..))") |
| | | private void logCaughtMethod() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching debugJEAccess() methods. |
| | | */ |
| | | @Pointcut("call(public static void org.opends.server." + |
| | | "loggers.debug.DebugLogger.debugJEAccess(..))") |
| | | private void logJEAccessMethod() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching debugData() methods. |
| | | */ |
| | | @Pointcut("call(public static void org.opends.server." + |
| | | "loggers.debug.DebugLogger.debugData(..))") |
| | | private void logDataMethod() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching debugProtocolElement() methods. |
| | | */ |
| | | @Pointcut("call(public static void org.opends.server." + |
| | | "loggers.debug.DebugLogger.debugProtocolElement(..))") |
| | | private void logProtocolElementMethod() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching all debug logging methods. |
| | | */ |
| | | @Pointcut("logMessageMethod() || logVerboseMethod() || logInfoMethod() || " + |
| | | "logWarningMethod() || logErrorMethod() || logCaughtMethod() || " + |
| | | "logJEAccessMethod() || logDataMethod() || logProtocolElementMethod()") |
| | | private void logMethods() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut to exclude all pointcuts which should not be adviced by the |
| | | * debug logger. |
| | | */ |
| | | @Pointcut("toStringMethod() || getMessageMethod() || " + |
| | | "getDebugPropertiesMethod() || logMethods()") |
| | | private void excluded() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching the execution of all public methods. |
| | | */ |
| | | @Pointcut("execution(!@(DebugLogger.NoDebugTracing || " + |
| | | "DebugLogger.NoEntryDebugTracing) public * *(..)) && " + |
| | | "!excluded()") |
| | | void tracedEntryMethod() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching the execution of all public methods. |
| | | */ |
| | | @Pointcut("execution(!@(DebugLogger.NoDebugTracing || " + |
| | | "DebugLogger.NoExitDebugTracing) public * *(..)) && " + |
| | | "!excluded()") |
| | | void tracedExitMethod() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching the execution of all public methods. |
| | | */ |
| | | @Pointcut("execution(@DebugLogger.TraceThrown public * *(..)) && " + |
| | | "!excluded()") |
| | | void tracedThrownMethod() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching the execution of all constructors. |
| | | */ |
| | | @Pointcut("execution(!@(DebugLogger.NoDebugTracing || " + |
| | | "DebugLogger.NoEntryDebugTracing) public new(..)) && !excluded()") |
| | | void tracedEntryConstructor() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching the execution of all constructors. |
| | | */ |
| | | @Pointcut("execution(!@(DebugLogger.NoDebugTracing || " + |
| | | "DebugLogger.NoExitDebugTracing) public new(..)) && !excluded()") |
| | | void tracedExitConstructor() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching only if there are publishers. |
| | | * |
| | | * @return if debug logging is enabled. |
| | | */ |
| | | @Pointcut("if()") |
| | | public static boolean shouldTrace() |
| | | { |
| | | return DebugLogger.enabled; |
| | | } |
| | | |
| | | // The class this aspect traces. |
| | | String className; |
| | | |
| | | //The current class level trace settings. |
| | | ConcurrentHashMap<DebugLogPublisher, TraceSettings> classSettings = |
| | | new ConcurrentHashMap<DebugLogPublisher, TraceSettings>(); |
| | | |
| | | //The current method level trace settings. |
| | | ConcurrentHashMap<DebugLogPublisher, Map<String, TraceSettings>> |
| | | methodSettings = new ConcurrentHashMap<DebugLogPublisher, |
| | | Map<String, TraceSettings>>(); |
| | | |
| | | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | @Before("staticinitialization(*)") |
| | | public void initializeTracer(JoinPoint.StaticPart thisJoinPointStaticPart) |
| | | { |
| | | classTracers.add(this); |
| | | className = thisJoinPointStaticPart.getSignature().getDeclaringTypeName(); |
| | | |
| | | // Get the settings from all publishers. |
| | | for(DebugLogPublisher logPublisher : |
| | | debugPublishers.values()) |
| | | { |
| | | TraceSettings cSettings = logPublisher.getClassSettings(className); |
| | | classSettings.put(logPublisher, cSettings); |
| | | |
| | | // For some reason, the compiler doesn't see that |
| | | // debugLogPublihser.getMethodSettings returns a parameterized Map. |
| | | // This problem goes away if a parameterized verson of DebugLogPublisher |
| | | // is used. However, we can't not use reflection to instantiate a generic |
| | | // DebugLogPublisher<? extends DebugLogPublisherCfg> type. The only thing |
| | | // we can do is to just supress the compiler warnings. |
| | | Map<String, TraceSettings> mSettings = |
| | | logPublisher.getMethodSettings(className); |
| | | if(mSettings != null) |
| | | { |
| | | methodSettings.put(logPublisher, mSettings); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisJoinPoint the JoinPoint reflection object. |
| | | */ |
| | | @Before("shouldTrace() && tracedEntryConstructor()") |
| | | public void traceConstructor(JoinPoint thisJoinPoint) |
| | | { |
| | | String signature = thisJoinPoint.getSignature().getName(); |
| | | String sl = thisJoinPoint.getSourceLocation().toString(); |
| | | Object[] args = thisJoinPoint.getArgs(); |
| | | for(DebugLogPublisher logPublisher : debugPublishers.values()) |
| | | { |
| | | TraceSettings settings = getSettings(logPublisher, signature); |
| | | if (DEFAULT_CONSTRUCTOR_LEVEL.intValue() >= |
| | | getEffectiveLevel(settings, DebugLogCategory.CONSTRUCTOR).intValue()) |
| | | { |
| | | logPublisher.traceConstructor(DebugLogger.DEFAULT_CONSTRUCTOR_LEVEL, |
| | | settings, signature, sl, args); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisJoinPoint the JoinPoint reflection object. |
| | | * @param obj the object this method operations on. |
| | | */ |
| | | @Before("shouldTrace() && tracedEntryMethod() && nonStaticContext(obj)") |
| | | public void traceNonStaticMethodEntry(JoinPoint thisJoinPoint, Object obj) |
| | | { |
| | | String signature = thisJoinPoint.getSignature().getName(); |
| | | String sl = thisJoinPoint.getSourceLocation().toString(); |
| | | Object[] args = thisJoinPoint.getArgs(); |
| | | for(DebugLogPublisher logPublisher : debugPublishers.values()) |
| | | { |
| | | TraceSettings settings = getSettings(logPublisher, signature); |
| | | if (DEFAULT_ENTRY_EXIT_LEVEL.intValue() >= |
| | | getEffectiveLevel(settings, DebugLogCategory.ENTER).intValue()) |
| | | { |
| | | logPublisher.traceNonStaticMethodEntry(DEFAULT_ENTRY_EXIT_LEVEL, |
| | | settings, signature, sl, obj, |
| | | args); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisJoinPoint the JoinPoint reflection object. |
| | | */ |
| | | @Before("shouldTrace() && tracedEntryMethod() && staticContext()") |
| | | public void traceStaticMethodEntry(JoinPoint thisJoinPoint) |
| | | { |
| | | String signature = thisJoinPoint.getSignature().getName(); |
| | | String sl = thisJoinPoint.getSourceLocation().toString(); |
| | | Object[] args = thisJoinPoint.getArgs(); |
| | | for(DebugLogPublisher logPublisher : debugPublishers.values()) |
| | | { |
| | | TraceSettings settings = getSettings(logPublisher, signature); |
| | | if (DEFAULT_ENTRY_EXIT_LEVEL.intValue() >= |
| | | getEffectiveLevel(settings, DebugLogCategory.ENTER).intValue()) |
| | | { |
| | | logPublisher.traceStaticMethodEntry(DEFAULT_ENTRY_EXIT_LEVEL, settings, |
| | | signature, sl, args); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param ret the return value of the method. |
| | | */ |
| | | @AfterReturning(pointcut = "shouldTrace() && " + |
| | | "(tracedExitMethod() || tracedExitConstructor())", |
| | | returning = "ret") |
| | | public void traceReturn(JoinPoint.StaticPart thisJoinPointStaticPart, |
| | | Object ret) |
| | | { |
| | | String signature = thisJoinPointStaticPart.getSignature().getName(); |
| | | String sl = thisJoinPointStaticPart.getSourceLocation().toString(); |
| | | for(DebugLogPublisher logPublisher : debugPublishers.values()) |
| | | { |
| | | TraceSettings settings = getSettings(logPublisher, signature); |
| | | if (DEFAULT_ENTRY_EXIT_LEVEL.intValue() >= |
| | | getEffectiveLevel(settings, DebugLogCategory.EXIT).intValue()) |
| | | { |
| | | logPublisher.traceReturn(DEFAULT_ENTRY_EXIT_LEVEL, settings, signature, |
| | | sl, ret); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param ex the exception thrown. |
| | | */ |
| | | @SuppressAjWarnings({"adviceDidNotMatch"}) |
| | | @AfterThrowing(pointcut = "shouldTrace() && tracedThrownMethod()", |
| | | throwing = "ex") |
| | | public void traceThrown(JoinPoint.StaticPart thisJoinPointStaticPart, |
| | | Throwable ex) |
| | | { |
| | | String signature = thisJoinPointStaticPart.getSignature().getName(); |
| | | String sl = thisJoinPointStaticPart.getSourceLocation().toString(); |
| | | for(DebugLogPublisher logPublisher : debugPublishers.values()) |
| | | { |
| | | TraceSettings settings = getSettings(logPublisher, signature); |
| | | if (DEFAULT_THROWN_LEVEL.intValue() >= |
| | | getEffectiveLevel(settings, DebugLogCategory.THROWN).intValue()) |
| | | { |
| | | logPublisher.traceThrown(DEFAULT_THROWN_LEVEL, settings, signature, sl, |
| | | ex); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param level the level of the log message. |
| | | * @param ex the exception thrown. |
| | | */ |
| | | @SuppressAjWarnings({"adviceDidNotMatch"}) |
| | | @Around("shouldTrace() && logThrownMethod() && args(level, ex)") |
| | | public void traceThrown(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | LogLevel level, Throwable ex) |
| | | { |
| | | String signature = |
| | | thisEnclosingJoinPointStaticPart.getSignature().getName(); |
| | | String sl = thisJoinPointStaticPart.getSourceLocation().toString(); |
| | | for(DebugLogPublisher logPublisher : debugPublishers.values()) |
| | | { |
| | | TraceSettings settings = getSettings(logPublisher, signature); |
| | | if (level.intValue() >= |
| | | getEffectiveLevel(settings, DebugLogCategory.THROWN).intValue()) |
| | | { |
| | | logPublisher.traceThrown(level, settings, signature, sl, ex); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param msg message to format and log. |
| | | */ |
| | | @SuppressAjWarnings({"adviceDidNotMatch"}) |
| | | @Around("shouldTrace() && logVerboseMethod() && args(msg)") |
| | | public void traceVerbose(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | String msg) |
| | | { |
| | | String signature = |
| | | thisEnclosingJoinPointStaticPart.getSignature().getName(); |
| | | String sl = thisJoinPointStaticPart.getSourceLocation().toString(); |
| | | for(DebugLogPublisher logPublisher : debugPublishers.values()) |
| | | { |
| | | TraceSettings settings = getSettings(logPublisher, signature); |
| | | if (DebugLogLevel.VERBOSE.intValue() >= |
| | | getEffectiveLevel(settings, DebugLogCategory.MESSAGE).intValue()) |
| | | { |
| | | logPublisher.traceMessage(DebugLogLevel.VERBOSE, settings, signature, |
| | | sl, msg); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param msg message to format and log. |
| | | * @param msgArgs arguments to place into the format string. |
| | | */ |
| | | @SuppressAjWarnings({"adviceDidNotMatch"}) |
| | | @Around("shouldTrace() && logVerboseMethod() && args(msg, msgArgs)") |
| | | public void traceVerbose(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | String msg, Object[] msgArgs) |
| | | { |
| | | String signature = |
| | | thisEnclosingJoinPointStaticPart.getSignature().getName(); |
| | | String sl = thisJoinPointStaticPart.getSourceLocation().toString(); |
| | | msg = DebugMessageFormatter.format(msg, msgArgs); |
| | | for(DebugLogPublisher logPublisher : debugPublishers.values()) |
| | | { |
| | | TraceSettings settings = getSettings(logPublisher, signature); |
| | | if (DebugLogLevel.VERBOSE.intValue() >= |
| | | getEffectiveLevel(settings, DebugLogCategory.MESSAGE).intValue()) |
| | | { |
| | | logPublisher.traceMessage(DebugLogLevel.VERBOSE, settings, signature, |
| | | sl, msg); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param msg message to format and log. |
| | | */ |
| | | @SuppressAjWarnings({"adviceDidNotMatch"}) |
| | | @Around("shouldTrace() && logInfoMethod() && args(msg)") |
| | | public void traceInfo(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | String msg) |
| | | { |
| | | String signature = |
| | | thisEnclosingJoinPointStaticPart.getSignature().getName(); |
| | | String sl = thisJoinPointStaticPart.getSourceLocation().toString(); |
| | | for(DebugLogPublisher logPublisher : debugPublishers.values()) |
| | | { |
| | | TraceSettings settings = getSettings(logPublisher, signature); |
| | | if (DebugLogLevel.INFO.intValue() >= |
| | | getEffectiveLevel(settings, DebugLogCategory.MESSAGE).intValue()) |
| | | { |
| | | logPublisher.traceMessage(DebugLogLevel.INFO, settings, signature, sl, |
| | | msg); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param msg message to format and log. |
| | | * @param msgArgs arguments to place into the format string. |
| | | */ |
| | | @SuppressAjWarnings({"adviceDidNotMatch"}) |
| | | @Around("shouldTrace() && logInfoMethod() && args(msg, msgArgs)") |
| | | public void traceInfo(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | String msg, Object[] msgArgs) |
| | | { |
| | | String signature = |
| | | thisEnclosingJoinPointStaticPart.getSignature().getName(); |
| | | String sl = thisJoinPointStaticPart.getSourceLocation().toString(); |
| | | msg = DebugMessageFormatter.format(msg, msgArgs); |
| | | for(DebugLogPublisher logPublisher : debugPublishers.values()) |
| | | { |
| | | TraceSettings settings = getSettings(logPublisher, signature); |
| | | if (DebugLogLevel.INFO.intValue() >= |
| | | getEffectiveLevel(settings, DebugLogCategory.MESSAGE).intValue()) |
| | | { |
| | | logPublisher.traceMessage(DebugLogLevel.INFO, settings, signature, sl, |
| | | msg); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param msg message to format and log. |
| | | */ |
| | | @SuppressAjWarnings({"adviceDidNotMatch"}) |
| | | @Around("shouldTrace() && logWarningMethod() && args(msg)") |
| | | public void traceWarning(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | String msg) |
| | | |
| | | { |
| | | String signature = |
| | | thisEnclosingJoinPointStaticPart.getSignature().getName(); |
| | | String sl = thisJoinPointStaticPart.getSourceLocation().toString(); |
| | | for(DebugLogPublisher logPublisher : debugPublishers.values()) |
| | | { |
| | | TraceSettings settings = getSettings(logPublisher, signature); |
| | | if (DebugLogLevel.WARNING.intValue() >= |
| | | getEffectiveLevel(settings, DebugLogCategory.MESSAGE).intValue()) |
| | | { |
| | | logPublisher.traceMessage(DebugLogLevel.WARNING, settings, signature, |
| | | sl, msg); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param msg message to format and log. |
| | | * @param msgArgs arguments to place into the format string. |
| | | */ |
| | | @SuppressAjWarnings({"adviceDidNotMatch"}) |
| | | @Around("shouldTrace() && logWarningMethod() && args(msg, msgArgs)") |
| | | public void traceWarning(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | String msg, Object[] msgArgs) |
| | | { |
| | | String signature = |
| | | thisEnclosingJoinPointStaticPart.getSignature().getName(); |
| | | String sl = thisJoinPointStaticPart.getSourceLocation().toString(); |
| | | msg = DebugMessageFormatter.format(msg, msgArgs); |
| | | for(DebugLogPublisher logPublisher : debugPublishers.values()) |
| | | { |
| | | TraceSettings settings = getSettings(logPublisher, signature); |
| | | if (DebugLogLevel.WARNING.intValue() >= |
| | | getEffectiveLevel(settings, DebugLogCategory.MESSAGE).intValue()) |
| | | { |
| | | logPublisher.traceMessage(DebugLogLevel.WARNING, settings, signature, |
| | | sl, msg); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param msg message to format and log. |
| | | */ |
| | | @SuppressAjWarnings({"adviceDidNotMatch"}) |
| | | @Around("shouldTrace() && logErrorMethod() && args(msg)") |
| | | public void traceError(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | String msg) |
| | | |
| | | { |
| | | String signature = |
| | | thisEnclosingJoinPointStaticPart.getSignature().getName(); |
| | | String sl = thisJoinPointStaticPart.getSourceLocation().toString(); |
| | | for(DebugLogPublisher logPublisher : debugPublishers.values()) |
| | | { |
| | | TraceSettings settings = getSettings(logPublisher, signature); |
| | | if (DebugLogLevel.ERROR.intValue() >= |
| | | getEffectiveLevel(settings, DebugLogCategory.MESSAGE).intValue()) |
| | | { |
| | | logPublisher.traceMessage(DebugLogLevel.ERROR, settings, signature, sl, |
| | | msg); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param msg message to format and log. |
| | | * @param msgArgs arguments to place into the format string. |
| | | */ |
| | | @SuppressAjWarnings({"adviceDidNotMatch"}) |
| | | @Around("shouldTrace() && logErrorMethod() && args(msg, msgArgs)") |
| | | public void traceError(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | String msg, Object[] msgArgs) |
| | | { |
| | | String signature = |
| | | thisEnclosingJoinPointStaticPart.getSignature().getName(); |
| | | String sl = thisJoinPointStaticPart.getSourceLocation().toString(); |
| | | msg = DebugMessageFormatter.format(msg, msgArgs); |
| | | for(DebugLogPublisher logPublisher : debugPublishers.values()) |
| | | { |
| | | TraceSettings settings = getSettings(logPublisher, signature); |
| | | if (DebugLogLevel.ERROR.intValue() >= |
| | | getEffectiveLevel(settings, DebugLogCategory.MESSAGE).intValue()) |
| | | { |
| | | logPublisher.traceMessage(DebugLogLevel.ERROR, settings, signature, sl, |
| | | msg); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param level the level of the log message. |
| | | * @param msg message to format and log. |
| | | */ |
| | | @SuppressAjWarnings({"adviceDidNotMatch"}) |
| | | @Around("shouldTrace() && logMessageMethod() && args(level, msg)") |
| | | public void traceMessage(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | LogLevel level, String msg) |
| | | { |
| | | String signature = |
| | | thisEnclosingJoinPointStaticPart.getSignature().getName(); |
| | | String sl = thisJoinPointStaticPart.getSourceLocation().toString(); |
| | | for(DebugLogPublisher logPublisher : debugPublishers.values()) |
| | | { |
| | | TraceSettings settings = getSettings(logPublisher, signature); |
| | | if (level.intValue() >= |
| | | getEffectiveLevel(settings, DebugLogCategory.MESSAGE).intValue()) |
| | | { |
| | | logPublisher.traceMessage(level, settings, signature, sl, msg); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param level the level of the log message. |
| | | * @param msg message to format and log. |
| | | * @param msgArgs arguments to place into the format string. |
| | | */ |
| | | @SuppressAjWarnings({"adviceDidNotMatch"}) |
| | | @Around("shouldTrace() && logMessageMethod() && args(level, msg, msgArgs)") |
| | | public void traceMessage(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | LogLevel level, String msg, Object... msgArgs) |
| | | { |
| | | String signature = |
| | | thisEnclosingJoinPointStaticPart.getSignature().getName(); |
| | | String sl = thisJoinPointStaticPart.getSourceLocation().toString(); |
| | | msg = DebugMessageFormatter.format(msg, msgArgs); |
| | | for(DebugLogPublisher logPublisher : debugPublishers.values()) |
| | | { |
| | | TraceSettings settings = getSettings(logPublisher, signature); |
| | | if (level.intValue() >= |
| | | getEffectiveLevel(settings, DebugLogCategory.MESSAGE).intValue()) |
| | | { |
| | | logPublisher.traceMessage(level, settings, signature, sl, msg); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param level the level of the log message. |
| | | * @param ex the exception caught. |
| | | */ |
| | | @SuppressAjWarnings({"adviceDidNotMatch"}) |
| | | @Around("shouldTrace() && logCaughtMethod() && args(level, ex)") |
| | | public void traceCaught(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | LogLevel level, Throwable ex) |
| | | { |
| | | String signature = |
| | | thisEnclosingJoinPointStaticPart.getSignature().getName(); |
| | | String sl = thisJoinPointStaticPart.getSourceLocation().toString(); |
| | | for(DebugLogPublisher logPublisher : debugPublishers.values()) |
| | | { |
| | | TraceSettings settings = getSettings(logPublisher, signature); |
| | | if (level.intValue() >= |
| | | getEffectiveLevel(settings, DebugLogCategory.CAUGHT).intValue()) |
| | | { |
| | | logPublisher.traceCaught(level, settings, signature, sl, ex); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param level the level of the log message. |
| | | * @param status status of the JE operation. |
| | | * @param database the database handle. |
| | | * @param txn transaction handle (may be null). |
| | | * @param key the key to dump. |
| | | * @param data the data to dump. |
| | | */ |
| | | @SuppressAjWarnings({"adviceDidNotMatch"}) |
| | | @Around("shouldTrace() && logJEAccessMethod() && args(level, status, " + |
| | | "database, txn, key, data)") |
| | | public void traceJEAccess(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | LogLevel level, OperationStatus status, |
| | | Database database, Transaction txn, |
| | | DatabaseEntry key, DatabaseEntry data) |
| | | { |
| | | String signature = |
| | | thisEnclosingJoinPointStaticPart.getSignature().getName(); |
| | | String sl = thisJoinPointStaticPart.getSourceLocation().toString(); |
| | | for(DebugLogPublisher logPublisher : debugPublishers.values()) |
| | | { |
| | | TraceSettings settings = getSettings(logPublisher, signature); |
| | | if (level.intValue() >= |
| | | getEffectiveLevel(settings, |
| | | DebugLogCategory.DATABASE_ACCESS).intValue()) |
| | | { |
| | | logPublisher.traceJEAccess(level, settings, signature, sl, status, |
| | | database, txn, key, data); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param level the level of the log message. |
| | | * @param data the data to dump. |
| | | */ |
| | | @SuppressAjWarnings({"adviceDidNotMatch"}) |
| | | @Around("shouldTrace() && logDataMethod() && args(level, data)") |
| | | public void traceData(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | LogLevel level, byte[] data) |
| | | { |
| | | String signature = |
| | | thisEnclosingJoinPointStaticPart.getSignature().getName(); |
| | | String sl = thisJoinPointStaticPart.getSourceLocation().toString(); |
| | | for(DebugLogPublisher logPublisher : debugPublishers.values()) |
| | | { |
| | | TraceSettings settings = getSettings(logPublisher, signature); |
| | | if (level.intValue() >= |
| | | getEffectiveLevel(settings, DebugLogCategory.DATA).intValue()) |
| | | { |
| | | logPublisher.traceData(level, settings, signature, sl, data); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param level the level of the log message. |
| | | * @param element the protocol element to dump. |
| | | */ |
| | | @SuppressAjWarnings({"adviceDidNotMatch"}) |
| | | @Around("shouldTrace() && logProtocolElementMethod() && args(level, element)") |
| | | public void traceProtocolElement(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | LogLevel level, ProtocolElement element) |
| | | { |
| | | String signature = |
| | | thisEnclosingJoinPointStaticPart.getSignature().getName(); |
| | | String sl = thisJoinPointStaticPart.getSourceLocation().toString(); |
| | | for(DebugLogPublisher logPublisher : debugPublishers.values()) |
| | | { |
| | | TraceSettings settings = getSettings(logPublisher, signature); |
| | | if (level.intValue() >= |
| | | getEffectiveLevel(settings, DebugLogCategory.PROTOCOL).intValue()) |
| | | { |
| | | logPublisher.traceProtocolElement(level, settings, signature, sl, |
| | | element); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param level the level of the log message. |
| | | * @param buffer the data to dump. |
| | | */ |
| | | @SuppressAjWarnings({"adviceDidNotMatch"}) |
| | | @Around("shouldTrace() && logDataMethod() && args(level, buffer)") |
| | | public void traceData(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | LogLevel level, ByteBuffer buffer) |
| | | { |
| | | String signature = |
| | | thisEnclosingJoinPointStaticPart.getSignature().getName(); |
| | | String sl = thisJoinPointStaticPart.getSourceLocation().toString(); |
| | | for(DebugLogPublisher logPublisher : debugPublishers.values()) |
| | | { |
| | | TraceSettings settings = getSettings(logPublisher, signature); |
| | | if (level.intValue() >= |
| | | getEffectiveLevel(settings, DebugLogCategory.DATA).intValue()) |
| | | { |
| | | logPublisher.traceData(level, settings, signature, sl, buffer.array()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Get the current trace settings in effect for the specified method. |
| | | * |
| | | * @param debugLogPublisher - the debug publisher to get the trace settings |
| | | * from. |
| | | * @param method - the method to get trace settings for |
| | | * @return the current trace settings in effect |
| | | */ |
| | | protected final TraceSettings getSettings(DebugLogPublisher debugLogPublisher, |
| | | String method) |
| | | { |
| | | TraceSettings settings = this.classSettings.get(debugLogPublisher); |
| | | |
| | | Map<String, TraceSettings> methodSettings = |
| | | this.methodSettings.get(debugLogPublisher); |
| | | if (methodSettings != null) |
| | | { |
| | | TraceSettings mSettings = methodSettings.get(method); |
| | | |
| | | if (mSettings == null) |
| | | { |
| | | // Try looking for an undecorated method name |
| | | int idx = method.indexOf('('); |
| | | if (idx != -1) |
| | | { |
| | | mSettings = |
| | | methodSettings.get(method.substring(0, idx)); |
| | | } |
| | | } |
| | | |
| | | if (mSettings != null) settings = mSettings; |
| | | } |
| | | |
| | | return settings; |
| | | } |
| | | |
| | | /** |
| | | * Retrieve the current log level given the trace settings and log category. |
| | | * |
| | | * @param settings the trace settings to test from. |
| | | * @param category the log category to test. |
| | | * @return the effective log level. |
| | | */ |
| | | protected final LogLevel getEffectiveLevel(TraceSettings settings, |
| | | LogCategory category) |
| | | { |
| | | LogLevel level = settings.level; |
| | | Set<LogCategory> includedCategories = settings.includeCategories; |
| | | |
| | | if(includedCategories != null && |
| | | !includedCategories.contains(category)) |
| | | { |
| | | level = DebugLogLevel.DISABLED; |
| | | } |
| | | |
| | | return level; |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.loggers.debug; |
| | | |
| | | import org.opends.server.api.*; |
| | | import org.opends.server.loggers.*; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.opends.server.util.TimeThread; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | | import static org.opends.server.util.StaticUtils.getFileForPath; |
| | | import static org.opends.server.util.ServerConstants.PROPERTY_DEBUG_TARGET; |
| | | import org.opends.server.admin.std.server.DebugTargetCfg; |
| | | import org.opends.server.admin.std.server.FileBasedDebugLogPublisherCfg; |
| | | import org.opends.server.admin.std.meta.DebugLogPublisherCfgDefn; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.server.ConfigurationDeleteListener; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import static org.opends.server.messages.ConfigMessages. |
| | | MSGID_CONFIG_LOGGER_INVALID_ROTATION_POLICY; |
| | | import static org.opends.server.messages.ConfigMessages. |
| | | MSGID_CONFIG_LOGGER_INVALID_RETENTION_POLICY; |
| | | import static org.opends.server.messages.ConfigMessages. |
| | | MSGID_CONFIG_LOGGING_CANNOT_CREATE_WRITER; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | |
| | | import java.util.*; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | |
| | | import com.sleepycat.je.*; |
| | | |
| | | /** |
| | | * The debug log publisher implementation that writes debug messages to files |
| | | * on disk. It also maintains the rotation and retention polices of the log |
| | | * files. |
| | | */ |
| | | public class TextDebugLogPublisher |
| | | extends DebugLogPublisher<FileBasedDebugLogPublisherCfg> |
| | | implements ConfigurationChangeListener<FileBasedDebugLogPublisherCfg>, |
| | | ConfigurationAddListener<DebugTargetCfg>, |
| | | ConfigurationDeleteListener<DebugTargetCfg> |
| | | { |
| | | private static long globalSequenceNumber; |
| | | |
| | | private TextWriter writer; |
| | | |
| | | private FileBasedDebugLogPublisherCfg currentConfig; |
| | | |
| | | /** |
| | | * Returns an instance of the text debug log publisher that will print |
| | | * all messages to the provided writer. This is used to print the messages |
| | | * to the console when the server starts up. By default, only error level |
| | | * messages are printed. Special debug targets are also parsed from |
| | | * system properties if any are specified. |
| | | * |
| | | * @param writer The text writer where the message will be written to. |
| | | * @return The instance of the text error log publisher that will print |
| | | * all messages to standard out. |
| | | */ |
| | | public static TextDebugLogPublisher |
| | | getStartupTextDebugPublisher(TextWriter writer) |
| | | { |
| | | TextDebugLogPublisher startupPublisher = new TextDebugLogPublisher(); |
| | | startupPublisher.writer = writer; |
| | | |
| | | startupPublisher.addTraceSettings(null, |
| | | new TraceSettings(DebugLogLevel.ERROR)); |
| | | |
| | | Set<Map.Entry<Object, Object>> propertyEntries = |
| | | System.getProperties().entrySet(); |
| | | for(Map.Entry<Object, Object> entry : propertyEntries) |
| | | { |
| | | if(((String)entry.getKey()).startsWith(PROPERTY_DEBUG_TARGET)) |
| | | { |
| | | String value = (String)entry.getValue(); |
| | | int settingsStart= value.indexOf(":"); |
| | | |
| | | //See if the scope and settings exists |
| | | if(settingsStart > 0) |
| | | { |
| | | String scope = value.substring(0, settingsStart); |
| | | TraceSettings settings = |
| | | TraceSettings.parseTraceSettings( |
| | | value.substring(settingsStart+1)); |
| | | if(settings != null) |
| | | { |
| | | startupPublisher.addTraceSettings(scope, settings); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | return startupPublisher; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void initializeDebugLogPublisher(FileBasedDebugLogPublisherCfg config) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | File logFile = getFileForPath(config.getLogFile()); |
| | | FileNamingPolicy fnPolicy = new TimeStampNaming(logFile); |
| | | |
| | | try |
| | | { |
| | | FilePermission perm = |
| | | FilePermission.decodeUNIXMode(config.getLogFileMode()); |
| | | |
| | | LogPublisherErrorHandler errorHandler = |
| | | new LogPublisherErrorHandler(config.dn()); |
| | | |
| | | boolean writerAutoFlush = |
| | | config.isAutoFlush() && !config.isAsynchronous(); |
| | | |
| | | MultifileTextWriter writer = |
| | | new MultifileTextWriter("Multifile Text Writer for " + |
| | | config.dn().toNormalizedString(), |
| | | config.getTimeInterval(), |
| | | fnPolicy, |
| | | perm, |
| | | errorHandler, |
| | | "UTF-8", |
| | | writerAutoFlush, |
| | | config.isAppend(), |
| | | (int)config.getBufferSize()); |
| | | |
| | | // Validate retention and rotation policies. |
| | | for(DN dn : config.getRotationPolicyDN()) |
| | | { |
| | | RotationPolicy policy = DirectoryServer.getRotationPolicy(dn); |
| | | if(policy != null) |
| | | { |
| | | writer.addRotationPolicy(policy); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ROTATION_POLICY; |
| | | String message = getMessage(msgID, dn.toString(), |
| | | config.dn().toString()); |
| | | throw new ConfigException(msgID, message); |
| | | } |
| | | } |
| | | for(DN dn: config.getRetentionPolicyDN()) |
| | | { |
| | | RetentionPolicy policy = DirectoryServer.getRetentionPolicy(dn); |
| | | if(policy != null) |
| | | { |
| | | writer.addRetentionPolicy(policy); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_RETENTION_POLICY; |
| | | String message = getMessage(msgID, dn.toString(), |
| | | config.dn().toString()); |
| | | throw new ConfigException(msgID, message); |
| | | } |
| | | } |
| | | |
| | | if(config.isAsynchronous()) |
| | | { |
| | | this.writer = new AsyncronousTextWriter("Asyncronous Text Writer for " + |
| | | config.dn().toNormalizedString(), config.getQueueSize(), |
| | | config.isAutoFlush(), writer); |
| | | } |
| | | else |
| | | { |
| | | this.writer = writer; |
| | | } |
| | | } |
| | | catch(DirectoryException e) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGING_CANNOT_CREATE_WRITER; |
| | | String message = getMessage(msgID, config.dn().toString(), |
| | | String.valueOf(e)); |
| | | throw new InitializationException(msgID, message, e); |
| | | |
| | | } |
| | | catch(IOException e) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGING_CANNOT_CREATE_WRITER; |
| | | String message = getMessage(msgID, config.dn().toString(), |
| | | String.valueOf(e)); |
| | | throw new InitializationException(msgID, message, e); |
| | | |
| | | } |
| | | |
| | | |
| | | config.addDebugTargetAddListener(this); |
| | | config.addDebugTargetDeleteListener(this); |
| | | |
| | | //Get the default/global settings |
| | | LogLevel logLevel = |
| | | DebugLogLevel.parse(config.getDefaultDebugLevel().name()); |
| | | Set<LogCategory> logCategories = null; |
| | | if(!config.getDefaultDebugCategory().isEmpty()) |
| | | { |
| | | logCategories = |
| | | new HashSet<LogCategory>(config.getDefaultDebugCategory().size()); |
| | | for(DebugLogPublisherCfgDefn.DefaultDebugCategory category : |
| | | config.getDefaultDebugCategory()) |
| | | { |
| | | logCategories.add(DebugLogCategory.parse(category.name())); |
| | | } |
| | | } |
| | | |
| | | TraceSettings defaultSettings = |
| | | new TraceSettings(logLevel, logCategories, |
| | | config.isDefaultOmitMethodEntryArguments(), |
| | | config.isDefaultOmitMethodReturnValue(), |
| | | config.getDefaultThrowableStackFrames(), |
| | | config.isDefaultIncludeThrowableCause()); |
| | | |
| | | addTraceSettings(null, defaultSettings); |
| | | |
| | | for(String name : config.listDebugTargets()) |
| | | { |
| | | DebugTargetCfg targetCfg = config.getDebugTarget(name); |
| | | |
| | | addTraceSettings(targetCfg.getDebugScope(), new TraceSettings(targetCfg)); |
| | | } |
| | | |
| | | currentConfig = config; |
| | | |
| | | config.addFileBasedDebugChangeListener(this); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationChangeAcceptable( |
| | | FileBasedDebugLogPublisherCfg config, List<String> unacceptableReasons) |
| | | { |
| | | // Make sure the permission is valid. |
| | | try |
| | | { |
| | | if(!currentConfig.getLogFileMode().equalsIgnoreCase( |
| | | config.getLogFileMode())) |
| | | { |
| | | FilePermission.decodeUNIXMode(config.getLogFileMode()); |
| | | } |
| | | if(!currentConfig.getLogFile().equalsIgnoreCase(config.getLogFile())) |
| | | { |
| | | File logFile = getFileForPath(config.getLogFile()); |
| | | if(logFile.createNewFile()) |
| | | { |
| | | logFile.delete(); |
| | | } |
| | | } |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGING_CANNOT_CREATE_WRITER; |
| | | String message = getMessage(msgID, config.dn().toString(), |
| | | stackTraceToSingleLineString(e)); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | |
| | | // Validate retention and rotation policies. |
| | | for(DN dn : config.getRotationPolicyDN()) |
| | | { |
| | | RotationPolicy policy = DirectoryServer.getRotationPolicy(dn); |
| | | if(policy == null) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ROTATION_POLICY; |
| | | String message = getMessage(msgID, dn.toString(), |
| | | config.dn().toString()); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | } |
| | | for(DN dn: config.getRetentionPolicyDN()) |
| | | { |
| | | RetentionPolicy policy = DirectoryServer.getRetentionPolicy(dn); |
| | | if(policy != null) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_RETENTION_POLICY; |
| | | String message = getMessage(msgID, dn.toString(), |
| | | config.dn().toString()); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | FileBasedDebugLogPublisherCfg config) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | //Get the default/global settings |
| | | LogLevel logLevel = |
| | | DebugLogLevel.parse(config.getDefaultDebugLevel().name()); |
| | | Set<LogCategory> logCategories = null; |
| | | if(!config.getDefaultDebugCategory().isEmpty()) |
| | | { |
| | | logCategories = |
| | | new HashSet<LogCategory>(config.getDefaultDebugCategory().size()); |
| | | for(DebugLogPublisherCfgDefn.DefaultDebugCategory category : |
| | | config.getDefaultDebugCategory()) |
| | | { |
| | | logCategories.add(DebugLogCategory.parse(category.name())); |
| | | } |
| | | } |
| | | |
| | | TraceSettings defaultSettings = |
| | | new TraceSettings(logLevel, logCategories, |
| | | config.isDefaultOmitMethodEntryArguments(), |
| | | config.isDefaultOmitMethodReturnValue(), |
| | | config.getDefaultThrowableStackFrames(), |
| | | config.isDefaultIncludeThrowableCause()); |
| | | |
| | | addTraceSettings(null, defaultSettings); |
| | | |
| | | DebugLogger.addTracerSettings(this); |
| | | |
| | | File logFile = getFileForPath(config.getLogFile()); |
| | | FileNamingPolicy fnPolicy = new TimeStampNaming(logFile); |
| | | |
| | | try |
| | | { |
| | | FilePermission perm = |
| | | FilePermission.decodeUNIXMode(config.getLogFileMode()); |
| | | |
| | | boolean writerAutoFlush = |
| | | config.isAutoFlush() && !config.isAsynchronous(); |
| | | |
| | | TextWriter currentWriter; |
| | | // Determine the writer we are using. If we were writing asyncronously, |
| | | // we need to modify the underlaying writer. |
| | | if(writer instanceof AsyncronousTextWriter) |
| | | { |
| | | currentWriter = ((AsyncronousTextWriter)writer).getWrappedWriter(); |
| | | } |
| | | else |
| | | { |
| | | currentWriter = writer; |
| | | } |
| | | |
| | | if(currentWriter instanceof MultifileTextWriter) |
| | | { |
| | | MultifileTextWriter mfWriter = (MultifileTextWriter)writer; |
| | | |
| | | mfWriter.setNamingPolicy(fnPolicy); |
| | | mfWriter.setFilePermissions(perm); |
| | | mfWriter.setAppend(config.isAppend()); |
| | | mfWriter.setAutoFlush(writerAutoFlush); |
| | | mfWriter.setBufferSize((int)config.getBufferSize()); |
| | | mfWriter.setInterval(config.getTimeInterval()); |
| | | |
| | | mfWriter.removeAllRetentionPolicies(); |
| | | mfWriter.removeAllRotationPolicies(); |
| | | |
| | | for(DN dn : config.getRotationPolicyDN()) |
| | | { |
| | | RotationPolicy policy = DirectoryServer.getRotationPolicy(dn); |
| | | if(policy != null) |
| | | { |
| | | mfWriter.addRotationPolicy(policy); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_ROTATION_POLICY; |
| | | String message = getMessage(msgID, dn.toString(), |
| | | config.dn().toString()); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | messages.add(message); |
| | | } |
| | | } |
| | | for(DN dn: config.getRetentionPolicyDN()) |
| | | { |
| | | RetentionPolicy policy = DirectoryServer.getRetentionPolicy(dn); |
| | | if(policy != null) |
| | | { |
| | | mfWriter.addRetentionPolicy(policy); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGER_INVALID_RETENTION_POLICY; |
| | | String message = getMessage(msgID, dn.toString(), |
| | | config.dn().toString()); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | messages.add(message); |
| | | } |
| | | } |
| | | |
| | | |
| | | if(writer instanceof AsyncronousTextWriter && !config.isAsynchronous()) |
| | | { |
| | | // The asynronous setting is being turned off. |
| | | AsyncronousTextWriter asyncWriter = ((AsyncronousTextWriter)writer); |
| | | writer = mfWriter; |
| | | asyncWriter.shutdown(false); |
| | | } |
| | | |
| | | if(!(writer instanceof AsyncronousTextWriter) && |
| | | config.isAsynchronous()) |
| | | { |
| | | // The asynronous setting is being turned on. |
| | | AsyncronousTextWriter asyncWriter = |
| | | new AsyncronousTextWriter("Asyncronous Text Writer for " + |
| | | config.dn().toNormalizedString(), config.getQueueSize(), |
| | | config.isAutoFlush(), |
| | | mfWriter); |
| | | writer = asyncWriter; |
| | | } |
| | | |
| | | if((currentConfig.isAsynchronous() && config.isAsynchronous()) && |
| | | (currentConfig.getQueueSize() != config.getQueueSize())) |
| | | { |
| | | adminActionRequired = true; |
| | | } |
| | | |
| | | currentConfig = config; |
| | | } |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | int msgID = MSGID_CONFIG_LOGGING_CANNOT_CREATE_WRITER; |
| | | String message = getMessage(msgID, config.dn().toString(), |
| | | stackTraceToSingleLineString(e)); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | messages.add(message); |
| | | |
| | | } |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationAddAcceptable(DebugTargetCfg config, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | return getTraceSettings(config.getDebugScope()) == null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationDeleteAcceptable(DebugTargetCfg config, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | // A delete should always be acceptable. |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationAdd(DebugTargetCfg config) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | addTraceSettings(config.getDebugScope(), new TraceSettings(config)); |
| | | |
| | | DebugLogger.addTracerSettings(this); |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationDelete(DebugTargetCfg config) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | removeTraceSettings(config.getDebugScope()); |
| | | |
| | | DebugLogger.addTracerSettings(this); |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void traceConstructor(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, |
| | | Object[] args) |
| | | { |
| | | LogCategory category = DebugLogCategory.CONSTRUCTOR; |
| | | String msg = ""; |
| | | if(!settings.noArgs) |
| | | { |
| | | msg = buildDefaultEntryMessage(args); |
| | | } |
| | | publish(category, level, signature, sourceLocation, msg, null); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void traceNonStaticMethodEntry(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, |
| | | Object obj, |
| | | Object[] args) |
| | | { |
| | | LogCategory category = DebugLogCategory.ENTER; |
| | | String msg = ""; |
| | | if(!settings.noArgs) |
| | | { |
| | | msg = buildDefaultEntryMessage(args); |
| | | } |
| | | String stack = null; |
| | | int stackDepth = settings.stackDepth; |
| | | |
| | | // Inject a stack trace if requested |
| | | if (stackDepth > 0) { |
| | | stack = DebugStackTraceFormatter.formatStackTrace( |
| | | DebugStackTraceFormatter.SMART_FRAME_FILTER, |
| | | stackDepth); |
| | | } |
| | | publish(category, level, signature, sourceLocation, msg, stack); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void traceStaticMethodEntry(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, |
| | | Object[] args) |
| | | { |
| | | LogCategory category = DebugLogCategory.ENTER; |
| | | String msg = ""; |
| | | if(!settings.noArgs) |
| | | { |
| | | msg = buildDefaultEntryMessage(args); |
| | | } |
| | | String stack = null; |
| | | int stackDepth = settings.stackDepth; |
| | | |
| | | // Inject a stack trace if requested |
| | | if (stackDepth > 0) { |
| | | stack= |
| | | DebugStackTraceFormatter.formatStackTrace( |
| | | DebugStackTraceFormatter.SMART_FRAME_FILTER, |
| | | stackDepth); |
| | | } |
| | | publish(category, level, signature, sourceLocation, msg, stack); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void traceReturn(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, |
| | | Object ret) |
| | | { |
| | | LogCategory category = DebugLogCategory.EXIT; |
| | | String msg = ""; |
| | | if(!settings.noRetVal) |
| | | { |
| | | msg = DebugMessageFormatter.format("returned={%s}", |
| | | new Object[] {ret}); |
| | | } |
| | | publish(category, level, signature, sourceLocation, msg, null); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void traceThrown(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, |
| | | Throwable ex) |
| | | { |
| | | LogCategory category = DebugLogCategory.THROWN; |
| | | String stack = null; |
| | | int stackDepth = settings.stackDepth; |
| | | |
| | | String msg = DebugMessageFormatter.format("thrown={%s}", |
| | | new Object[] {ex}); |
| | | |
| | | // Inject a stack trace if requested |
| | | if (stackDepth > 0) { |
| | | stack= |
| | | DebugStackTraceFormatter.formatStackTrace(ex, |
| | | DebugStackTraceFormatter.SMART_FRAME_FILTER, |
| | | stackDepth, settings.includeCause); |
| | | } |
| | | publish(category, level, signature, sourceLocation, msg, stack); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void traceMessage(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, |
| | | String msg) |
| | | { |
| | | LogCategory category = DebugLogCategory.MESSAGE; |
| | | publish(category, level, signature, sourceLocation, msg, null); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void traceCaught(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, Throwable ex) |
| | | { |
| | | LogCategory category = DebugLogCategory.CAUGHT; |
| | | String msg = DebugMessageFormatter.format("caught={%s}", |
| | | new Object[] {ex}); |
| | | |
| | | publish(category, level, signature, sourceLocation, msg, null); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void traceJEAccess(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, |
| | | OperationStatus status, |
| | | Database database, Transaction txn, |
| | | DatabaseEntry key, DatabaseEntry data) |
| | | { |
| | | LogCategory category = DebugLogCategory.DATABASE_ACCESS; |
| | | |
| | | // Build the string that is common to category DATABASE_ACCESS. |
| | | StringBuilder builder = new StringBuilder(); |
| | | builder.append(" ("); |
| | | builder.append(status.toString()); |
| | | builder.append(")"); |
| | | builder.append(" db="); |
| | | try |
| | | { |
| | | builder.append(database.getDatabaseName()); |
| | | } |
| | | catch(DatabaseException de) |
| | | { |
| | | builder.append(de.toString()); |
| | | } |
| | | if (txn != null) |
| | | { |
| | | builder.append(" txnid="); |
| | | try |
| | | { |
| | | builder.append(txn.getId()); |
| | | } |
| | | catch(DatabaseException de) |
| | | { |
| | | builder.append(de.toString()); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | builder.append(" txnid=none"); |
| | | } |
| | | |
| | | builder.append(ServerConstants.EOL); |
| | | if(key != null) |
| | | { |
| | | builder.append("key:"); |
| | | builder.append(ServerConstants.EOL); |
| | | StaticUtils.byteArrayToHexPlusAscii(builder, key.getData(), 4); |
| | | } |
| | | |
| | | // If the operation was successful we log the same common information |
| | | // plus the data |
| | | if (status == OperationStatus.SUCCESS && data != null) |
| | | { |
| | | |
| | | builder.append("data(len="); |
| | | builder.append(data.getSize()); |
| | | builder.append("):"); |
| | | builder.append(ServerConstants.EOL); |
| | | StaticUtils.byteArrayToHexPlusAscii(builder, data.getData(), 4); |
| | | |
| | | } |
| | | |
| | | publish(category, level, signature, sourceLocation, builder.toString(), |
| | | null); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void traceData(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, |
| | | byte[] data) |
| | | { |
| | | LogCategory category = DebugLogCategory.DATA; |
| | | if(data != null) |
| | | { |
| | | StringBuilder builder = new StringBuilder(); |
| | | builder.append(ServerConstants.EOL); |
| | | builder.append("data(len="); |
| | | builder.append(data.length); |
| | | builder.append("):"); |
| | | builder.append(ServerConstants.EOL); |
| | | StaticUtils.byteArrayToHexPlusAscii(builder, data, 4); |
| | | |
| | | publish(category, level, signature, sourceLocation, builder.toString(), |
| | | null); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void traceProtocolElement(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, |
| | | ProtocolElement element) |
| | | { |
| | | LogCategory category = DebugLogCategory.PROTOCOL; |
| | | if(element != null) |
| | | { |
| | | StringBuilder builder = new StringBuilder(); |
| | | builder.append(ServerConstants.EOL); |
| | | element.toString(builder, 4); |
| | | publish(category, level, signature, sourceLocation, builder.toString(), |
| | | null); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void close() |
| | | { |
| | | writer.shutdown(); |
| | | |
| | | if(currentConfig != null) |
| | | { |
| | | currentConfig.removeFileBasedDebugChangeListener(this); |
| | | } |
| | | } |
| | | |
| | | |
| | | // Publishes a record, optionally performing some "special" work: |
| | | // - injecting a stack trace into the message |
| | | // - format the message with argument values |
| | | private void publish(LogCategory category, LogLevel level, String signature, |
| | | String sourceLocation, String msg, String stack) |
| | | { |
| | | Thread thread = Thread.currentThread(); |
| | | |
| | | StringBuilder buf = new StringBuilder(); |
| | | // Emit the timestamp. |
| | | buf.append("["); |
| | | buf.append(TimeThread.getLocalTime()); |
| | | buf.append("] "); |
| | | |
| | | // Emit the seq num |
| | | buf.append(globalSequenceNumber++); |
| | | buf.append(" "); |
| | | |
| | | // Emit debug category. |
| | | buf.append(category); |
| | | buf.append(" "); |
| | | |
| | | // Emit the debug level. |
| | | buf.append(level); |
| | | buf.append(" "); |
| | | |
| | | // Emit thread info. |
| | | buf.append("thread={"); |
| | | buf.append(thread.getName()); |
| | | buf.append("("); |
| | | buf.append(thread.getId()); |
| | | buf.append(")} "); |
| | | |
| | | if(thread instanceof DirectoryThread) |
| | | { |
| | | buf.append("threadDetail={"); |
| | | for(Map.Entry entry : |
| | | ((DirectoryThread)thread).getDebugProperties().entrySet()) |
| | | { |
| | | buf.append(entry.getKey()); |
| | | buf.append("="); |
| | | buf.append(entry.getValue()); |
| | | buf.append(" "); |
| | | } |
| | | buf.append("} "); |
| | | } |
| | | |
| | | // Emit method info. |
| | | buf.append("method={"); |
| | | buf.append(signature); |
| | | buf.append(" @ "); |
| | | buf.append(sourceLocation); |
| | | buf.append("} "); |
| | | |
| | | // Emit message. |
| | | buf.append(msg); |
| | | |
| | | // Emit Stack Trace. |
| | | if(stack != null) |
| | | { |
| | | buf.append("\nStack Trace:\n"); |
| | | buf.append(stack); |
| | | } |
| | | |
| | | writer.writeRecord(buf.toString()); |
| | | } |
| | | |
| | | private String buildDefaultEntryMessage(Object[] args) |
| | | { |
| | | StringBuffer format = new StringBuffer(); |
| | | for (int i = 0; i < args.length; i++) |
| | | { |
| | | if (i != 0) format.append(", "); |
| | | format.append("arg"); |
| | | format.append(i + 1); |
| | | format.append("={%s}"); |
| | | } |
| | | |
| | | return DebugMessageFormatter.format(format.toString(), args); |
| | | } |
| | | } |
| | |
| | | |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import org.opends.server.types.DebugLogCategory; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.loggers.LogLevel; |
| | | import org.opends.server.loggers.LogCategory; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.meta.DebugTargetCfgDefn; |
| | | import org.opends.server.admin.std.server.DebugTargetCfg; |
| | | |
| | | import java.util.Set; |
| | | import java.util.HashSet; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * This class encapsulates the trace settings in effect at a given traceing |
| | | * scope. |
| | | */ |
| | | public class TraceSettings |
| | | implements ConfigurationChangeListener<DebugTargetCfg> |
| | | { |
| | | /** A TraceSettings object representing a fully disabled trace state. */ |
| | | static final TraceSettings DISABLED = |
| | | public static final TraceSettings DISABLED = |
| | | new TraceSettings(DebugLogLevel.DISABLED); |
| | | |
| | | static final String STACK_DUMP_KEYWORD = "stack"; |
| | | static final String INCLUDE_CAUSE_KEYWORD = "cause"; |
| | | static final String SUPPRESS_ARG_KEYWORD = "noargs"; |
| | | static final String SUPPRESS_RETVAL_KEYWORD = "noretval"; |
| | | static final String INCLUDE_CATEGORY_KEYWORD = "category"; |
| | | static final String LEVEL_KEYWORD = "level"; |
| | | private static final String STACK_DUMP_KEYWORD = "stack"; |
| | | private static final String INCLUDE_CAUSE_KEYWORD = "cause"; |
| | | private static final String SUPPRESS_ARG_KEYWORD = "noargs"; |
| | | private static final String SUPPRESS_RETVAL_KEYWORD = "noretval"; |
| | | private static final String INCLUDE_CATEGORY_KEYWORD = "category"; |
| | | private static final String LEVEL_KEYWORD = "level"; |
| | | |
| | | final LogLevel level; |
| | | final Set<LogCategory> includeCategories; |
| | | /** |
| | | * The log level of this setting. |
| | | */ |
| | | LogLevel level; |
| | | |
| | | final boolean noArgs; |
| | | final boolean noRetVal; |
| | | final int stackDepth; |
| | | final boolean includeCause; |
| | | /** |
| | | * The log categories for this setting. |
| | | */ |
| | | Set<LogCategory> includeCategories; |
| | | |
| | | /** |
| | | * Indicates if method arguments should be logged. |
| | | */ |
| | | boolean noArgs; |
| | | |
| | | /** |
| | | * Indicates if method return values should be logged. |
| | | */ |
| | | boolean noRetVal; |
| | | |
| | | /** |
| | | * The level of stack frames to include. |
| | | */ |
| | | int stackDepth; |
| | | |
| | | /** |
| | | * Indicates if the cause exception is included in exception messages. |
| | | */ |
| | | boolean includeCause; |
| | | |
| | | private DebugTargetCfg currentConfig; |
| | | |
| | | /** |
| | | * Construct new trace settings at the specified log level. |
| | |
| | | } |
| | | |
| | | /** |
| | | * Construct a new trace settings from the provided configuration. |
| | | * |
| | | * @param config The debug target configuration that contains the information |
| | | * to use to initialize this trace setting. |
| | | */ |
| | | public TraceSettings(DebugTargetCfg config) |
| | | { |
| | | this.level = |
| | | DebugLogLevel.parse(config.getDebugLevel().name()); |
| | | |
| | | Set<LogCategory> logCategories = null; |
| | | if(!config.getDebugCategory().isEmpty()) |
| | | { |
| | | logCategories = |
| | | new HashSet<LogCategory>(config.getDebugCategory().size()); |
| | | for(DebugTargetCfgDefn.DebugCategory category : |
| | | config.getDebugCategory()) |
| | | { |
| | | logCategories.add(DebugLogCategory.parse(category.name())); |
| | | } |
| | | } |
| | | |
| | | this.includeCategories = logCategories; |
| | | this.noArgs = config.isOmitMethodEntryArguments(); |
| | | this.noRetVal = config.isOmitMethodReturnValue(); |
| | | this.stackDepth = config.getThrowableStackFrames(); |
| | | this.includeCause = config.isIncludeThrowableCause(); |
| | | |
| | | currentConfig = config; |
| | | config.addChangeListener(this); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationChangeAcceptable(DebugTargetCfg config, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | // This should alwas be acceptable. We are assuing that the scope for this |
| | | // trace setting is the same sine its part of the DN. |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationChange(DebugTargetCfg config) |
| | | { |
| | | // Default result code. |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | |
| | | // We can assume that the target scope did not change since its the |
| | | // naming attribute. Changing it would result in a modify DN. |
| | | |
| | | this.level = |
| | | DebugLogLevel.parse(config.getDebugLevel().name()); |
| | | |
| | | Set<LogCategory> logCategories = null; |
| | | if(!config.getDebugCategory().isEmpty()) |
| | | { |
| | | logCategories = |
| | | new HashSet<LogCategory>(config.getDebugCategory().size()); |
| | | for(DebugTargetCfgDefn.DebugCategory category : |
| | | config.getDebugCategory()) |
| | | { |
| | | logCategories.add(DebugLogCategory.parse(category.name())); |
| | | } |
| | | } |
| | | |
| | | this.includeCategories = logCategories; |
| | | this.noArgs = config.isOmitMethodEntryArguments(); |
| | | this.noRetVal = config.isOmitMethodReturnValue(); |
| | | this.stackDepth = config.getThrowableStackFrames(); |
| | | this.includeCause = config.isIncludeThrowableCause(); |
| | | |
| | | this.currentConfig = config; |
| | | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | /** |
| | | * Parse trace settings from the string representation. |
| | | * |
| | | * @param value the trace settings string to be parsed. |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * The message ID for the message that will be used if a configuration entry |
| | | * defines a Directory Server rotation policy but the associated class cannot |
| | | * be instantiated as a rotation policy. This takes three arguments, which |
| | | * are the class name, the DN of the configuration entry, and a string |
| | | * representation of the exception that was caught. |
| | | */ |
| | | public static final int MSGID_CONFIG_ROTATION_POLICY_INVALID_CLASS = |
| | | CATEGORY_MASK_CONFIG | SEVERITY_MASK_SEVERE_ERROR | 657; |
| | | |
| | | |
| | | /** |
| | | * The message ID for the message that will be used if a configuration entry |
| | | * defines a Directory Server retention policy but the associated class cannot |
| | | * be instantiated as a retention policy. This takes three arguments, which |
| | | * are the class name, the DN of the configuration entry, and a string |
| | | * representation of the exception that was caught. |
| | | */ |
| | | public static final int MSGID_CONFIG_RETENTION_POLICY_INVALID_CLASS = |
| | | CATEGORY_MASK_CONFIG | SEVERITY_MASK_SEVERE_ERROR | 658; |
| | | |
| | | |
| | | /** |
| | | * The message ID for the message that will be used if an error occurs while |
| | | * trying to create a rotation policy from a configuration entry. This takes |
| | | * two arguments, which are the DN of the configuration entry and a message |
| | | * that explains the problem that occurred. |
| | | */ |
| | | public static final int MSGID_CONFIG_ROTATION_POLICY_CANNOT_CREATE_POLICY = |
| | | CATEGORY_MASK_CONFIG | SEVERITY_MASK_SEVERE_ERROR | 659; |
| | | |
| | | |
| | | /** |
| | | * The message ID for the message that will be used if an error occurs while |
| | | * trying to create a retention policy from a configuration entry. This takes |
| | | * two arguments, which are the DN of the configuration entry and a message |
| | | * that explains the problem that occurred. |
| | | */ |
| | | public static final int MSGID_CONFIG_RETENTION_POLICY_CANNOT_CREATE_POLICY = |
| | | CATEGORY_MASK_CONFIG | SEVERITY_MASK_SEVERE_ERROR | 660; |
| | | |
| | | |
| | | /** |
| | | * The message ID for the message that will be used if an error occurs while |
| | | * trying to create a text writer for a text log publisher. This takes |
| | | * two arguments, the DN of the onfiguration entry and a message that explains |
| | | * the problem that occurred. |
| | | */ |
| | | public static final int MSGID_CONFIG_LOGGING_CANNOT_CREATE_WRITER = |
| | | CATEGORY_MASK_CONFIG | SEVERITY_MASK_SEVERE_ERROR | 661; |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * Associates a set of generic messages with the message IDs defined in this |
| | | * class. |
| | |
| | | "An error occurred while trying to load an instance " + |
| | | "of class %s referenced in configuration entry %s as a " + |
| | | "virtual attribute provider: %s"); |
| | | registerMessage(MSGID_CONFIG_ROTATION_POLICY_INVALID_CLASS, |
| | | "Class %s specified in attribute " + ATTR_LOGGER_CLASS + |
| | | " of configuration entry %s cannot be instantiated as " + |
| | | "a Directory Server log rotation policy: %s"); |
| | | registerMessage(MSGID_CONFIG_RETENTION_POLICY_INVALID_CLASS, |
| | | "Class %s specified in attribute " + ATTR_LOGGER_CLASS + |
| | | " of configuration entry %s cannot be instantiated as " + |
| | | "a Directory Server log retention policy: %s"); |
| | | registerMessage(MSGID_CONFIG_ROTATION_POLICY_CANNOT_CREATE_POLICY, |
| | | "An error occurred while attempting to create a " + |
| | | "Directory Server log rotation policy from the " + |
| | | "information in configuration entry %s: %s"); |
| | | registerMessage(MSGID_CONFIG_RETENTION_POLICY_CANNOT_CREATE_POLICY, |
| | | "An error occurred while attempting to create a " + |
| | | "Directory Server log retention policy from the " + |
| | | "information in configuration entry %s: %s"); |
| | | registerMessage(MSGID_CONFIG_LOGGING_CANNOT_CREATE_WRITER, |
| | | "An error occured while attempting create a text writer " + |
| | | "for a Directory Server logger from the information " + |
| | | "in configuration entry %s: %s"); |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | public class LoggerMessages |
| | | { |
| | | /** |
| | | * The message ID for the message that will be used if the access logger |
| | | * cannot add an appropriate log handler. This takes a single argument, which |
| | | * is a string representation of the exception that was caught. |
| | | * The message ID for the message that will be used if an error occured |
| | | * while writing a log record. This takes a two arguments, which |
| | | * are the logger that encountered the error and a string |
| | | * representation of the exception that was caught. |
| | | */ |
| | | public static final int MSGID_LOG_ACCESS_CANNOT_ADD_FILE_HANDLER = |
| | | public static final int MSGID_LOGGER_ERROR_WRITING_RECORD = |
| | | CATEGORY_MASK_LOG | SEVERITY_MASK_SEVERE_ERROR | 1; |
| | | |
| | | |
| | | |
| | | /** |
| | | * The message ID for the message that will be used if the error logger |
| | | * cannot add an appropriate log handler. This takes a single argument, which |
| | | * is a string representation of the exception that was caught. |
| | | * The message ID for the message that will be used if an error occured |
| | | * while opening a log file. This takes a two arguments, which |
| | | * are the logger that encountered the error and a string |
| | | * representation of the exception that was caught. |
| | | */ |
| | | public static final int MSGID_LOG_ERROR_CANNOT_ADD_FILE_HANDLER = |
| | | public static final int MSGID_LOGGER_ERROR_OPENING_FILE = |
| | | CATEGORY_MASK_LOG | SEVERITY_MASK_SEVERE_ERROR | 2; |
| | | |
| | | |
| | | |
| | | /** |
| | | * The message ID for the message that will be used if the debug logger |
| | | * cannot add an appropriate log handler. This takes a single argument, which |
| | | * is a string representation of the exception that was caught. |
| | | * The message ID for the message that will be used if an error occured |
| | | * while closing a log file. This takes a two arguments, which |
| | | * are the logger that encountered the error and a string |
| | | * representation of the exception that was caught. |
| | | */ |
| | | public static final int MSGID_LOG_DEBUG_CANNOT_ADD_FILE_HANDLER = |
| | | public static final int MSGID_LOGGER_ERROR_CLOSING_FILE = |
| | | CATEGORY_MASK_LOG | SEVERITY_MASK_SEVERE_ERROR | 3; |
| | | |
| | | |
| | | /** |
| | | * The message ID for the message that will be used as the description of the |
| | | * configuration attribute specifying the nickname of the certificate to use |
| | | * for SSL and StartTLS communication. |
| | | */ |
| | | public static final int MSGID_LOG_DESCRIPTION_SSL_CERT_NICKNAME = |
| | | CATEGORY_MASK_LOG | SEVERITY_MASK_INFORMATIONAL | 4; |
| | | |
| | | /** |
| | | * The message ID for the description of the configuration attribute that |
| | | * specifies the file size limit for rotation. |
| | | * The message ID for the message that will be used if an error occured |
| | | * while flushing the writer buffer. This takes a two arguments, which |
| | | * are the logger that encountered the error and a string |
| | | * representation of the exception that was caught. |
| | | */ |
| | | public static final int MSGID_LOGGER_ROTATION_SIZE_LIMIT = |
| | | CATEGORY_MASK_LOG | SEVERITY_MASK_INFORMATIONAL | 5; |
| | | public static final int MSGID_LOGGER_ERROR_FLUSHING_BUFFER = |
| | | CATEGORY_MASK_LOG | SEVERITY_MASK_SEVERE_ERROR | 4; |
| | | |
| | | /** |
| | | * The message ID for the description of the configuration attribute that |
| | | * specifies the time limit for rotation. |
| | | */ |
| | | public static final int MSGID_LOGGER_ROTATION_FIXED_TIME_LIMIT = |
| | | CATEGORY_MASK_LOG | SEVERITY_MASK_INFORMATIONAL | 6; |
| | | |
| | | |
| | | /** |
| | | * The message ID for the description of the configuration attribute that |
| | | * specifies the number of files for the retention policy. |
| | | * The message ID for the message that will be used if the specified |
| | | * string is not a valid error severity name. This takes the name |
| | | * of the invalid severity as the argument. |
| | | */ |
| | | public static final int MSGID_LOGGER_RETENTION_NUMBER_OF_FILES = |
| | | CATEGORY_MASK_LOG | SEVERITY_MASK_INFORMATIONAL | 7; |
| | | public static final int MSGID_ERROR_LOGGER_INVALID_SEVERITY = |
| | | CATEGORY_MASK_LOG | SEVERITY_MASK_MILD_WARNING | 5; |
| | | |
| | | /** |
| | | * The message ID for the description of the configuration attribute that |
| | | * specifies the disk space used for the size based retention policy. |
| | | |
| | | /** |
| | | * The message ID for the message that will be used if the specified |
| | | * string is not a valid error category name. This takes the name |
| | | * of the invalid category as the argument. |
| | | */ |
| | | public static final int MSGID_LOGGER_RETENTION_DISK_SPACE_USED = |
| | | CATEGORY_MASK_LOG | SEVERITY_MASK_INFORMATIONAL | 8; |
| | | public static final int MSGID_ERROR_LOGGER_INVALID_CATEGORY = |
| | | CATEGORY_MASK_LOG | SEVERITY_MASK_MILD_WARNING | 6; |
| | | |
| | | |
| | | /** |
| | | * The message ID for the description of the configuration attribute that |
| | | * specifies the thread time interval. |
| | | |
| | | /** |
| | | * The message ID for the message that will be used if the specified |
| | | * string is not a valid error override severity. This takes the name |
| | | * of the invalid severity as the argument. |
| | | */ |
| | | public static final int MSGID_LOGGER_THREAD_INTERVAL = |
| | | CATEGORY_MASK_LOG | SEVERITY_MASK_INFORMATIONAL | 9; |
| | | |
| | | /** |
| | | * The message ID for the description of the configuration attribute that |
| | | * specifies the log buffer size. |
| | | */ |
| | | public static final int MSGID_LOGGER_BUFFER_SIZE = |
| | | CATEGORY_MASK_LOG | SEVERITY_MASK_INFORMATIONAL | 10; |
| | | |
| | | |
| | | /** |
| | | * The message ID for the description of the configuration attribute that |
| | | * specifies the free disk space allowed. |
| | | */ |
| | | public static final int MSGID_LOGGER_RETENTION_FREE_DISK_SPACE = |
| | | CATEGORY_MASK_LOG | SEVERITY_MASK_INFORMATIONAL | 11; |
| | | public static final int MSGID_ERROR_LOGGER_INVALID_OVERRIDE_SEVERITY = |
| | | CATEGORY_MASK_LOG | SEVERITY_MASK_MILD_WARNING | 7; |
| | | |
| | | |
| | | |
| | |
| | | */ |
| | | public static void registerMessages() |
| | | { |
| | | registerMessage(MSGID_LOG_ACCESS_CANNOT_ADD_FILE_HANDLER, |
| | | "Unable to add a file handler for the Directory Server " + |
| | | "access logger: %s"); |
| | | registerMessage(MSGID_LOG_ERROR_CANNOT_ADD_FILE_HANDLER, |
| | | "Unable to add a file handler for the Directory Server " + |
| | | "error logger: %s"); |
| | | registerMessage(MSGID_LOG_DEBUG_CANNOT_ADD_FILE_HANDLER, |
| | | "Unable to add a file handler for the Directory Server " + |
| | | "debug logger: %s"); |
| | | registerMessage(MSGID_LOG_DESCRIPTION_SSL_CERT_NICKNAME, |
| | | "Specifies the nickname of the certificate that the " + |
| | | "connection handler should use when accepting SSL-based " + |
| | | "connections or performing StartTLS negotiation. " + |
| | | "Changes to this configuration attribute will not take " + |
| | | "effect until the connection handler is disabled and " + |
| | | "re-enabled, or until the Directory Server is restarted"); |
| | | registerMessage(MSGID_LOGGER_ROTATION_SIZE_LIMIT, |
| | | "Specifies the size limit for the file before rotation " + |
| | | "takes place"); |
| | | registerMessage(MSGID_LOGGER_ROTATION_FIXED_TIME_LIMIT, |
| | | "Specifies the time interval before the log file rotation" + |
| | | " takes place"); |
| | | registerMessage(MSGID_LOGGER_RETENTION_NUMBER_OF_FILES, |
| | | "Specifies the number of log files that need to " + |
| | | " be retained"); |
| | | registerMessage(MSGID_LOGGER_RETENTION_DISK_SPACE_USED, |
| | | "Specifies the amount of disk space that log files " + |
| | | " can use"); |
| | | registerMessage(MSGID_LOGGER_THREAD_INTERVAL, |
| | | "Specifies the time interval that the logger thread " + |
| | | " wakes up after"); |
| | | registerMessage(MSGID_LOGGER_BUFFER_SIZE, |
| | | "Specifies the log file buffer size"); |
| | | registerMessage(MSGID_LOGGER_RETENTION_FREE_DISK_SPACE, |
| | | "Specifies the free disk space allowed"); |
| | | registerMessage(MSGID_LOGGER_ERROR_WRITING_RECORD, |
| | | "Unable to write log record for logger " + |
| | | "%s: %s. Any further writing errors will be ignored"); |
| | | registerMessage(MSGID_LOGGER_ERROR_OPENING_FILE, |
| | | "Unable to open log file %s for logger %s: %s"); |
| | | registerMessage(MSGID_LOGGER_ERROR_CLOSING_FILE, |
| | | "Unable to close log file for logger %s: %s"); |
| | | registerMessage(MSGID_LOGGER_ERROR_FLUSHING_BUFFER, |
| | | "Unable to flush writer buffer for logger %s: %s"); |
| | | registerMessage(MSGID_ERROR_LOGGER_INVALID_SEVERITY, |
| | | "Invalid error log severity %s"); |
| | | registerMessage(MSGID_ERROR_LOGGER_INVALID_CATEGORY, |
| | | "Invalid error log category %s"); |
| | | registerMessage(MSGID_ERROR_LOGGER_INVALID_OVERRIDE_SEVERITY, |
| | | "invalid override of severity level %s"); |
| | | |
| | | } |
| | | } |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.PluginMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.PluginMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | import static |
| | | org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ProtocolMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | |
| | | |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.ProtocolMessages.*; |
| | | |
| | |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.opends.server.types.SearchResultReference; |
| | | |
| | | import static org.opends.server.loggers.Access.*; |
| | | import static org.opends.server.loggers.AccessLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugData; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugProtocolElement; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.ProtocolMessages.*; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | |
| | | |
| | | |
| | | |
| | | import static org.opends.server.loggers.Access.logConnect; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.AccessLogger.logConnect; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.ProtocolMessages.*; |
| | | import org.opends.server.types.DisconnectReason; |
| | |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.ReplicationMessages.*; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.ReplicationMessages.*; |
| | | |
| | |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugInfo; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | |
| | | import static org.opends.server.config.ConfigConstants.ATTR_BACKEND_CLASS; |
| | | import static org.opends.server.config.ConfigConstants.ATTR_BACKEND_ID; |
| | | import static org.opends.server.config.ConfigConstants.DN_BACKEND_BASE; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugInfo; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | |
| | | */ |
| | | package org.opends.server.replication.server; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.ReplicationMessages.*; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | |
| | | */ |
| | | package org.opends.server.replication.server; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.ReplicationMessages.*; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | |
| | | */ |
| | | package org.opends.server.replication.server; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.ReplicationMessages.*; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | |
| | | */ |
| | | package org.opends.server.replication.server; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.ReplicationMessages.*; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | |
| | | */ |
| | | package org.opends.server.replication.server; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.ReplicationMessages.*; |
| | | import static org.opends.server.util.StaticUtils.getFileForPath; |
| | |
| | | */ |
| | | package org.opends.server.replication.server; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugInfo; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | |
| | | */ |
| | | package org.opends.server.replication.server; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.ReplicationMessages.*; |
| | | |
| | |
| | | */ |
| | | package org.opends.server.replication.server; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.ReplicationMessages.*; |
| | | |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | |
| | |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.ByteString; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import org.opends.server.types.ErrorLogCategory; |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.PrintableString.*; |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.PrintableString.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | |
| | | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | |
| | | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | import static org.opends.server.messages.ToolMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.util.ServerConstants.DATE_FORMAT_GMT_TIME; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.opends.server.util.ServerConstants. |
| | | BACKUP_DIRECTORY_DESCRIPTOR_FILE; |
| | |
| | | import static org.opends.server.messages.ToolMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import org.opends.server.backends.task.Task; |
| | | import org.opends.server.backends.task.TaskState; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | import org.opends.server.config.StringConfigAttribute; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.loggers.Error; |
| | | import org.opends.server.loggers.ErrorLogger; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import org.opends.server.messages.TaskMessages; |
| | | import org.opends.server.protocols.asn1.ASN1OctetString; |
| | |
| | | int msgID = MSGID_CANNOT_DETERMINE_BACKEND_ID; |
| | | String message = getMessage(msgID, String.valueOf(configEntry.getDN()), |
| | | ce.getMessage()); |
| | | Error.logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | ErrorLogger.logError(ErrorLogCategory.BACKEND, |
| | | ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | return null; |
| | | } |
| | | catch (Exception e) |
| | |
| | | int msgID = MSGID_CANNOT_DETERMINE_BACKEND_ID; |
| | | String message = getMessage(msgID, String.valueOf(configEntry.getDN()), |
| | | getExceptionMessage(e)); |
| | | Error.logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | ErrorLogger.logError(ErrorLogCategory.BACKEND, |
| | | ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | return null; |
| | | } |
| | | } |
| | |
| | | { |
| | | int msgID = MSGID_CANNOT_DECODE_BACKEND_BASE_DN; |
| | | String message = getMessage(msgID, DN_BACKEND_BASE, de.getErrorMessage()); |
| | | Error.logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | ErrorLogger.logError(ErrorLogCategory.BACKEND, |
| | | ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | return configEntries; |
| | | } |
| | | catch (Exception e) |
| | |
| | | int msgID = MSGID_CANNOT_DECODE_BACKEND_BASE_DN; |
| | | String message = getMessage(msgID, DN_BACKEND_BASE, |
| | | getExceptionMessage(e)); |
| | | Error.logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | ErrorLogger.logError(ErrorLogCategory.BACKEND, |
| | | ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | return configEntries; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_CANNOT_RETRIEVE_BACKEND_BASE_ENTRY; |
| | | String message = getMessage(msgID, DN_BACKEND_BASE, ce.getMessage()); |
| | | Error.logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | ErrorLogger.logError(ErrorLogCategory.BACKEND, |
| | | ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | return configEntries; |
| | | } |
| | | catch (Exception e) |
| | |
| | | int msgID = MSGID_CANNOT_RETRIEVE_BACKEND_BASE_ENTRY; |
| | | String message = getMessage(msgID, DN_BACKEND_BASE, |
| | | getExceptionMessage(e)); |
| | | Error.logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | ErrorLogger.logError(ErrorLogCategory.BACKEND, |
| | | ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | return configEntries; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_CANNOT_DETERMINE_BACKEND_ID; |
| | | String message = getMessage(msgID, String.valueOf(configEntry.getDN()), |
| | | ce.getMessage()); |
| | | Error.logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | ErrorLogger.logError(ErrorLogCategory.BACKEND, |
| | | ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | continue; |
| | | } |
| | | catch (Exception e) |
| | |
| | | int msgID = MSGID_CANNOT_DETERMINE_BACKEND_ID; |
| | | String message = getMessage(msgID, String.valueOf(configEntry.getDN()), |
| | | getExceptionMessage(e)); |
| | | Error.logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | ErrorLogger.logError(ErrorLogCategory.BACKEND, |
| | | ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | continue; |
| | | } |
| | | |
| | |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.config.DNConfigAttribute; |
| | | import org.opends.server.config.StringConfigAttribute; |
| | | import org.opends.server.core.CoreConfigManager; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.LockFileManager; |
| | | import org.opends.server.extensions.ConfigFileHandler; |
| | | import org.opends.server.loggers.StartupErrorLogger; |
| | | import org.opends.server.loggers.ThreadFilterTextErrorLogPublisher; |
| | | import org.opends.server.loggers.TextWriter; |
| | | import org.opends.server.loggers.ErrorLogger; |
| | | import org.opends.server.types.BackupConfig; |
| | | import org.opends.server.types.BackupDirectory; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | import org.opends.server.util.args.BooleanArgument; |
| | | import org.opends.server.util.args.StringArgument; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.ToolMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.util.StaticUtils; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | |
| | | |
| | |
| | | */ |
| | | public class BackUpDB |
| | | { |
| | | private static DN publisherDN = null; |
| | | /** |
| | | * The main method for BackUpDB tool. |
| | | * |
| | |
| | | { |
| | | int retCode = mainBackUpDB(args); |
| | | |
| | | if(publisherDN != null) |
| | | { |
| | | ErrorLogger.removeErrorLogPublisher(publisherDN); |
| | | } |
| | | |
| | | if(retCode != 0) |
| | | { |
| | | System.exit(retCode); |
| | |
| | | |
| | | // FIXME -- Install a custom logger to capture information about the state |
| | | // of the export. |
| | | StartupErrorLogger startupLogger = new StartupErrorLogger(); |
| | | startupLogger.initializeErrorLogger(null); |
| | | addErrorLogger(startupLogger); |
| | | try |
| | | { |
| | | publisherDN = DN.decode("cn=Custom Logger for BackUpDB"); |
| | | ThreadFilterTextErrorLogPublisher publisher = |
| | | new ThreadFilterTextErrorLogPublisher(Thread.currentThread(), |
| | | new TextWriter.STDOUT()); |
| | | ErrorLogger.addErrorLogPublisher(publisherDN, publisher); |
| | | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | System.err.println("Error installing the custom error logger: " + |
| | | StaticUtils.stackTraceToSingleLineString(e)); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | ArrayList<Backend> backendList = new ArrayList<Backend>(); |
| | | ArrayList<ConfigEntry> entryList = new ArrayList<ConfigEntry>(); |
| | | ArrayList<List<DN>> dnList = new ArrayList<List<DN>>(); |
| | | getBackends(backendList, entryList, dnList); |
| | | BackendToolUtils.getBackends(backendList, entryList, dnList); |
| | | int numBackends = backendList.size(); |
| | | |
| | | boolean multiple; |
| | |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves information about the backends defined in the Directory Server |
| | | * configuration. |
| | | * |
| | | * @param backendList A list into which instantiated (but not initialized) |
| | | * backend instances will be placed. |
| | | * @param entryList A list into which the config entries associated with |
| | | * the backends will be placed. |
| | | * @param dnList A list into which the set of base DNs for each backend |
| | | * will be placed. |
| | | */ |
| | | private static void getBackends(ArrayList<Backend> backendList, |
| | | ArrayList<ConfigEntry> entryList, |
| | | ArrayList<List<DN>> dnList) |
| | | { |
| | | // Get the base entry for all backend configuration. |
| | | DN backendBaseDN = null; |
| | | try |
| | | { |
| | | backendBaseDN = DN.decode(DN_BACKEND_BASE); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | int msgID = MSGID_CANNOT_DECODE_BACKEND_BASE_DN; |
| | | String message = getMessage(msgID, DN_BACKEND_BASE, de.getErrorMessage()); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, message, |
| | | msgID); |
| | | System.exit(1); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_DECODE_BACKEND_BASE_DN; |
| | | String message = getMessage(msgID, DN_BACKEND_BASE, |
| | | getExceptionMessage(e)); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, message, |
| | | msgID); |
| | | |
| | | System.exit(1); |
| | | } |
| | | |
| | | ConfigEntry baseEntry = null; |
| | | try |
| | | { |
| | | baseEntry = DirectoryServer.getConfigEntry(backendBaseDN); |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | | int msgID = MSGID_CANNOT_RETRIEVE_BACKEND_BASE_ENTRY; |
| | | String message = getMessage(msgID, DN_BACKEND_BASE, ce.getMessage()); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, message, |
| | | msgID); |
| | | System.exit(1); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_RETRIEVE_BACKEND_BASE_ENTRY; |
| | | String message = getMessage(msgID, DN_BACKEND_BASE, |
| | | getExceptionMessage(e)); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, message, |
| | | msgID); |
| | | System.exit(1); |
| | | } |
| | | |
| | | |
| | | // Iterate through the immediate children, attempting to parse them as |
| | | // backends. |
| | | for (ConfigEntry configEntry : baseEntry.getChildren().values()) |
| | | { |
| | | // Get the backend ID attribute from the entry. If there isn't one, then |
| | | // skip the entry. |
| | | String backendID = null; |
| | | try |
| | | { |
| | | int msgID = MSGID_CONFIG_BACKEND_ATTR_DESCRIPTION_BACKEND_ID; |
| | | StringConfigAttribute idStub = |
| | | new StringConfigAttribute(ATTR_BACKEND_ID, getMessage(msgID), |
| | | true, false, true); |
| | | StringConfigAttribute idAttr = |
| | | (StringConfigAttribute) configEntry.getConfigAttribute(idStub); |
| | | if (idAttr == null) |
| | | { |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | backendID = idAttr.activeValue(); |
| | | } |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | | int msgID = MSGID_CANNOT_DETERMINE_BACKEND_ID; |
| | | String message = getMessage(msgID, String.valueOf(configEntry.getDN()), |
| | | ce.getMessage()); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | System.exit(1); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_DETERMINE_BACKEND_ID; |
| | | String message = getMessage(msgID, String.valueOf(configEntry.getDN()), |
| | | getExceptionMessage(e)); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | System.exit(1); |
| | | } |
| | | |
| | | |
| | | // Get the backend class name attribute from the entry. If there isn't |
| | | // one, then just skip the entry. |
| | | String backendClassName = null; |
| | | try |
| | | { |
| | | int msgID = MSGID_CONFIG_BACKEND_ATTR_DESCRIPTION_CLASS; |
| | | StringConfigAttribute classStub = |
| | | new StringConfigAttribute(ATTR_BACKEND_CLASS, getMessage(msgID), |
| | | true, false, false); |
| | | StringConfigAttribute classAttr = |
| | | (StringConfigAttribute) configEntry.getConfigAttribute(classStub); |
| | | if (classAttr == null) |
| | | { |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | backendClassName = classAttr.activeValue(); |
| | | } |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | | int msgID = MSGID_CANNOT_DETERMINE_BACKEND_CLASS; |
| | | String message = getMessage(msgID, String.valueOf(configEntry.getDN()), |
| | | ce.getMessage()); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | System.exit(1); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_DETERMINE_BACKEND_CLASS; |
| | | String message = getMessage(msgID, String.valueOf(configEntry.getDN()), |
| | | getExceptionMessage(e)); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | System.exit(1); |
| | | } |
| | | |
| | | Class backendClass = null; |
| | | try |
| | | { |
| | | backendClass = Class.forName(backendClassName); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_BACKEND_CLASS; |
| | | String message = getMessage(msgID, backendClassName, |
| | | String.valueOf(configEntry.getDN()), |
| | | getExceptionMessage(e)); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | System.exit(1); |
| | | } |
| | | |
| | | Backend backend = null; |
| | | try |
| | | { |
| | | backend = (Backend) backendClass.newInstance(); |
| | | backend.setBackendID(backendID); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_INSTANTIATE_BACKEND_CLASS; |
| | | String message = getMessage(msgID, backendClassName, |
| | | String.valueOf(configEntry.getDN()), |
| | | getExceptionMessage(e)); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | System.exit(1); |
| | | } |
| | | |
| | | |
| | | // Get the base DN attribute from the entry. If there isn't one, then |
| | | // just skip this entry. |
| | | List<DN> baseDNs = null; |
| | | try |
| | | { |
| | | int msgID = MSGID_CONFIG_BACKEND_ATTR_DESCRIPTION_BASE_DNS; |
| | | DNConfigAttribute baseDNStub = |
| | | new DNConfigAttribute(ATTR_BACKEND_BASE_DN, getMessage(msgID), |
| | | true, true, true); |
| | | DNConfigAttribute baseDNAttr = |
| | | (DNConfigAttribute) configEntry.getConfigAttribute(baseDNStub); |
| | | if (baseDNAttr == null) |
| | | { |
| | | msgID = MSGID_NO_BASES_FOR_BACKEND; |
| | | String message = getMessage(msgID, |
| | | String.valueOf(configEntry.getDN())); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | } |
| | | else |
| | | { |
| | | baseDNs = baseDNAttr.activeValues(); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_DETERMINE_BASES_FOR_BACKEND; |
| | | String message = getMessage(msgID, String.valueOf(configEntry.getDN()), |
| | | getExceptionMessage(e)); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | System.exit(1); |
| | | } |
| | | |
| | | |
| | | backendList.add(backend); |
| | | entryList.add(configEntry); |
| | | dnList.add(baseDNs); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | import static org.opends.server.messages.ToolMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.LockFileManager; |
| | | import org.opends.server.extensions.ConfigFileHandler; |
| | | import org.opends.server.loggers.StartupErrorLogger; |
| | | import org.opends.server.loggers.ThreadFilterTextErrorLogPublisher; |
| | | import org.opends.server.loggers.TextWriter; |
| | | import org.opends.server.loggers.ErrorLogger; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.DN; |
| | |
| | | import org.opends.server.util.args.IntegerArgument; |
| | | import org.opends.server.util.args.StringArgument; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.ToolMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.util.StaticUtils; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | |
| | | |
| | |
| | | */ |
| | | public class ExportLDIF |
| | | { |
| | | private static DN publisherDN = null; |
| | | /** |
| | | * The main method for ExportLDIF tool. |
| | | * |
| | |
| | | { |
| | | int retCode = mainExportLDIF(args); |
| | | |
| | | if(publisherDN != null) |
| | | { |
| | | ErrorLogger.removeErrorLogPublisher(publisherDN); |
| | | } |
| | | |
| | | if(retCode != 0) |
| | | { |
| | | System.exit(retCode); |
| | |
| | | |
| | | // FIXME -- Install a custom logger to capture information about the state |
| | | // of the export. |
| | | StartupErrorLogger startupLogger = new StartupErrorLogger(); |
| | | startupLogger.initializeErrorLogger(null); |
| | | addErrorLogger(startupLogger); |
| | | try |
| | | { |
| | | publisherDN = DN.decode("cn=Custom Logger for ExportLDIF"); |
| | | ThreadFilterTextErrorLogPublisher publisher = |
| | | new ThreadFilterTextErrorLogPublisher(Thread.currentThread(), |
| | | new TextWriter.STDOUT()); |
| | | ErrorLogger.addErrorLogPublisher(publisherDN, publisher); |
| | | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | System.err.println("Error installing the custom error logger: " + |
| | | StaticUtils.stackTraceToSingleLineString(e)); |
| | | } |
| | | |
| | | |
| | | |
| | | // Make sure that the Directory Server plugin initialization is performed. |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.LockFileManager; |
| | | import org.opends.server.extensions.ConfigFileHandler; |
| | | import org.opends.server.loggers.StartupErrorLogger; |
| | | import org.opends.server.loggers.ThreadFilterTextErrorLogPublisher; |
| | | import org.opends.server.loggers.TextWriter; |
| | | import org.opends.server.loggers.ErrorLogger; |
| | | import org.opends.server.tools.makeldif.TemplateFile; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | import org.opends.server.util.args.StringArgument; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.ToolMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.util.StaticUtils; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | |
| | | |
| | |
| | | */ |
| | | public static final int LDIF_BUFFER_SIZE = 1048576; |
| | | |
| | | private static DN publisherDN = null; |
| | | |
| | | |
| | | /** |
| | |
| | | { |
| | | int retCode = mainImportLDIF(args); |
| | | |
| | | if(publisherDN != null) |
| | | { |
| | | ErrorLogger.removeErrorLogPublisher(publisherDN); |
| | | } |
| | | |
| | | if(retCode != 0) |
| | | { |
| | | System.exit(retCode); |
| | |
| | | { |
| | | // FIXME -- Install a custom logger to capture information about the |
| | | // state of the import. |
| | | StartupErrorLogger startupLogger = new StartupErrorLogger(); |
| | | startupLogger.initializeErrorLogger(null); |
| | | addErrorLogger(startupLogger); |
| | | try |
| | | { |
| | | publisherDN = DN.decode("cn=Custom Logger for ImportLDIF"); |
| | | ThreadFilterTextErrorLogPublisher publisher = |
| | | new ThreadFilterTextErrorLogPublisher(Thread.currentThread(), |
| | | new TextWriter.STDOUT()); |
| | | ErrorLogger.addErrorLogPublisher(publisherDN, publisher); |
| | | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | System.err.println("Error installing the custom error logger: " + |
| | | StaticUtils.stackTraceToSingleLineString(e)); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | import static org.opends.server.messages.ToolMessages.*; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import org.opends.server.loggers.StartupErrorLogger; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import org.opends.server.loggers.ThreadFilterTextErrorLogPublisher; |
| | | import org.opends.server.loggers.TextWriter; |
| | | import org.opends.server.loggers.ErrorLogger; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.CoreConfigManager; |
| | | import org.opends.server.core.LockFileManager; |
| | |
| | | */ |
| | | public class RebuildIndex |
| | | { |
| | | private static DN publisherDN = null; |
| | | |
| | | /** |
| | | * Processes the command-line arguments and invokes the rebuild process. |
| | | * |
| | |
| | | */ |
| | | public static void main(String[] args) |
| | | { |
| | | int retCode = mainRebuildIndex(args); |
| | | |
| | | if(publisherDN != null) |
| | | { |
| | | ErrorLogger.removeErrorLogPublisher(publisherDN); |
| | | } |
| | | |
| | | if(retCode != 0) |
| | | { |
| | | System.exit(retCode); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Processes the command-line arguments and invokes the rebuild process. |
| | | * |
| | | * @param args The command-line arguments provided to this program. |
| | | * |
| | | * @return The error code. |
| | | */ |
| | | public static int mainRebuildIndex(String[] args) |
| | | { |
| | | // Define the command-line arguments that may be used with this program. |
| | | StringArgument configClass = null; |
| | | StringArgument configFile = null; |
| | |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.err.println(argParser.getUsage()); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | // If we should just display usage information, then print it and exit. |
| | | if (argParser.usageDisplayed()) |
| | | { |
| | | System.exit(0); |
| | | return 0; |
| | | } |
| | | |
| | | |
| | |
| | | if (numArgs == 0) |
| | | { |
| | | System.out.println(argParser.getUsage()); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.out.println(argParser.getUsage()); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | // Perform the initial bootstrap of the Directory Server and process the |
| | |
| | | int msgID = MSGID_SERVER_BOOTSTRAP_ERROR; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | try |
| | |
| | | int msgID = MSGID_CANNOT_LOAD_CONFIG; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_CONFIG; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | |
| | | // FIXME -- Install a custom logger to capture information about the state |
| | | // of the verify process. |
| | | StartupErrorLogger startupLogger = new StartupErrorLogger(); |
| | | startupLogger.initializeErrorLogger(null); |
| | | addErrorLogger(startupLogger); |
| | | try |
| | | { |
| | | publisherDN = DN.decode("cn=Custom Logger for RebuildIndex"); |
| | | ThreadFilterTextErrorLogPublisher publisher = |
| | | new ThreadFilterTextErrorLogPublisher(Thread.currentThread(), |
| | | new TextWriter.STDOUT()); |
| | | ErrorLogger.addErrorLogPublisher(publisherDN, publisher); |
| | | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | System.err.println("Error installing the custom error logger: " + |
| | | StaticUtils.stackTraceToSingleLineString(e)); |
| | | } |
| | | |
| | | // Decode the base DN provided by the user. |
| | | DN rebuildBaseDN = null; |
| | |
| | | de.getErrorMessage()); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, message, |
| | | msgID); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | getExceptionMessage(e)); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, message, |
| | | msgID); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | // Get information about the backends defined in the server. |
| | |
| | | String message = getMessage(msgID, baseDNString.getValue()); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | break; |
| | | } |
| | |
| | | String message = getMessage(msgID, baseDNString.getValue()); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, message, |
| | | msgID); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | if (!(backend instanceof BackendImpl)) |
| | |
| | | String message = getMessage(msgID); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, message, |
| | | msgID); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | // Initialize the rebuild configuration. |
| | |
| | | String.valueOf(failureReason)); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | return; |
| | | return 1; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | |
| | | getExceptionMessage(e)); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | return; |
| | | return 1; |
| | | } |
| | | |
| | | // Launch the rebuild process. |
| | |
| | | message, msgID); |
| | | } |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | } |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.LockFileManager; |
| | | import org.opends.server.extensions.ConfigFileHandler; |
| | | import org.opends.server.loggers.StartupErrorLogger; |
| | | import org.opends.server.loggers.ThreadFilterTextErrorLogPublisher; |
| | | import org.opends.server.loggers.TextWriter; |
| | | import org.opends.server.loggers.ErrorLogger; |
| | | import org.opends.server.types.BackupDirectory; |
| | | import org.opends.server.types.BackupInfo; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | import org.opends.server.util.args.BooleanArgument; |
| | | import org.opends.server.util.args.StringArgument; |
| | | |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.ToolMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.util.StaticUtils; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | |
| | | |
| | |
| | | */ |
| | | public class RestoreDB |
| | | { |
| | | private static DN publisherDN = null; |
| | | /** |
| | | * The main method for RestoreDB tool. |
| | | * |
| | |
| | | { |
| | | int retCode = mainRestoreDB(args); |
| | | |
| | | if(publisherDN != null) |
| | | { |
| | | ErrorLogger.removeErrorLogPublisher(publisherDN); |
| | | } |
| | | |
| | | if(retCode != 0) |
| | | { |
| | | System.exit(retCode); |
| | |
| | | |
| | | // FIXME -- Install a custom logger to capture information about the state |
| | | // of the export. |
| | | StartupErrorLogger startupLogger = new StartupErrorLogger(); |
| | | startupLogger.initializeErrorLogger(null); |
| | | addErrorLogger(startupLogger); |
| | | try |
| | | { |
| | | publisherDN = DN.decode("cn=Custom Logger for RestoreDB"); |
| | | ThreadFilterTextErrorLogPublisher publisher = |
| | | new ThreadFilterTextErrorLogPublisher(Thread.currentThread(), |
| | | new TextWriter.STDOUT()); |
| | | ErrorLogger.addErrorLogPublisher(publisherDN, publisher); |
| | | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | System.err.println("Error installing the custom error logger: " + |
| | | StaticUtils.stackTraceToSingleLineString(e)); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.LockFileManager; |
| | | import org.opends.server.extensions.ConfigFileHandler; |
| | | import org.opends.server.loggers.StartupErrorLogger; |
| | | import org.opends.server.loggers.ThreadFilterTextErrorLogPublisher; |
| | | import org.opends.server.loggers.TextWriter; |
| | | import org.opends.server.loggers.ErrorLogger; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.ErrorLogCategory; |
| | |
| | | import java.util.List; |
| | | |
| | | import static org.opends.server.messages.ToolMessages.*; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.util.StaticUtils; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | |
| | | |
| | |
| | | */ |
| | | public class VerifyIndex |
| | | { |
| | | private static DN publisherDN = null; |
| | | /** |
| | | * Processes the command-line arguments and invokes the verify process. |
| | | * |
| | |
| | | */ |
| | | public static void main(String[] args) |
| | | { |
| | | int retCode = mainVerifyIndex(args); |
| | | |
| | | if(publisherDN != null) |
| | | { |
| | | ErrorLogger.removeErrorLogPublisher(publisherDN); |
| | | } |
| | | |
| | | if(retCode != 0) |
| | | { |
| | | System.exit(retCode); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Processes the command-line arguments and invokes the verify process. |
| | | * |
| | | * @param args The command-line arguments provided to this program. |
| | | * @return The error code. |
| | | */ |
| | | public static int mainVerifyIndex(String[] args) |
| | | { |
| | | // Define the command-line arguments that may be used with this program. |
| | | StringArgument configClass = null; |
| | | StringArgument configFile = null; |
| | |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.err.println(argParser.getUsage()); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | // If we should just display usage information, then print it and exit. |
| | | if (argParser.usageDisplayed()) |
| | | { |
| | | System.exit(0); |
| | | return 0; |
| | | } |
| | | |
| | | |
| | |
| | | if (numArgs == 0) |
| | | { |
| | | System.out.println(argParser.getUsage()); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.out.println(argParser.getUsage()); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | // Perform the initial bootstrap of the Directory Server and process the |
| | |
| | | int msgID = MSGID_SERVER_BOOTSTRAP_ERROR; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | try |
| | |
| | | int msgID = MSGID_CANNOT_LOAD_CONFIG; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_CONFIG; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | // FIXME -- Install a custom logger to capture information about the state |
| | | // of the verify process. |
| | | StartupErrorLogger startupLogger = new StartupErrorLogger(); |
| | | startupLogger.initializeErrorLogger(null); |
| | | addErrorLogger(startupLogger); |
| | | try |
| | | { |
| | | publisherDN = DN.decode("cn=Custom Logger for VerifyIndex"); |
| | | ThreadFilterTextErrorLogPublisher publisher = |
| | | new ThreadFilterTextErrorLogPublisher(Thread.currentThread(), |
| | | new TextWriter.STDOUT()); |
| | | ErrorLogger.addErrorLogPublisher(publisherDN, publisher); |
| | | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | System.err.println("Error installing the custom error logger: " + |
| | | StaticUtils.stackTraceToSingleLineString(e)); |
| | | } |
| | | |
| | | |
| | | // Decode the base DN provided by the user. |
| | |
| | | de.getErrorMessage()); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, message, |
| | | msgID); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | getExceptionMessage(e)); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, message, |
| | | msgID); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | |
| | | String message = getMessage(msgID, baseDNString.getValue()); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | break; |
| | | } |
| | |
| | | String message = getMessage(msgID, baseDNString.getValue()); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, message, |
| | | msgID); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | if (!(backend instanceof BackendImpl)) |
| | |
| | | String message = getMessage(msgID); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, message, |
| | | msgID); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | // Initialize the verify configuration. |
| | |
| | | String.valueOf(failureReason)); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | return; |
| | | return 1; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | |
| | | getExceptionMessage(e)); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | return; |
| | | return 1; |
| | | } |
| | | |
| | | |
| | |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_WARNING, |
| | | message, msgID); |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | } |
| | |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.CoreMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.UtilityMessages.*; |
| | |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.BackendMessages.*; |
| | | import static org.opends.server.messages.CoreMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | |
| | | import static |
| | | org.opends.server.loggers.debug.DebugLogger.debugVerbose; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugInfo; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.CoreMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugInfo; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugProtocolElement; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.UtilityMessages.*; |
| | | import static org.opends.server.util.StaticUtils.toLowerCase; |
| | |
| | | |
| | | |
| | | /** |
| | | * The name of the system property that can be used to enable or disable |
| | | * the debug logger on startup. |
| | | */ |
| | | public static final String PROPERTY_DEBUG_ENABLED = |
| | | "org.opends.server.debug.enabled"; |
| | | |
| | | |
| | | |
| | | /** |
| | | * The name of the system property that can be used to specify a target |
| | | * for the debug logger on startup. |
| | | */ |
| | | public static final String PROPERTY_DEBUG_TARGET = |
| | | "org.opends.server.debug.target"; |
| | | |
| | | /** |
| | | * The name of the system property that can be used to specify a level |
| | | * for the error logger on startup. |
| | | */ |
| | | public static final String PROPERTY_ERROR_LEVEL = |
| | | "org.opends.server.error.level"; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | // Log to the error log. |
| | | org.opends.server.loggers.Error.logError(ErrorLogCategory.CORE_SERVER, |
| | | org.opends.server.loggers.ErrorLogger.logError(ErrorLogCategory.CORE_SERVER, |
| | | ErrorLogSeverity.SEVERE_ERROR, |
| | | UtilityMessages.MSGID_VALIDATOR_PRECONDITION_NOT_MET, |
| | | messageWithStack); |
| | |
| | | - |
| | | replace: ds-cfg-key-store-pin-file |
| | | |
| | | dn: cn=File-Based Debug Logger,cn=Loggers,cn=config |
| | | changetype: modify |
| | | replace: ds-cfg-override-severity |
| | | ds-cfg-override-severity: EXCEPTION=INFO |
| | | |
| | | dn: ds-cfg-backend-id=unindexedRoot,cn=Backends,cn=config |
| | | changetype: add |
| | | objectClass: top |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.LockFileManager; |
| | | import org.opends.server.extensions.ConfigFileHandler; |
| | | import org.opends.server.loggers.Access; |
| | | import org.opends.server.loggers.Error; |
| | | import org.opends.server.loggers.debug.DebugLogFormatter; |
| | | import org.opends.server.loggers.debug.DebugConfiguration; |
| | | import org.opends.server.loggers.AccessLogger; |
| | | import org.opends.server.loggers.TextErrorLogPublisher; |
| | | import org.opends.server.loggers.ErrorLogger; |
| | | import org.opends.server.loggers.TextAccessLogPublisher; |
| | | import org.opends.server.loggers.debug.TextDebugLogPublisher; |
| | | import org.opends.server.loggers.debug.DebugLogger; |
| | | import org.opends.server.plugins.InvocationCounterPlugin; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | |
| | | return; |
| | | } |
| | | |
| | | String debugTarget = System.getProperty("org.opends.test.debug.target"); |
| | | if(debugTarget != null) |
| | | { |
| | | System.setProperty("org.opends.server.debug.enabled", "true"); |
| | | System.setProperty("org.opends.server.debug.target.1", debugTarget); |
| | | } |
| | | DebugConfiguration testDebugConfig = |
| | | DebugConfiguration.getStartupConfiguration(); |
| | | testDebugConfig.removeAllPublishers(true); |
| | | testDebugConfig.addPublisher(TestListener.DEBUG_LOG_PUBLISHER); |
| | | |
| | | DebugLogger debugLogger = DebugLogger.getLogger(); |
| | | debugLogger.updateConfiguration(testDebugConfig); |
| | | |
| | | InvocationCounterPlugin.resetStartupCalled(); |
| | | |
| | | // Get the build root and use it to create a test package directory. |
| | |
| | | testRoot.mkdirs(); |
| | | //db_verify is second jeb backend used by the jeb verify test cases |
| | | //db_rebuild is the third jeb backend used by the jeb rebuild test cases |
| | | //db_unindexed is the forth backend used by the unindexed search privilege |
| | | //test cases |
| | | String[] subDirectories = { "bak", "bin", "changelogDb", "classes", |
| | | "config", "db", "db_verify", "ldif", "lib", |
| | | "locks", "logs", "db_rebuild", "db_unindexed", |
| | |
| | | DirectoryServer directoryServer = DirectoryServer.getInstance(); |
| | | directoryServer.bootstrapServer(); |
| | | directoryServer.initializeConfiguration(configClass, configFile); |
| | | Error.removeAllErrorLoggers(false); |
| | | Access.addAccessLogger(TestAccessLogger.getInstance()); |
| | | Error.addErrorLogger(TestErrorLogger.getInstance()); |
| | | |
| | | String debugTarget = System.getProperty("org.opends.test.debug.target"); |
| | | if(debugTarget != null) |
| | | { |
| | | System.setProperty("org.opends.server.debug.enabled", "true"); |
| | | System.setProperty("org.opends.server.debug.target.1", debugTarget); |
| | | } |
| | | |
| | | try |
| | | { |
| | | TextDebugLogPublisher startupDebugPublisher = |
| | | TextDebugLogPublisher.getStartupTextDebugPublisher( |
| | | TestListener.DEBUG_TEXT_WRITER); |
| | | DebugLogger.removeAllDebugLogPublishers(); |
| | | DebugLogger.addDebugLogPublisher(DN.decode("cn=Test Debug Publisher"), |
| | | startupDebugPublisher); |
| | | |
| | | TextErrorLogPublisher startupErrorPublisher = |
| | | TextErrorLogPublisher.getStartupTextErrorPublisher( |
| | | TestListener.ERROR_TEXT_WRITER); |
| | | ErrorLogger.removeAllErrorLogPublishers(); |
| | | ErrorLogger.addErrorLogPublisher(DN.decode("cn=Test Error Publisher"), |
| | | startupErrorPublisher); |
| | | |
| | | TextAccessLogPublisher startupAccessPublisher = |
| | | TextAccessLogPublisher.getStartupTextAccessPublisher( |
| | | TestListener.ACCESS_TEXT_WRITER); |
| | | AccessLogger.removeAllAccessLogPublishers(); |
| | | AccessLogger.addAccessLogPublisher(DN.decode("cn=Test Access Publisher"), |
| | | startupAccessPublisher); |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | System.out.println("Error installing test log publishers: " + |
| | | e.toString()); |
| | | } |
| | | |
| | | directoryServer.startServer(); |
| | | |
| | | assertTrue(InvocationCounterPlugin.startupCalled()); |
| | |
| | | import org.testng.xml.XmlSuite; |
| | | import static org.opends.server.util.ServerConstants.EOL; |
| | | import static org.opends.server.TestCaseUtils.originalSystemErr; |
| | | import org.opends.server.loggers.debug.DebugLogFormatter; |
| | | import org.opends.server.loggers.debug.DebugConfiguration; |
| | | import org.opends.server.loggers.debug.TraceSettings; |
| | | import org.opends.server.loggers.debug.DebugLogger; |
| | | import org.opends.server.loggers.LogLevel; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | |
| | | import java.util.List; |
| | | import java.util.LinkedHashMap; |
| | |
| | | public static final String ANT_TESTS_FAILED_FILE_NAME = ".tests-failed-marker"; |
| | | |
| | | /** |
| | | * The Log Publisher for the Debug Logger |
| | | * The test text writer for the Debug Logger |
| | | */ |
| | | public static TestLogPublisher DEBUG_LOG_PUBLISHER = |
| | | new TestLogPublisher(new DebugLogFormatter()); |
| | | public static TestTextWriter DEBUG_TEXT_WRITER = |
| | | new TestTextWriter(); |
| | | |
| | | /** |
| | | * The test text writer for the Debug Logger |
| | | */ |
| | | public static TestTextWriter ERROR_TEXT_WRITER = |
| | | new TestTextWriter(); |
| | | |
| | | /** |
| | | * The test text writer for the Debug Logger |
| | | */ |
| | | public static TestTextWriter ACCESS_TEXT_WRITER = |
| | | new TestTextWriter(); |
| | | |
| | | private static final String DIVIDER_LINE = "-------------------------------------------------------------------------------" + EOL; |
| | | |
| | |
| | | |
| | | public void onTestStart(ITestResult tr) { |
| | | super.onTestStart(tr); |
| | | TestAccessLogger.clear(); |
| | | TestErrorLogger.clear(); |
| | | ACCESS_TEXT_WRITER.clear(); |
| | | ERROR_TEXT_WRITER.clear(); |
| | | DEBUG_TEXT_WRITER.clear(); |
| | | TestCaseUtils.clearSystemOutContents(); |
| | | TestCaseUtils.clearSystemErrContents(); |
| | | |
| | | DEBUG_LOG_PUBLISHER.clear(); |
| | | } |
| | | |
| | | |
| | |
| | | failureInfo.append("parameter[" + i + "]: ").append(parameter).append(EOL); |
| | | } |
| | | |
| | | List<String> messages = TestAccessLogger.getMessages(); |
| | | List<String> messages = ACCESS_TEXT_WRITER.getMessages(); |
| | | if (! messages.isEmpty()) |
| | | { |
| | | failureInfo.append(EOL); |
| | |
| | | } |
| | | } |
| | | |
| | | messages = TestErrorLogger.getMessages(); |
| | | messages = ERROR_TEXT_WRITER.getMessages(); |
| | | if (! messages.isEmpty()) |
| | | { |
| | | failureInfo.append(EOL); |
| | |
| | | } |
| | | } |
| | | |
| | | messages = DEBUG_LOG_PUBLISHER.getMessages(); |
| | | messages = DEBUG_TEXT_WRITER.getMessages(); |
| | | if(! messages.isEmpty()) |
| | | { |
| | | failureInfo.append(EOL); |
| File was renamed from opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/TestLogPublisher.java |
| | |
| | | */ |
| | | package org.opends.server; |
| | | |
| | | import org.opends.server.api.LogPublisher; |
| | | import org.opends.server.loggers.LoggerErrorHandler; |
| | | import org.opends.server.loggers.TextLogFormatter; |
| | | import org.opends.server.loggers.LogRecord; |
| | | import org.opends.server.loggers.TextWriter; |
| | | |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.ArrayList; |
| | | |
| | | /** |
| | | * This class provides an implementation of an log publisher which will store |
| | | * all messages logged in memory. It provides methods to retrieve and clear the |
| | | * sets of accumulated log messages. It is only intended for use in the context |
| | | * of the unit test framework, where it will provide a means of getting any |
| | | * log messages associated with failed test cases. |
| | | */ |
| | | public class TestLogPublisher implements LogPublisher |
| | | public class TestTextWriter implements TextWriter |
| | | { |
| | | private TextLogFormatter formatter; |
| | | |
| | | // The list that will hold the messages logged. |
| | | private final LinkedList<String> messageList; |
| | | |
| | | public TestLogPublisher(TextLogFormatter formatter) |
| | | public TestTextWriter() |
| | | { |
| | | this.messageList = new LinkedList<String>(); |
| | | this.formatter = formatter; |
| | | messageList = new LinkedList<String>(); |
| | | } |
| | | |
| | | public synchronized void publish(LogRecord record, |
| | | LoggerErrorHandler handler) |
| | | public synchronized void writeRecord(String record) |
| | | { |
| | | try |
| | | { |
| | | messageList.add(formatter.format(record)); |
| | | } |
| | | catch(Throwable t) |
| | | { |
| | | if(handler != null) |
| | | { |
| | | handler.handleError(record, t); |
| | | } |
| | | } |
| | | messageList.add(record); |
| | | } |
| | | |
| | | public synchronized void shutdown() |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void flush() |
| | | { |
| | | // No implementation is required. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void shutdown() |
| | | { |
| | | messageList.clear(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public long getBytesWritten() |
| | | { |
| | | // No implemention is required. Just return 0; |
| | | return 0; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves a copy of the set of messages logged to this error logger since |
| | | * the last time it was cleared. A copy of the list is returned to avoid |
| | | * a ConcurrentModificationException. |
| | |
| | | return new ArrayList<String>(messageList); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Clears any messages currently stored by this logger. |
| | | */ |
| | |
| | | { |
| | | messageList.clear(); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package org.opends.server.replication; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugInfo; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | |
| | | |
| | | package org.opends.server.replication; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.net.ServerSocket; |
| | |
| | | */ |
| | | package org.opends.server.replication; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.testng.Assert.assertNotNull; |
| | | import static org.testng.Assert.fail; |
| | | |
| | |
| | | */ |
| | | package org.opends.server.replication; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.testng.Assert.assertTrue; |
| | | import static org.testng.Assert.fail; |
| | | |
| | |
| | | |
| | | package org.opends.server.replication; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.testng.Assert.assertEquals; |
| | | import static org.testng.Assert.assertTrue; |
| | | import static org.testng.Assert.fail; |
| | |
| | | |
| | | package org.opends.server.replication; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.net.ServerSocket; |