Skip to content

Instantly share code, notes, and snippets.

@norrs
Created April 1, 2014 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save norrs/9921413 to your computer and use it in GitHub Desktop.
Save norrs/9921413 to your computer and use it in GitHub Desktop.
zookeeper-1371.patch
Index: src/java/test/org/apache/zookeeper/test/MultiTransactionTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/java/test/org/apache/zookeeper/test/MultiTransactionTest.java (revision b5c25d7ee1b940f919f718032d101c26c46f30b2)
+++ src/java/test/org/apache/zookeeper/test/MultiTransactionTest.java (revision )
@@ -26,7 +26,6 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import org.apache.log4j.Logger;
import org.apache.zookeeper.AsyncCallback;
import org.apache.zookeeper.AsyncCallback.MultiCallback;
import org.apache.zookeeper.CreateMode;
@@ -51,10 +50,12 @@
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@RunWith(Parameterized.class)
public class MultiTransactionTest extends ClientBase {
- private static final Logger LOG = Logger.getLogger(MultiTransactionTest.class);
+ private static final Logger LOG = LoggerFactory.getLogger(MultiTransactionTest.class);
private ZooKeeper zk;
private ZooKeeper zk_chroot;
@@ -488,7 +489,7 @@
Assert.fail("Should have thrown a KeeperException for invalid version");
} catch (KeeperException e) {
//PASS
- LOG.error("STACKTRACE: " + e);
+ LOG.error("STACKTRACE: ", e);
}
Assert.assertNull(zk.exists("/multi", null));
@@ -568,10 +569,10 @@
Assert.assertNotNull(results);
for (OpResult r : results) {
- LOG.info("RESULT==> " + r);
+ LOG.info("RESULT==> {}", r);
if (r instanceof ErrorResult) {
ErrorResult er = (ErrorResult) r;
- LOG.info("ERROR RESULT: " + er + " ERR=>" + KeeperException.Code.get(er.getErr()));
+ LOG.info("ERROR RESULT: {} ERR=> {}", er, KeeperException.Code.get(er.getErr()));
}
}
}
Index: build.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- build.xml (revision b5c25d7ee1b940f919f718032d101c26c46f30b2)
+++ build.xml (revision )
@@ -17,7 +17,7 @@
limitations under the License.
-->
-<project name="ZooKeeper" default="jar"
+<project name="ZooKeeper" default="jar"
xmlns:ivy="antlib:org.apache.ivy.ant"
xmlns:artifact="antlib:org.apache.maven.artifact.ant"
xmlns:maven="antlib:org.apache.maven.artifact.ant">
@@ -28,7 +28,7 @@
<property name="name" value="zookeeper" />
<property environment="env"/>
-
+
<property name="version-major" value="3" />
<property name="version-minor" value="5" />
<property name="version-patch" value="0" />
@@ -38,7 +38,7 @@
<property name="revision.dir" value="${basedir}/.revision" />
<property name="revision.properties" value="revision.properties" />
<property file="${basedir}/src/java/${revision.properties}" />
-
+
<property name="javac.target" value="1.5" />
<property name="javac.source" value="1.5" />
@@ -59,7 +59,7 @@
<property name="build.dir" value="${basedir}/build" />
<property name="distribution" value="${basedir}/distribution" />
<property name="src_generated.dir" value="${src.dir}/java/generated" />
- <property name="c.src.dir" value="${src.dir}/c" />
+ <property name="c.src.dir" value="${src.dir}/c" />
<property name="csrc_generated.dir" value="${c.src.dir}/generated" />
<property name="jute.file" value="${src.dir}/zookeeper.jute" />
@@ -116,14 +116,14 @@
<property name="ivy.test.lib" value="${build.dir}/test/lib"/>
<property name="ivy.jdiff.lib" value="${build.dir}/jdiff/lib"/>
<property name="ivysettings.xml" value="${basedir}/ivysettings.xml"/>
-
+
<property name="mvnrepo" value="http://repo2.maven.org/maven2"/>
<property name="tsk.org" value="/org/apache/maven/maven-ant-tasks/"/>
<property name="ant-task.version" value="2.1.3"/>
<property name="ant_task_repo_url"
value="${mvnrepo}${tsk.org}${ant-task.version}/maven-ant-tasks-${ant-task.version}.jar"/>
<property name="ant_task.jar" location="${ivy.lib}/maven-ant-tasks-${ant-task.version}.jar"/>
-
+
<available property="clover.present"
classname="com.cenqua.clover.CloverInstr"
classpath="${clover.home}/lib/clover.jar"/>
@@ -159,7 +159,7 @@
<property name="jdiff.build.dir" value="${build.docs}/jdiff"/>
<property name="jdiff.xml.dir" value="${lib.dir}/jdiff"/>
<property name="jdiff.stable" value="3.1.1"/>
- <property name="jdiff.stable.javadoc"
+ <property name="jdiff.stable.javadoc"
value="http://hadoop.apache.org/zookeeper/docs/r${jdiff.stable}/api/"/>
<!-- eclipse property set -->
@@ -186,14 +186,14 @@
<property name="staging_repo_id" value="apache.staging.https"/>
<property name="wagon-http.version" value="2.4"/>
<property name="snapshots_repo_id" value="apache.snapshots.https"/>
- <property name="asfrepo" value="https://repository.apache.org"/>
- <property name="snapshots_repo_url"
- value="${asfrepo}/content/repositories/snapshots"/>
+ <property name="asfrepo" value="https://repository.apache.org"/>
+ <property name="snapshots_repo_url"
+ value="${asfrepo}/content/repositories/snapshots"/>
<property name="staging_repo_url"
- value="${asfrepo}/service/local/staging/deploy/maven2"/>
- <property name="gpg-plugin"
+ value="${asfrepo}/service/local/staging/deploy/maven2"/>
+ <property name="gpg-plugin"
value="org.apache.maven.plugins:maven-gpg-plugin:1.4:sign-and-deploy-file"/>
- <property name="deploy-plugin"
+ <property name="deploy-plugin"
value="org.apache.maven.plugins:maven-deploy-plugin:2.8.1:deploy-file"/>
<property name="main-jar" value="${dist.maven.dir}/${final.name}.jar"/>
<property name="tests-jar" value="${dist.maven.dir}/${final.name}-tests.jar"/>
@@ -243,6 +243,15 @@
<path refid="java.classpath"/>
</path>
+ <path id="test.java.classpath.without.log4j">
+ <pathelement location="${test.java.classes}" />
+ <fileset dir="${ivy.test.lib}">
+ <include name="**/*.jar" />
+ <exclude name="**/*log4j*.jar"/>
+ </fileset>
+ <path refid="java.classpath"/>
+ </path>
+
<path id="package.classpath">
<fileset dir="${ivy.package.lib}">
<include name="**/jdeb*.jar" />
@@ -252,7 +261,7 @@
<!-- ====================================================== -->
<!-- Generate and compile the Java files -->
<!-- ====================================================== -->
- <target name="init">
+ <target name="init">
<mkdir dir="${build.classes}" />
<mkdir dir="${ivy.lib}"/>
@@ -267,8 +276,8 @@
<format property="year" pattern="yyyy" timezone="GMT"/>
</tstamp>
</target>
-
-
+
+
<target name="generate_jute_parser" depends="init,ivy-retrieve">
<property name="jute_javacc.dir" value="${build.dir}/jute_compiler" />
<property name="jute_javacc.packagedir" value="/org/apache/jute/compiler/generated" />
@@ -282,11 +291,11 @@
javacchome="${ivy.lib}"
/>
</target>
-
+
<target name="jute" depends="generate_jute_parser">
<javac srcdir="${jute_javacc.dir}" destdir="${build.classes}" includeantruntime="false"
target="${javac.target}" source="${javac.source}"
- includes="org/apache/jute/**" debug="on"
+ includes="org/apache/jute/**" debug="on"
>
<src path="${java.src.dir}" />
<src path="${jute_javacc.dir}" />
@@ -305,13 +314,13 @@
<java classname="org.apache.jute.compiler.generated.Rcc" fork="true" dir="${src_generated.dir}">
<arg value="-l" />
<arg value="java" />
- <arg value="../../zookeeper.jute" />
+ <arg value="../../zookeeper.jute" />
<classpath>
<pathelement path="${build.classes}" />
<pathelement path="${jute_javacc.dir}" />
</classpath>
</java>
-
+
<java classname="org.apache.jute.compiler.generated.Rcc" fork="true" dir="${csrc_generated.dir}">
<arg value="-l" />
<arg value="c" />
@@ -329,13 +338,13 @@
target="${javac.target}" source="${javac.source}"
includes="org/apache/zookeeper/version/util/**" debug="on" />
</target>
-
+
<target name="svn-revision" unless="lastRevision">
<mkdir dir="${revision.dir}" />
<condition property="shell.name" value="cmd" else="sh">
<os family="windows"/>
</condition>
- <condition property="revision.cmd.line"
+ <condition property="revision.cmd.line"
value="/c ${src.dir}\lastRevision.bat" else="${src.dir}/lastRevision.sh">
<os family="windows"/>
</condition>
@@ -344,10 +353,10 @@
</exec>
<property file="${revision.dir}/${revision.properties}" />
</target>
-
+
<target name="version-info" depends="ver-gen,svn-revision">
<mkdir dir="${src_generated.dir}" />
- <java classname="org.apache.zookeeper.version.util.VerGen" fork="true"
+ <java classname="org.apache.zookeeper.version.util.VerGen" fork="true"
dir="${src_generated.dir}">
<arg value="${version}" />
<arg value="${lastRevision}" />
@@ -357,12 +366,12 @@
</classpath>
</java>
</target>
-
+
<target name="build-generated" depends="compile_jute,version-info,process-template" >
<javac srcdir="${src_generated.dir}" destdir="${build.classes}" includeantruntime="false"
target="${javac.target}" source="${javac.source}" debug="on" />
</target>
-
+
<target name="ivy-download" unless="ivy.jar.exists" depends="init">
<delete dir="${lib.dir}"
includes="ivy-*.jar" excludes="ivy-${ivy.version}.jar"/>
@@ -374,7 +383,7 @@
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant" classpathref="java.classpath"/>
<!-- ensure that ivy taskdef is only run once, otw ant will error -->
- <property name="ivy.initialized" value="true"/>
+ <property name="ivy.initialized" value="true"/>
</target>
<target name="ivy-init" depends="ivy-download,ivy-taskdef">
@@ -425,7 +434,7 @@
</filterchain>
</copy>
</target>
-
+
<target name="ivy-retrieve-mvn-ant-task" depends="init,ivy-init">
<ivy:retrieve settingsRef="${ant.project.name}" conf="mvn-ant-task"
pattern="${ivy.lib}/[artifact]-[revision].[ext]"/>
@@ -519,7 +528,7 @@
<link href="${javadoc.link.java}"/>
<classpath refid="java.classpath"/>
</javadoc>
- </target>
+ </target>
<target name="javadoc" depends="jar" description="Generate javadoc">
<mkdir dir="${build.javadoc}"/>
@@ -560,11 +569,11 @@
<classpath>
<fileset dir="${basedir}">
<include name="${jar.name}"/>
- </fileset>
+ </fileset>
<path refid="java.classpath"/>
</classpath>
</javadoc>
- </target>
+ </target>
<!-- ====================================================== -->
<!-- Make zookeeper.jar -->
@@ -590,11 +599,11 @@
<attribute name="Built-At" value="${build.time}"/>
<attribute name="Built-On" value="${host.name}" />
<attribute name="Implementation-Title" value="org.apache.zookeeper"/>
- <attribute name="Implementation-Version" value="${revision}"/>
+ <attribute name="Implementation-Version" value="${revision}"/>
<attribute name="Implementation-Vendor" value="The Apache Software Foundation"/>
-
+
<!-- The following are OSGi manifest headers -->
- <!-- currently hardcoded, when things get more complicated we could use BND
+ <!-- currently hardcoded, when things get more complicated we could use BND
http://www.aqute.biz/Code/Bnd to generate them -->
<attribute name="Bundle-Vendor" value="The Apache Software Foundation"/>
<attribute name="Bundle-Name" value="ZooKeeper Bundle"/>
@@ -608,7 +617,7 @@
</manifest>
</jar>
</target>
-
+
<!-- ====================================================== -->
<!-- Make zookeeper-bin.jar -->
<!-- ====================================================== -->
@@ -631,11 +640,11 @@
<attribute name="Built-At" value="${build.time}"/>
<attribute name="Built-On" value="${host.name}" />
<attribute name="Implementation-Title" value="org.apache.zookeeper"/>
- <attribute name="Implementation-Version" value="${revision}"/>
+ <attribute name="Implementation-Version" value="${revision}"/>
<attribute name="Implementation-Vendor" value="The Apache Software Foundation"/>
-
+
<!-- The following are OSGi manifest headers -->
- <!-- currently hardcoded, when things get more complicated we could use BND
+ <!-- currently hardcoded, when things get more complicated we could use BND
http://www.aqute.biz/Code/Bnd to generate them -->
<attribute name="Bundle-Vendor" value="The Apache Software Foundation"/>
<attribute name="Bundle-Name" value="ZooKeeper Bundle"/>
@@ -663,7 +672,7 @@
<attribute name="Built-At" value="${build.time}"/>
<attribute name="Built-On" value="${host.name}" />
<attribute name="Implementation-Title" value="org.apache.zookeeper"/>
- <attribute name="Implementation-Version" value="${revision}"/>
+ <attribute name="Implementation-Version" value="${revision}"/>
<attribute name="Implementation-Vendor" value="The Apache Software Foundation"/>
</manifest>
</jar>
@@ -681,7 +690,7 @@
<attribute name="Built-At" value="${build.time}"/>
<attribute name="Built-On" value="${host.name}" />
<attribute name="Implementation-Title" value="org.apache.zookeeper"/>
- <attribute name="Implementation-Version" value="${revision}"/>
+ <attribute name="Implementation-Version" value="${revision}"/>
<attribute name="Implementation-Vendor" value="The Apache Software Foundation"/>
</manifest>
</jar>
@@ -699,7 +708,7 @@
<attribute name="Built-At" value="${build.time}"/>
<attribute name="Built-On" value="${host.name}" />
<attribute name="Implementation-Title" value="org.apache.zookeeper"/>
- <attribute name="Implementation-Version" value="${revision}"/>
+ <attribute name="Implementation-Version" value="${revision}"/>
<attribute name="Implementation-Vendor" value="The Apache Software Foundation"/>
</manifest>
</jar>
@@ -710,7 +719,7 @@
<!-- ================================================================== -->
<!-- -->
<!-- ================================================================== -->
- <target name="package"
+ <target name="package"
depends="jar,bin-jar,src-jar,javadoc-jar,test-jar,api-report,create-cppunit-configure,compile-test"
description="Build distribution">
<mkdir dir="${dist.dir}"/>
@@ -737,9 +746,9 @@
<property name="package.share" value=""/>
<fileset file="${contrib.dir}/build.xml"/>
<fileset file="${recipes.dir}/build.xml"/>
- </subant>
+ </subant>
- <copy todir="${dist.dir}">
+ <copy todir="${dist.dir}">
<fileset file="${build.dir}/${final.name}.jar"/>
</copy>
@@ -749,8 +758,8 @@
<mkdir dir="${dist.maven.dir}"/>
<copy file="${build.dir}/${final.name}-bin.jar"
- tofile="${dist.maven.dir}/${final.name}.jar"/>
- <copy todir="${dist.maven.dir}">
+ tofile="${dist.maven.dir}/${final.name}.jar"/>
+ <copy todir="${dist.maven.dir}">
<fileset file="${build.dir}/${final.name}-sources.jar"/>
<fileset file="${build.dir}/${final.name}-javadoc.jar"/>
</copy>
@@ -771,7 +780,7 @@
<checksum file="${dist.maven.dir}/${final.name}.pom" algorithm="sha1"/>
<copy file="${build.dir}/${final.name}-test.jar"
- tofile="${dist.maven.dir}/${final.name}-tests.jar"/>
+ tofile="${dist.maven.dir}/${final.name}-tests.jar"/>
<checksum file="${dist.maven.dir}/${final.name}-tests.jar" algorithm="sha1"/>
<checksum file="${dist.maven.dir}/${final.name}-tests.jar" algorithm="md5"/>
@@ -800,7 +809,7 @@
<copy todir="${dist.dir}/src" includeEmptyDirs="true">
<fileset dir="src" excludes="**/*.template **/docs/build/**/* **/ivy*.jar"/>
</copy>
-
+
<chmod perm="ugo+x" type="file" parallel="false">
<fileset dir="${dist.dir}/bin"/>
<fileset dir="${dist.dir}/src/contrib/">
@@ -844,7 +853,7 @@
<fileset file="${recipes.dir}/build.xml"/>
</subant>
- <copy todir="${dist.dir}/share/zookeeper">
+ <copy todir="${dist.dir}/share/zookeeper">
<fileset file="${build.dir}/${final.name}.jar"/>
</copy>
@@ -854,12 +863,12 @@
<mkdir dir="${dist.maven.dir}"/>
<copy file="${build.dir}/${final.name}-bin.jar"
- tofile="${dist.maven.dir}/${final.name}.jar"/>
- <copy todir="${dist.maven.dir}">
+ tofile="${dist.maven.dir}/${final.name}.jar"/>
+ <copy todir="${dist.maven.dir}">
<fileset file="${build.dir}/${final.name}-sources.jar"/>
<fileset file="${build.dir}/${final.name}-javadoc.jar"/>
</copy>
-
+
<checksum file="${dist.maven.dir}/${final.name}.jar" algorithm="md5"/>
<checksum file="${dist.maven.dir}/${final.name}.jar" algorithm="sha1"/>
<checksum file="${dist.maven.dir}/${final.name}-sources.jar" algorithm="md5"/>
@@ -874,8 +883,8 @@
</ivy:makepom>
<checksum file="${dist.maven.dir}/${name}.pom" algorithm="md5"/>
<checksum file="${dist.maven.dir}/${name}.pom" algorithm="sha1"/>
-
-
+
+
<copy file="${build.dir}/${final.name}-test.jar"
tofile="${dist.maven.dir}/${final.name}-tests.jar"/>
<checksum file="${dist.maven.dir}/${final.name}-tests.jar" algorithm="sha1"/>
@@ -925,7 +934,7 @@
<replacetoken>/tmp/zookeeper</replacetoken>
<replacevalue>${VAR_DIR}/data</replacevalue>
</replace>
-
+
<chmod perm="ugo+x" type="file" parallel="false">
<fileset dir="${dist.dir}/bin"/>
<fileset dir="${dist.dir}/sbin"/>
@@ -1028,7 +1037,7 @@
<property name="dist.dir" value="${dist.dir}"/>
<fileset file="${contrib.dir}/build.xml"/>
<fileset file="${recipes.dir}/build.xml"/>
- </subant>
+ </subant>
<path id="c.lib">
<fileset dir="${build.dir}">
<include name="${final.name}-lib.tar.gz"/>
@@ -1133,10 +1142,10 @@
</tarfileset>
<tarfileset dir="${build.dir}/c/build/${package.prefix}/include" prefix="${package.prefix}/include">
<include name="**" />
- </tarfileset>
+ </tarfileset>
<tarfileset dir="${build.dir}/c/build/${package.prefix}/lib" filemode="755" prefix="${package.prefix}/lib">
<include name="**" />
- </tarfileset>
+ </tarfileset>
<tarfileset dir="${build.dir}/${final.name}/conf" filemode="644" prefix="${package.conf.dir}">
<include name="**" />
</tarfileset>
@@ -1188,7 +1197,7 @@
<target name="signanddeploy" if="staging">
<deploy repo-url="${staging_repo_url}" repo-id="${staging_repo_id}" plugin="${gpg-plugin}" profile="-Pgpg"/>
- </target>
+ </target>
<target name="simpledeploy" unless="staging">
<deploy plugin="${deploy-plugin}"/>
@@ -1197,7 +1206,7 @@
<!-- ====================================================== -->
<!-- mvn-install. Installing the jar and pom file to .m2 -->
<!-- ====================================================== -->
-
+
<target name="mvn-taskdef" depends="ivy-retrieve-mvn-ant-task">
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="antlib:org.apache.maven.artifact.ant" classpathref="mvn-ant-task-classpath"/>
@@ -1209,11 +1218,11 @@
<echo message="${dist.maven.dir}/${final.name}-sources.jar" />
<echo message="${dist.maven.dir}/${final.name}-javadoc.jar" />
<echo message="${dist.maven.dir}/${final.name}-tests.jar" />
-
+
<artifact:pom id="zookeeper-pom" file="${dist.maven.dir}/${name}.pom"/>
<echo>The version is ${zookeeper-pom.version}</echo>
<echo message="${dist.maven.dir}/${final.name}.jar" />
-
+
<artifact:install file="${dist.maven.dir}/${final.name}.jar">
<pom refid="zookeeper-pom" />
<attach file="${dist.maven.dir}/${final.name}.jar" type="jar"/>
@@ -1234,7 +1243,7 @@
<delete dir="${csrc_generated.dir}" />
<delete file="${lib.dir}/Null.java"/>
<delete file="${lib.dir}/rats.jar" />
- <delete file="${jdiff.xml.dir}/${name}_${version}.xml"/>
+ <delete file="${jdiff.xml.dir}/${name}_${version}.xml"/>
<delete file="${jar.name}" />
<delete dir="${distribution}"/>
<delete dir="${revision.dir}"/>
@@ -1245,9 +1254,9 @@
</target>
<target name="clean-contrib">
- <subant target="clean">
+ <subant target="clean">
<fileset file="${contrib.dir}/build.xml"/>
- </subant>
+ </subant>
</target>
<target name="clean-recipes">
@@ -1295,6 +1304,35 @@
</and>
</condition>
+ <target name="junit.run.nolog4j">
+ <junit showoutput="${test.output}"
+ printsummary="${test.junit.printsummary}"
+ haltonfailure="${test.junit.haltonfailure}"
+ fork="yes"
+ forkmode="${test.junit.fork.mode}"
+ maxmemory="${test.junit.maxmem}"
+ dir="${basedir}" timeout="${test.timeout}"
+ errorProperty="tests.failed.nolog4j"
+ failureProperty="tests.failed.nolog4j">
+ <sysproperty key="build.test.dir" value="${test.tmp.dir}"/>
+ <sysproperty key="test.data.dir" value="${test.data.dir}"/>
+ <!-- superDigest is used by the tests/main code. If this is not set
+ as part of starting the jvm there is no guarantee that the static
+ initializers in the java code will see this (esp when running
+ with junit fork mode set to "once")-->
+ <sysproperty key="zookeeper.DigestAuthenticationProvider.superDigest"
+ value="super:D/InIHSb7yEEbrWz8b9l71RjZJU="/>
+ <classpath refid="test.java.classpath.without.log4j"/>
+ <formatter type="${test.junit.output.format}"/>
+ <batchtest todir="${test.log.dir}" if="fulltest">
+ <fileset dir="${test.src.dir}">
+ <include name="**/*${test.category}NoLog4j*.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ <fail if="tests.failed.nolog4j">Tests failed!</fail>
+ </target>
+
<target name="junit.run">
<junit showoutput="${test.output}"
printsummary="${test.junit.printsummary}"
@@ -1323,15 +1361,19 @@
<fileset dir="${test.src.dir}">
<include name="**/*${test.category}Test.java"/>
<exclude name="**/*HammerTest.java"/>
+ <exclude name="**/*${test.category}NoLog4j*.java"/>
</fileset>
</batchtest>
<batchtest todir="${test.log.dir}" if="fulltest">
<fileset dir="${test.src.dir}">
<include name="**/*${test.category}Test.java"/>
+ <exclude name="**/*${test.category}NoLog4j*.java"/>
</fileset>
</batchtest>
<batchtest todir="${test.log.dir}" if="testcase">
- <fileset dir="${test.src.dir}" includes="**/${testcase}.java"/>
+ <fileset dir="${test.src.dir}" includes="**/${testcase}.java">
+ <exclude name="**/*${test.category}NoLog4j*.java"/>
+ </fileset>
</batchtest>
</junit>
<fail if="tests.failed">Tests failed!</fail>
@@ -1341,7 +1383,7 @@
<condition property="need.cppunit.configure">
<not> <available file="${c.src.dir}/configure"/> </not>
</condition>
- </target>
+ </target>
<target name="check-cppunit-makefile" depends="init" >
<condition property="need.cppunit.makefile">
@@ -1367,7 +1409,7 @@
</exec>
</target>
- <target name="create-cppunit-makefile" depends="check-cppunit-makefile"
+ <target name="create-cppunit-makefile" depends="check-cppunit-makefile"
if="need.cppunit.makefile">
<antcall target="create-cppunit-configure">
<param name="cppunit" value="true"/>
@@ -1386,7 +1428,7 @@
<antcall target="test-cppunit">
<param name="cppunit" value="true"/>
</antcall>
- </target>
+ </target>
<target name="test-cppunit"
@@ -1402,7 +1444,7 @@
<arg line="clean check"/>
</exec>
</target>
-
+
<target name="test-unit-category">
<property name="test.category" value="Unit"/>
</target>
@@ -1426,23 +1468,25 @@
<antcall target="test-core"/>
<antcall target="test-contrib"/>
</target>
-
+
<target name="test-contrib" description="to run contrib tests">
<!-- yet to implement -->
</target>
-
- <target name="test-core-java" depends="test-init, test-category, junit.run"/>
+
+ <target name="test-core-java" depends="test-init, test-category, junit.run"/>
+ <target name="test-core-java-nolog4j" depends="test-init, test-category, junit.run.nolog4j"/>
+
- <target name="test-core-cppunit" depends="test-init, test-category, call-test-cppunit"/>
+ <target name="test-core-cppunit" depends="test-init, test-category, call-test-cppunit"/>
- <target name="test-core" depends="test-core-java, test-core-cppunit"/>
+ <target name="test-core" depends="test-core-java, test-core-java-nolog4j, test-core-cppunit"/>
<!-- ====================================================== -->
<!-- Run optional third-party tool targets -->
<!-- ====================================================== -->
<!-- clover code coverage -->
- <target name="clover" depends="clover.setup, clover.info"
+ <target name="clover" depends="clover.setup, clover.info"
description="Instrument the Unit tests using Clover. Requires a Clover license and CLOVER_HOME environment variable set appropriately. To use, specify -Drun.clover=true on the command line."/>
<target name="clover.setup" if="clover.enabled">
@@ -1492,10 +1536,10 @@
<property name="findbugs.exclude.file" value="${config.dir}/findbugsExcludeFile.xml" />
<property name="findbugs.report.htmlfile" value="${findbugs.out.dir}/zookeeper-findbugs-report.html" />
<property name="findbugs.report.xmlfile" value="${findbugs.out.dir}/zookeeper-findbugs-report.xml" />
- <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"
+ <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"
classpath="${findbugs.home}/lib/findbugs-ant.jar" />
<mkdir dir="${findbugs.out.dir}" />
- <findbugs home="${findbugs.home}" output="xml:withMessages" excludeFilter="${findbugs.exclude.file}"
+ <findbugs home="${findbugs.home}" output="xml:withMessages" excludeFilter="${findbugs.exclude.file}"
outputFile="${findbugs.report.xmlfile}" effort="max" jvmargs="-Xmx512M">
<auxClasspath>
<fileset dir="${ivy.lib}">
@@ -1505,7 +1549,7 @@
<sourcePath path="${java.src.dir}" />
<class location="${build.dir}/${final.name}.jar" />
</findbugs>
- <xslt style="${findbugs.home}/src/xsl/default.xsl" in="${findbugs.report.xmlfile}"
+ <xslt style="${findbugs.home}/src/xsl/default.xsl" in="${findbugs.report.xmlfile}"
out="${findbugs.report.htmlfile}" />
</target>
@@ -1538,7 +1582,7 @@
</target>
<target name="cobertura-test" depends="test-init,cobertura-instrument">
- <junit showoutput="${test.output}" printsummary="yes" haltonfailure="no" fork="yes"
+ <junit showoutput="${test.output}" printsummary="yes" haltonfailure="no" fork="yes"
maxmemory="${test.junit.maxmem}" dir="${basedir}" timeout="${test.timeout}"
errorProperty="tests.failed" failureProperty="tests.failed">
<sysproperty key="build.test.dir" value="${test.tmp.dir}" />
@@ -1580,7 +1624,7 @@
<target name="cobertura-report" depends="cobertura-test">
<cobertura-report format="${test.cobertura.output.format}"
- destdir="${coveragereport.dir}" >
+ destdir="${coveragereport.dir}" >
<fileset dir="${java.src.dir}">
<include name="**/*.java" />
</fileset>
@@ -1590,7 +1634,7 @@
</cobertura-report>
</target>
- <target name="checkstyle" depends="checkstyle.check, set-checkstyle-classpath" if="checkstyle.home"
+ <target name="checkstyle" depends="checkstyle.check, set-checkstyle-classpath" if="checkstyle.home"
description="Run optional third-party tool targets">
<taskdef resource="checkstyletask.properties">
<classpath refid="checkstyle-classpath"/>
@@ -1605,17 +1649,17 @@
</target>
<target name="checkstyle.check" unless="checkstyle.home">
- <fail message="'checkstyle.home' is not defined. Please pass -Dcheckstyle.home=&lt;base of checkstyle installation&gt;
+ <fail message="'checkstyle.home' is not defined. Please pass -Dcheckstyle.home=&lt;base of checkstyle installation&gt;
to Ant on the command-line." />
</target>
-
+
<target name="set-checkstyle-classpath">
<path id="checkstyle-classpath">
<fileset dir="${checkstyle.home}">
<include name="**/*.jar"/>
</fileset>
</path>
- </target>
+ </target>
<!-- ================================================================== -->
<!-- Perform audit activities for the release -->
@@ -1667,12 +1711,12 @@
</target>
<target name="findbugs.check" depends="check-for-findbugs" unless="findbugs.present">
- <fail message="'findbugs.home' is not defined. Please pass -Dfindbugs.home=&lt;base of Findbugs installation&gt;
+ <fail message="'findbugs.home' is not defined. Please pass -Dfindbugs.home=&lt;base of Findbugs installation&gt;
to Ant on the command-line." />
</target>
<target name="patch.check" unless="patch.file">
- <fail message="'patch.file' is not defined. Please pass -Dpatch.file=&lt;location of patch file&gt;
+ <fail message="'patch.file' is not defined. Please pass -Dpatch.file=&lt;location of patch file&gt;
to Ant on the command-line." />
</target>
@@ -1739,18 +1783,18 @@
</classpath>
</javadoc>
</target>
-
+
<target name="write-null">
<exec executable="touch">
<arg value="${jdiff.home}/Null.java"/>
</exec>
- </target>
+ </target>
<target name="api-report" depends="api-xml">
<mkdir dir="${jdiff.build.dir}"/>
<javadoc sourcepath="${java.src.dir}"
destdir="${jdiff.build.dir}"
- excludepackagenames="org.apache.jute"
+ excludepackagenames="org.apache.jute"
sourceFiles="${jdiff.home}/Null.java">
<doclet name="jdiff.JDiff"
path="${ivy.jdiff.lib}/jdiff-1.0.9.jar:${ivy.jdiff.lib}/xerces-1.4.4.jar">
Index: ivy.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- ivy.xml (revision b5c25d7ee1b940f919f718032d101c26c46f30b2)
+++ ivy.xml (revision )
@@ -42,13 +42,13 @@
<dependencies>
<dependency org="org.slf4j" name="slf4j-api" rev="1.7.5"/>
- <dependency org="org.slf4j" name="slf4j-log4j12" rev="1.7.5" transitive="false"/>
+ <dependency org="org.slf4j" name="slf4j-log4j12" rev="1.7.5" transitive="false" conf="test->default"/>
<dependency org="commons-cli" name="commons-cli" rev="1.2" />
<dependency org="org.apache.maven.wagon" name="wagon-http" rev="2.4" conf="mvn-ant-task->default"/>
<dependency org="org.apache.maven" name="maven-ant-tasks" rev="2.1.3" conf="mvn-ant-task->default"/>
<!-- transitive false turns off dependency checking, log4j deps seem borked -->
- <dependency org="log4j" name="log4j" rev="1.2.16" transitive="false" conf="default"/>
+ <dependency org="log4j" name="log4j" rev="1.2.17" transitive="false" conf="test->default"/>
<dependency org="jline" name="jline" rev="2.11" transitive="false" conf="optional->default"/>
<dependency org="io.netty" name="netty" conf="default" rev="3.7.0.Final">
Index: src/contrib/loggraph/ivy.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/contrib/loggraph/ivy.xml (revision b5c25d7ee1b940f919f718032d101c26c46f30b2)
+++ src/contrib/loggraph/ivy.xml (revision )
@@ -31,11 +31,11 @@
</configurations>
<dependencies>
- <dependency org="org.slf4j" name="slf4j-api" rev="1.6.1"/>
- <dependency org="org.slf4j" name="slf4j-log4j12" rev="1.6.1" transitive="false"/>
+ <dependency org="org.slf4j" name="slf4j-api" rev="1.7.5"/>
+ <dependency org="org.slf4j" name="slf4j-log4j12" rev="1.7.5" transitive="false" conf="test->default" />
<!-- transitive false turns off dependency checking, log4j deps seem borked -->
- <dependency org="log4j" name="log4j" rev="1.2.15" transitive="false"/>
+ <dependency org="log4j" name="log4j" rev="1.2.17" transitive="false" conf="test->default" />
<dependency org="org.eclipse.jetty" name="jetty-server" rev="7.0.1.v20091125" />
<dependency org="org.eclipse.jetty" name="jetty-servlet" rev="7.0.1.v20091125" />
<dependency org="com.googlecode.json-simple" name="json-simple" rev="1.1" />
Index: src/java/main/org/apache/zookeeper/Login.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/java/main/org/apache/zookeeper/Login.java (revision b5c25d7ee1b940f919f718032d101c26c46f30b2)
+++ src/java/main/org/apache/zookeeper/Login.java (revision )
@@ -32,8 +32,9 @@
import javax.security.auth.login.LoginException;
import javax.security.auth.callback.CallbackHandler;
-import org.apache.log4j.Logger;
import org.apache.zookeeper.client.ZooKeeperSaslClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.security.auth.kerberos.KerberosTicket;
import javax.security.auth.Subject;
import java.util.Date;
@@ -41,7 +42,7 @@
import java.util.Set;
public class Login {
- private static final Logger LOG = Logger.getLogger(Login.class);
+ private static final Logger LOG = LoggerFactory.getLogger(Login.class);
public CallbackHandler callbackHandler;
// LoginThread will sleep until 80% of time from last refresh to
@@ -127,19 +128,20 @@
if (tgt == null) {
nextRefresh = now + MIN_TIME_BEFORE_RELOGIN;
nextRefreshDate = new Date(nextRefresh);
- LOG.warn("No TGT found: will try again at " + nextRefreshDate);
+ LOG.warn("No TGT found: will try again at {}", nextRefreshDate);
} else {
nextRefresh = getRefreshTime(tgt);
long expiry = tgt.getEndTime().getTime();
Date expiryDate = new Date(expiry);
if ((isUsingTicketCache) && (tgt.getEndTime().equals(tgt.getRenewTill()))) {
- LOG.error("The TGT cannot be renewed beyond the next expiry date: " + expiryDate + "." +
+ Object[] logPayload = {expiryDate, principal, principal};
+ LOG.error("The TGT cannot be renewed beyond the next expiry date: {}." +
"This process will not be able to authenticate new SASL connections after that " +
"time (for example, it will not be authenticate a new connection with a Zookeeper " +
"Quorum member). Ask your system administrator to either increase the " +
- "'renew until' time by doing : 'modprinc -maxrenewlife " + principal + "' within " +
- "kadmin, or instead, to generate a keytab for " + principal + ". Because the TGT's " +
- "expiry cannot be further extended by refreshing, exiting refresh thread now.");
+ "'renew until' time by doing : 'modprinc -maxrenewlife {}' within " +
+ "kadmin, or instead, to generate a keytab for {}. Because the TGT's " +
+ "expiry cannot be further extended by refreshing, exiting refresh thread now.", logPayload);
return;
}
// determine how long to sleep from looking at ticket's expiry.
@@ -156,23 +158,25 @@
// next scheduled refresh is sooner than (now + MIN_TIME_BEFORE_LOGIN).
Date until = new Date(nextRefresh);
Date newuntil = new Date(now + MIN_TIME_BEFORE_RELOGIN);
- LOG.warn("TGT refresh thread time adjusted from : " + until + " to : " + newuntil + " since "
+ Object[] logPayload = {until, newuntil, (MIN_TIME_BEFORE_RELOGIN / 1000)};
+ LOG.warn("TGT refresh thread time adjusted from : {} to : {} since "
+ "the former is sooner than the minimum refresh interval ("
- + MIN_TIME_BEFORE_RELOGIN / 1000 + " seconds) from now.");
+ + "{} seconds) from now.", logPayload);
}
nextRefresh = Math.max(nextRefresh, now + MIN_TIME_BEFORE_RELOGIN);
}
nextRefreshDate = new Date(nextRefresh);
if (nextRefresh > expiry) {
- LOG.error("next refresh: " + nextRefreshDate + " is later than expiry " + expiryDate
+ Object[] logPayload = {nextRefreshDate, expiryDate};
+ LOG.error("next refresh: {} is later than expiry {}"
+ ". This may indicate a clock skew problem. Check that this host and the KDC's "
- + "hosts' clocks are in sync. Exiting refresh thread.");
+ + "hosts' clocks are in sync. Exiting refresh thread.", logPayload);
return;
}
}
if (now < nextRefresh) {
Date until = new Date(nextRefresh);
- LOG.info("TGT refresh sleeping until: " + until.toString());
+ LOG.info("TGT refresh sleeping until: {}", until.toString());
try {
Thread.sleep(nextRefresh - now);
} catch (InterruptedException ie) {
@@ -181,10 +185,10 @@
}
}
else {
- LOG.error("nextRefresh:" + nextRefreshDate + " is in the past: exiting refresh thread. Check"
+ LOG.error("nextRefresh:{} is in the past: exiting refresh thread. Check"
+ " clock sync between this host and KDC - (KDC's clock is likely ahead of this host)."
+ " Manual intervention will be required for this client to successfully authenticate."
- + " Exiting refresh thread.");
+ + " Exiting refresh thread.", nextRefreshDate);
return;
}
if (isUsingTicketCache) {
@@ -196,7 +200,7 @@
int retry = 1;
while (retry >= 0) {
try {
- LOG.debug("running ticket cache refresh command: " + cmd + " " + kinitArgs);
+ LOG.debug("running ticket cache refresh command: {} {}", cmd, kinitArgs);
Shell.execCommand(cmd, kinitArgs);
break;
} catch (Exception e) {
@@ -210,8 +214,9 @@
return;
}
} else {
- LOG.warn("Could not renew TGT due to problem running shell command: '" + cmd
- + " " + kinitArgs + "'" + "; exception was:" + e + ". Exiting refresh thread.",e);
+ Object[] logPayload = {cmd, kinitArgs, e.toString(), e};
+ LOG.warn("Could not renew TGT due to problem running shell command:"
+ + " '{} {}'; exception was: {}. Exiting refresh thread.", logPayload);
return;
}
}
@@ -234,7 +239,7 @@
throw le;
}
} else {
- LOG.error("Could not refresh TGT for principal: " + principal + ".", le);
+ LOG.error("Could not refresh TGT for principal: {}.", principal, le);
}
}
}
@@ -261,7 +266,7 @@
try {
t.join();
} catch (InterruptedException e) {
- LOG.warn("error while waiting for Login thread to shutdown: " + e);
+ LOG.warn("error while waiting for Login thread to shutdown: ", e);
}
}
}
@@ -292,8 +297,8 @@
private long getRefreshTime(KerberosTicket tgt) {
long start = tgt.getStartTime().getTime();
long expires = tgt.getEndTime().getTime();
- LOG.info("TGT valid starting at: " + tgt.getStartTime().toString());
- LOG.info("TGT expires: " + tgt.getEndTime().toString());
+ LOG.info("TGT valid starting at: {}", tgt.getStartTime().toString());
+ LOG.info("TGT expires: {}", tgt.getEndTime().toString());
long proposedRefresh = start + (long) ((expires - start) *
(TICKET_RENEW_WINDOW + (TICKET_RENEW_JITTER * rng.nextDouble())));
if (proposedRefresh > expires) {
@@ -310,7 +315,7 @@
for(KerberosTicket ticket: tickets) {
KerberosPrincipal server = ticket.getServer();
if (server.getName().equals("krbtgt/" + server.getRealm() + "@" + server.getRealm())) {
- LOG.debug("Found tgt " + ticket + ".");
+ LOG.debug("Found tgt {}.", ticket);
return ticket;
}
}
@@ -321,8 +326,7 @@
long now = System.currentTimeMillis();
if (now - getLastLogin() < MIN_TIME_BEFORE_RELOGIN ) {
LOG.warn("Not attempting to re-login since the last re-login was " +
- "attempted less than " + (MIN_TIME_BEFORE_RELOGIN/1000) + " seconds"+
- " before.");
+ "attempted less than {} seconds before.", (MIN_TIME_BEFORE_RELOGIN/1000));
return false;
}
// register most recent relogin attempt
@@ -379,7 +383,7 @@
if (!hasSufficientTimeElapsed()) {
return;
}
- LOG.info("Initiating logout for " + principal);
+ LOG.info("Initiating logout for {}", principal);
synchronized (Login.class) {
//clear up the kerberos state. But the tokens are not cleared! As per
//the Java kerberos login module code, only the kerberos credentials
@@ -388,7 +392,7 @@
//login and also update the subject field of this instance to
//have the new credentials (pass it to the LoginContext constructor)
login = new LoginContext(loginContextName, getSubject());
- LOG.info("Initiating re-login for " + principal);
+ LOG.info("Initiating re-login for {}", principal);
login.login();
setLogin(login);
}
Index: src/java/main/org/apache/zookeeper/client/FourLetterWordMain.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/java/main/org/apache/zookeeper/client/FourLetterWordMain.java (revision b5c25d7ee1b940f919f718032d101c26c46f30b2)
+++ src/java/main/org/apache/zookeeper/client/FourLetterWordMain.java (revision )
@@ -18,16 +18,17 @@
package org.apache.zookeeper.client;
-import org.apache.log4j.Logger;
-
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class FourLetterWordMain {
- protected static final Logger LOG = Logger.getLogger(FourLetterWordMain.class);
+ protected static final Logger LOG = LoggerFactory.getLogger(FourLetterWordMain.class);
/**
* Send the 4letterword
@@ -40,7 +41,7 @@
public static String send4LetterWord(String host, int port, String cmd)
throws IOException
{
- LOG.info("connecting to " + host + " " + port);
+ LOG.info("connecting to {}:{}", host, port);
Socket sock = new Socket(host, port);
BufferedReader reader = null;
try {
Index: src/java/main/org/apache/zookeeper/Shell.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/java/main/org/apache/zookeeper/Shell.java (revision b5c25d7ee1b940f919f718032d101c26c46f30b2)
+++ src/java/main/org/apache/zookeeper/Shell.java (revision )
@@ -38,7 +38,8 @@
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* A base class for running a Unix command.
@@ -48,8 +49,8 @@
* time-intervals.
*/
abstract public class Shell {
-
+
- private static final Logger LOG = Logger.getLogger(Shell.class);
+ private static final Logger LOG = LoggerFactory.getLogger(Shell.class);
/** a Unix command to get the current user's name */
public final static String USER_NAME_COMMAND = "whoami";
Index: src/java/main/org/apache/zookeeper/jmx/ManagedUtil.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/java/main/org/apache/zookeeper/jmx/ManagedUtil.java (revision b5c25d7ee1b940f919f718032d101c26c46f30b2)
+++ src/java/main/org/apache/zookeeper/jmx/ManagedUtil.java (revision )
@@ -24,47 +24,96 @@
import javax.management.MBeanServer;
import javax.management.ObjectName;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.apache.log4j.jmx.HierarchyDynamicMBean;
-import org.apache.log4j.spi.LoggerRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Shared utilities
*/
public class ManagedUtil {
+ private static final Logger LOG = LoggerFactory.getLogger(ManagedUtil.class);
+
+ private static final boolean isLog4jJmxEnabled() {
+ boolean enabled = false;
+
+ try {
+ Class.forName("org.apache.log4j.spi.LoggerRepository");
+
+ if (Boolean.getBoolean("zookeeper.jmx.log4j.disable") == true) {
+ LOG.info("Log4j found but jmx support is disabled.");
+ } else {
+ enabled = true;
+ LOG.info("Log4j found with jmx enabled.");
+ }
+
+ } catch (ClassNotFoundException e) {
+ LOG.info("Log4j not found.");
+ }
+
+ return enabled;
+ }
+
+
/**
* Register the log4j JMX mbeans. Set environment variable
* "zookeeper.jmx.log4j.disable" to true to disable registration.
* @see http://logging.apache.org/log4j/1.2/apidocs/index.html?org/apache/log4j/jmx/package-summary.html
* @throws JMException if registration fails
*/
+ @SuppressWarnings("rawtypes")
public static void registerLog4jMBeans() throws JMException {
- if (Boolean.getBoolean("zookeeper.jmx.log4j.disable") == true) {
- return;
- }
-
+ if (isLog4jJmxEnabled()) {
+ LOG.debug("registerLog4jMBeans()");
- MBeanServer mbs = MBeanRegistry.getInstance().getPlatformMBeanServer();
+ MBeanServer mbs = MBeanRegistry.getInstance().getPlatformMBeanServer();
+ try {
- // Create and Register the top level Log4J MBean
+ // Create and Register the top level Log4J MBean
- HierarchyDynamicMBean hdm = new HierarchyDynamicMBean();
+ // org.apache.log4j.jmx.HierarchyDynamicMBean hdm = new org.apache.log4j.jmx.HierarchyDynamicMBean();
+ Object hdm = Class.forName("org.apache.log4j.jmx.HierarchyDynamicMBean").newInstance();
- ObjectName mbo = new ObjectName("log4j:hiearchy=default");
- mbs.registerMBean(hdm, mbo);
+ ObjectName mbo = new ObjectName("log4j:hiearchy=default");
+ mbs.registerMBean(hdm, mbo);
- // Add the root logger to the Hierarchy MBean
+ // Add the root logger to the Hierarchy MBean
- Logger rootLogger = Logger.getRootLogger();
- hdm.addLoggerMBean(rootLogger.getName());
+ // org.apache.log4j.Logger rootLogger =
+ // org.apache.log4j.Logger.getRootLogger();
+ Object rootLogger = Class.forName("org.apache.log4j.Logger")
+ .getMethod("getRootLogger", (Class<?>[]) null)
+ .invoke(null, (Object[]) null);
- // Get each logger from the Log4J Repository and add it to
- // the Hierarchy MBean created above.
- LoggerRepository r = LogManager.getLoggerRepository();
- Enumeration enumer = r.getCurrentLoggers();
- Logger logger = null;
+ // hdm.addLoggerMBean(rootLogger.getName());
+ Object rootLoggerName = rootLogger.getClass()
+ .getMethod("getName", (Class<?>[]) null)
+ .invoke(rootLogger, (Object[]) null);
+ hdm.getClass().getMethod("addLoggerMBean", String.class)
+ .invoke(hdm, rootLoggerName);
+ // Get each logger from the Log4J Repository and add it to the
+ // Hierarchy MBean created above.
+ // org.apache.log4j.spi.LoggerRepository r =
+ // org.apache.log4j.LogManager.getLoggerRepository();
+ Object r = Class.forName("org.apache.log4j.LogManager")
+ .getMethod("getLoggerRepository", (Class<?>[]) null)
+ .invoke(null, (Object[]) null);
+
+ // Enumeration enumer = r.getCurrentLoggers();
+ Enumeration enumer = (Enumeration) r.getClass()
+ .getMethod("getCurrentLoggers", (Class<?>[]) null)
+ .invoke(r, (Object[]) null);
+
- while (enumer.hasMoreElements()) {
+ while (enumer.hasMoreElements()) {
- logger = (Logger) enumer.nextElement();
- hdm.addLoggerMBean(logger.getName());
+ Object logger = enumer.nextElement();
+ // hdm.addLoggerMBean(logger.getName());
+ Object loggerName = logger.getClass()
+ .getMethod("getName", (Class<?>[]) null)
+ .invoke(logger, (Object[]) null);
+ hdm.getClass().getMethod("addLoggerMBean", String.class)
+ .invoke(hdm, loggerName);
+ }
+ } catch (Exception e) {
+ LOG.error("Problems while registering log4j jmx beans!", e);
+ throw new JMException(e.toString());
+ }
}
}
Index: src/docs/src/documentation/content/xdocs/zookeeperAdmin.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/docs/src/documentation/content/xdocs/zookeeperAdmin.xml (revision b5c25d7ee1b940f919f718032d101c26c46f30b2)
+++ src/docs/src/documentation/content/xdocs/zookeeperAdmin.xml (revision )
@@ -544,13 +544,24 @@
<section id="sc_logging">
<title>Logging</title>
- <para>ZooKeeper uses <emphasis role="bold">log4j</emphasis> version 1.2 as
- its logging infrastructure. The ZooKeeper default <filename>log4j.properties</filename>
+ <para>
+ ZooKeeper uses <emphasis role="bold"><ulink url="http://www.slf4j.org">SLF4J</ulink></emphasis>
+ version 1.7 as its logging infrastructure. For backward compatibility it is bound to
+ <emphasis role="bold">LOG4J</emphasis> but you can use
+ <emphasis role="bold"><ulink url="http://logback.qos.ch/">LOGBack</ulink></emphasis>
+ or any other supported logging framework of your choice.
+ </para>
+ <para>
+ The ZooKeeper default <filename>log4j.properties</filename>
- file resides in the <filename>conf</filename> directory. Log4j requires that
- <filename>log4j.properties</filename> either be in the working directory
+ file resides in the <filename>conf</filename> directory. Log4j requires that
+ <filename>log4j.properties</filename> either be in the working directory
- (the directory from which ZooKeeper is run) or be accessible from the classpath.</para>
+ (the directory from which ZooKeeper is run) or be accessible from the classpath.
+ </para>
- <para>For more information, see
+ <para>For more information about SLF4J, see
+ <ulink url="http://www.slf4j.org/manual.html">its manual</ulink>.</para>
+
+ <para>For more information about LOG4J, see
<ulink url="http://logging.apache.org/log4j/1.2/manual.html#defaultInit">Log4j Default Initialization Procedure</ulink>
of the log4j manual.</para>
Index: src/java/test/org/apache/zookeeper/server/ZxidRolloverTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/java/test/org/apache/zookeeper/server/ZxidRolloverTest.java (revision b5c25d7ee1b940f919f718032d101c26c46f30b2)
+++ src/java/test/org/apache/zookeeper/server/ZxidRolloverTest.java (revision )
@@ -21,7 +21,6 @@
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
-import org.apache.log4j.Logger;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.KeeperException.ConnectionLossException;
@@ -34,12 +33,14 @@
import org.apache.zookeeper.test.QuorumUtil.PeerStruct;
import org.junit.Assert;
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Verify ZOOKEEPER-1277 - ensure that we handle epoch rollover correctly.
*/
public class ZxidRolloverTest extends TestCase {
- private static final Logger LOG = Logger.getLogger(ZxidRolloverTest.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ZxidRolloverTest.class);
private QuorumUtil qu;
private ZooKeeperServer zksLeader;
@@ -54,7 +55,7 @@
@Override
protected void setUp() throws Exception {
- LOG.info("STARTING " + getName());
+ LOG.info("STARTING {}", getName());
// set the snap count to something low so that we force log rollover
// and verify that is working as part of the epoch rollover.
@@ -222,7 +223,7 @@
* wait for the clients to be re-connected after the re-election
*/
private int createNodes(ZooKeeper zk, int start, int count) throws Exception {
- LOG.info("Creating nodes " + start + " thru " + (start + count));
+ LOG.info("Creating nodes {} thru {}", start, (start + count));
int j = 0;
try {
for (int i = start; i < start + count; i++) {
@@ -241,10 +242,10 @@
* caused the roll-over, did not.
*/
private void checkNodes(ZooKeeper zk, int start, int count) throws Exception {
- LOG.info("Validating nodes " + start + " thru " + (start + count));
+ LOG.info("Validating nodes {} thru {}", start, (start + count));
for (int i = start; i < start + count; i++) {
assertNotNull(zk.exists("/foo" + i, false));
- LOG.error("Exists zxid:" + Long.toHexString(zk.exists("/foo" + i, false).getCzxid()));
+ LOG.error("Exists zxid: {}", Long.toHexString(zk.exists("/foo" + i, false).getCzxid()));
}
assertNull(zk.exists("/foo" + (start + count), false));
}
Index: src/java/test/org/apache/zookeeper/test/FollowerResyncConcurrencyTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/java/test/org/apache/zookeeper/test/FollowerResyncConcurrencyTest.java (revision b5c25d7ee1b940f919f718032d101c26c46f30b2)
+++ src/java/test/org/apache/zookeeper/test/FollowerResyncConcurrencyTest.java (revision )
@@ -108,7 +108,7 @@
ZooKeeper zk1 =
createClient(qu.getPeer(1).peer.getClientPort(), watcher1);
- LOG.info("zk1 has session id 0x" + Long.toHexString(zk1.getSessionId()));
+ LOG.info("zk1 has session id 0x{}", Long.toHexString(zk1.getSessionId()));
final String resyncPath = "/resyncundernewepoch";
zk1.create(resyncPath, null, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
@@ -133,19 +133,19 @@
+ qu.getPeer(3).clientPort, ClientBase.CONNECTION_TIMEOUT));
zk1 = createClient(qu.getPeer(1).peer.getClientPort(), watcher1);
- LOG.info("zk1 has session id 0x" + Long.toHexString(zk1.getSessionId()));
+ LOG.info("zk1 has session id 0x{}", Long.toHexString(zk1.getSessionId()));
assertNotNull("zk1 has data", zk1.exists(resyncPath, false));
final ZooKeeper zk2 =
createClient(qu.getPeer(2).peer.getClientPort(), watcher2);
- LOG.info("zk2 has session id 0x" + Long.toHexString(zk2.getSessionId()));
+ LOG.info("zk2 has session id 0x{}", Long.toHexString(zk2.getSessionId()));
assertNotNull("zk2 has data", zk2.exists(resyncPath, false));
final ZooKeeper zk3 =
createClient(qu.getPeer(3).peer.getClientPort(), watcher3);
- LOG.info("zk3 has session id 0x" + Long.toHexString(zk3.getSessionId()));
+ LOG.info("zk3 has session id 0x{}", Long.toHexString(zk3.getSessionId()));
assertNotNull("zk3 has data", zk3.exists(resyncPath, false));
@@ -224,13 +224,13 @@
/* Reusing the index variable to select a follower to connect to */
index = (index == 1) ? 2 : 1;
- LOG.info("Connecting to follower:" + index);
+ LOG.info("Connecting to follower: {}", index);
qu.shutdown(index);
final ZooKeeper zk3 =
createClient(qu.getPeer(3).peer.getClientPort(), watcher3);
- LOG.info("zk3 has session id 0x" + Long.toHexString(zk3.getSessionId()));
+ LOG.info("zk3 has session id 0x{}", Long.toHexString(zk3.getSessionId()));
zk3.create("/mybar", null, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);
@@ -238,11 +238,11 @@
final ZooKeeper zk1 =
createClient(qu.getPeer(index).peer.getClientPort(), watcher1);
- LOG.info("zk1 has session id 0x" + Long.toHexString(zk1.getSessionId()));
+ LOG.info("zk1 has session id 0x{}", Long.toHexString(zk1.getSessionId()));
final ZooKeeper zk2 =
createClient(qu.getPeer(index).peer.getClientPort(), watcher2);
- LOG.info("zk2 has session id 0x" + Long.toHexString(zk2.getSessionId()));
+ LOG.info("zk2 has session id 0x{}", Long.toHexString(zk2.getSessionId()));
zk1.create("/first", new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
@@ -309,15 +309,15 @@
// should use txnlog to catchup. For subsequent restart, the
// follower should use a diff to catchup.
mytestfooThread.start();
- LOG.info("Restarting follower " + index);
+ LOG.info("Restarting follower: {}", index);
qu.restart(index);
Thread.sleep(300);
- LOG.info("Shutdown follower " + index);
+ LOG.info("Shutdown follower: {}", index);
qu.shutdown(index);
Thread.sleep(300);
- LOG.info("Restarting follower " + index);
+ LOG.info("Restarting follower: {}", index);
qu.restart(index);
- LOG.info("Setting up server: " + index);
+ LOG.info("Setting up server: {}", index);
}
if((i % 1000) == 0){
Thread.sleep(1000);
@@ -407,19 +407,19 @@
/* Reusing the index variable to select a follower to connect to */
index = (index == 1) ? 2 : 1;
- LOG.info("Connecting to follower:" + index);
+ LOG.info("Connecting to follower: {}", index);
final ZooKeeper zk1 =
createClient(qu.getPeer(index).peer.getClientPort(), watcher1);
- LOG.info("zk1 has session id 0x" + Long.toHexString(zk1.getSessionId()));
+ LOG.info("zk1 has session id 0x{}", Long.toHexString(zk1.getSessionId()));
final ZooKeeper zk2 =
createClient(qu.getPeer(index).peer.getClientPort(), watcher2);
- LOG.info("zk2 has session id 0x" + Long.toHexString(zk2.getSessionId()));
+ LOG.info("zk2 has session id 0x{}", Long.toHexString(zk2.getSessionId()));
final ZooKeeper zk3 =
createClient(qu.getPeer(3).peer.getClientPort(), watcher3);
- LOG.info("zk3 has session id 0x" + Long.toHexString(zk3.getSessionId()));
+ LOG.info("zk3 has session id 0x{}", Long.toHexString(zk3.getSessionId()));
zk1.create("/first", new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
zk2.create("/mybar", null, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);
@@ -490,7 +490,7 @@
qu.startThenShutdown(index);
runNow.set(true);
qu.restart(index);
- LOG.info("Setting up server: " + index);
+ LOG.info("Setting up server: {}", index);
}
if(i>=1000 && i%2== 0) {
@@ -553,14 +553,14 @@
* verifying the state
*/
private boolean waitForPendingRequests(int timeout) throws InterruptedException {
- LOG.info("Wait for pending requests: " + pending.get());
+ LOG.info("Wait for pending requests: {}", pending.get());
for (int i = 0; i < timeout; ++i) {
Thread.sleep(1000);
if (pending.get() == 0) {
return true;
}
}
- LOG.info("Timeout waiting for pending requests: " + pending.get());
+ LOG.info("Timeout waiting for pending requests: {}", pending.get());
return false;
}
@@ -585,9 +585,10 @@
}
Thread.sleep(1000);
}
- LOG.info("Timeout waiting for zxid to sync: leader 0x" + Long.toHexString(leadZxid)+
- "clean 0x" + Long.toHexString(cleanZxid) +
- "restarted 0x" + Long.toHexString(restartedZxid));
+ LOG.info("Timeout waiting for zxid to sync: leader 0x{}" +
+ "clean 0x{}" +
+ "restarted 0x{}", Long.toHexString(leadZxid), Long.toHexString(cleanZxid),
+ Long.toHexString(restartedZxid));
return false;
}
@@ -628,7 +629,7 @@
ZKDatabase clean = qu.getPeer(3).peer.getActiveServer().getZKDatabase();
ZKDatabase lead = qu.getPeer(leaderIndex).peer.getActiveServer().getZKDatabase();
for(Long l : sessionsRestarted) {
- LOG.info("Validating ephemeral for session id 0x" + Long.toHexString(l));
+ LOG.info("Validating ephemeral for session id 0x{}", Long.toHexString(l));
assertTrue("Should have same set of sessions in both servers, did not expect: " + l, sessionsNotRestarted.contains(l));
Set<String> ephemerals = restarted.getEphemerals(l);
Set<String> cleanEphemerals = clean.getEphemerals(l);
@@ -674,7 +675,7 @@
while(qu.getPeer(index).peer.follower == null) {
index++;
}
- LOG.info("Connecting to follower:" + index);
+ LOG.info("Connecting to follower: {}", index);
TestableZooKeeper zk =
createTestableClient("localhost:" + qu.getPeer(index).peer.getClientPort());
@@ -716,7 +717,7 @@
while(qu.getPeer(index).peer.follower == null) {
index++;
}
- LOG.info("Connecting to follower:" + index);
+ LOG.info("Connecting to follower: {}", index);
TestableZooKeeper zk1 = createTestableClient(
"localhost:" + qu.getPeer(index).peer.getClientPort());
Index: src/java/test/org/apache/zookeeper/test/RestoreCommittedLogTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/java/test/org/apache/zookeeper/test/RestoreCommittedLogTest.java (revision b5c25d7ee1b940f919f718032d101c26c46f30b2)
+++ src/java/test/org/apache/zookeeper/test/RestoreCommittedLogTest.java (revision )
@@ -21,7 +21,6 @@
import java.io.File;
import java.util.List;
-import org.apache.log4j.Logger;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.PortAssignment;
import org.apache.zookeeper.WatchedEvent;
@@ -35,12 +34,14 @@
import org.apache.zookeeper.server.ZooKeeperServer;
import org.junit.Assert;
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/** After a replica starts, it should load commits in its committedLog list.
* This test checks if committedLog != 0 after replica restarted.
*/
public class RestoreCommittedLogTest extends ZKTestCase implements Watcher {
- private static final Logger LOG = Logger.getLogger(RestoreCommittedLogTest.class);
+ private static final Logger LOG = LoggerFactory.getLogger(RestoreCommittedLogTest.class);
private static final String HOSTPORT = "127.0.0.1:" + PortAssignment.unique();
private static final int CONNECTION_TIMEOUT = 3000;
/**
@@ -77,7 +78,7 @@
zks.startdata();
List<Proposal> committedLog = zks.getZKDatabase().getCommittedLog();
int logsize = committedLog.size();
- LOG.info("committedLog size = " + logsize);
+ LOG.info("committedLog size = {}", logsize);
Assert.assertTrue("log size != 0", (logsize != 0));
zks.shutdown();
}
Index: src/contrib/rest/ivy.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/contrib/rest/ivy.xml (revision b5c25d7ee1b940f919f718032d101c26c46f30b2)
+++ src/contrib/rest/ivy.xml (revision )
@@ -31,11 +31,11 @@
</configurations>
<dependencies>
- <dependency org="org.slf4j" name="slf4j-api" rev="1.6.1"/>
- <dependency org="org.slf4j" name="slf4j-log4j12" rev="1.6.1" transitive="false"/>
+ <dependency org="org.slf4j" name="slf4j-api" rev="1.7.5"/>
+ <dependency org="org.slf4j" name="slf4j-log4j12" rev="1.7.5" transitive="false" conf="test->default" />
<!-- transitive false turns off dependency checking, log4j deps seem borked -->
- <dependency org="log4j" name="log4j" rev="1.2.15" transitive="false"/>
+ <dependency org="log4j" name="log4j" rev="1.2.17" transitive="false" conf="test->default" />
<dependency org="asm" name="asm" rev="3.1" />
<dependency org="com.sun.grizzly" name="grizzly-servlet-webserver" rev="1.9.8" />
<dependency org="com.sun.jersey" name="jersey-server" rev="1.1.5.1" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment