Browse files

Removing unrelated files.

  • Loading branch information...
1 parent c452e6f commit 4afc3197390b28f7ae8287cb3bac2d351699657a Karthik Ranganathan committed Nov 20, 2012
Showing with 0 additions and 4,308 deletions.
  1. +0 −202 LICENSE
  2. +0 −28 README.md
  3. +0 −31 build.gradle
  4. +0 −13 codequality/HEADER
  5. +0 −189 codequality/checkstyle.xml
  6. +0 −1 gradle.properties
  7. +0 −12 gradle/buildscript.gradle
  8. +0 −23 gradle/check.gradle
  9. +0 −53 gradle/convention.gradle
  10. +0 −7 gradle/license.gradle
  11. +0 −63 gradle/maven.gradle
  12. +0 −1 gradle/netflix-oss.gradle
  13. +0 −62 gradle/release.gradle
  14. BIN gradle/wrapper/gradle-wrapper.jar
  15. +0 −6 gradle/wrapper/gradle-wrapper.properties
  16. +0 −164 gradlew
  17. +0 −90 gradlew.bat
  18. +0 −1 settings.gradle
  19. +0 −518 src/main/java/com/netflix/blitz4j/AsyncAppender.java
  20. +0 −179 src/main/java/com/netflix/blitz4j/BlitzConfig.java
  21. +0 −223 src/main/java/com/netflix/blitz4j/DefaultBlitz4jConfig.java
  22. +0 −66 src/main/java/com/netflix/blitz4j/LoggerCache.java
  23. +0 −485 src/main/java/com/netflix/blitz4j/LoggingConfiguration.java
  24. +0 −198 src/main/java/com/netflix/blitz4j/LoggingContext.java
  25. +0 −219 src/main/java/com/netflix/blitz4j/NFAppenderAttachableImpl.java
  26. +0 −45 src/main/java/com/netflix/blitz4j/NFCategoryFactory.java
  27. +0 −108 src/main/java/com/netflix/blitz4j/NFHierarchy.java
  28. +0 −204 src/main/java/com/netflix/blitz4j/NFLockFreeLogger.java
  29. +0 −39 src/main/java/com/netflix/blitz4j/NFRepositorySelector.java
  30. +0 −36 src/main/java/com/netflix/blitz4j/NFRootLogger.java
  31. +0 −44 src/main/java/com/netflix/logging/log4jAdapter/NFPatternLayout.java
  32. +0 −98 src/main/java/com/netflix/logging/log4jAdapter/NFPatternParser.java
  33. +0 −85 src/main/java/com/netflix/logging/messaging/BatcherFactory.java
  34. +0 −596 src/main/java/com/netflix/logging/messaging/MessageBatcher.java
  35. +0 −38 src/main/java/com/netflix/logging/messaging/MessageProcessor.java
  36. +0 −181 test/main/java/com/netflix/blitz4j/TestBlitz4j.java
View
202 LICENSE
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright 2012 Netflix, Inc.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
View
28 README.md
@@ -1,28 +0,0 @@
-Blitz4j
-=====
-
-Blitz4j is a logging framework built on top of log4j to reduce contention and enable highly scalable logging without affecting application performance characteristics.
-
-At Netflix, Blitz4j is used to log billions of events for monitoring, business intelligence reporting, debugging and other purposes. Blitz4j overcomes traditional log4j
-bottlenecks and comes built with a highly scalable and customizable asynchronous framework. Blitz4j comes with the ability to convert the existing log4j appenders to use
-the asynchronous model without changing the existing log4j configurations.
-
-Blitz4j uses archaius (http://www.github.com/Netflix/archaius) to reconfigure log4j dynamically and servo (http://www.github.com/Netflix/servo) to track the performance metrics
-regarding logging. Blitz4j also tries to mitigate data loss and provides a way to summarize the log information during log storms.
-
-
-BUILD
--------
-
-./gradlew clean build
-
-
-
-Support
-----------
-[Blitz4j Google Group] (https://groups.google.com/forum/?fromgroups#!forum/netflix_blitz4j)
-
-
-Documentation
---------------
-Please see [wiki] (https://github.com/Netflix/blitz4j/wiki) for detailed documentation.
View
31 build.gradle
@@ -1,31 +0,0 @@
-// Establish version and status
-ext.githubProjectName = rootProject.name // Change if github project name is not the same as the root project's name
-group = "com.netflix.${githubProjectName}"
-
-buildscript {
- repositories { mavenCentral() }
- apply from: file('gradle/buildscript.gradle'), to: buildscript
-}
-
-allprojects {
- repositories { mavenCentral() }
-}
-
-apply from: file('gradle/convention.gradle')
-apply from: file('gradle/maven.gradle')
-apply from: file('gradle/check.gradle')
-apply from: file('gradle/license.gradle')
-apply from: file('gradle/release.gradle')
-
-//apply plugin: 'war'
-//apply plugin: 'jetty'
-
-dependencies {
- compile 'com.netflix.servo:servo-core:0.4.26'
- compile 'com.netflix.archaius:archaius-core:0.4.1'
- compile 'org.slf4j:slf4j-api:1.6.4'
- compile 'log4j:log4j:1.2.17'
- compile 'org.slf4j:slf4j-api:1.6.4'
- compile 'commons-collections:commons-collections:3.2.1'
-}
-
View
13 codequality/HEADER
@@ -1,13 +0,0 @@
-Copyright ${year} Netflix, Inc.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
View
189 codequality/checkstyle.xml
@@ -1,189 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE module PUBLIC
- "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
- "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
-
-<module name="Checker">
-
- <!-- Checks that a package-info.java file exists for each package. -->
- <!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocPackage -->
- <!--
- <module name="JavadocPackage">
- <property name="allowLegacy" value="true"/>
- </module>
- -->
-
- <!-- Checks whether files end with a new line. -->
- <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
- <module name="NewlineAtEndOfFile"/>
-
- <!-- Checks that property files contain the same keys. -->
- <!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
- <module name="Translation"/>
-
- <!-- Checks for Size Violations. -->
- <!-- See http://checkstyle.sf.net/config_sizes.html -->
- <module name="FileLength"/>
-
- <!-- Checks for whitespace -->
- <!-- See http://checkstyle.sf.net/config_whitespace.html -->
- <module name="FileTabCharacter"/>
-
- <!-- Miscellaneous other checks. -->
- <!-- See http://checkstyle.sf.net/config_misc.html -->
- <module name="RegexpSingleline">
- <property name="format" value="\s+$"/>
- <property name="minimum" value="0"/>
- <property name="maximum" value="0"/>
- <property name="message" value="Line has trailing spaces."/>
- <property name="severity" value="info"/>
- </module>
-
- <module name="TreeWalker">
-
- <!-- Checks for Javadoc comments. -->
- <!-- See http://checkstyle.sf.net/config_javadoc.html -->
- <module name="JavadocMethod">
- <property name="scope" value="package"/>
- <property name="allowMissingParamTags" value="true"/>
- <property name="allowMissingThrowsTags" value="true"/>
- <property name="allowMissingReturnTag" value="true"/>
- <property name="allowThrowsTagsForSubclasses" value="true"/>
- <property name="allowUndeclaredRTE" value="true"/>
- <property name="allowMissingPropertyJavadoc" value="true"/>
- </module>
- <module name="JavadocType">
- <property name="scope" value="package"/>
- </module>
- <module name="JavadocVariable">
- <property name="scope" value="package"/>
- </module>
- <module name="JavadocStyle">
- <property name="checkEmptyJavadoc" value="true"/>
- </module>
-
- <!-- Checks for Naming Conventions. -->
- <!-- See http://checkstyle.sf.net/config_naming.html -->
- <module name="ConstantName"/>
- <module name="LocalFinalVariableName"/>
- <module name="LocalVariableName"/>
- <module name="MemberName"/>
- <module name="MethodName"/>
- <module name="PackageName"/>
- <module name="ParameterName"/>
- <module name="StaticVariableName"/>
- <module name="TypeName"/>
-
- <!-- Checks for imports -->
- <!-- See http://checkstyle.sf.net/config_import.html -->
- <module name="AvoidStarImport"/>
- <module name="IllegalImport"/> <!-- defaults to sun.* packages -->
- <module name="RedundantImport"/>
- <module name="UnusedImports"/>
-
-
- <!-- Checks for Size Violations. -->
- <!-- See http://checkstyle.sf.net/config_sizes.html -->
- <module name="LineLength">
- <!-- what is a good max value? -->
- <property name="max" value="120"/>
- <!-- ignore lines like "$File: //depot/... $" -->
- <property name="ignorePattern" value="\$File.*\$"/>
- <property name="severity" value="info"/>
- </module>
- <module name="MethodLength"/>
- <module name="ParameterNumber"/>
-
-
- <!-- Checks for whitespace -->
- <!-- See http://checkstyle.sf.net/config_whitespace.html -->
- <module name="EmptyForIteratorPad"/>
- <module name="GenericWhitespace"/>
- <module name="MethodParamPad"/>
- <module name="NoWhitespaceAfter"/>
- <module name="NoWhitespaceBefore"/>
- <module name="OperatorWrap"/>
- <module name="ParenPad"/>
- <module name="TypecastParenPad"/>
- <module name="WhitespaceAfter"/>
- <module name="WhitespaceAround"/>
-
- <!-- Modifier Checks -->
- <!-- See http://checkstyle.sf.net/config_modifiers.html -->
- <module name="ModifierOrder"/>
- <module name="RedundantModifier"/>
-
-
- <!-- Checks for blocks. You know, those {}'s -->
- <!-- See http://checkstyle.sf.net/config_blocks.html -->
- <module name="AvoidNestedBlocks"/>
- <module name="EmptyBlock">
- <property name="option" value="text"/>
- </module>
- <module name="LeftCurly"/>
- <module name="NeedBraces"/>
- <module name="RightCurly"/>
-
-
- <!-- Checks for common coding problems -->
- <!-- See http://checkstyle.sf.net/config_coding.html -->
- <!-- <module name="AvoidInlineConditionals"/> -->
- <module name="DoubleCheckedLocking"/> <!-- MY FAVOURITE -->
- <module name="EmptyStatement"/>
- <module name="EqualsHashCode"/>
- <module name="HiddenField">
- <property name="ignoreConstructorParameter" value="true"/>
- <property name="ignoreSetter" value="true"/>
- <property name="severity" value="warning"/>
- </module>
- <module name="IllegalInstantiation"/>
- <module name="InnerAssignment"/>
- <module name="MagicNumber">
- <property name="severity" value="warning"/>
- </module>
- <module name="MissingSwitchDefault"/>
- <!-- Problem with finding exception types... -->
- <module name="RedundantThrows">
- <property name="allowUnchecked" value="true"/>
- <property name="suppressLoadErrors" value="true"/>
- <property name="severity" value="info"/>
- </module>
- <module name="SimplifyBooleanExpression"/>
- <module name="SimplifyBooleanReturn"/>
-
- <!-- Checks for class design -->
- <!-- See http://checkstyle.sf.net/config_design.html -->
- <!-- <module name="DesignForExtension"/> -->
- <module name="FinalClass"/>
- <module name="HideUtilityClassConstructor"/>
- <module name="InterfaceIsType"/>
- <module name="VisibilityModifier"/>
-
-
- <!-- Miscellaneous other checks. -->
- <!-- See http://checkstyle.sf.net/config_misc.html -->
- <module name="ArrayTypeStyle"/>
- <!-- <module name="FinalParameters"/> -->
- <module name="TodoComment">
- <property name="format" value="TODO"/>
- <property name="severity" value="info"/>
- </module>
- <module name="UpperEll"/>
-
- <module name="FileContentsHolder"/> <!-- Required by comment suppression filters -->
-
- </module>
-
- <!-- Enable suppression comments -->
- <module name="SuppressionCommentFilter">
- <property name="offCommentFormat" value="CHECKSTYLE IGNORE\s+(\S+)"/>
- <property name="onCommentFormat" value="CHECKSTYLE END IGNORE\s+(\S+)"/>
- <property name="checkFormat" value="$1"/>
- </module>
- <module name="SuppressWithNearbyCommentFilter">
- <!-- Syntax is "SUPPRESS CHECKSTYLE name" -->
- <property name="commentFormat" value="SUPPRESS CHECKSTYLE (\w+)"/>
- <property name="checkFormat" value="$1"/>
- <property name="influenceFormat" value="1"/>
- </module>
-</module>
View
1 gradle.properties
@@ -1 +0,0 @@
-version=1.6
View
12 gradle/buildscript.gradle
@@ -1,12 +0,0 @@
-// Executed in context of buildscript
-repositories {
- maven {
- name 'build-repo'
- url 'https://github.com/Netflix-Skunkworks/build-repo/raw/master/releases/'
- }
-}
-dependencies {
- classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.6.0'
- classpath 'com.mapvine:gradle-cobertura-plugin:0.1'
- classpath 'gradle-release:gradle-release:1.0-SNAPSHOT'
-}
View
23 gradle/check.gradle
@@ -1,23 +0,0 @@
-// Checkstyle
-apply plugin: 'checkstyle'
-tasks.withType(Checkstyle) { ignoreFailures = true }
-checkstyle {
- ignoreFailures = true // Waiting on GRADLE-2163
- configFile = rootProject.file('codequality/checkstyle.xml')
-}
-
-// FindBugs
-//apply plugin: 'findbugs'
-//tasks.withType(Findbugs) { reports.html.enabled true }
-
-// PMD
-//apply plugin: 'pmd'
-//tasks.withType(Pmd) { reports.html.enabled true }
-
-apply plugin: 'cobertura'
-cobertura {
- sourceDirs = sourceSets.main.java.srcDirs
- format = 'html'
- includes = ['**/*.java', '**/*.groovy']
- excludes = []
-}
View
53 gradle/convention.gradle
@@ -1,53 +0,0 @@
-apply plugin: 'java' // Plugin as major conventions
-
-sourceCompatibility = 1.6
-
-// GRADLE-2087 workaround, perform after java plugin
-status = version.contains('-SNAPSHOT')?'snapshot':'release'
-
-task sourcesJar(type: Jar, dependsOn:classes) {
- from sourceSets.main.allSource
- classifier 'sources'
- extension 'jar'
-}
-
-task javadocJar(type: Jar, dependsOn:javadoc) {
- from javadoc.destinationDir
- classifier 'javadoc'
- extension 'jar'
-}
-
-configurations.add('sources')
-configurations.add('javadoc')
-configurations.archives {
- extendsFrom configurations.sources
- extendsFrom configurations.javadoc
-}
-
-// When outputing to an Ivy repo, we want to use the proper type field
-gradle.taskGraph.whenReady {
- def isNotMaven = !it.hasTask(project.uploadMavenCentral)
- if (isNotMaven) {
- def artifacts = project.configurations.sources.artifacts
- def sourceArtifact = artifacts.iterator().next()
- sourceArtifact.type = 'sources'
- }
-}
-
-artifacts {
- sources(sourcesJar) {
- // Weird Gradle quirk where type will be used for the extension, but only for sources
- type 'jar'
- }
- javadoc(javadocJar) {
- type 'javadoc'
- }
-}
-
-// Ensure output is on a new line
-javadoc.doFirst { println "" }
-
-// Generate wrapper, which is distributed as part of source to alleviate the need of installing gradle
-task createWrapper(type: Wrapper) {
- gradleVersion = '1.1'
-}
View
7 gradle/license.gradle
@@ -1,7 +0,0 @@
-// Dependency for plugin was set in buildscript.gradle
-
-apply plugin: 'license' //nl.javadude.gradle.plugins.license.LicensePlugin
-license {
- header rootProject.file('codequality/HEADER')
- ext.year = Calendar.getInstance().get(Calendar.YEAR)
-}
View
63 gradle/maven.gradle
@@ -1,63 +0,0 @@
-// Maven side of things
-apply plugin: 'maven' // Java plugin has to have been already applied for the conf2scope mappings to work
-apply plugin: 'signing'
-
-signing {
- required { gradle.taskGraph.hasTask(uploadMavenCentral) }
- sign configurations.archives
-}
-
-/**
- * Publishing to Maven Central example provided from http://jedicoder.blogspot.com/2011/11/automated-gradle-project-deployment-to.html
- * artifactory will execute uploadArchives to force generation of ivy.xml, and we don't want that to trigger an upload to maven
- * central, so using custom upload task.
- */
-task uploadMavenCentral(type:Upload, dependsOn: signArchives) {
- configuration = configurations.archives
- doFirst {
- repositories.mavenDeployer {
- beforeDeployment { org.gradle.api.artifacts.maven.MavenDeployment deployment -> signing.signPom(deployment) }
-
- // To test deployment locally, use the following instead of oss.sonatype.org
- //repository(url: "file://localhost/${rootProject.rootDir}/repo")
-
- repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2') {
- authentication(userName: rootProject.sonatypeUsername, password: rootProject.sonatypePassword)
- }
-
- // Prevent datastamp from being appending to artifacts during deployment
- uniqueVersion = false
-
- // Closure to configure all the POM with extra info, common to all projects
- pom.project {
- name "${project.name}"
- description "${project.name} developed by Netflix"
- developers {
- developer {
- id 'netflixgithub'
- name 'Netflix Open Source Development'
- email 'talent@netflix.com'
- }
- }
- licenses {
- license {
- name 'The Apache Software License, Version 2.0'
- url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
- distribution 'repo'
- }
- }
- url "https://github.com/Netflix/${rootProject.githubProjectName}"
- scm {
- connection "scm:git:git@github.com:Netflix/${rootProject.githubProjectName}.git"
- url "scm:git:git@github.com:Netflix/${rootProject.githubProjectName}.git"
- developerConnection "scm:git:git@github.com:Netflix/${rootProject.githubProjectName}.git"
- }
- issueManagement {
- system 'github'
- url "https://github.com/Netflix/${rootProject.githubProjectName}/issues"
- }
- }
- }
- }
-}
-
View
1 gradle/netflix-oss.gradle
@@ -1 +0,0 @@
-apply from: 'http://artifacts.netflix.com/gradle-netflix-local/artifactory.gradle'
View
62 gradle/release.gradle
@@ -1,62 +0,0 @@
-apply plugin: 'release'
-
-// Ignore release plugin's task because it calls out via GradleBuild. This is a good place to put an email to send out
-task release(overwrite: true, dependsOn: commitNewVersion) << {
- // This is a good place to put an email to send out
-}
-commitNewVersion.dependsOn updateVersion
-updateVersion.dependsOn createReleaseTag
-createReleaseTag.dependsOn preTagCommit
-preTagCommit.dependsOn build
-preTagCommit.dependsOn checkSnapshotDependencies
-//checkSnapshotDependencies.dependsOn confirmReleaseVersion // Introduced in 1.0, forces readLine
-//confirmReleaseVersion.dependsOn unSnapshotVersion
-checkSnapshotDependencies.dependsOn unSnapshotVersion // Remove once above is fixed
-unSnapshotVersion.dependsOn checkUpdateNeeded
-checkUpdateNeeded.dependsOn checkCommitNeeded
-checkCommitNeeded.dependsOn initScmPlugin
-
-[
- uploadIvyLocal: 'uploadLocal',
- uploadArtifactory: 'artifactoryPublish', // Call out to compile against internal repository
- buildWithArtifactory: 'build' // Build against internal repository
-].each { key, value ->
- // Call out to compile against internal repository
- task "${key}"(type: GradleBuild) {
- startParameter = project.gradle.startParameter.newInstance()
- startParameter.addInitScript( file('gradle/netflix-oss.gradle') )
- startParameter.getExcludedTaskNames().add('check')
- tasks = [ 'build', value ]
- }
-}
-task releaseArtifactory(dependsOn: [checkSnapshotDependencies, uploadArtifactory])
-
-// Ensure upload happens before taggging but after all pre-checks
-releaseArtifactory.dependsOn checkSnapshotDependencies
-createReleaseTag.dependsOn releaseArtifactory
-gradle.taskGraph.whenReady { taskGraph ->
- if ( taskGraph.hasTask(uploadArtifactory) && rootProject.status == 'release' && !taskGraph.hasTask(':release') ) {
- throw new GradleException('"release" task has to be run before uploading a release to Artifactory')
- }
-}
-
-project.uploadMavenCentral.dependsOn rootProject.checkSnapshotDependencies
-rootProject.createReleaseTag.dependsOn project.uploadMavenCentral
-gradle.taskGraph.whenReady { taskGraph ->
- if ( taskGraph.hasTask(project.uploadMavenCentral) && !taskGraph.hasTask(':release') ) {
- throw new GradleException('"release" task has to be run before uploading to Maven Central')
- }
-}
-
-// Prevent plugin from asking for a version number interactively
-ext.'gradle.release.useAutomaticVersion' = "true"
-
-release {
- // http://tellurianring.com/wiki/gradle/release
- failOnCommitNeeded=true
- failOnPublishNeeded=true
- failOnUnversionedFiles=true
- failOnUpdateNeeded=true
- includeProjectNameInTag=true
- requireBranch = null
-}
View
BIN gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
View
6 gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +0,0 @@
-#Tue Aug 14 16:28:54 PDT 2012
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
-distributionUrl=http\://services.gradle.org/distributions/gradle-1.1-bin.zip
View
164 gradlew
@@ -1,164 +0,0 @@
-#!/bin/bash
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn ( ) {
- echo "$*"
-}
-
-die ( ) {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
-esac
-
-# For Cygwin, ensure paths are in UNIX format before anything is touched.
-if $cygwin ; then
- [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
-fi
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/"
-APP_HOME="`pwd -P`"
-cd "$SAVED"
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
-}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
-
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
View
90 gradlew.bat
@@ -1,90 +0,0 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windowz variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
View
1 settings.gradle
@@ -1 +0,0 @@
-rootProject.name='blitz4j'
View
518 src/main/java/com/netflix/blitz4j/AsyncAppender.java
@@ -1,518 +0,0 @@
-/*
- * Copyright 2012 Netflix, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.netflix.blitz4j;
-
-import java.text.MessageFormat;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.log4j.Appender;
-import org.apache.log4j.AppenderSkeleton;
-import org.apache.log4j.helpers.AppenderAttachableImpl;
-import org.apache.log4j.spi.AppenderAttachable;
-import org.apache.log4j.spi.LocationInfo;
-import org.apache.log4j.spi.LoggingEvent;
-
-import com.google.common.cache.CacheBuilder;
-import com.netflix.logging.messaging.BatcherFactory;
-import com.netflix.logging.messaging.MessageBatcher;
-import com.netflix.logging.messaging.MessageProcessor;
-import com.netflix.servo.annotations.DataSourceType;
-import com.netflix.servo.monitor.DynamicCounter;
-import com.netflix.servo.monitor.Monitors;
-import com.netflix.servo.monitor.Stopwatch;
-import com.netflix.servo.monitor.Timer;
-
-/**
- * A log4j appender implementation that logs the events asynchronously after
- * storing the events in a buffer. The buffer implementation uses an instance of
- * {@link com.netflix.logging.messaging.MessageBatcher}.
- * <p>
- * Incoming events are first stored in a queue and then worker thread(s) takes
- * the messages and writes it to the underlying appenders. This makes the
- * logging of the messages efficient for the following reasons
- *
- * 1) Logging threads do not block until the event is written to the
- * destination, but block only until the message is written to the queue which
- * should be way faster than having to wait until it is written to the
- * underlying destination
- *
- * 2) During log storms, the in-memory buffer overflows the message to another
- * structure which logs just the summary and not each log message
- * </p>
- * <p>
- * By default the buffer holds up to 10K messages and summary up to 5K entries.
- * Depending on the memory constraints and logging frequency, both these are
- * configurable. The summary also starts dropping its entries when it stays
- * there longer than 1 min which is configurable as well.
- * </p>
- *
- * @author Karthik Ranganathan
- *
- */
-public class AsyncAppender extends AppenderSkeleton implements
- AppenderAttachable {
-
- private static final BlitzConfig CONFIGURATION = LoggingConfiguration
- .getInstance().getConfiguration();
- private static final int SLEEP_TIME_MS = 1;
- private static final String BATCHER_NAME_LIMITER = ".";
- private static final String APPENDER_NAME = "ASYNC";
- private MessageBatcher<LoggingEvent> batcher;
- private String originalAppenderName;
- private static final String LOGGER_ASYNC_APPENDER = "asyncAppenders";
- private AppenderAttachableImpl appenders = new AppenderAttachableImpl();
-
- // The Map to the summary events
- private ConcurrentMap<String, LogSummary> logSummaryMap = new ConcurrentHashMap<String, LogSummary>();
-
- private Timer putBufferTimeTracer;
- private Timer putDiscardMapTimeTracer;
- private Timer locationInfoTimer;
- private Timer saveThreadLocalTimer;
-
-
- public AsyncAppender() {
- this.name = APPENDER_NAME;
-
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime
- * result
- + ((originalAppenderName == null) ? 0 : originalAppenderName
- .hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- AsyncAppender other = (AsyncAppender) obj;
- if (originalAppenderName == null) {
- if (other.originalAppenderName != null)
- return false;
- } else if (!originalAppenderName.equals(other.originalAppenderName))
- return false;
- return true;
- }
-
- /**
- * Initialize the batcher that stores the messages and calls the underlying
- * appenders.
- *
- * @param appenderName
- * - The name of the appender for which the batcher is created
- */
- private void initBatcher(String appenderName) {
- MessageProcessor<LoggingEvent> messageProcessor = new MessageProcessor<LoggingEvent>() {
- @Override
- public void process(List<LoggingEvent> objects) {
- processLoggingEvents(objects);
- }
- };
- String batcherName = this.getClass().getName() + BATCHER_NAME_LIMITER
- + appenderName;
- batcher = BatcherFactory.createBatcher(batcherName, messageProcessor);
- batcher.setTarget(messageProcessor);
-
- }
-
- /**
- * Process the logging events. This is called by the batcher.
- *
- * @param loggingEvents
- * - The logging events to be written to the underlying appender
- */
- private void processLoggingEvents(List<LoggingEvent> loggingEvents) {
- // Lazy initialization of the appender. This is needed because the
- // original appenders configuration may be available only after the
- // complete
- // log4j initialization.
- while (appenders.getAllAppenders() == null) {
- if ((batcher == null) || (batcher.isPaused())) {
- try {
- Thread.sleep(SLEEP_TIME_MS);
- } catch (InterruptedException ignore) {
-
- }
- continue;
- }
-
- org.apache.log4j.Logger asyncLogger = LoggerCache.getInstance()
- .getOrCreateLogger(LOGGER_ASYNC_APPENDER);
- Appender originalAppender = asyncLogger
- .getAppender(originalAppenderName);
- if (originalAppender == null) {
- try {
- Thread.sleep(SLEEP_TIME_MS);
- } catch (InterruptedException ignore) {
-
- }
- continue;
- }
- appenders.addAppender(originalAppender);
- }
- // First take the overflown summary events and put it back in the queue
- for (Iterator<Entry<String, LogSummary>> iter = logSummaryMap
- .entrySet().iterator(); iter.hasNext();) {
- Entry<String, LogSummary> mapEntry = (Entry<String, LogSummary>) iter
- .next();
- // If the space is not available, then exit immediately
- if (batcher.isSpaceAvailable()) {
- LogSummary logSummary = mapEntry.getValue();
- LoggingEvent event = logSummary.createEvent();
- // Put the event in the queue and remove the event from the summary
- if (batcher.process(event)) {
- iter.remove();
- } else {
- break;
- }
- } else {
- break;
- }
-
- }
- // Process the events from the queue and call the underlying
- // appender
- for (LoggingEvent event : loggingEvents) {
- appenders.appendLoopOnAppenders(event);
-
- }
-
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.log4j.AppenderSkeleton#append(org.apache.log4j.spi.LoggingEvent)
- */
- public void append(final LoggingEvent event) {
- boolean isBufferSpaceAvailable = (batcher.isSpaceAvailable() && (logSummaryMap
- .size() == 0));
- boolean isBufferPutSuccessful = false;
- LocationInfo locationInfo = null;
- // Reject it when we have a fast property as these can be expensive
- Stopwatch s = locationInfoTimer.start();
- if (CONFIGURATION.shouldSummarizeOverflow(this.originalAppenderName)) {
- if (CONFIGURATION.shouldGenerateBlitz4jLocationInfo()) {
- locationInfo = LoggingContext.getInstance()
- .generateLocationInfo(event);
- } else if (CONFIGURATION.shouldGenerateLog4jLocationInfo()) {
- locationInfo = event.getLocationInformation();
- }
- }
- s.stop();
-
- if (isBufferSpaceAvailable) {
- // Save the thread local info in the event so that the
- // processing threads can have access to the thread local of the arriving event
- Stopwatch sThreadLocal = saveThreadLocalTimer.start();
- saveThreadLocalInfo(event);
- sThreadLocal.stop();
- isBufferPutSuccessful = putInBuffer(event);
- }
- // If the buffer is full, then summarize the information
- if (CONFIGURATION.shouldSummarizeOverflow(this.originalAppenderName) && (!isBufferPutSuccessful)) {
- DynamicCounter.increment(this.originalAppenderName
- + "_summarizeEvent", null);
- Stopwatch t = putDiscardMapTimeTracer.start();
- String loggerKey = event.getLoggerName();
- if (locationInfo != null) {
- loggerKey = locationInfo.getClassName() + "_"
- + locationInfo.getLineNumber();
- }
-
- LogSummary summary = (LogSummary) logSummaryMap.get(loggerKey);
- if (summary == null) {
- // Saving the thread local info is needed only for the first
- // time
- // creation of the summary
- saveThreadLocalInfo(event);
- summary = new LogSummary(event);
- logSummaryMap.put(loggerKey, summary);
- } else {
- // The event summary is already there, just increment the
- // count
- summary.add(event);
- }
- t.stop();
- } else if (!CONFIGURATION.shouldSummarizeOverflow(this.originalAppenderName) && (!isBufferPutSuccessful)) {
- // Record the event that are not summarized and which are just
- // discarded
- DynamicCounter.increment(this.originalAppenderName
- + "_discardEvent", null);
- }
-
- }
-
- /**
- * Sets the name of the underlying appender that is wrapped by this
- * <code>AsyncAppender</code>
- *
- * @param name
- * - The name of the underlying appender
- */
- public void setOriginalAppenderName(String name) {
- this.originalAppenderName = name;
- this.initBatcher(this.originalAppenderName);
- this.putBufferTimeTracer = Monitors.newTimer("putBuffer",
- TimeUnit.NANOSECONDS);
- this.putDiscardMapTimeTracer = Monitors.newTimer("putDiscardMap",
- TimeUnit.NANOSECONDS);
- this.locationInfoTimer = Monitors.newTimer("locationInfo",
- TimeUnit.NANOSECONDS);
- this.saveThreadLocalTimer = Monitors.newTimer("saveThreadLocal",
- TimeUnit.NANOSECONDS);
-
- this.logSummaryMap = CacheBuilder
- .newBuilder()
- .initialCapacity(5000)
- .maximumSize(
- CONFIGURATION.getLogSummarySize(originalAppenderName))
- .expireAfterWrite(
- CONFIGURATION
- .getLogSummaryExpiry(originalAppenderName),
- TimeUnit.SECONDS).<String, LogSummary> build().asMap();
- try {
- Monitors.registerObject(this.originalAppenderName, this);
- } catch (Throwable e) {
- if (CONFIGURATION.shouldPrintLoggingErrors()) {
- System.err.println("Cannot register monitor for AsyncAppender "
- + this.originalAppenderName);
- e.printStackTrace();
- }
- }
- }
-
- /**
- * Save the thread local info of the event in the event itself for
- * processing later.
- *
- * @param event
- * - The logging event for which the information should be saved
- */
- private void saveThreadLocalInfo(final LoggingEvent event) {
- // Set the NDC and thread name for the calling thread as these
- // LoggingEvent fields were not set at event creation time.
- event.getNDC();
- event.getThreadName();
- // Get a copy of this thread's MDC.
- event.getMDCCopy();
- }
-
- /**
- * Puts the logging events to the in-memory buffer.
- *
- * @param event
- * - The event that needs to be put in the buffer.
- * @return - true, if the put was successful, false otherwise
- */
- private boolean putInBuffer(final LoggingEvent event) {
- DynamicCounter.increment(this.originalAppenderName + "_putInBuffer",
- null);
- Stopwatch t = putBufferTimeTracer.start();
- boolean hasPut = false;
- if (batcher.process(event)) {
- hasPut = true;
- } else {
- hasPut = false;
- }
- t.stop();
- return hasPut;
- }
-
- /**
- * Summary of discarded logging events for a logger.
- */
- private static final class LogSummary {
- private LoggingEvent event;
- private int count;
-
- /**
- * Create new instance.
- *
- * @param event
- * event, may not be null.
- */
- public LogSummary(final LoggingEvent event) {
- count = 1;
- this.event = event;
- }
-
- /**
- * Add discarded event to summary.
- *
- * @param event
- * event, may not be null.
- */
- public void add(final LoggingEvent event) {
- count++;
- }
-
- /**
- * Create event with summary information.
- *
- * @return new event.
- */
- public LoggingEvent createEvent() {
- String msg = MessageFormat
- .format("{1}[Summarized {0} messages of this type because the internal buffer was full]",
- new Object[] { new Integer(count),
- event.getMessage() });
- LoggingEvent loggingEvent = new LoggingEvent(
- event.getFQNOfLoggerClass(), event.getLogger(),
- event.getTimeStamp(), event.getLevel(), msg, Thread
- .currentThread().getName(),
- event.getThrowableInformation(), null, null,
- event.getProperties());
- return loggingEvent;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.log4j.AppenderSkeleton#close()
- */
- @Override
- public void close() {
- synchronized (appenders) {
- appenders.removeAllAppenders();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.log4j.spi.AppenderAttachable#getAllAppenders()
- */
- @Override
- public Enumeration getAllAppenders() {
- synchronized (appenders) {
- return appenders.getAllAppenders();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.log4j.spi.AppenderAttachable#getAppender(java.lang.String)
- */
- @Override
- public Appender getAppender(final String name) {
- synchronized (appenders) {
- return appenders.getAppender(name);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.log4j.spi.AppenderAttachable#isAttached(org.apache.log4j.Appender
- * )
- */
- @Override
- public boolean isAttached(final Appender appender) {
- synchronized (appenders) {
- return appenders.isAttached(appender);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.log4j.AppenderSkeleton#requiresLayout()
- */
- @Override
- public boolean requiresLayout() {
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.log4j.spi.AppenderAttachable#removeAllAppenders()
- */
- @Override
- public void removeAllAppenders() {
- synchronized (appenders) {
- appenders.removeAllAppenders();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.log4j.spi.AppenderAttachable#removeAppender(org.apache.log4j
- * .Appender)
- */
- @Override
- public void removeAppender(final Appender appender) {
- synchronized (appenders) {
- appenders.removeAppender(appender);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.log4j.spi.AppenderAttachable#removeAppender(java.lang.String)
- */
- @Override
- public void removeAppender(final String name) {
- synchronized (appenders) {
- appenders.removeAppender(name);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.log4j.spi.AppenderAttachable#addAppender(org.apache.log4j.
- * Appender)
- */
- @Override
- public void addAppender(final Appender newAppender) {
- synchronized (appenders) {
- appenders.addAppender(newAppender);
- }
- }
-
- @com.netflix.servo.annotations.Monitor(name = "discardMapSize", type = DataSourceType.GAUGE)
- public int getDiscadMapSize() {
- return logSummaryMap.size();
- }
-
-}
View
179 src/main/java/com/netflix/blitz4j/BlitzConfig.java
@@ -1,179 +0,0 @@
-package com.netflix.blitz4j;
-
-public interface BlitzConfig {
-
- /**
- * Indicates whether blitz4j should use its less contended implementation.
- *
- * @return
- */
- public abstract boolean shouldUseLockFree();
-
- /**
- * Indicates whether blitz4j should print the errors during logging for
- * debugging.
- *
- * @return
- */
- public abstract boolean shouldPrintLoggingErrors();
-
- /**
- * Get the list of asynchronous appenders. The configuration is specified
- * similar to any log4j loging override
- * (ie)log4j.logger.asyncAppenders=INFO,MYAPPENDER. The logging level in
- * this definitions bears no specific significance and is only for
- * completion.
- *
- * @return
- */
- public abstract String[] getAsyncAppenders();
-
- /**
- * Get the time in seconds that the summary that is stored will expire.
- *
- * @param originalAppenderName
- * - The name of the appender for which the logging is done
- * @return
- */
- public abstract int getLogSummaryExpiry(String originalAppenderName);
-
- /**
- * Get the size of the log summary information.
- *
- * @param originalAppenderName
- * - The name of the appender for which the logging is done
- * @return
- */
- public abstract int getLogSummarySize(String originalAppenderName);
-
- /**
- * Checks whether the blitz4j based location information is generated or
- * not.
- *
- * @return - true, if the location information need to be generated, false
- * otherwise.
- */
- public abstract boolean shouldGenerateBlitz4jLocationInfo();
-
- /**
- * Checks whether the log4j based location information is generated or not.
- *
- * @return - true, if the location information need to be generated, false
- * otherwise.
- */
- public abstract boolean shouldGenerateLog4jLocationInfo();
-
- /**
- * Checks whether the summary information should be generated when the
- * asynchronous buffer becomes full.
- *
- * @param originalAppenderName
- * - The appender name for which the logging is done
- * @return - true, if the information should be summarized, false otherwise
- */
- public abstract boolean shouldSummarizeOverflow(String originalAppenderName);
-
- /**
- * Get the list of asynchronous appender names so that they can be treated a
- * little differently during dynamic reconfiguration.
- *
- * @return - The list of asynchronous appender names
- */
- public abstract String[] getAsyncAppenderImplementationNames();
-
- /**
- * Gets the maximum number of messages allowed in the buffer.
- *
- * @param batcherName
- * - The name of the batcher
- * @return - an integer value denoting the size of the buffer
- */
- public abstract int getBatcherQueueMaxMessages(String batcherName);
-
- /**
- * Gets the batch size of each batch for which the log processing is done.
- *
- * @param batcherName
- * - The name of the batcher
- * @return - an integer value denoting the size of the batch
- */
- public abstract int getBatchSize(String batcherName);
-
- /**
- * Get the time to wait before the batcher flushes out all its messages in
- * the buffer.
- *
- * @param batcherName
- * - The name of the batcher
- * @return - time in seconds
- */
- public abstract int getBatcherWaitTimeBeforeShutdown(String batcherName);
-
- /**
- * Gets the time to wait for the messages to be batcher before it is given
- * to processor threads.
- *
- * @param batcherName
- * - The name of the batcher.
- * @return - double value in seconds
- */
- public abstract double getBatcherMaxDelay(String batcherName);
-
- /**
- * Checks to see whether the caller threads should block and wait if the
- * internal buffer is full.
- *
- * @param batcherName
- * - The name of the batcher.
- * @return - true, if the caller threads should block and wait, false
- * otherwise.
- */
- public abstract boolean shouldWaitWhenBatcherQueueNotEmpty(
- String batcherName);
-
- /**
- * Gets the minimum number of processing threads that should be run to
- * handle the messages.
- *
- * @param batcherName
- * - The name of the batcher.
- * @return - an integer value indicating the minimum number of threads to be
- * run
- */
- public abstract int getBatcherMinThreads(String batcherName);
-
- /**
- * Gets the maximum number of processing threads that should be run to
- * handle the messages.
- *
- * @param batcherName
- * - The name of the batcher
- * @return - an integer value indicating the maximum number of threads to be
- * run
- */
- public abstract int getBatcherMaxThreads(String batcherName);
-
- /**
- * Gets the time to keep the processing threads alive when they are idle.
- *
- * @param batcherName
- * - The name of the batcher
- * @return - time in seconds
- */
- public abstract int getBatcherThreadKeepAliveTime(String batcherName);
-
- /**
- * Checks to see if the collector threads that hands the message to the
- * processor threads should participate in processing or not when all the
- * threads are used up.
- *
- * @param batcherName
- * - The name of the batcher
- * @return - true if the collector threads participates in processing, false
- * if the processing is rejected. If the processing is rejected, it
- * is retried indefinitely.
- */
- public abstract boolean shouldRejectWhenAllBatcherThreadsUsed(
- String batcherName);
-
-}
View
223 src/main/java/com/netflix/blitz4j/DefaultBlitz4jConfig.java
@@ -1,223 +0,0 @@
-/*
- * Copyright 2012 Netflix, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.netflix.blitz4j;
-
-import com.netflix.config.DynamicPropertyFactory;
-
-/**
- * The configuration class for blitz4j.
- *
- * All custom configurations can be specified by properties as defined by the
- * configurations.
- *
- * @author Karthik Ranganathan
- *
- */
-public class DefaultBlitz4jConfig implements BlitzConfig {
-
- private static final DynamicPropertyFactory CONFIGURATION = DynamicPropertyFactory.getInstance();
-
- /* (non-Javadoc)
- * @see com.netflix.blitz4j.BlitzConfig#shouldUseLockFree()
- */
- @Override
- public boolean shouldUseLockFree() {
- return CONFIGURATION
- .getBooleanProperty("netflix.blitz4j.lockfree", true).get();
- }
-
- /* (non-Javadoc)
- * @see com.netflix.blitz4j.BlitzConfig#shouldPrintLoggingErrors()
- */
- @Override
- public boolean shouldPrintLoggingErrors() {
- return CONFIGURATION
- .getBooleanProperty("netflix.blitz4j.printLoggingErrors", false)
- .get();
- }
-
- /* (non-Javadoc)
- * @see com.netflix.blitz4j.BlitzConfig#getAsyncAppenders()
- */
- @Override
- public String[] getAsyncAppenders() {
- return CONFIGURATION
- .getStringProperty("log4j.logger.asyncAppenders", "OFF").get()
- .split(",");
-
- }
-
- /* (non-Javadoc)
- * @see com.netflix.blitz4j.BlitzConfig#getLogSummaryExpiry(java.lang.String)
- */
- @Override
- public int getLogSummaryExpiry(String originalAppenderName) {
-
- return CONFIGURATION
- .getIntProperty(
- "netflix.blitz4j." + originalAppenderName
- + ".discardEntryExpireSeconds", 60).get();
-
- }
-
- /* (non-Javadoc)
- * @see com.netflix.blitz4j.BlitzConfig#getLogSummarySize(java.lang.String)
- */
- @Override
- public int getLogSummarySize(String originalAppenderName) {
-
- return CONFIGURATION
- .getIntProperty(
- "netflix.blitz4j." + originalAppenderName
- + ".discardMapSize", 10000).get();
-
- }
-
- /* (non-Javadoc)
- * @see com.netflix.blitz4j.BlitzConfig#shouldGenerateBlitz4jLocationInfo()
- */
- @Override
- public boolean shouldGenerateBlitz4jLocationInfo() {
- return CONFIGURATION
- .getBooleanProperty(
- "netflix.blitz4j.generateBlitz4jLocationInfo", true)
- .get();
-
- }
-
- /* (non-Javadoc)
- * @see com.netflix.blitz4j.BlitzConfig#shouldGenerateLog4jLocationInfo()
- */
- @Override
- public boolean shouldGenerateLog4jLocationInfo() {
- return CONFIGURATION
- .getBooleanProperty(
- "netflix.blitz4j.generateLog4jLocationInfo", false)
- .get();
-
- }
-
- /* (non-Javadoc)
- * @see com.netflix.blitz4j.BlitzConfig#shouldSummarizeOverflow(java.lang.String)
- */
- @Override
- public boolean shouldSummarizeOverflow(String originalAppenderName) {
- return CONFIGURATION
- .getBooleanProperty(
- "netflix.blitz4j" + originalAppenderName
- + ".summarizeOverflow", true).get();
- }
-
- /* (non-Javadoc)
- * @see com.netflix.blitz4j.BlitzConfig#getAsyncAppenderImplementationNames()
- */
- @Override
- public String[] getAsyncAppenderImplementationNames() {
- return CONFIGURATION
- .getStringProperty("blitz4j.asyncAppenders",
- "com.netflix.blitz4j.AsyncAppender").get().split(",");
- }
-
- /* (non-Javadoc)
- * @see com.netflix.blitz4j.BlitzConfig#getBatcherQueueMaxMessages(java.lang.String)
- */
- @Override
- public int getBatcherQueueMaxMessages(String batcherName) {
- return CONFIGURATION
- .getIntProperty(batcherName + "." + "queue.maxMessages", 10000)
- .get();
- }
-
- /* (non-Javadoc)
- * @see com.netflix.blitz4j.BlitzConfig#getBatchSize(java.lang.String)
- */
- @Override
- public int getBatchSize(String batcherName) {
- return CONFIGURATION
- .getIntProperty(batcherName + "." + "batch.maxMessages", 30)
- .get();
- }
-
- /* (non-Javadoc)
- * @see com.netflix.blitz4j.BlitzConfig#getBatcherWaitTimeBeforeShutdown(java.lang.String)
- */
- @Override
- public int getBatcherWaitTimeBeforeShutdown(String batcherName) {
- return CONFIGURATION
- .getIntProperty(batcherName + ".waitTimeinMillis", 10000).get();
- }
-
- /* (non-Javadoc)
- * @see com.netflix.blitz4j.BlitzConfig#getBatcherMaxDelay(java.lang.String)
- */
- @Override
- public double getBatcherMaxDelay(String batcherName) {
- return CONFIGURATION
- .getDoubleProperty(batcherName + "." + "batch.maxDelay", 0.5)
- .get();
- }
-
- /* (non-Javadoc)
- * @see com.netflix.blitz4j.BlitzConfig#shouldWaitWhenBatcherQueueNotEmpty(java.lang.String)
- */
- @Override
- public boolean shouldWaitWhenBatcherQueueNotEmpty(String batcherName) {
- return CONFIGURATION
- .getBooleanProperty(batcherName + ".blocking", false).get();
-
- }
-
- /* (non-Javadoc)
- * @see com.netflix.blitz4j.BlitzConfig#getBatcherMinThreads(java.lang.String)
- */
- @Override
- public int getBatcherMinThreads(String batcherName) {
- return CONFIGURATION
- .getIntProperty(batcherName + ".minThreads", 1).get();
-
- }
-
- /* (non-Javadoc)
- * @see com.netflix.blitz4j.BlitzConfig#getBatcherMaxThreads(java.lang.String)
- */
- @Override
- public int getBatcherMaxThreads(String batcherName) {
- return CONFIGURATION
- .getIntProperty(batcherName + ".maxThreads", 3).get();
-
- }
-
- /* (non-Javadoc)
- * @see com.netflix.blitz4j.BlitzConfig#getBatcherThreadKeepAliveTime(java.lang.String)
- */
- @Override
- public int getBatcherThreadKeepAliveTime(String batcherName) {
- return CONFIGURATION
- .getIntProperty(batcherName + ".keepAliveTime", 900).get();
-
- }
-
- /* (non-Javadoc)
- * @see com.netflix.blitz4j.BlitzConfig#shouldRejectWhenAllBatcherThreadsUsed(java.lang.String)
- */
- @Override
- public boolean shouldRejectWhenAllBatcherThreadsUsed(String batcherName) {
- return CONFIGURATION
- .getBooleanProperty(batcherName + ".rejectWhenFull", false)
- .get();
- }
-}
View
66 src/main/java/com/netflix/blitz4j/LoggerCache.java
@@ -1,66 +0,0 @@
-/*
- * Copyright 2012 Netflix, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.netflix.blitz4j;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.log4j.Logger;
-
-
-/**
- * The class that caches log4j loggers.
- *
- * <p>
- * This will be much more contention free than log4j caching since the the cache uses a {@link java.util.concurrent.ConcurrentHashMap} instead of {@link java.util.Map}
- * </p>
- *
- * @author Karthik Ranganathan
- *
- */
-public class LoggerCache {
- private static LoggerCache instance = new LoggerCache();
- private Map<String, Logger> appenderLoggerMap = new ConcurrentHashMap<String, Logger>(5000);
-
-
- private LoggerCache() {
-
- }
-
- public static LoggerCache getInstance() {
- return instance;
- }
-
- /**
- * Get the logger to be used for the given class.
- * @param clazz - The class for which the logger needs to be returned
- * @return- The log4j logger object
- */
- public Logger getOrCreateLogger(String clazz) {
- Logger logger = appenderLoggerMap.get(clazz);
- if (logger == null) {
- // If multiple threads do the puts, that is fine as it is a one time thing
- logger = Logger.getLogger(clazz);
- appenderLoggerMap.put(clazz, logger);
- }
- return logger;
- }
-
- public void clearAll() {
- appenderLoggerMap.clear();
- }
-}
View
485 src/main/java/com/netflix/blitz4j/LoggingConfiguration.java
@@ -1,485 +0,0 @@
-/*
- * Copyright 2012 Netflix, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.netflix.blitz4j;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.RejectedExecutionException;
-import java.util.concurrent.SynchronousQueue;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.log4j.PropertyConfigurator;
-import org.apache.log4j.spi.LoggerFactory;
-import org.slf4j.Logger;
-
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import com.netflix.config.ConfigurationManager;
-import com.netflix.config.ExpandedConfigurationListenerAdapter;
-import com.netflix.config.PropertyListener;
-import com.netflix.logging.messaging.BatcherFactory;
-import com.netflix.logging.messaging.MessageBatcher;
-
-/**
- * The main configuration class that bootstraps the <em>blitz4j</em>
- * implementation.
- *
- * <p>
- * The users can either use {@link #configure()} or
- * {@link #configure(Properties)} to kick start the configuration. If the
- * <code>log4j.configuration</code> is provided, the properties are additionally
- * loaded from the provided {@link URL}.
- * </p>
- *
- * <p>
- * The list of appenders to be automatically converted can be provided by the
- * property <code>log4j.logger.asyncAppenders</code>. The configuration takes
- * these appenders and automatically enables them for asynchronous logging.
- * </p>
- *
- * @author Karthik Ranganathan
- *
- */
-public class LoggingConfiguration implements PropertyListener {
-
- private static final String BLITZ_LOGGER_FACTORY = "com.netflix.blitz4j.NFCategoryFactory";
- private static final String PROP_LOG4J_CONFIGURATION = "log4j.configuration";
- private static final Object guard = new Object();
- private static final String PROP_LOG4J_LOGGER_FACTORY = "log4j.loggerFactory";
- private static final String LOG4J_FACTORY_IMPL = "com.netflix.logging.log4jAdapter.NFCategoryFactory";
-
- private static final String LOG4J_LOGGER_FACTORY = "log4j.loggerFactory";
- private static final BlitzConfig blitz4jConfig = new DefaultBlitz4jConfig();
-
- private static final String PROP_LOG4J_ORIGINAL_APPENDER_NAME = "originalAppenderName";
- private static final String LOG4J_PREFIX = "log4j.logger";
- private static final String LOG4J_APPENDER_DELIMITER = ".";
- private static final String LOG4J_APPENDER_PREFIX = "log4j.appender";
- private static final String ASYNC_APPENDERNAME_SUFFIX = "_ASYNC";
- private static final String ROOT_CATEGORY = "rootCategory";
- private static final String ROOT_LOGGER = "rootLogger";
- private Map<String, String> originalAsyncAppenderNameMap = new HashMap<String, String>();
- private Properties props = new Properties();
- Properties updatedProps = new Properties();
- private final ExecutorService executorPool;
- private Logger logger;
- private static final int SLEEP_TIME_MS = 200;
- private static final CharSequence PROP_LOG4J_ASYNC_APPENDERS = "log4j.logger.asyncAppenders";
-
- private static LoggingConfiguration instance = new LoggingConfiguration();
-
- private LoggingConfiguration() {
- ThreadFactory threadFactory = new ThreadFactoryBuilder()
- .setDaemon(false).setNameFormat("DynamicLog4jListener").build();
-
- this.executorPool = new ThreadPoolExecutor(0, 1, 15 * 60,
- TimeUnit.SECONDS, new SynchronousQueue(), threadFactory);
- }
-
- /**
- * Kick start the blitz4j implementation
- */
- public void configure() {
- this.configure(null);
- }
-
- /**
- * Kick start the blitz4j implementation.
- *
- * @param props
- * - The overriding <em>log4j</em> properties if any.
- */
- public void configure(Properties props) {
- this.originalAsyncAppenderNameMap.clear();
- if (props != null) {
- this.props = props;
- }
- if (this.props != null) {
- Enumeration enumeration = this.props.propertyNames();
-
- while (enumeration.hasMoreElements()) {
- String key = (String) enumeration.nextElement();
- ConfigurationManager.getConfigInstance().setProperty(key,
- props.getProperty(key));
- }
- }
- NFHierarchy nfHierarchy = null;
- // Make log4j use blitz4j implementations
- if (blitz4jConfig.shouldUseLockFree()) {
- nfHierarchy = new NFHierarchy(new NFRootLogger(
- org.apache.log4j.Level.INFO));
- org.apache.log4j.LogManager.setRepositorySelector(
- new NFRepositorySelector(nfHierarchy), guard);
- }
- String log4jLoggerFactory = System
- .getProperty(PROP_LOG4J_LOGGER_FACTORY);
- if (log4jLoggerFactory != null) {
- this.props.setProperty(PROP_LOG4J_LOGGER_FACTORY,
- log4jLoggerFactory);
- if (nfHierarchy != null) {
- try {
- LoggerFactory loggerFactory = (LoggerFactory) Class
- .forName(log4jLoggerFactory).newInstance();
- nfHierarchy.setLoggerFactory(loggerFactory);
- } catch (Throwable e) {
- System.err
- .println("Cannot set the logger factory. Hence reverting to default.");
- e.printStackTrace();
- }
- }
- } else {
- if (blitz4jConfig.shouldUseLockFree()) {
- this.props.setProperty(PROP_LOG4J_LOGGER_FACTORY,
- BLITZ_LOGGER_FACTORY);
- }
- }
- String log4jConfigurationFile = System
- .getProperty(PROP_LOG4J_CONFIGURATION);
-
- if (log4jConfigurationFile != null) {
- InputStream in = null;
- try {
- URL url = new URL(log4jConfigurationFile);
- in = url.openStream();
- this.props.load(in);
- } catch (Throwable t) {
- throw new RuntimeException(
- "Cannot load log4 configuration file specified in "
- + PROP_LOG4J_CONFIGURATION, t);
- } finally {
-
- if (in != null) {
- try {
- in.close();
- } catch (IOException ignore) {
-
- }
- }
- }
-
- }
- String[] asyncAppenderArray = blitz4jConfig.getAsyncAppenders();
- if (asyncAppenderArray == null) {
- return;
- }
- for (int i = 0; i < asyncAppenderArray.length; i++) {
- String oneAppenderName = asyncAppenderArray[i];
- if (i == 0) {
- continue;
- }
- String oneAsyncAppenderName = oneAppenderName
- + ASYNC_APPENDERNAME_SUFFIX;
- originalAsyncAppenderNameMap.put(oneAppenderName,
- oneAsyncAppenderName);
- }
- try {
- convertConfiguredAppendersToAsync(this.props);
- } catch (Throwable e) {
- throw new RuntimeException("Could not configure async appenders ",
- e);
- }
- PropertyConfigurator.configure(this.props);
- this.logger = org.slf4j.LoggerFactory
- .getLogger(LoggingConfiguration.class);
- ConfigurationManager.getConfigInstance().addConfigurationListener(
- new ExpandedConfigurationListenerAdapter(this));
- }
-
- public static LoggingConfiguration getInstance() {
- return instance;
- }
-
- public BlitzConfig getConfiguration() {
- return this.blitz4jConfig;
- }
-
- /**
- * Shuts down blitz4j cleanly by flushing out all the async related
- * messages.
- */
- public void stop() {
- MessageBatcher batcher = null;
- for (String originalAppenderName : originalAsyncAppenderNameMap
- .keySet()) {
- String batcherName = AsyncAppender.class.getName() + "."
- + originalAppenderName;
- batcher = BatcherFactory.getBatcher(batcherName);
- if (batcher == null) {
- continue;
- }
- batcher.stop();
- }
- for (String originalAppenderName : originalAsyncAppenderNameMap
- .keySet()) {
- String batcherName = AsyncAppender.class.getName() + "."
- + originalAppenderName;
- batcher = BatcherFactory.getBatcher(batcherName);
- if (batcher == null) {
- continue;
- }
- BatcherFactory.removeBatcher(batcherName);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.netflix.config.PropertyListener#addProperty(java.lang.Object,
- * java.lang.String, java.lang.Object, boolean)
- */
- public void addProperty(Object source, String name, Object value,
- boolean beforeUpdate) {
- if (shouldProcessProperty(name, beforeUpdate)) {
- updatedProps.put(name, value);
- reConfigureAsynchronously();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.netflix.config.PropertyListener#clear(java.lang.Object, boolean)
- */
- public void clear(Object source, boolean beforeUpdate) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.netflix.config.PropertyListener#clearProperty(java.lang.Object,
- * java.lang.String, java.lang.Object, boolean)
- */
- public void clearProperty(Object source, String name, Object value,
- boolean beforeUpdate) {
- if (shouldProcessProperty(name, beforeUpdate)) {
- updatedProps.remove(name);
- reConfigureAsynchronously();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.netflix.config.PropertyListener#configSourceLoaded(java.lang.Object)
- */
- public void configSourceLoaded(Object source) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.netflix.config.PropertyListener#setProperty(java.lang.Object,
- * java.lang.String, java.lang.Object, boolean)
- */
- public void setProperty(Object source, String name, Object value,
- boolean beforeUpdate) {
- if (shouldProcessProperty(name, beforeUpdate)) {
- updatedProps.put(name, value);
- reConfigureAsynchronously();
- }
- }
-
- /**
- * Reconfigure log4j at run-time.
- *
- * @param name
- * - The name of the property that changed
- * @param value
- * - The new value of the property
- * @throws FileNotFoundException
- * @throws ConfigurationException
- */
- private void reConfigure() throws ConfigurationException,
- FileNotFoundException {
-
- Properties consolidatedProps = new Properties();
- consolidatedProps.putAll(props);
- logger.info("Updated properties is :" + updatedProps);
- consolidatedProps.putAll(updatedProps);
- logger.info("The root category for log4j.rootCategory now is "
- + consolidatedProps.getProperty("log4j.rootCategory"));
- logger.info("The root category for log4j.rootLogger now is "
- + consolidatedProps.getProperty("log4j.rootLogger"));
-
- // Pause the async appenders so that the appenders are not accessed
- for (String originalAppenderName : originalAsyncAppenderNameMap
- .keySet()) {
- MessageBatcher asyncBatcher = BatcherFactory
- .getBatcher(AsyncAppender.class.getName() + "."
- + originalAppenderName);
- if (asyncBatcher == null) {
- continue;
- }
- asyncBatcher.pause();
- }
-
- // Configure log4j using the new set of properties
- configureLog4j(consolidatedProps);
- // Resume all the batchers to continue logging
- for (String originalAppenderName : originalAsyncAppenderNameMap
- .keySet()) {
- MessageBatcher asyncBatcher = BatcherFactory
- .getBatcher(AsyncAppender.class.getName() + "."
- + originalAppenderName);
- if (asyncBatcher == null) {
-