You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flume.apache.org by de...@apache.org on 2018/02/05 14:48:36 UTC

[1/7] flume git commit: FLUME-2050. Upgrade to Log4j 2.10.0 [Forced Update!]

Repository: flume
Updated Branches:
  refs/heads/trunk ffc555443 -> 286c24424 (forced update)


http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sinks/flume-ng-kafka-sink/src/test/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/flume-ng-sinks/flume-ng-kafka-sink/src/test/resources/log4j2.xml b/flume-ng-sinks/flume-ng-kafka-sink/src/test/resources/log4j2.xml
new file mode 100644
index 0000000..1263a38
--- /dev/null
+++ b/flume-ng-sinks/flume-ng-kafka-sink/src/test/resources/log4j2.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+<Configuration status="OFF">
+  <Properties>
+    <Property name="kafka.logs.dir">target/logs</Property>
+  </Properties>
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="%d (%t) [%p - %l] %m%n" />
+    </Console>
+    <RollingFile name="kafka" fileName="${kafka.logs.dir}/server.log">
+      <PatternLayout pattern="[%d] %p %m (%c)%n" />
+      <CronTriggeringPolicy schedule="0 0 0 * * ?"/>
+    </RollingFile>
+    <RollingFile name="stateChange" fileName="${kafka.logs.dir}/state-change.log">
+      <PatternLayout pattern="[%d] %p %m (%c)%n" />
+      <CronTriggeringPolicy schedule="0 0 0 * * ?"/>
+    </RollingFile>
+    <RollingFile name="request" fileName="${kafka.logs.dir}/kafka-request.log">
+      <PatternLayout pattern="[%d] %p %m (%c)%n" />
+      <CronTriggeringPolicy schedule="0 0 0 * * ?"/>
+    </RollingFile>
+    <RollingFile name="cleaner" fileName="${kafka.logs.dir}/log-cleaner.log">
+      <PatternLayout pattern="[%d] %p %m (%c)%n" />
+      <CronTriggeringPolicy schedule="0 0 0 * * ?"/>
+    </RollingFile>
+    <RollingFile name="controller" fileName="${kafka.logs.dir}/controller.log">
+      <PatternLayout pattern="[%d] %p %m (%c)%n" />
+      <CronTriggeringPolicy schedule="0 0 0 * * ?"/>
+    </RollingFile>
+  </Appenders>
+
+  <Loggers>
+    <Logger name="kafka" level="info">
+      <AppenderRef ref="kafka"/>
+    </Logger>
+    <Logger name="kafka.network.RequestChannel.*" level="WARN" additivity="false">
+      <AppenderRef ref="request"/>
+    </Logger>
+    <Logger name="kafka.request.logger" level="WARN" additivity="false">
+      <AppenderRef ref="request"/>
+    </Logger>
+    <Logger name="kafka.controller" level="TRACE" additivity="false">
+      <AppenderRef ref="controller"/>
+    </Logger>
+    <Logger name="kafka.log.cleaner" level="INFO" additivity="false">
+      <AppenderRef ref="cleaner"/>
+    </Logger>
+    <Logger name="state.change.logger" level="TRACE" additivity="false">
+      <AppenderRef ref="stateChange"/>
+    </Logger>
+    <Root level="INFO">
+      <AppenderRef ref="Console" />
+    </Root>
+  </Loggers>
+</Configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sinks/flume-ng-morphline-solr-sink/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-sinks/flume-ng-morphline-solr-sink/pom.xml b/flume-ng-sinks/flume-ng-morphline-solr-sink/pom.xml
index e41adfc..84ddf94 100644
--- a/flume-ng-sinks/flume-ng-morphline-solr-sink/pom.xml
+++ b/flume-ng-sinks/flume-ng-morphline-solr-sink/pom.xml
@@ -61,13 +61,6 @@ limitations under the License.
       <optional>true</optional>
     </dependency>
 
-    <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>jcl-over-slf4j</artifactId>
-      <version>${slf4j.version}</version> <!-- flume provides 1.7.2 and solr depends on 1.6.4 -->
-      <scope>provided</scope>
-    </dependency>
-
     <dependency> <!-- see http://lucene.apache.org/solr -->
       <groupId>org.apache.solr</groupId>
       <artifactId>solr-test-framework</artifactId>
@@ -90,6 +83,36 @@ limitations under the License.
     </dependency>
 
     <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-jcl</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sinks/flume-ng-morphline-solr-sink/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/flume-ng-sinks/flume-ng-morphline-solr-sink/src/test/resources/log4j.properties b/flume-ng-sinks/flume-ng-morphline-solr-sink/src/test/resources/log4j.properties
deleted file mode 100644
index 4bfd3fc..0000000
--- a/flume-ng-sinks/flume-ng-morphline-solr-sink/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,34 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-log4j.rootLogger=WARN, A1
-
-log4j.logger.org.apache.flume.sink=INFO
-#log4j.logger.org.apache.flume.sink.solr=DEBUG
-log4j.logger.org.apache.solr=INFO
-#log4j.logger.org.apache.solr.hadoop=DEBUG
-log4j.logger.org.kitesdk.morphline=DEBUG
-log4j.logger.org.apache.solr.morphline=DEBUG
-log4j.logger.org.apache.solr.update.processor.LogUpdateProcessor=WARN
-log4j.logger.org.apache.solr.core.SolrCore=WARN
-log4j.logger.org.apache.solr.search.SolrIndexSearcher=ERROR
-
-# A1 is set to be a ConsoleAppender.
-log4j.appender.A1=org.apache.log4j.ConsoleAppender
-
-# A1 uses PatternLayout.
-log4j.appender.A1.layout=org.apache.log4j.PatternLayout
-log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sinks/flume-ng-morphline-solr-sink/src/test/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/flume-ng-sinks/flume-ng-morphline-solr-sink/src/test/resources/log4j2.xml b/flume-ng-sinks/flume-ng-morphline-solr-sink/src/test/resources/log4j2.xml
new file mode 100644
index 0000000..61de228
--- /dev/null
+++ b/flume-ng-sinks/flume-ng-morphline-solr-sink/src/test/resources/log4j2.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+<Configuration status="OFF">
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="%-4r [%t] %-5p %c %x - %m%n" />
+    </Console>
+  </Appenders>
+  <Loggers>
+    <Logger name="org.apache.flume.sink" level="INFO"/>
+    <Logger name="org.apache.solr" level="DEBUG"/>
+    <Logger name="org.kitesdk.morphline" level="DEBUG"/>
+    <Logger name="org.apache.solr.morphline" level="DEBUG"/>
+    <Logger name="org.apache.solr" level="DEBUG"/>
+    <Logger name="org.apache.solr.update.processor.LogUpdateProcessor" level="WARN"/>
+    <Logger name="org.apache.solr.core.SolrCore" level="WARN"/>
+    <Logger name="org.apache.solr.search.SolrIndexSearcher" level="ERROR"/>
+    <Root level="WARN">
+      <AppenderRef ref="Console" />
+    </Root>
+  </Loggers>
+</Configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sources/flume-jms-source/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-sources/flume-jms-source/pom.xml b/flume-ng-sources/flume-jms-source/pom.xml
index 555f36c..fb2eb76 100644
--- a/flume-ng-sources/flume-jms-source/pom.xml
+++ b/flume-ng-sources/flume-jms-source/pom.xml
@@ -65,8 +65,26 @@ limitations under the License.
     </dependency>
 
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
       <scope>test</scope>
     </dependency>
 

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sources/flume-kafka-source/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-sources/flume-kafka-source/pom.xml b/flume-ng-sources/flume-kafka-source/pom.xml
index ae8004f..b653fbd 100644
--- a/flume-ng-sources/flume-kafka-source/pom.xml
+++ b/flume-ng-sources/flume-kafka-source/pom.xml
@@ -61,6 +61,16 @@
     <dependency>
       <groupId>org.apache.zookeeper</groupId>
       <artifactId>zookeeper</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>log4j</groupId>
+          <artifactId>log4j</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.slf4j</groupId>
+          <artifactId>slf4j-log4j12</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.mockito</groupId>
@@ -76,6 +86,16 @@
       <artifactId>kafka_2.10</artifactId>
       <classifier>test</classifier>
       <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>log4j</groupId>
+          <artifactId>log4j</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.slf4j</groupId>
+          <artifactId>slf4j-log4j12</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
   </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sources/flume-kafka-source/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/flume-ng-sources/flume-kafka-source/src/test/resources/log4j.properties b/flume-ng-sources/flume-kafka-source/src/test/resources/log4j.properties
deleted file mode 100644
index 78b1067..0000000
--- a/flume-ng-sources/flume-kafka-source/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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.
-#
-
-
-log4j.rootLogger = INFO, out
-
-log4j.appender.out = org.apache.log4j.ConsoleAppender
-log4j.appender.out.layout = org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern = %d (%t) [%p - %l] %m%n
-
-log4j.logger.org.apache.flume = INFO
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sources/flume-kafka-source/src/test/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/flume-ng-sources/flume-kafka-source/src/test/resources/log4j2.xml b/flume-ng-sources/flume-kafka-source/src/test/resources/log4j2.xml
new file mode 100644
index 0000000..7caf0d2
--- /dev/null
+++ b/flume-ng-sources/flume-kafka-source/src/test/resources/log4j2.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+<Configuration status="OFF">
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="%d (%t) [%p - %l] %m%n" />
+    </Console>
+  </Appenders>
+  <Loggers>
+    <Logger name="org.apache.flume" level="INFO"/>
+    <Root level="INFO">
+      <AppenderRef ref="Console" />
+    </Root>
+  </Loggers>
+</Configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sources/flume-scribe-source/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-sources/flume-scribe-source/pom.xml b/flume-ng-sources/flume-scribe-source/pom.xml
index dc46c62..933f5aa 100644
--- a/flume-ng-sources/flume-scribe-source/pom.xml
+++ b/flume-ng-sources/flume-scribe-source/pom.xml
@@ -150,8 +150,26 @@ limitations under the License.
     </dependency>
 
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
       <scope>test</scope>
     </dependency>
 

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sources/flume-twitter-source/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/flume-ng-sources/flume-twitter-source/src/test/resources/log4j.properties b/flume-ng-sources/flume-twitter-source/src/test/resources/log4j.properties
deleted file mode 100644
index 7755024..0000000
--- a/flume-ng-sources/flume-twitter-source/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,33 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-log4j.rootLogger=WARN, A1
-
-log4j.logger.org.apache.flume.sink=INFO
-#log4j.logger.org.apache.flume.sink.solr=DEBUG
-log4j.logger.org.apache.solr=INFO
-#log4j.logger.org.apache.solr.hadoop=DEBUG
-log4j.logger.org.apache.solr.morphline=DEBUG
-log4j.logger.org.apache.solr.update.processor.LogUpdateProcessor=WARN
-log4j.logger.org.apache.solr.core.SolrCore=WARN
-log4j.logger.org.apache.solr.search.SolrIndexSearcher=ERROR
-
-# A1 is set to be a ConsoleAppender.
-log4j.appender.A1=org.apache.log4j.ConsoleAppender
-
-# A1 uses PatternLayout.
-log4j.appender.A1.layout=org.apache.log4j.PatternLayout
-log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sources/flume-twitter-source/src/test/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/flume-ng-sources/flume-twitter-source/src/test/resources/log4j2.xml b/flume-ng-sources/flume-twitter-source/src/test/resources/log4j2.xml
new file mode 100644
index 0000000..0f3d384
--- /dev/null
+++ b/flume-ng-sources/flume-twitter-source/src/test/resources/log4j2.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+<Configuration status="OFF">
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="%-4r [%t] %-5p %c %x - %m%n" />
+    </Console>
+  </Appenders>
+  <Loggers>
+    <Logger name="org.apache.flume.sink" level="INFO"/>
+    <Logger name="org.apache.solr" level="INFO"/>
+    <Logger name="org.apache.solr.morphline" level="DEBUG"/>
+    <Logger name="org.apache.solr" level="DEBUG"/>
+    <Logger name="org.apache.solr.update.processor.LogUpdateProcessor" level="WARN"/>
+    <Logger name="org.apache.solr.core.SolrCore" level="WARN"/>
+    <Logger name="org.apache.solr.search.SolrIndexSearcher" level="ERROR"/>
+    <Root level="WARN">
+      <AppenderRef ref="Console" />
+    </Root>
+  </Loggers>
+</Configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-tests/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-tests/pom.xml b/flume-ng-tests/pom.xml
index 2a4b42c..ee3f4f4 100644
--- a/flume-ng-tests/pom.xml
+++ b/flume-ng-tests/pom.xml
@@ -41,8 +41,18 @@
       <artifactId>flume-ng-configuration</artifactId>
     </dependency>
     <dependency>
-      <groupId>log4j</groupId>
-      <artifactId>log4j</artifactId>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
@@ -59,6 +69,16 @@
       <groupId>org.apache.hadoop</groupId>
       <artifactId>${hadoop.common.artifact.id}</artifactId>
       <optional>true</optional>
+      <exclusions>
+        <exclusion>
+          <groupId>log4j</groupId>
+          <artifactId>log4j</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.slf4j</groupId>
+          <artifactId>slf4j-log4j12</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>com.google.guava</groupId>

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-tests/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/flume-ng-tests/src/test/resources/log4j.properties b/flume-ng-tests/src/test/resources/log4j.properties
deleted file mode 100644
index 739ecc8..0000000
--- a/flume-ng-tests/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-
-
-log4j.rootLogger = INFO, out
-
-log4j.appender.out = org.apache.log4j.ConsoleAppender
-log4j.appender.out.layout = org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern = %d (%t) [%p - %l] %m%n
-
-log4j.logger.org.apache.flume = DEBUG

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-tests/src/test/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/flume-ng-tests/src/test/resources/log4j2.xml b/flume-ng-tests/src/test/resources/log4j2.xml
new file mode 100644
index 0000000..a6e2e30
--- /dev/null
+++ b/flume-ng-tests/src/test/resources/log4j2.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+<Configuration status="OFF">
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="%d (%t) [%p - %l] %m%n" />
+    </Console>
+  </Appenders>
+  <Loggers>
+    <Root level="INFO">
+      <Logger name="org.apache.flume" level="DEBUG"/>
+      <AppenderRef ref="Console" />
+    </Root>
+  </Loggers>
+</Configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index da84b5b..14a7e89 100644
--- a/pom.xml
+++ b/pom.xml
@@ -81,8 +81,7 @@ limitations under the License.
     <kite.version>1.0.0</kite.version>
     <hive.version>1.0.0</hive.version>
     <lifecycle-mapping.version>1.0.0</lifecycle-mapping.version>
-    <log4j-extras.version>1.1</log4j-extras.version>
-    <log4j-log4j.version>1.2.17</log4j-log4j.version>
+    <log4j.version>2.10.0</log4j.version>
     <mapdb.version>0.9.9</mapdb.version>
     <mina.version>2.0.4</mina.version>
     <mockito.version>1.9.0</mockito.version>
@@ -203,6 +202,16 @@ limitations under the License.
             <groupId>org.apache.hadoop</groupId>
             <artifactId>${hadoop.common.artifact.id}</artifactId>
             <version>${hadoop.version}</version>
+            <exclusions>
+              <exclusion>
+                <groupId>log4j</groupId>
+                <artifactId>log4j</artifactId>
+              </exclusion>
+              <exclusion>
+                <groupId>org.slf4j</groupId>
+                <artifactId>slf4j-log4j12</artifactId>
+              </exclusion>
+            </exclusions>
           </dependency>
           <dependency>
             <groupId>org.apache.hadoop</groupId>
@@ -217,6 +226,14 @@ limitations under the License.
                 <groupId>tomcat</groupId>
                 <artifactId>jasper-runtime</artifactId>
               </exclusion>
+              <exclusion>
+                <groupId>log4j</groupId>
+                <artifactId>log4j</artifactId>
+              </exclusion>
+              <exclusion>
+                <groupId>org.slf4j</groupId>
+                <artifactId>slf4j-log4j12</artifactId>
+              </exclusion>
             </exclusions>
           </dependency>
           <dependency>
@@ -237,6 +254,14 @@ limitations under the License.
                 <groupId>tomcat</groupId>
                 <artifactId>jasper-runtime</artifactId>
               </exclusion>
+              <exclusion>
+                <groupId>log4j</groupId>
+                <artifactId>log4j</artifactId>
+              </exclusion>
+              <exclusion>
+                <groupId>org.slf4j</groupId>
+                <artifactId>slf4j-log4j12</artifactId>
+              </exclusion>
             </exclusions>
           </dependency>
           <dependency>
@@ -253,6 +278,16 @@ limitations under the License.
             <groupId>org.apache.hadoop</groupId>
             <artifactId>hadoop-auth</artifactId>
             <version>${hadoop.version}</version>
+            <exclusions>
+              <exclusion>
+                <groupId>log4j</groupId>
+                <artifactId>log4j</artifactId>
+              </exclusion>
+              <exclusion>
+                <groupId>org.slf4j</groupId>
+                <artifactId>slf4j-log4j12</artifactId>
+              </exclusion>
+            </exclusions>
           </dependency>
 
           <dependency>
@@ -282,6 +317,17 @@ limitations under the License.
             <artifactId>flume-dataset-sink</artifactId>
             <version>${project.version}</version>
           </dependency>
+          <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>1.2.17</version>
+            <scope>test</scope>
+          </dependency>
+          <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <scope>test</scope>
+          </dependency>
         </dependencies>
       </dependencyManagement>
     </profile>
@@ -304,6 +350,16 @@ limitations under the License.
             <groupId>org.apache.hadoop</groupId>
             <artifactId>${hadoop.common.artifact.id}</artifactId>
             <version>${hadoop.version}</version>
+            <exclusions>
+              <exclusion>
+                <groupId>log4j</groupId>
+                <artifactId>log4j</artifactId>
+              </exclusion>
+              <exclusion>
+                <groupId>org.slf4j</groupId>
+                <artifactId>slf4j-log4j12</artifactId>
+              </exclusion>
+            </exclusions>
           </dependency>
           <dependency>
             <groupId>org.apache.hadoop</groupId>
@@ -318,6 +374,14 @@ limitations under the License.
                 <groupId>tomcat</groupId>
                 <artifactId>jasper-runtime</artifactId>
               </exclusion>
+              <exclusion>
+                <groupId>log4j</groupId>
+                <artifactId>log4j</artifactId>
+              </exclusion>
+              <exclusion>
+                <groupId>org.slf4j</groupId>
+                <artifactId>slf4j-log4j12</artifactId>
+              </exclusion>
             </exclusions>
           </dependency>
           <dependency>
@@ -349,6 +413,16 @@ limitations under the License.
             <groupId>org.apache.hadoop</groupId>
             <artifactId>hadoop-auth</artifactId>
             <version>${hadoop.version}</version>
+            <exclusions>
+              <exclusion>
+                <groupId>log4j</groupId>
+                <artifactId>log4j</artifactId>
+              </exclusion>
+              <exclusion>
+                <groupId>org.slf4j</groupId>
+                <artifactId>slf4j-log4j12</artifactId>
+              </exclusion>
+            </exclusions>
           </dependency>
 
           <!-- Ideally this should be optional, but making it optional causes
@@ -408,6 +482,14 @@ limitations under the License.
                 <groupId>tomcat</groupId>
                 <artifactId>jasper-runtime</artifactId>
               </exclusion>
+              <exclusion>
+                <groupId>log4j</groupId>
+                <artifactId>log4j</artifactId>
+              </exclusion>
+              <exclusion>
+                <groupId>org.slf4j</groupId>
+                <artifactId>slf4j-log4j12</artifactId>
+              </exclusion>
             </exclusions>
           </dependency>
 
@@ -426,6 +508,14 @@ limitations under the License.
                 <groupId>tomcat</groupId>
                 <artifactId>jasper-runtime</artifactId>
               </exclusion>
+              <exclusion>
+                <groupId>log4j</groupId>
+                <artifactId>log4j</artifactId>
+              </exclusion>
+              <exclusion>
+                <groupId>org.slf4j</groupId>
+                <artifactId>slf4j-log4j12</artifactId>
+              </exclusion>
             </exclusions>
           </dependency>
 
@@ -442,6 +532,17 @@ limitations under the License.
             <artifactId>flume-dataset-sink</artifactId>
             <version>${project.version}</version>
           </dependency>
+          <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>1.2.17</version>
+            <scope>test</scope>
+          </dependency>
+          <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <scope>test</scope>
+          </dependency>
         </dependencies>
       </dependencyManagement>
     </profile>
@@ -991,25 +1092,33 @@ limitations under the License.
       </dependency>
 
       <dependency>
-        <groupId>log4j</groupId>
-        <artifactId>log4j</artifactId>
-        <version>${log4j-log4j.version}</version>
-        <exclusions>
-          <exclusion>
-            <groupId>com.sun.jdmk</groupId>
-            <artifactId>jmxtools</artifactId>
-          </exclusion>
-          <exclusion>
-            <groupId>com.sun.jmx</groupId>
-            <artifactId>jmxri</artifactId>
-          </exclusion>
-        </exclusions>
+        <groupId>org.apache.logging.log4j</groupId>
+        <artifactId>log4j-api</artifactId>
+        <version>${log4j.version}</version>
       </dependency>
 
       <dependency>
-        <groupId>log4j</groupId>
-        <artifactId>apache-log4j-extras</artifactId>
-        <version>${log4j-extras.version}</version>
+        <groupId>org.apache.logging.log4j</groupId>
+        <artifactId>log4j-core</artifactId>
+        <version>${log4j.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.apache.logging.log4j</groupId>
+        <artifactId>log4j-slf4j-impl</artifactId>
+        <version>${log4j.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.apache.logging.log4j</groupId>
+        <artifactId>log4j-1.2-api</artifactId>
+        <version>${log4j.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.apache.logging.log4j</groupId>
+        <artifactId>log4j-jcl</artifactId>
+        <version>${log4j.version}</version>
       </dependency>
 
       <dependency>
@@ -1019,9 +1128,16 @@ limitations under the License.
       </dependency>
 
       <dependency>
+        <groupId>log4j</groupId>
+        <artifactId>log4j</artifactId>
+        <version>1.2.17</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-log4j12</artifactId>
         <version>${slf4j.version}</version>
+        <scope>test</scope>
       </dependency>
 
       <dependency>
@@ -1134,6 +1250,14 @@ limitations under the License.
             <groupId>tomcat</groupId>
             <artifactId>jasper-runtime</artifactId>
           </exclusion>
+          <exclusion>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+          </exclusion>
         </exclusions>
       </dependency>
 
@@ -1216,6 +1340,12 @@ limitations under the License.
         <groupId>org.apache.zookeeper</groupId>
         <artifactId>zookeeper</artifactId>
         <version>${zookeeper.version}</version>
+        <exclusions>
+          <exclusion>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+          </exclusion>
+        </exclusions>
        </dependency>
 
       <dependency>
@@ -1516,6 +1646,16 @@ limitations under the License.
         <groupId>org.apache.kafka</groupId>
         <artifactId>kafka_2.10</artifactId>
         <version>${kafka.version}</version>
+        <exclusions>
+          <exclusion>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+          </exclusion>
+        </exclusions>
       </dependency>
       <dependency>
         <groupId>org.apache.kafka</groupId>
@@ -1546,11 +1686,31 @@ limitations under the License.
         <groupId>org.apache.hive</groupId>
         <artifactId>hive-exec</artifactId>
         <version>${hive.version}</version>
+        <exclusions>
+          <exclusion>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+          </exclusion>
+        </exclusions>
       </dependency>
       <dependency>
         <groupId>org.apache.hive</groupId>
         <artifactId>hive-metastore</artifactId>
         <version>${hive.version}</version>
+        <exclusions>
+          <exclusion>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+          </exclusion>
+        </exclusions>
       </dependency>
 
       <dependency>
@@ -1563,6 +1723,16 @@ limitations under the License.
         <groupId>org.apache.hive.hcatalog</groupId>
         <artifactId>hive-hcatalog-streaming</artifactId>
         <version>${hive.version}</version>
+        <exclusions>
+          <exclusion>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+          </exclusion>
+        </exclusions>
       </dependency>
 
       <dependency>


[3/7] flume git commit: FLUME-3195. Split the KafkaChannelTest to avoid timeouts

Posted by de...@apache.org.
FLUME-3195. Split the KafkaChannelTest to avoid timeouts

KafkaChannelTest had quite a few test methods so during the build sometimes it
caused a timeout. Refactoring it to smaller test classes decrease the chance of
timeouts.

This closes #183

Reviewers: Miklos Csanady, Ferenc Szabo

(Viktor Somogyi via Ferenc Szabo)


Project: http://git-wip-us.apache.org/repos/asf/flume/repo
Commit: http://git-wip-us.apache.org/repos/asf/flume/commit/5a70cd7b
Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/5a70cd7b
Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/5a70cd7b

Branch: refs/heads/trunk
Commit: 5a70cd7b3773d322d15a6adb04811c121d1f3976
Parents: 69c66ef
Author: Viktor Somogyi <vi...@cloudera.com>
Authored: Thu Nov 16 13:01:12 2017 +0100
Committer: Denes Arvay <de...@apache.org>
Committed: Fri Jan 26 16:23:03 2018 +0100

----------------------------------------------------------------------
 .../channel/kafka/TestBasicFunctionality.java   | 213 +++++
 .../flume/channel/kafka/TestKafkaChannel.java   | 897 -------------------
 .../channel/kafka/TestKafkaChannelBase.java     | 272 ++++++
 .../channel/kafka/TestOffsetsAndMigration.java  | 194 ++++
 .../channel/kafka/TestParseAsFlumeEvent.java    | 132 +++
 .../flume/channel/kafka/TestPartitions.java     | 179 ++++
 .../flume/channel/kafka/TestRollback.java       |  84 ++
 7 files changed, 1074 insertions(+), 897 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flume/blob/5a70cd7b/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestBasicFunctionality.java
----------------------------------------------------------------------
diff --git a/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestBasicFunctionality.java b/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestBasicFunctionality.java
new file mode 100644
index 0000000..4ff0ee6
--- /dev/null
+++ b/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestBasicFunctionality.java
@@ -0,0 +1,213 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.flume.channel.kafka;
+
+import org.apache.flume.Context;
+import org.apache.flume.Event;
+import org.apache.flume.conf.Configurables;
+import org.apache.kafka.clients.CommonClientConfigs;
+import org.apache.kafka.clients.consumer.ConsumerConfig;
+import org.apache.kafka.clients.producer.KafkaProducer;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.ExecutorCompletionService;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import static org.apache.flume.channel.kafka.KafkaChannelConfiguration.BOOTSTRAP_SERVERS_CONFIG;
+import static org.apache.flume.channel.kafka.KafkaChannelConfiguration.BROKER_LIST_FLUME_KEY;
+import static org.apache.flume.channel.kafka.KafkaChannelConfiguration.GROUP_ID_FLUME;
+import static org.apache.flume.channel.kafka.KafkaChannelConfiguration.KEY_HEADER;
+import static org.apache.flume.channel.kafka.KafkaChannelConfiguration.READ_SMALLEST_OFFSET;
+import static org.apache.flume.channel.kafka.KafkaChannelConfiguration.TOPIC_CONFIG;
+
+public class TestBasicFunctionality extends TestKafkaChannelBase {
+
+  @Test
+  public void testProps() throws Exception {
+    Context context = new Context();
+    context.put("kafka.producer.some-parameter", "1");
+    context.put("kafka.consumer.another-parameter", "1");
+    context.put(BOOTSTRAP_SERVERS_CONFIG, testUtil.getKafkaServerUrl());
+    context.put(TOPIC_CONFIG, topic);
+
+    final KafkaChannel channel = new KafkaChannel();
+    Configurables.configure(channel, context);
+
+    Properties consumerProps = channel.getConsumerProps();
+    Properties producerProps = channel.getProducerProps();
+
+    Assert.assertEquals(producerProps.getProperty("some-parameter"), "1");
+    Assert.assertEquals(consumerProps.getProperty("another-parameter"), "1");
+  }
+
+  @Test
+  public void testOldConfig() throws Exception {
+    Context context = new Context();
+    context.put(BROKER_LIST_FLUME_KEY, testUtil.getKafkaServerUrl());
+    context.put(GROUP_ID_FLUME, "flume-something");
+    context.put(READ_SMALLEST_OFFSET, "true");
+    context.put("topic", topic);
+
+    final KafkaChannel channel = new KafkaChannel();
+    Configurables.configure(channel, context);
+
+    Properties consumerProps = channel.getConsumerProps();
+    Properties producerProps = channel.getProducerProps();
+
+    Assert.assertEquals(producerProps.getProperty(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG),
+        testUtil.getKafkaServerUrl());
+    Assert.assertEquals(consumerProps.getProperty(ConsumerConfig.GROUP_ID_CONFIG),
+        "flume-something");
+    Assert.assertEquals(consumerProps.getProperty(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG),
+        "earliest");
+  }
+
+
+  @Test
+  public void testStopAndStart() throws Exception {
+    doTestStopAndStart(false, false);
+  }
+
+  @Test
+  public void testStopAndStartWithRollback() throws Exception {
+    doTestStopAndStart(true, true);
+  }
+
+  @Test
+  public void testStopAndStartWithRollbackAndNoRetry() throws Exception {
+    doTestStopAndStart(true, false);
+  }
+
+  @Test
+  public void testNullKeyNoHeader() throws Exception {
+    doTestNullKeyNoHeader();
+  }
+
+  /**
+   * Tests that sub-properties get set correctly if you run the configure() method twice
+   * (fix for FLUME-2857)
+   *
+   * @throws Exception
+   */
+  @Test
+  public void testDefaultSettingsOnReConfigure() throws Exception {
+    String sampleProducerProp = "compression.type";
+    String sampleProducerVal = "snappy";
+
+    String sampleConsumerProp = "fetch.min.bytes";
+    String sampleConsumerVal = "99";
+
+    Context context = prepareDefaultContext(false);
+    context.put(KafkaChannelConfiguration.KAFKA_PRODUCER_PREFIX + sampleProducerProp,
+        sampleProducerVal);
+    context.put(KafkaChannelConfiguration.KAFKA_CONSUMER_PREFIX + sampleConsumerProp,
+        sampleConsumerVal);
+
+    final KafkaChannel channel = createChannel(context);
+
+    Assert.assertEquals(sampleProducerVal,
+        channel.getProducerProps().getProperty(sampleProducerProp));
+    Assert.assertEquals(sampleConsumerVal,
+        channel.getConsumerProps().getProperty(sampleConsumerProp));
+
+    context = prepareDefaultContext(false);
+    channel.configure(context);
+
+    Assert.assertNull(channel.getProducerProps().getProperty(sampleProducerProp));
+    Assert.assertNull(channel.getConsumerProps().getProperty(sampleConsumerProp));
+
+  }
+
+
+  private void doTestNullKeyNoHeader() throws Exception {
+    final KafkaChannel channel = startChannel(false);
+    Properties props = channel.getProducerProps();
+    KafkaProducer<String, byte[]> producer = new KafkaProducer<>(props);
+
+    for (int i = 0; i < 50; i++) {
+      ProducerRecord<String, byte[]> data =
+          new ProducerRecord<>(topic, null, String.valueOf(i).getBytes());
+      producer.send(data).get();
+    }
+    ExecutorCompletionService<Void> submitterSvc = new
+        ExecutorCompletionService<>(Executors.newCachedThreadPool());
+    List<Event> events = pullEvents(channel, submitterSvc,
+        50, false, false);
+    wait(submitterSvc, 5);
+    List<String> finals = new ArrayList<>(50);
+    for (int i = 0; i < 50; i++) {
+      finals.add(i, events.get(i).getHeaders().get(KEY_HEADER));
+    }
+    for (int i = 0; i < 50; i++) {
+      Assert.assertTrue(finals.get(i) == null);
+    }
+    channel.stop();
+  }
+
+  /**
+   * This method starts a channel, puts events into it. The channel is then
+   * stopped and restarted. Then we check to make sure if all events we put
+   * come out. Optionally, 10 events are rolled back,
+   * and optionally we restart the agent immediately after and we try to pull it
+   * out.
+   *
+   * @param rollback
+   * @param retryAfterRollback
+   * @throws Exception
+   */
+  private void doTestStopAndStart(boolean rollback,
+                                  boolean retryAfterRollback) throws Exception {
+    final KafkaChannel channel = startChannel(true);
+    ExecutorService underlying = Executors
+        .newCachedThreadPool();
+    ExecutorCompletionService<Void> submitterSvc =
+        new ExecutorCompletionService<>(underlying);
+    final List<List<Event>> events = createBaseList();
+    putEvents(channel, events, submitterSvc);
+    wait(submitterSvc, 5);
+    channel.stop();
+    final KafkaChannel channel2 = startChannel(true);
+    int total = 50;
+    if (rollback && !retryAfterRollback) {
+      total = 40;
+    }
+    final List<Event> eventsPulled =
+        pullEvents(channel2, submitterSvc, total, rollback, retryAfterRollback);
+    wait(submitterSvc, 5);
+    channel2.stop();
+    if (!retryAfterRollback && rollback) {
+      final KafkaChannel channel3 = startChannel(true);
+      int expectedRemaining = 50 - eventsPulled.size();
+      final List<Event> eventsPulled2 =
+          pullEvents(channel3, submitterSvc, expectedRemaining, false, false);
+      wait(submitterSvc, 5);
+      Assert.assertEquals(expectedRemaining, eventsPulled2.size());
+      eventsPulled.addAll(eventsPulled2);
+      channel3.stop();
+    }
+    underlying.shutdownNow();
+    verify(eventsPulled);
+  }
+}

http://git-wip-us.apache.org/repos/asf/flume/blob/5a70cd7b/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestKafkaChannel.java
----------------------------------------------------------------------
diff --git a/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestKafkaChannel.java b/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestKafkaChannel.java
deleted file mode 100644
index 5e5f2d0..0000000
--- a/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestKafkaChannel.java
+++ /dev/null
@@ -1,897 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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 org.apache.flume.channel.kafka;
-
-import com.google.common.collect.Lists;
-import kafka.admin.AdminUtils;
-import kafka.utils.ZKGroupTopicDirs;
-import kafka.utils.ZkUtils;
-import org.apache.commons.lang.RandomStringUtils;
-import org.apache.flume.Context;
-import org.apache.flume.Event;
-import org.apache.flume.Transaction;
-import org.apache.flume.conf.Configurables;
-import org.apache.flume.event.EventBuilder;
-import org.apache.flume.shared.kafka.test.KafkaPartitionTestUtil;
-import org.apache.flume.shared.kafka.test.PartitionOption;
-import org.apache.flume.shared.kafka.test.PartitionTestScenario;
-import org.apache.flume.sink.kafka.util.TestUtil;
-import org.apache.kafka.clients.CommonClientConfigs;
-import org.apache.kafka.clients.consumer.ConsumerConfig;
-import org.apache.kafka.clients.consumer.KafkaConsumer;
-import org.apache.kafka.clients.consumer.OffsetAndMetadata;
-import org.apache.kafka.clients.producer.KafkaProducer;
-import org.apache.kafka.clients.producer.ProducerRecord;
-import org.apache.kafka.clients.producer.RecordMetadata;
-import org.apache.kafka.common.TopicPartition;
-import org.apache.kafka.common.security.JaasUtils;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CyclicBarrier;
-import java.util.concurrent.ExecutorCompletionService;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import static org.apache.flume.channel.kafka.KafkaChannelConfiguration.*;
-
-public class TestKafkaChannel {
-
-  private static TestUtil testUtil = TestUtil.getInstance();
-  private String topic = null;
-  private final Set<String> usedTopics = new HashSet<String>();
-
-  private static final int DEFAULT_TOPIC_PARTITIONS = 5;
-
-  @BeforeClass
-  public static void setupClass() throws Exception {
-    testUtil.prepare();
-    Thread.sleep(2500);
-  }
-
-  @Before
-  public void setup() throws Exception {
-    topic = findUnusedTopic();
-    try {
-      createTopic(topic, DEFAULT_TOPIC_PARTITIONS);
-    } catch (Exception e) {
-    }
-    Thread.sleep(2500);
-  }
-
-  @AfterClass
-  public static void tearDown() {
-    testUtil.tearDown();
-  }
-
-  //Make sure the props are picked up correctly.
-  @Test
-  public void testProps() throws Exception {
-    Context context = new Context();
-    context.put("kafka.producer.some-parameter", "1");
-    context.put("kafka.consumer.another-parameter", "1");
-    context.put(BOOTSTRAP_SERVERS_CONFIG, testUtil.getKafkaServerUrl());
-    context.put(TOPIC_CONFIG, topic);
-
-    final KafkaChannel channel = new KafkaChannel();
-    Configurables.configure(channel, context);
-
-    Properties consumerProps = channel.getConsumerProps();
-    Properties producerProps = channel.getProducerProps();
-
-    Assert.assertEquals(producerProps.getProperty("some-parameter"), "1");
-    Assert.assertEquals(consumerProps.getProperty("another-parameter"), "1");
-  }
-
-  @Test
-  public void testOldConfig() throws Exception {
-    Context context = new Context();
-    context.put(BROKER_LIST_FLUME_KEY,testUtil.getKafkaServerUrl());
-    context.put(GROUP_ID_FLUME,"flume-something");
-    context.put(READ_SMALLEST_OFFSET,"true");
-    context.put("topic",topic);
-
-    final KafkaChannel channel = new KafkaChannel();
-    Configurables.configure(channel, context);
-
-    Properties consumerProps = channel.getConsumerProps();
-    Properties producerProps = channel.getProducerProps();
-
-    Assert.assertEquals(producerProps.getProperty(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG),
-                        testUtil.getKafkaServerUrl());
-    Assert.assertEquals(consumerProps.getProperty(ConsumerConfig.GROUP_ID_CONFIG),
-                        "flume-something");
-    Assert.assertEquals(consumerProps.getProperty(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG),
-                        "earliest");
-  }
-
-  @Test
-  public void testSuccess() throws Exception {
-    doTestSuccessRollback(false, false);
-  }
-
-  @Test
-  public void testSuccessInterleave() throws Exception {
-    doTestSuccessRollback(false, true);
-  }
-
-  @Test
-  public void testRollbacks() throws Exception {
-    doTestSuccessRollback(true, false);
-  }
-
-  @Test
-  public void testRollbacksInterleave() throws Exception {
-    doTestSuccessRollback(true, true);
-  }
-
-  private void doTestSuccessRollback(final boolean rollback,
-                                     final boolean interleave) throws Exception {
-    final KafkaChannel channel = startChannel(true);
-    writeAndVerify(rollback, channel, interleave);
-    channel.stop();
-  }
-
-
-  @Test
-  public void testStopAndStart() throws Exception {
-    doTestStopAndStart(false, false);
-  }
-
-  @Test
-  public void testStopAndStartWithRollback() throws Exception {
-    doTestStopAndStart(true, true);
-  }
-
-  @Test
-  public void testStopAndStartWithRollbackAndNoRetry() throws Exception {
-    doTestStopAndStart(true, false);
-  }
-
-  @Test
-  public void testParseAsFlumeEventFalse() throws Exception {
-    doParseAsFlumeEventFalse(false);
-  }
-
-  @Test
-  public void testParseAsFlumeEventFalseCheckHeader() throws Exception {
-    doParseAsFlumeEventFalse(true);
-  }
-
-  @Test
-  public void testParseAsFlumeEventFalseAsSource() throws Exception {
-    doParseAsFlumeEventFalseAsSource(false);
-  }
-
-  @Test
-  public void testParseAsFlumeEventFalseAsSourceCheckHeader() throws Exception {
-    doParseAsFlumeEventFalseAsSource(true);
-  }
-
-  @Test
-  public void testNullKeyNoHeader() throws Exception {
-    doTestNullKeyNoHeader();
-  }
-
-  @Test
-  public void testOffsetsNotCommittedOnStop() throws Exception {
-    String message = "testOffsetsNotCommittedOnStop-" + System.nanoTime();
-
-    KafkaChannel channel = startChannel(false);
-
-    KafkaProducer<String, byte[]> producer =
-        new KafkaProducer<String, byte[]>(channel.getProducerProps());
-    ProducerRecord<String, byte[]> data =
-        new ProducerRecord<String, byte[]>(topic, "header-" + message, message.getBytes());
-    producer.send(data).get();
-    producer.flush();
-    producer.close();
-
-    Event event = takeEventWithoutCommittingTxn(channel);
-    Assert.assertNotNull(event);
-    Assert.assertTrue(Arrays.equals(message.getBytes(), event.getBody()));
-
-    // Stop the channel without committing the transaction
-    channel.stop();
-
-    channel = startChannel(false);
-
-    // Message should still be available
-    event = takeEventWithoutCommittingTxn(channel);
-    Assert.assertNotNull(event);
-    Assert.assertTrue(Arrays.equals(message.getBytes(), event.getBody()));
-  }
-
-  @Test
-  public void testMigrateOffsetsNone() throws Exception {
-    doTestMigrateZookeeperOffsets(false, false, "testMigrateOffsets-none");
-  }
-
-  @Test
-  public void testMigrateOffsetsZookeeper() throws Exception {
-    doTestMigrateZookeeperOffsets(true, false, "testMigrateOffsets-zookeeper");
-  }
-
-  @Test
-  public void testMigrateOffsetsKafka() throws Exception {
-    doTestMigrateZookeeperOffsets(false, true, "testMigrateOffsets-kafka");
-  }
-
-  @Test
-  public void testMigrateOffsetsBoth() throws Exception {
-    doTestMigrateZookeeperOffsets(true, true, "testMigrateOffsets-both");
-  }
-
-  @Test
-  public void testPartitionHeaderSet() throws Exception {
-    doPartitionHeader(PartitionTestScenario.PARTITION_ID_HEADER_ONLY);
-  }
-
-  @Test
-  public void testPartitionHeaderNotSet() throws Exception {
-    doPartitionHeader(PartitionTestScenario.NO_PARTITION_HEADERS);
-  }
-
-  @Test
-  public void testStaticPartitionAndHeaderSet() throws Exception {
-    doPartitionHeader(PartitionTestScenario.STATIC_HEADER_AND_PARTITION_ID);
-  }
-
-  @Test
-  public void testStaticPartitionHeaderNotSet() throws Exception {
-    doPartitionHeader(PartitionTestScenario.STATIC_HEADER_ONLY);
-  }
-
-  @Test
-  public void testPartitionHeaderMissing() throws Exception {
-    doPartitionErrors(PartitionOption.NOTSET);
-  }
-
-  @Test(expected = org.apache.flume.ChannelException.class)
-  public void testPartitionHeaderOutOfRange() throws Exception {
-    doPartitionErrors(PartitionOption.VALIDBUTOUTOFRANGE);
-  }
-
-  @Test(expected = org.apache.flume.ChannelException.class)
-  public void testPartitionHeaderInvalid() throws Exception {
-    doPartitionErrors(PartitionOption.NOTANUMBER);
-  }
-
-  /**
-   * Tests that sub-properties get set correctly if you run the configure() method twice
-   * (fix for FLUME-2857)
-   * @throws Exception
-   */
-  @Test
-  public void testDefaultSettingsOnReConfigure() throws Exception {
-    String sampleProducerProp = "compression.type";
-    String sampleProducerVal = "snappy";
-
-    String sampleConsumerProp = "fetch.min.bytes";
-    String sampleConsumerVal = "99";
-
-    Context context = prepareDefaultContext(false);
-    context.put(KafkaChannelConfiguration.KAFKA_PRODUCER_PREFIX + sampleProducerProp,
-        sampleProducerVal);
-    context.put(KafkaChannelConfiguration.KAFKA_CONSUMER_PREFIX + sampleConsumerProp,
-        sampleConsumerVal);
-
-    final KafkaChannel channel = createChannel(context);
-
-    Assert.assertEquals(sampleProducerVal,
-        channel.getProducerProps().getProperty(sampleProducerProp));
-    Assert.assertEquals(sampleConsumerVal,
-        channel.getConsumerProps().getProperty(sampleConsumerProp));
-
-    context = prepareDefaultContext(false);
-    channel.configure(context);
-
-    Assert.assertNull(channel.getProducerProps().getProperty(sampleProducerProp));
-    Assert.assertNull(channel.getConsumerProps().getProperty(sampleConsumerProp));
-
-  }
-
-  public void doTestMigrateZookeeperOffsets(boolean hasZookeeperOffsets, boolean hasKafkaOffsets,
-                                            String group) throws Exception {
-    // create a topic with 1 partition for simplicity
-    topic = findUnusedTopic();
-    createTopic(topic, 1);
-
-    Context context = prepareDefaultContext(false);
-    context.put(ZOOKEEPER_CONNECT_FLUME_KEY, testUtil.getZkUrl());
-    context.put(GROUP_ID_FLUME, group);
-    final KafkaChannel channel = createChannel(context);
-
-    // Produce some data and save an offset
-    Long fifthOffset = 0L;
-    Long tenthOffset = 0L;
-    Properties props = channel.getProducerProps();
-    KafkaProducer<String, byte[]> producer = new KafkaProducer<>(props);
-    for (int i = 1; i <= 50; i++) {
-      ProducerRecord<String, byte[]> data =
-          new ProducerRecord<>(topic, null, String.valueOf(i).getBytes());
-      RecordMetadata recordMetadata = producer.send(data).get();
-      if (i == 5) {
-        fifthOffset = recordMetadata.offset();
-      }
-      if (i == 10) {
-        tenthOffset = recordMetadata.offset();
-      }
-    }
-
-    // Commit 10th offset to zookeeper
-    if (hasZookeeperOffsets) {
-      ZkUtils zkUtils = ZkUtils.apply(testUtil.getZkUrl(), 30000, 30000,
-          JaasUtils.isZkSecurityEnabled());
-      ZKGroupTopicDirs topicDirs = new ZKGroupTopicDirs(group, topic);
-      // we commit the tenth offset to ensure some data is missed.
-      Long offset = tenthOffset + 1;
-      zkUtils.updatePersistentPath(topicDirs.consumerOffsetDir() + "/0", offset.toString(),
-          zkUtils.updatePersistentPath$default$3());
-      zkUtils.close();
-    }
-
-    // Commit 5th offset to kafka
-    if (hasKafkaOffsets) {
-      Map<TopicPartition, OffsetAndMetadata> offsets = new HashMap<>();
-      offsets.put(new TopicPartition(topic, 0), new OffsetAndMetadata(fifthOffset + 1));
-      KafkaConsumer<String, byte[]> consumer = new KafkaConsumer<>(channel.getConsumerProps());
-      consumer.commitSync(offsets);
-      consumer.close();
-    }
-
-    // Start the channel and read some data
-    channel.start();
-    ExecutorCompletionService<Void> submitterSvc = new
-        ExecutorCompletionService<Void>(Executors.newCachedThreadPool());
-    List<Event> events = pullEvents(channel, submitterSvc,
-        20, false, false);
-    wait(submitterSvc, 5);
-    List<Integer> finals = new ArrayList<Integer>(40);
-    for (Event event: events) {
-      finals.add(Integer.parseInt(new String(event.getBody())));
-    }
-    channel.stop();
-
-    if (!hasKafkaOffsets && !hasZookeeperOffsets) {
-      // The default behavior is to read the entire log
-      Assert.assertTrue("Channel should read the the first message", finals.contains(1));
-    } else if (hasKafkaOffsets && hasZookeeperOffsets) {
-      // Respect Kafka offsets if they exist
-      Assert.assertFalse("Channel should not read the 5th message", finals.contains(5));
-      Assert.assertTrue("Channel should read the 6th message", finals.contains(6));
-    } else if (hasKafkaOffsets) {
-      // Respect Kafka offsets if they exist (don't fail if zookeeper offsets are missing)
-      Assert.assertFalse("Channel should not read the 5th message", finals.contains(5));
-      Assert.assertTrue("Channel should read the 6th message", finals.contains(6));
-    } else {
-      // Otherwise migrate the ZooKeeper offsets if they exist
-      Assert.assertFalse("Channel should not read the 10th message", finals.contains(10));
-      Assert.assertTrue("Channel should read the 11th message", finals.contains(11));
-    }
-  }
-
-  /**
-   * This function tests three scenarios:
-   * 1. PartitionOption.VALIDBUTOUTOFRANGE: An integer partition is provided,
-   *    however it exceeds the number of partitions available on the topic.
-   *    Expected behaviour: ChannelException thrown.
-   *
-   * 2. PartitionOption.NOTSET: The partition header is not actually set.
-   *    Expected behaviour: Exception is not thrown because the code avoids an NPE.
-   *
-   * 3. PartitionOption.NOTANUMBER: The partition header is set, but is not an Integer.
-   *    Expected behaviour: ChannelExeption thrown.
-   *
-   * @param option
-   * @throws Exception
-   */
-  private void doPartitionErrors(PartitionOption option) throws Exception {
-    Context context = prepareDefaultContext(false);
-    context.put(PARTITION_HEADER_NAME, KafkaPartitionTestUtil.PARTITION_HEADER);
-    String tempTopic = findUnusedTopic();
-    createTopic(tempTopic, 5);
-    final KafkaChannel channel = createChannel(context);
-    channel.start();
-
-    Transaction tx = channel.getTransaction();
-    tx.begin();
-
-    Map<String, String> headers = new HashMap<String, String>();
-    switch (option) {
-      case VALIDBUTOUTOFRANGE:
-        headers.put(KafkaPartitionTestUtil.PARTITION_HEADER,
-            String.valueOf(DEFAULT_TOPIC_PARTITIONS + 2));
-        break;
-      case NOTSET:
-        headers.put("wrong-header", "2");
-        break;
-      case NOTANUMBER:
-        headers.put(KafkaPartitionTestUtil.PARTITION_HEADER, "not-a-number");
-        break;
-      default:
-        break;
-    }
-
-    Event event = EventBuilder.withBody(String.valueOf(9).getBytes(), headers);
-
-    channel.put(event);
-
-    tx.commit();
-
-    deleteTopic(tempTopic);
-  }
-
-  /**
-   * This method tests both the default behavior (usePartitionHeader=false)
-   * and the behaviour when the partitionId setting is used.
-   * Under the default behaviour, one would expect an even distribution of
-   * messages to partitions, however when partitionId is used we manually create
-   * a large skew to some partitions and then verify that this actually happened
-   * by reading messages directly using a Kafka Consumer.
-   *
-   * @param usePartitionHeader
-   * @param staticPtn
-   * @throws Exception
-   */
-  private void doPartitionHeader(PartitionTestScenario scenario) throws Exception {
-    final int numPtns = DEFAULT_TOPIC_PARTITIONS;
-    final int numMsgs = numPtns * 10;
-    final Integer staticPtn = DEFAULT_TOPIC_PARTITIONS - 2 ;
-    Context context = prepareDefaultContext(false);
-    if (scenario == PartitionTestScenario.PARTITION_ID_HEADER_ONLY ||
-        scenario == PartitionTestScenario.STATIC_HEADER_AND_PARTITION_ID) {
-      context.put(PARTITION_HEADER_NAME, "partition-header");
-    }
-    if (scenario == PartitionTestScenario.STATIC_HEADER_AND_PARTITION_ID ||
-        scenario == PartitionTestScenario.STATIC_HEADER_ONLY) {
-      context.put(STATIC_PARTITION_CONF, staticPtn.toString());
-    }
-    final KafkaChannel channel = createChannel(context);
-    channel.start();
-
-    // Create a map of PartitionId:List<Messages> according to the desired distribution
-    // Initialise with empty ArrayLists
-    Map<Integer, List<Event>> partitionMap = new HashMap<Integer, List<Event>>(numPtns);
-    for (int i = 0; i < numPtns; i++) {
-      partitionMap.put(i, new ArrayList<Event>());
-    }
-    Transaction tx = channel.getTransaction();
-    tx.begin();
-
-    List<Event> orderedEvents = KafkaPartitionTestUtil.generateSkewedMessageList(scenario, numMsgs,
-                                                                 partitionMap, numPtns, staticPtn);
-
-    for (Event event : orderedEvents) {
-      channel.put(event);
-    }
-
-    tx.commit();
-
-    Map<Integer, List<byte[]>> resultsMap = KafkaPartitionTestUtil.retrieveRecordsFromPartitions(
-                                                       topic, numPtns, channel.getConsumerProps());
-
-    KafkaPartitionTestUtil.checkResultsAgainstSkew(scenario, partitionMap, resultsMap, staticPtn,
-                                                   numMsgs);
-
-    channel.stop();
-  }
-
-  private Event takeEventWithoutCommittingTxn(KafkaChannel channel) {
-    for (int i = 0; i < 5; i++) {
-      Transaction txn = channel.getTransaction();
-      txn.begin();
-
-      Event event = channel.take();
-      if (event != null) {
-        return event;
-      } else {
-        txn.commit();
-        txn.close();
-      }
-    }
-    return null;
-  }
-
-  private void doParseAsFlumeEventFalse(Boolean checkHeaders) throws Exception {
-    final KafkaChannel channel = startChannel(false);
-    Properties props = channel.getProducerProps();
-    KafkaProducer<String, byte[]> producer = new KafkaProducer<String, byte[]>(props);
-
-    for (int i = 0; i < 50; i++) {
-      ProducerRecord<String, byte[]> data =
-          new ProducerRecord<String, byte[]>(topic, String.valueOf(i) + "-header",
-                                             String.valueOf(i).getBytes());
-      producer.send(data).get();
-    }
-    ExecutorCompletionService<Void> submitterSvc = new
-        ExecutorCompletionService<Void>(Executors.newCachedThreadPool());
-    List<Event> events = pullEvents(channel, submitterSvc, 50, false, false);
-    wait(submitterSvc, 5);
-    Map<Integer, String> finals = new HashMap<Integer, String>();
-    for (int i = 0; i < 50; i++) {
-      finals.put(Integer.parseInt(new String(events.get(i).getBody())),
-                 events.get(i).getHeaders().get(KEY_HEADER));
-    }
-    for (int i = 0; i < 50; i++) {
-      Assert.assertTrue(finals.keySet().contains(i));
-      if (checkHeaders) {
-        Assert.assertTrue(finals.containsValue(String.valueOf(i) + "-header"));
-      }
-      finals.remove(i);
-    }
-    Assert.assertTrue(finals.isEmpty());
-    channel.stop();
-  }
-
-  private void doTestNullKeyNoHeader() throws Exception {
-    final KafkaChannel channel = startChannel(false);
-    Properties props = channel.getProducerProps();
-    KafkaProducer<String, byte[]> producer = new KafkaProducer<String, byte[]>(props);
-
-    for (int i = 0; i < 50; i++) {
-      ProducerRecord<String, byte[]> data =
-          new ProducerRecord<String, byte[]>(topic, null, String.valueOf(i).getBytes());
-      producer.send(data).get();
-    }
-    ExecutorCompletionService<Void> submitterSvc = new
-            ExecutorCompletionService<Void>(Executors.newCachedThreadPool());
-    List<Event> events = pullEvents(channel, submitterSvc,
-            50, false, false);
-    wait(submitterSvc, 5);
-    List<String> finals = new ArrayList<String>(50);
-    for (int i = 0; i < 50; i++) {
-      finals.add(i, events.get(i).getHeaders().get(KEY_HEADER));
-    }
-    for (int i = 0; i < 50; i++) {
-      Assert.assertTrue( finals.get(i) == null);
-    }
-    channel.stop();
-  }
-
-  /**
-   * Like the previous test but here we write to the channel like a Flume source would do
-   * to verify that the events are written as text and not as an Avro object
-   *
-   * @throws Exception
-   */
-  public void doParseAsFlumeEventFalseAsSource(Boolean checkHeaders) throws Exception {
-    final KafkaChannel channel = startChannel(false);
-
-    List<String> msgs = new ArrayList<String>();
-    Map<String, String> headers = new HashMap<String, String>();
-    for (int i = 0; i < 50; i++) {
-      msgs.add(String.valueOf(i));
-    }
-    Transaction tx = channel.getTransaction();
-    tx.begin();
-    for (int i = 0; i < msgs.size(); i++) {
-      headers.put(KEY_HEADER, String.valueOf(i) + "-header");
-      channel.put(EventBuilder.withBody(msgs.get(i).getBytes(), headers));
-    }
-    tx.commit();
-    ExecutorCompletionService<Void> submitterSvc =
-        new ExecutorCompletionService<Void>(Executors.newCachedThreadPool());
-    List<Event> events = pullEvents(channel, submitterSvc, 50, false, false);
-    wait(submitterSvc, 5);
-    Map<Integer, String> finals = new HashMap<Integer, String>();
-    for (int i = 0; i < 50; i++) {
-      finals.put(Integer.parseInt(new String(events.get(i).getBody())),
-                 events.get(i).getHeaders().get(KEY_HEADER));
-    }
-    for (int i = 0; i < 50; i++) {
-      Assert.assertTrue(finals.keySet().contains(i));
-      if (checkHeaders) {
-        Assert.assertTrue(finals.containsValue(String.valueOf(i) + "-header"));
-      }
-      finals.remove(i);
-    }
-    Assert.assertTrue(finals.isEmpty());
-    channel.stop();
-  }
-
-  /**
-   * This method starts a channel, puts events into it. The channel is then
-   * stopped and restarted. Then we check to make sure if all events we put
-   * come out. Optionally, 10 events are rolled back,
-   * and optionally we restart the agent immediately after and we try to pull it
-   * out.
-   *
-   * @param rollback
-   * @param retryAfterRollback
-   * @throws Exception
-   */
-  private void doTestStopAndStart(boolean rollback,
-                                  boolean retryAfterRollback) throws Exception {
-    final KafkaChannel channel = startChannel(true);
-    ExecutorService underlying = Executors
-            .newCachedThreadPool();
-    ExecutorCompletionService<Void> submitterSvc =
-            new ExecutorCompletionService<Void>(underlying);
-    final List<List<Event>> events = createBaseList();
-    putEvents(channel, events, submitterSvc);
-    int completed = 0;
-    wait(submitterSvc, 5);
-    channel.stop();
-    final KafkaChannel channel2 = startChannel(true);
-    int total = 50;
-    if (rollback && !retryAfterRollback) {
-      total = 40;
-    }
-    final List<Event> eventsPulled =
-            pullEvents(channel2, submitterSvc, total, rollback, retryAfterRollback);
-    wait(submitterSvc, 5);
-    channel2.stop();
-    if (!retryAfterRollback && rollback) {
-      final KafkaChannel channel3 = startChannel(true);
-      int expectedRemaining = 50 - eventsPulled.size();
-      final List<Event> eventsPulled2 =
-              pullEvents(channel3, submitterSvc, expectedRemaining, false, false);
-      wait(submitterSvc, 5);
-      Assert.assertEquals(expectedRemaining, eventsPulled2.size());
-      eventsPulled.addAll(eventsPulled2);
-      channel3.stop();
-    }
-    underlying.shutdownNow();
-    verify(eventsPulled);
-  }
-
-  private KafkaChannel startChannel(boolean parseAsFlume) throws Exception {
-    Context context = prepareDefaultContext(parseAsFlume);
-    KafkaChannel channel = createChannel(context);
-    channel.start();
-    return channel;
-  }
-
-  private KafkaChannel createChannel(Context context) throws Exception {
-    final KafkaChannel channel = new KafkaChannel();
-    Configurables.configure(channel, context);
-    return channel;
-  }
-
-  private void writeAndVerify(final boolean testRollbacks,
-                              final KafkaChannel channel) throws Exception {
-    writeAndVerify(testRollbacks, channel, false);
-  }
-
-  private void writeAndVerify(final boolean testRollbacks,
-                              final KafkaChannel channel, final boolean interleave)
-      throws Exception {
-
-    final List<List<Event>> events = createBaseList();
-
-    ExecutorCompletionService<Void> submitterSvc =
-        new ExecutorCompletionService<Void>(Executors.newCachedThreadPool());
-
-    putEvents(channel, events, submitterSvc);
-
-    if (interleave) {
-      wait(submitterSvc, 5);
-    }
-
-    ExecutorCompletionService<Void> submitterSvc2 =
-        new ExecutorCompletionService<Void>(Executors.newCachedThreadPool());
-
-    final List<Event> eventsPulled = pullEvents(channel, submitterSvc2, 50, testRollbacks, true);
-
-    if (!interleave) {
-      wait(submitterSvc, 5);
-    }
-    wait(submitterSvc2, 5);
-
-    verify(eventsPulled);
-  }
-
-  private List<List<Event>> createBaseList() {
-    final List<List<Event>> events = new ArrayList<List<Event>>();
-    for (int i = 0; i < 5; i++) {
-      List<Event> eventList = new ArrayList<Event>(10);
-      events.add(eventList);
-      for (int j = 0; j < 10; j++) {
-        Map<String, String> hdrs = new HashMap<String, String>();
-        String v = (String.valueOf(i) + " - " + String
-                .valueOf(j));
-        hdrs.put("header", v);
-        eventList.add(EventBuilder.withBody(v.getBytes(), hdrs));
-      }
-    }
-    return events;
-  }
-
-  private void putEvents(final KafkaChannel channel, final List<List<Event>>
-          events, ExecutorCompletionService<Void> submitterSvc) {
-    for (int i = 0; i < 5; i++) {
-      final int index = i;
-      submitterSvc.submit(new Callable<Void>() {
-        @Override
-        public Void call() {
-          Transaction tx = channel.getTransaction();
-          tx.begin();
-          List<Event> eventsToPut = events.get(index);
-          for (int j = 0; j < 10; j++) {
-            channel.put(eventsToPut.get(j));
-          }
-          try {
-            tx.commit();
-          } finally {
-            tx.close();
-          }
-          return null;
-        }
-      });
-    }
-  }
-
-  private List<Event> pullEvents(final KafkaChannel channel,
-                                 ExecutorCompletionService<Void> submitterSvc, final int total,
-                                 final boolean testRollbacks, final boolean retryAfterRollback) {
-    final List<Event> eventsPulled = Collections.synchronizedList(new
-            ArrayList<Event>(50));
-    final CyclicBarrier barrier = new CyclicBarrier(5);
-    final AtomicInteger counter = new AtomicInteger(0);
-    final AtomicInteger rolledBackCount = new AtomicInteger(0);
-    final AtomicBoolean startedGettingEvents = new AtomicBoolean(false);
-    final AtomicBoolean rolledBack = new AtomicBoolean(false);
-    for (int k = 0; k < 5; k++) {
-      final int index = k;
-      submitterSvc.submit(new Callable<Void>() {
-        @Override
-        public Void call() throws Exception {
-          Transaction tx = null;
-          final List<Event> eventsLocal = Lists.newLinkedList();
-          int takenByThisThread = 0;
-          channel.registerThread();
-          Thread.sleep(1000);
-          barrier.await();
-          while (counter.get() < (total - rolledBackCount.get())) {
-            if (tx == null) {
-              tx = channel.getTransaction();
-              tx.begin();
-            }
-            try {
-              Event e = channel.take();
-              if (e != null) {
-                startedGettingEvents.set(true);
-                eventsLocal.add(e);
-              } else {
-                if (testRollbacks &&
-                        index == 4 &&
-                        (!rolledBack.get()) &&
-                        startedGettingEvents.get()) {
-                  tx.rollback();
-                  tx.close();
-                  tx = null;
-                  rolledBack.set(true);
-                  final int eventsLocalSize = eventsLocal.size();
-                  eventsLocal.clear();
-                  if (!retryAfterRollback) {
-                    rolledBackCount.set(eventsLocalSize);
-                    return null;
-                  }
-                } else {
-                  tx.commit();
-                  tx.close();
-                  tx = null;
-                  eventsPulled.addAll(eventsLocal);
-                  counter.getAndAdd(eventsLocal.size());
-                  eventsLocal.clear();
-                }
-              }
-            } catch (Exception ex) {
-              eventsLocal.clear();
-              if (tx != null) {
-                tx.rollback();
-                tx.close();
-              }
-              tx = null;
-              ex.printStackTrace();
-            }
-          }
-          // Close txn.
-          return null;
-        }
-      });
-    }
-    return eventsPulled;
-  }
-
-  private void wait(ExecutorCompletionService<Void> submitterSvc, int max)
-          throws Exception {
-    int completed = 0;
-    while (completed < max) {
-      submitterSvc.take();
-      completed++;
-    }
-  }
-
-  private void verify(List<Event> eventsPulled) {
-    Assert.assertFalse(eventsPulled.isEmpty());
-    Assert.assertEquals(50, eventsPulled.size());
-    Set<String> eventStrings = new HashSet<String>();
-    for (Event e : eventsPulled) {
-      Assert.assertEquals(e.getHeaders().get("header"), new String(e.getBody()));
-      eventStrings.add(e.getHeaders().get("header"));
-    }
-    for (int i = 0; i < 5; i++) {
-      for (int j = 0; j < 10; j++) {
-        String v = String.valueOf(i) + " - " + String.valueOf(j);
-        Assert.assertTrue(eventStrings.contains(v));
-        eventStrings.remove(v);
-      }
-    }
-    Assert.assertTrue(eventStrings.isEmpty());
-  }
-
-  private Context prepareDefaultContext(boolean parseAsFlume) {
-    // Prepares a default context with Kafka Server Properties
-    Context context = new Context();
-    context.put(BOOTSTRAP_SERVERS_CONFIG, testUtil.getKafkaServerUrl());
-    context.put(PARSE_AS_FLUME_EVENT, String.valueOf(parseAsFlume));
-    context.put(TOPIC_CONFIG, topic);
-
-    return context;
-  }
-
-  public String findUnusedTopic() {
-    String newTopic = null;
-    boolean topicFound = false;
-    while (!topicFound) {
-      newTopic = RandomStringUtils.randomAlphabetic(8);
-      if (!usedTopics.contains(newTopic)) {
-        usedTopics.add(newTopic);
-        topicFound = true;
-      }
-    }
-    return newTopic;
-  }
-
-  public static void createTopic(String topicName, int numPartitions) {
-    int sessionTimeoutMs = 10000;
-    int connectionTimeoutMs = 10000;
-    ZkUtils zkUtils =
-        ZkUtils.apply(testUtil.getZkUrl(), sessionTimeoutMs, connectionTimeoutMs, false);
-    int replicationFactor = 1;
-    Properties topicConfig = new Properties();
-    AdminUtils.createTopic(zkUtils, topicName, numPartitions, replicationFactor, topicConfig);
-  }
-
-  public static void deleteTopic(String topicName) {
-    int sessionTimeoutMs = 10000;
-    int connectionTimeoutMs = 10000;
-    ZkUtils zkUtils =
-        ZkUtils.apply(testUtil.getZkUrl(), sessionTimeoutMs, connectionTimeoutMs, false);
-    AdminUtils.deleteTopic(zkUtils, topicName);
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/flume/blob/5a70cd7b/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestKafkaChannelBase.java
----------------------------------------------------------------------
diff --git a/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestKafkaChannelBase.java b/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestKafkaChannelBase.java
new file mode 100644
index 0000000..9f139d6
--- /dev/null
+++ b/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestKafkaChannelBase.java
@@ -0,0 +1,272 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.flume.channel.kafka;
+
+import com.google.common.collect.Lists;
+import kafka.admin.AdminUtils;
+import kafka.utils.ZkUtils;
+import org.apache.commons.lang.RandomStringUtils;
+import org.apache.flume.Context;
+import org.apache.flume.Event;
+import org.apache.flume.Transaction;
+import org.apache.flume.conf.Configurables;
+import org.apache.flume.event.EventBuilder;
+import org.apache.flume.sink.kafka.util.TestUtil;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.ExecutorCompletionService;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static org.apache.flume.channel.kafka.KafkaChannelConfiguration.BOOTSTRAP_SERVERS_CONFIG;
+import static org.apache.flume.channel.kafka.KafkaChannelConfiguration.PARSE_AS_FLUME_EVENT;
+import static org.apache.flume.channel.kafka.KafkaChannelConfiguration.TOPIC_CONFIG;
+
+public class TestKafkaChannelBase {
+
+  static TestUtil testUtil = TestUtil.getInstance();
+  String topic = null;
+  private final Set<String> usedTopics = new HashSet<>();
+
+  static final int DEFAULT_TOPIC_PARTITIONS = 5;
+
+  @BeforeClass
+  public static void setupClass() throws Exception {
+    testUtil.prepare();
+    Thread.sleep(2500);
+  }
+
+  @Before
+  public void setup() throws Exception {
+    topic = findUnusedTopic();
+    createTopic(topic, DEFAULT_TOPIC_PARTITIONS);
+    Thread.sleep(2500);
+  }
+
+  @AfterClass
+  public static void tearDown() {
+    testUtil.tearDown();
+  }
+
+  String findUnusedTopic() {
+    String newTopic = null;
+    boolean topicFound = false;
+    while (!topicFound) {
+      newTopic = RandomStringUtils.randomAlphabetic(8);
+      if (!usedTopics.contains(newTopic)) {
+        usedTopics.add(newTopic);
+        topicFound = true;
+      }
+    }
+    return newTopic;
+  }
+
+  static void createTopic(String topicName, int numPartitions) {
+    int sessionTimeoutMs = 10000;
+    int connectionTimeoutMs = 10000;
+    ZkUtils zkUtils =
+        ZkUtils.apply(testUtil.getZkUrl(), sessionTimeoutMs, connectionTimeoutMs, false);
+    int replicationFactor = 1;
+    Properties topicConfig = new Properties();
+    AdminUtils.createTopic(zkUtils, topicName, numPartitions, replicationFactor, topicConfig);
+  }
+
+  static void deleteTopic(String topicName) {
+    int sessionTimeoutMs = 10000;
+    int connectionTimeoutMs = 10000;
+    ZkUtils zkUtils =
+        ZkUtils.apply(testUtil.getZkUrl(), sessionTimeoutMs, connectionTimeoutMs, false);
+    AdminUtils.deleteTopic(zkUtils, topicName);
+  }
+
+  KafkaChannel startChannel(boolean parseAsFlume) throws Exception {
+    Context context = prepareDefaultContext(parseAsFlume);
+    KafkaChannel channel = createChannel(context);
+    channel.start();
+    return channel;
+  }
+
+  Context prepareDefaultContext(boolean parseAsFlume) {
+    // Prepares a default context with Kafka Server Properties
+    Context context = new Context();
+    context.put(BOOTSTRAP_SERVERS_CONFIG, testUtil.getKafkaServerUrl());
+    context.put(PARSE_AS_FLUME_EVENT, String.valueOf(parseAsFlume));
+    context.put(TOPIC_CONFIG, topic);
+
+    return context;
+  }
+
+  KafkaChannel createChannel(Context context) throws Exception {
+    final KafkaChannel channel = new KafkaChannel();
+    Configurables.configure(channel, context);
+    return channel;
+  }
+
+  List<Event> pullEvents(final KafkaChannel channel,
+                         ExecutorCompletionService<Void> submitterSvc, final int total,
+                         final boolean testRollbacks, final boolean retryAfterRollback) {
+    final List<Event> eventsPulled = Collections.synchronizedList(new
+        ArrayList<Event>(50));
+    final CyclicBarrier barrier = new CyclicBarrier(5);
+    final AtomicInteger counter = new AtomicInteger(0);
+    final AtomicInteger rolledBackCount = new AtomicInteger(0);
+    final AtomicBoolean startedGettingEvents = new AtomicBoolean(false);
+    final AtomicBoolean rolledBack = new AtomicBoolean(false);
+    for (int k = 0; k < 5; k++) {
+      final int index = k;
+      submitterSvc.submit(new Callable<Void>() {
+        @Override
+        public Void call() throws Exception {
+          Transaction tx = null;
+          final List<Event> eventsLocal = Lists.newLinkedList();
+          channel.registerThread();
+          Thread.sleep(1000);
+          barrier.await();
+          while (counter.get() < (total - rolledBackCount.get())) {
+            if (tx == null) {
+              tx = channel.getTransaction();
+              tx.begin();
+            }
+            try {
+              Event e = channel.take();
+              if (e != null) {
+                startedGettingEvents.set(true);
+                eventsLocal.add(e);
+              } else {
+                if (testRollbacks &&
+                    index == 4 &&
+                    (!rolledBack.get()) &&
+                    startedGettingEvents.get()) {
+                  tx.rollback();
+                  tx.close();
+                  tx = null;
+                  rolledBack.set(true);
+                  final int eventsLocalSize = eventsLocal.size();
+                  eventsLocal.clear();
+                  if (!retryAfterRollback) {
+                    rolledBackCount.set(eventsLocalSize);
+                    return null;
+                  }
+                } else {
+                  tx.commit();
+                  tx.close();
+                  tx = null;
+                  eventsPulled.addAll(eventsLocal);
+                  counter.getAndAdd(eventsLocal.size());
+                  eventsLocal.clear();
+                }
+              }
+            } catch (Exception ex) {
+              eventsLocal.clear();
+              if (tx != null) {
+                tx.rollback();
+                tx.close();
+              }
+              tx = null;
+              ex.printStackTrace();
+            }
+          }
+          // Close txn.
+          return null;
+        }
+      });
+    }
+    return eventsPulled;
+  }
+
+  void wait(ExecutorCompletionService<Void> submitterSvc, int max)
+      throws Exception {
+    int completed = 0;
+    while (completed < max) {
+      submitterSvc.take();
+      completed++;
+    }
+  }
+
+  List<List<Event>> createBaseList() {
+    final List<List<Event>> events = new ArrayList<>();
+    for (int i = 0; i < 5; i++) {
+      List<Event> eventList = new ArrayList<>(10);
+      events.add(eventList);
+      for (int j = 0; j < 10; j++) {
+        Map<String, String> hdrs = new HashMap<>();
+        String v = (String.valueOf(i) + " - " + String
+            .valueOf(j));
+        hdrs.put("header", v);
+        eventList.add(EventBuilder.withBody(v.getBytes(), hdrs));
+      }
+    }
+    return events;
+  }
+
+  void putEvents(final KafkaChannel channel, final List<List<Event>>
+      events, ExecutorCompletionService<Void> submitterSvc) {
+    for (int i = 0; i < 5; i++) {
+      final int index = i;
+      submitterSvc.submit(new Callable<Void>() {
+        @Override
+        public Void call() {
+          Transaction tx = channel.getTransaction();
+          tx.begin();
+          List<Event> eventsToPut = events.get(index);
+          for (int j = 0; j < 10; j++) {
+            channel.put(eventsToPut.get(j));
+          }
+          try {
+            tx.commit();
+          } finally {
+            tx.close();
+          }
+          return null;
+        }
+      });
+    }
+  }
+
+  void verify(List<Event> eventsPulled) {
+    Assert.assertFalse(eventsPulled.isEmpty());
+    Assert.assertEquals(50, eventsPulled.size());
+    Set<String> eventStrings = new HashSet<>();
+    for (Event e : eventsPulled) {
+      Assert.assertEquals(e.getHeaders().get("header"), new String(e.getBody()));
+      eventStrings.add(e.getHeaders().get("header"));
+    }
+    for (int i = 0; i < 5; i++) {
+      for (int j = 0; j < 10; j++) {
+        String v = String.valueOf(i) + " - " + String.valueOf(j);
+        Assert.assertTrue(eventStrings.contains(v));
+        eventStrings.remove(v);
+      }
+    }
+    Assert.assertTrue(eventStrings.isEmpty());
+  }
+}

http://git-wip-us.apache.org/repos/asf/flume/blob/5a70cd7b/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestOffsetsAndMigration.java
----------------------------------------------------------------------
diff --git a/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestOffsetsAndMigration.java b/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestOffsetsAndMigration.java
new file mode 100644
index 0000000..47c583a
--- /dev/null
+++ b/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestOffsetsAndMigration.java
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.flume.channel.kafka;
+
+import kafka.utils.ZKGroupTopicDirs;
+import kafka.utils.ZkUtils;
+import org.apache.flume.Context;
+import org.apache.flume.Event;
+import org.apache.flume.Transaction;
+import org.apache.kafka.clients.consumer.KafkaConsumer;
+import org.apache.kafka.clients.consumer.OffsetAndMetadata;
+import org.apache.kafka.clients.producer.KafkaProducer;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.apache.kafka.clients.producer.RecordMetadata;
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.security.JaasUtils;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutorCompletionService;
+import java.util.concurrent.Executors;
+
+import static org.apache.flume.channel.kafka.KafkaChannelConfiguration.GROUP_ID_FLUME;
+import static org.apache.flume.channel.kafka.KafkaChannelConfiguration.ZOOKEEPER_CONNECT_FLUME_KEY;
+
+public class TestOffsetsAndMigration extends TestKafkaChannelBase {
+
+  @Test
+  public void testOffsetsNotCommittedOnStop() throws Exception {
+    String message = "testOffsetsNotCommittedOnStop-" + System.nanoTime();
+
+    KafkaChannel channel = startChannel(false);
+
+    KafkaProducer<String, byte[]> producer =
+        new KafkaProducer<>(channel.getProducerProps());
+    ProducerRecord<String, byte[]> data =
+        new ProducerRecord<>(topic, "header-" + message, message.getBytes());
+    producer.send(data).get();
+    producer.flush();
+    producer.close();
+
+    Event event = takeEventWithoutCommittingTxn(channel);
+    Assert.assertNotNull(event);
+    Assert.assertTrue(Arrays.equals(message.getBytes(), event.getBody()));
+
+    // Stop the channel without committing the transaction
+    channel.stop();
+
+    channel = startChannel(false);
+
+    // Message should still be available
+    event = takeEventWithoutCommittingTxn(channel);
+    Assert.assertNotNull(event);
+    Assert.assertTrue(Arrays.equals(message.getBytes(), event.getBody()));
+  }
+
+  @Test
+  public void testMigrateOffsetsNone() throws Exception {
+    doTestMigrateZookeeperOffsets(false, false, "testMigrateOffsets-none");
+  }
+
+  @Test
+  public void testMigrateOffsetsZookeeper() throws Exception {
+    doTestMigrateZookeeperOffsets(true, false, "testMigrateOffsets-zookeeper");
+  }
+
+  @Test
+  public void testMigrateOffsetsKafka() throws Exception {
+    doTestMigrateZookeeperOffsets(false, true, "testMigrateOffsets-kafka");
+  }
+
+  @Test
+  public void testMigrateOffsetsBoth() throws Exception {
+    doTestMigrateZookeeperOffsets(true, true, "testMigrateOffsets-both");
+  }
+
+  private Event takeEventWithoutCommittingTxn(KafkaChannel channel) {
+    for (int i = 0; i < 5; i++) {
+      Transaction txn = channel.getTransaction();
+      txn.begin();
+
+      Event event = channel.take();
+      if (event != null) {
+        return event;
+      } else {
+        txn.commit();
+        txn.close();
+      }
+    }
+    return null;
+  }
+
+  private void doTestMigrateZookeeperOffsets(boolean hasZookeeperOffsets, boolean hasKafkaOffsets,
+                                             String group) throws Exception {
+    // create a topic with 1 partition for simplicity
+    topic = findUnusedTopic();
+    createTopic(topic, 1);
+
+    Context context = prepareDefaultContext(false);
+    context.put(ZOOKEEPER_CONNECT_FLUME_KEY, testUtil.getZkUrl());
+    context.put(GROUP_ID_FLUME, group);
+    final KafkaChannel channel = createChannel(context);
+
+    // Produce some data and save an offset
+    Long fifthOffset = 0L;
+    Long tenthOffset = 0L;
+    Properties props = channel.getProducerProps();
+    KafkaProducer<String, byte[]> producer = new KafkaProducer<>(props);
+    for (int i = 1; i <= 50; i++) {
+      ProducerRecord<String, byte[]> data =
+          new ProducerRecord<>(topic, null, String.valueOf(i).getBytes());
+      RecordMetadata recordMetadata = producer.send(data).get();
+      if (i == 5) {
+        fifthOffset = recordMetadata.offset();
+      }
+      if (i == 10) {
+        tenthOffset = recordMetadata.offset();
+      }
+    }
+
+    // Commit 10th offset to zookeeper
+    if (hasZookeeperOffsets) {
+      ZkUtils zkUtils = ZkUtils.apply(testUtil.getZkUrl(), 30000, 30000,
+          JaasUtils.isZkSecurityEnabled());
+      ZKGroupTopicDirs topicDirs = new ZKGroupTopicDirs(group, topic);
+      // we commit the tenth offset to ensure some data is missed.
+      Long offset = tenthOffset + 1;
+      zkUtils.updatePersistentPath(topicDirs.consumerOffsetDir() + "/0", offset.toString(),
+          zkUtils.updatePersistentPath$default$3());
+      zkUtils.close();
+    }
+
+    // Commit 5th offset to kafka
+    if (hasKafkaOffsets) {
+      Map<TopicPartition, OffsetAndMetadata> offsets = new HashMap<>();
+      offsets.put(new TopicPartition(topic, 0), new OffsetAndMetadata(fifthOffset + 1));
+      KafkaConsumer<String, byte[]> consumer = new KafkaConsumer<>(channel.getConsumerProps());
+      consumer.commitSync(offsets);
+      consumer.close();
+    }
+
+    // Start the channel and read some data
+    channel.start();
+    ExecutorCompletionService<Void> submitterSvc = new
+        ExecutorCompletionService<>(Executors.newCachedThreadPool());
+    List<Event> events = pullEvents(channel, submitterSvc,
+        20, false, false);
+    wait(submitterSvc, 5);
+    List<Integer> finals = new ArrayList<>(40);
+    for (Event event : events) {
+      finals.add(Integer.parseInt(new String(event.getBody())));
+    }
+    channel.stop();
+
+    if (!hasKafkaOffsets && !hasZookeeperOffsets) {
+      // The default behavior is to read the entire log
+      Assert.assertTrue("Channel should read the the first message", finals.contains(1));
+    } else if (hasKafkaOffsets && hasZookeeperOffsets) {
+      // Respect Kafka offsets if they exist
+      Assert.assertFalse("Channel should not read the 5th message", finals.contains(5));
+      Assert.assertTrue("Channel should read the 6th message", finals.contains(6));
+    } else if (hasKafkaOffsets) {
+      // Respect Kafka offsets if they exist (don't fail if zookeeper offsets are missing)
+      Assert.assertFalse("Channel should not read the 5th message", finals.contains(5));
+      Assert.assertTrue("Channel should read the 6th message", finals.contains(6));
+    } else {
+      // Otherwise migrate the ZooKeeper offsets if they exist
+      Assert.assertFalse("Channel should not read the 10th message", finals.contains(10));
+      Assert.assertTrue("Channel should read the 11th message", finals.contains(11));
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/flume/blob/5a70cd7b/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestParseAsFlumeEvent.java
----------------------------------------------------------------------
diff --git a/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestParseAsFlumeEvent.java b/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestParseAsFlumeEvent.java
new file mode 100644
index 0000000..6baad77
--- /dev/null
+++ b/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestParseAsFlumeEvent.java
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.flume.channel.kafka;
+
+import org.apache.flume.Event;
+import org.apache.flume.Transaction;
+import org.apache.flume.event.EventBuilder;
+import org.apache.kafka.clients.producer.KafkaProducer;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutorCompletionService;
+import java.util.concurrent.Executors;
+
+import static org.apache.flume.channel.kafka.KafkaChannelConfiguration.KEY_HEADER;
+
+public class TestParseAsFlumeEvent extends TestKafkaChannelBase {
+
+  @Test
+  public void testParseAsFlumeEventFalse() throws Exception {
+    doParseAsFlumeEventFalse(false);
+  }
+
+  @Test
+  public void testParseAsFlumeEventFalseCheckHeader() throws Exception {
+    doParseAsFlumeEventFalse(true);
+  }
+
+  @Test
+  public void testParseAsFlumeEventFalseAsSource() throws Exception {
+    doParseAsFlumeEventFalseAsSource(false);
+  }
+
+  @Test
+  public void testParseAsFlumeEventFalseAsSourceCheckHeader() throws Exception {
+    doParseAsFlumeEventFalseAsSource(true);
+  }
+
+  private void doParseAsFlumeEventFalse(Boolean checkHeaders) throws Exception {
+    final KafkaChannel channel = startChannel(false);
+    Properties props = channel.getProducerProps();
+    KafkaProducer<String, byte[]> producer = new KafkaProducer<>(props);
+
+    for (int i = 0; i < 50; i++) {
+      ProducerRecord<String, byte[]> data =
+          new ProducerRecord<>(topic, String.valueOf(i) + "-header",
+              String.valueOf(i).getBytes());
+      producer.send(data).get();
+    }
+    ExecutorCompletionService<Void> submitterSvc = new
+        ExecutorCompletionService<>(Executors.newCachedThreadPool());
+    List<Event> events = pullEvents(channel, submitterSvc, 50, false, false);
+    wait(submitterSvc, 5);
+    Map<Integer, String> finals = new HashMap<>();
+    for (int i = 0; i < 50; i++) {
+      finals.put(Integer.parseInt(new String(events.get(i).getBody())),
+          events.get(i).getHeaders().get(KEY_HEADER));
+    }
+    for (int i = 0; i < 50; i++) {
+      Assert.assertTrue(finals.keySet().contains(i));
+      if (checkHeaders) {
+        Assert.assertTrue(finals.containsValue(String.valueOf(i) + "-header"));
+      }
+      finals.remove(i);
+    }
+    Assert.assertTrue(finals.isEmpty());
+    channel.stop();
+  }
+
+  /**
+   * Like the previous test but here we write to the channel like a Flume source would do
+   * to verify that the events are written as text and not as an Avro object
+   *
+   * @throws Exception
+   */
+  private void doParseAsFlumeEventFalseAsSource(Boolean checkHeaders) throws Exception {
+    final KafkaChannel channel = startChannel(false);
+
+    List<String> msgs = new ArrayList<>();
+    Map<String, String> headers = new HashMap<>();
+    for (int i = 0; i < 50; i++) {
+      msgs.add(String.valueOf(i));
+    }
+    Transaction tx = channel.getTransaction();
+    tx.begin();
+    for (int i = 0; i < msgs.size(); i++) {
+      headers.put(KEY_HEADER, String.valueOf(i) + "-header");
+      channel.put(EventBuilder.withBody(msgs.get(i).getBytes(), headers));
+    }
+    tx.commit();
+    ExecutorCompletionService<Void> submitterSvc =
+        new ExecutorCompletionService<>(Executors.newCachedThreadPool());
+    List<Event> events = pullEvents(channel, submitterSvc, 50, false, false);
+    wait(submitterSvc, 5);
+    Map<Integer, String> finals = new HashMap<>();
+    for (int i = 0; i < 50; i++) {
+      finals.put(Integer.parseInt(new String(events.get(i).getBody())),
+          events.get(i).getHeaders().get(KEY_HEADER));
+    }
+    for (int i = 0; i < 50; i++) {
+      Assert.assertTrue(finals.keySet().contains(i));
+      if (checkHeaders) {
+        Assert.assertTrue(finals.containsValue(String.valueOf(i) + "-header"));
+      }
+      finals.remove(i);
+    }
+    Assert.assertTrue(finals.isEmpty());
+    channel.stop();
+  }
+}

http://git-wip-us.apache.org/repos/asf/flume/blob/5a70cd7b/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestPartitions.java
----------------------------------------------------------------------
diff --git a/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestPartitions.java b/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestPartitions.java
new file mode 100644
index 0000000..9652fb1
--- /dev/null
+++ b/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestPartitions.java
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.flume.channel.kafka;
+
+import org.apache.flume.Context;
+import org.apache.flume.Event;
+import org.apache.flume.Transaction;
+import org.apache.flume.event.EventBuilder;
+import org.apache.flume.shared.kafka.test.KafkaPartitionTestUtil;
+import org.apache.flume.shared.kafka.test.PartitionOption;
+import org.apache.flume.shared.kafka.test.PartitionTestScenario;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.apache.flume.channel.kafka.KafkaChannelConfiguration.PARTITION_HEADER_NAME;
+import static org.apache.flume.channel.kafka.KafkaChannelConfiguration.STATIC_PARTITION_CONF;
+
+public class TestPartitions extends TestKafkaChannelBase {
+
+  @Test
+  public void testPartitionHeaderSet() throws Exception {
+    doPartitionHeader(PartitionTestScenario.PARTITION_ID_HEADER_ONLY);
+  }
+
+  @Test
+  public void testPartitionHeaderNotSet() throws Exception {
+    doPartitionHeader(PartitionTestScenario.NO_PARTITION_HEADERS);
+  }
+
+  @Test
+  public void testStaticPartitionAndHeaderSet() throws Exception {
+    doPartitionHeader(PartitionTestScenario.STATIC_HEADER_AND_PARTITION_ID);
+  }
+
+  @Test
+  public void testStaticPartitionHeaderNotSet() throws Exception {
+    doPartitionHeader(PartitionTestScenario.STATIC_HEADER_ONLY);
+  }
+
+  @Test
+  public void testPartitionHeaderMissing() throws Exception {
+    doPartitionErrors(PartitionOption.NOTSET);
+  }
+
+  @Test(expected = org.apache.flume.ChannelException.class)
+  public void testPartitionHeaderOutOfRange() throws Exception {
+    doPartitionErrors(PartitionOption.VALIDBUTOUTOFRANGE);
+  }
+
+  @Test(expected = org.apache.flume.ChannelException.class)
+  public void testPartitionHeaderInvalid() throws Exception {
+    doPartitionErrors(PartitionOption.NOTANUMBER);
+  }
+
+  /**
+   * This method tests both the default behavior (usePartitionHeader=false)
+   * and the behaviour when the partitionId setting is used.
+   * Under the default behaviour, one would expect an even distribution of
+   * messages to partitions, however when partitionId is used we manually create
+   * a large skew to some partitions and then verify that this actually happened
+   * by reading messages directly using a Kafka Consumer.
+   *
+   * @param scenario
+   * @throws Exception
+   */
+  private void doPartitionHeader(PartitionTestScenario scenario) throws Exception {
+    final int numPtns = DEFAULT_TOPIC_PARTITIONS;
+    final int numMsgs = numPtns * 10;
+    final Integer staticPtn = DEFAULT_TOPIC_PARTITIONS - 2;
+    Context context = prepareDefaultContext(false);
+    if (scenario == PartitionTestScenario.PARTITION_ID_HEADER_ONLY ||
+        scenario == PartitionTestScenario.STATIC_HEADER_AND_PARTITION_ID) {
+      context.put(PARTITION_HEADER_NAME, "partition-header");
+    }
+    if (scenario == PartitionTestScenario.STATIC_HEADER_AND_PARTITION_ID ||
+        scenario == PartitionTestScenario.STATIC_HEADER_ONLY) {
+      context.put(STATIC_PARTITION_CONF, staticPtn.toString());
+    }
+    final KafkaChannel channel = createChannel(context);
+    channel.start();
+
+    // Create a map of PartitionId:List<Messages> according to the desired distribution
+    // Initialise with empty ArrayLists
+    Map<Integer, List<Event>> partitionMap = new HashMap<>(numPtns);
+    for (int i = 0; i < numPtns; i++) {
+      partitionMap.put(i, new ArrayList<Event>());
+    }
+    Transaction tx = channel.getTransaction();
+    tx.begin();
+
+    List<Event> orderedEvents = KafkaPartitionTestUtil.generateSkewedMessageList(scenario, numMsgs,
+        partitionMap, numPtns, staticPtn);
+
+    for (Event event : orderedEvents) {
+      channel.put(event);
+    }
+
+    tx.commit();
+
+    Map<Integer, List<byte[]>> resultsMap = KafkaPartitionTestUtil.retrieveRecordsFromPartitions(
+        topic, numPtns, channel.getConsumerProps());
+
+    KafkaPartitionTestUtil.checkResultsAgainstSkew(scenario, partitionMap, resultsMap, staticPtn,
+        numMsgs);
+
+    channel.stop();
+  }
+
+  /**
+   * This function tests three scenarios:
+   * 1. PartitionOption.VALIDBUTOUTOFRANGE: An integer partition is provided,
+   * however it exceeds the number of partitions available on the topic.
+   * Expected behaviour: ChannelException thrown.
+   * <p>
+   * 2. PartitionOption.NOTSET: The partition header is not actually set.
+   * Expected behaviour: Exception is not thrown because the code avoids an NPE.
+   * <p>
+   * 3. PartitionOption.NOTANUMBER: The partition header is set, but is not an Integer.
+   * Expected behaviour: ChannelExeption thrown.
+   *
+   * @param option
+   * @throws Exception
+   */
+  private void doPartitionErrors(PartitionOption option) throws Exception {
+    Context context = prepareDefaultContext(false);
+    context.put(PARTITION_HEADER_NAME, KafkaPartitionTestUtil.PARTITION_HEADER);
+    String tempTopic = findUnusedTopic();
+    createTopic(tempTopic, 5);
+    final KafkaChannel channel = createChannel(context);
+    channel.start();
+
+    Transaction tx = channel.getTransaction();
+    tx.begin();
+
+    Map<String, String> headers = new HashMap<>();
+    switch (option) {
+      case VALIDBUTOUTOFRANGE:
+        headers.put(KafkaPartitionTestUtil.PARTITION_HEADER,
+            String.valueOf(DEFAULT_TOPIC_PARTITIONS + 2));
+        break;
+      case NOTSET:
+        headers.put("wrong-header", "2");
+        break;
+      case NOTANUMBER:
+        headers.put(KafkaPartitionTestUtil.PARTITION_HEADER, "not-a-number");
+        break;
+      default:
+        break;
+    }
+
+    Event event = EventBuilder.withBody(String.valueOf(9).getBytes(), headers);
+
+    channel.put(event);
+
+    tx.commit();
+
+    deleteTopic(tempTopic);
+  }
+}

http://git-wip-us.apache.org/repos/asf/flume/blob/5a70cd7b/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestRollback.java
----------------------------------------------------------------------
diff --git a/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestRollback.java b/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestRollback.java
new file mode 100644
index 0000000..6e9e1e2
--- /dev/null
+++ b/flume-ng-channels/flume-kafka-channel/src/test/java/org/apache/flume/channel/kafka/TestRollback.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.flume.channel.kafka;
+
+import org.apache.flume.Event;
+import org.junit.Test;
+
+import java.util.List;
+import java.util.concurrent.ExecutorCompletionService;
+import java.util.concurrent.Executors;
+
+public class TestRollback extends TestKafkaChannelBase {
+
+  @Test
+  public void testSuccess() throws Exception {
+    doTestSuccessRollback(false, false);
+  }
+
+  @Test
+  public void testSuccessInterleave() throws Exception {
+    doTestSuccessRollback(false, true);
+  }
+
+  @Test
+  public void testRollbacks() throws Exception {
+    doTestSuccessRollback(true, false);
+  }
+
+  @Test
+  public void testRollbacksInterleave() throws Exception {
+    doTestSuccessRollback(true, true);
+  }
+
+  private void doTestSuccessRollback(final boolean rollback,
+                                     final boolean interleave) throws Exception {
+    final KafkaChannel channel = startChannel(true);
+    writeAndVerify(rollback, channel, interleave);
+    channel.stop();
+  }
+
+  private void writeAndVerify(final boolean testRollbacks,
+                              final KafkaChannel channel, final boolean interleave)
+      throws Exception {
+
+    final List<List<Event>> events = createBaseList();
+
+    ExecutorCompletionService<Void> submitterSvc =
+        new ExecutorCompletionService<Void>(Executors.newCachedThreadPool());
+
+    putEvents(channel, events, submitterSvc);
+
+    if (interleave) {
+      wait(submitterSvc, 5);
+    }
+
+    ExecutorCompletionService<Void> submitterSvc2 =
+        new ExecutorCompletionService<Void>(Executors.newCachedThreadPool());
+
+    final List<Event> eventsPulled = pullEvents(channel, submitterSvc2, 50, testRollbacks, true);
+
+    if (!interleave) {
+      wait(submitterSvc, 5);
+    }
+    wait(submitterSvc2, 5);
+
+    verify(eventsPulled);
+  }
+}


[5/7] flume git commit: FLUME-3201. Fix SyslogUtil to handle RFC3164 format in December correctly

Posted by de...@apache.org.
FLUME-3201. Fix SyslogUtil to handle RFC3164 format in December correctly

This closes #188

Reviewers: Tristan Stevens, Miklos Csanady

(Ferenc Szabo via Denes Arvay)


Project: http://git-wip-us.apache.org/repos/asf/flume/repo
Commit: http://git-wip-us.apache.org/repos/asf/flume/commit/31d1a573
Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/31d1a573
Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/31d1a573

Branch: refs/heads/trunk
Commit: 31d1a573f7fa9b65d8474794e318b63e8a109f62
Parents: 93510c6
Author: Ferenc Szabo <fs...@cloudera.com>
Authored: Wed Dec 6 09:39:51 2017 +0100
Committer: Denes Arvay <de...@apache.org>
Committed: Fri Jan 26 16:23:26 2018 +0100

----------------------------------------------------------------------
 .../org/apache/flume/source/SyslogUtils.java    | 36 ++++++--
 .../apache/flume/source/TestSyslogUtils.java    | 87 +++++++++++++-------
 2 files changed, 86 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flume/blob/31d1a573/flume-ng-core/src/main/java/org/apache/flume/source/SyslogUtils.java
----------------------------------------------------------------------
diff --git a/flume-ng-core/src/main/java/org/apache/flume/source/SyslogUtils.java b/flume-ng-core/src/main/java/org/apache/flume/source/SyslogUtils.java
index 43a10e1..e9d4d8f 100644
--- a/flume-ng-core/src/main/java/org/apache/flume/source/SyslogUtils.java
+++ b/flume-ng-core/src/main/java/org/apache/flume/source/SyslogUtils.java
@@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory;
 import java.io.ByteArrayOutputStream;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.Clock;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Calendar;
@@ -93,6 +94,7 @@ public class SyslogUtils {
   public static final Integer MIN_SIZE = 10;
   public static final Integer DEFAULT_SIZE = 2500;
   private final boolean isUdp;
+  private Clock clock;
   private boolean isBadEvent;
   private boolean isIncompleteEvent;
   private Integer maxSize;
@@ -190,12 +192,21 @@ public class SyslogUtils {
 
   public SyslogUtils(boolean isUdp) {
     this(DEFAULT_SIZE,
-        new HashSet<String>(Arrays.asList(SyslogSourceConfigurationConstants.DEFAULT_KEEP_FIELDS)),
+        new HashSet<>(Arrays.asList(SyslogSourceConfigurationConstants.DEFAULT_KEEP_FIELDS)),
         isUdp);
   }
 
-  public SyslogUtils(Integer eventSize, Set<String> keepFields, boolean isUdp) {
+  public SyslogUtils(Integer defaultSize, Set<String> keepFields, boolean isUdp) {
+      this(defaultSize,
+              keepFields,
+              isUdp,
+              Clock.system(Clock.systemDefaultZone().getZone())
+      );
+  }
+
+  public SyslogUtils(Integer eventSize, Set<String> keepFields, boolean isUdp, Clock clock) {
     this.isUdp = isUdp;
+    this.clock = clock;
     isBadEvent = false;
     isIncompleteEvent = false;
     maxSize = (eventSize < MIN_SIZE) ? MIN_SIZE : eventSize;
@@ -370,6 +381,7 @@ public class SyslogUtils {
             for (int dt = 0; dt < fmt.dateFormat.size(); dt++) {
               try {
                 Date parsedDate = fmt.dateFormat.get(dt).parse(value);
+
                 /*
                  * Some code to try and add some smarts to the year insertion.
                  * Original code just added the current year which was okay-ish, but around
@@ -384,8 +396,12 @@ public class SyslogUtils {
                  * 1 month in the future) of timestamps.
                  */
                 if (fmt.addYear) {
-                  Calendar cal = Calendar.getInstance();
-                  cal.setTime(parsedDate);
+                  // Parsing from dateformatter without year part would use system clock
+                  // so we have to set the year part from the used clock instance
+                  parsedDate.setYear(new Date(clock.millis()).getYear());
+
+                  Calendar calParsed = Calendar.getInstance();
+                  calParsed.setTime(parsedDate);
                   Calendar calMinusOneMonth = Calendar.getInstance();
                   calMinusOneMonth.setTime(parsedDate);
                   calMinusOneMonth.add(Calendar.MONTH, -1);
@@ -394,19 +410,21 @@ public class SyslogUtils {
                   calPlusElevenMonths.setTime(parsedDate);
                   calPlusElevenMonths.add(Calendar.MONTH, +11);
 
-                  if (cal.getTimeInMillis() > System.currentTimeMillis() &&
-                      calMinusOneMonth.getTimeInMillis() > System.currentTimeMillis()) {
+                  long currentTimeMillis = clock.millis();
+
+                  if (calParsed.getTimeInMillis() > currentTimeMillis &&
+                      calMinusOneMonth.getTimeInMillis() > currentTimeMillis) {
                     //Need to roll back a year
                     Calendar c1 = Calendar.getInstance();
                     c1.setTime(parsedDate);
                     c1.add(Calendar.YEAR, -1);
                     parsedDate = c1.getTime();
-                  } else if (cal.getTimeInMillis() < System.currentTimeMillis() &&
-                             calPlusElevenMonths.getTimeInMillis() < System.currentTimeMillis()) {
+                  } else if (calParsed.getTimeInMillis() < currentTimeMillis &&
+                             calPlusElevenMonths.getTimeInMillis() < currentTimeMillis) {
                     //Need to roll forward a year
                     Calendar c1 = Calendar.getInstance();
                     c1.setTime(parsedDate);
-                    c1.add(Calendar.YEAR, -1);
+                    c1.add(Calendar.YEAR, +1);
                     parsedDate = c1.getTime();
                   }
                 }

http://git-wip-us.apache.org/repos/asf/flume/blob/31d1a573/flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogUtils.java
----------------------------------------------------------------------
diff --git a/flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogUtils.java b/flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogUtils.java
index 80d8dac..2479413 100644
--- a/flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogUtils.java
+++ b/flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogUtils.java
@@ -26,6 +26,9 @@ import org.junit.Test;
 
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.Clock;
+import java.time.LocalDateTime;
+import java.time.ZoneOffset;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.HashSet;
@@ -130,7 +133,7 @@ public class TestSyslogUtils {
 
   @Test
   public void TestHeader9() throws ParseException {
-    SimpleDateFormat sdf = new SimpleDateFormat("MMM  d hh:MM:ss");
+    SimpleDateFormat sdf = new SimpleDateFormat("MMM  d hh:MM:ss", Locale.ENGLISH);
     Calendar cal = Calendar.getInstance();
 
     String year = String.valueOf(cal.get(Calendar.YEAR));
@@ -145,7 +148,7 @@ public class TestSyslogUtils {
 
   @Test
   public void TestHeader10() throws ParseException {
-    SimpleDateFormat sdf = new SimpleDateFormat("MMM  d hh:MM:ss");
+    SimpleDateFormat sdf = new SimpleDateFormat("MMM  d hh:MM:ss", Locale.ENGLISH);
     Calendar cal = Calendar.getInstance();
 
     String year = String.valueOf(cal.get(Calendar.YEAR));
@@ -175,7 +178,7 @@ public class TestSyslogUtils {
 
   @Test
   public void TestRfc3164HeaderApacheLogWithNulls() throws ParseException {
-    SimpleDateFormat sdf = new SimpleDateFormat("MMM  d hh:MM:ss");
+    SimpleDateFormat sdf = new SimpleDateFormat("MMM  d hh:MM:ss", Locale.ENGLISH);
     Calendar cal = Calendar.getInstance();
 
     String year = String.valueOf(cal.get(Calendar.YEAR));
@@ -196,41 +199,53 @@ public class TestSyslogUtils {
    */
   @Test
   public void TestRfc3164Dates() throws ParseException {
-    for (int i = -10; i <= 1; i++) {
-      SimpleDateFormat sdf = new SimpleDateFormat("MMM  d hh:MM:ss");
-      Date date = new Date(System.currentTimeMillis());
-      Calendar cal = Calendar.getInstance();
-      cal.setTime(date);
-      cal.add(Calendar.MONTH, i);
-
-      //Small tweak to avoid the 1 month in the future ticking over by a few seconds between now
-      //and when the checkHeader actually runs
-      if (i == 1) {
-        cal.add(Calendar.DAY_OF_MONTH, -1);
+    //We're going to run this test using a mocked clock, once for the next 13 months
+    for (int monthOffset = 0; monthOffset <= 13; monthOffset++) {
+      Clock mockClock = Clock.fixed(
+              LocalDateTime.now().plusMonths(monthOffset).toInstant(ZoneOffset.UTC),
+              Clock.systemDefaultZone().getZone()
+      );
+
+      //We're then going to try input dates (without the year) for all 12 months, starting
+      //10 months ago, and finishing next month (all relative to our mocked clock)
+      for (int i = -10; i <= 1; i++) {
+        SimpleDateFormat sdf = new SimpleDateFormat("MMM  d hh:MM:ss", Locale.ENGLISH);
+        Date date = new Date(mockClock.millis());
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.add(Calendar.MONTH, i);
+
+        //Small tweak to avoid the 1 month in the future ticking over by a few seconds between now
+        //and when the checkHeader actually runs
+        if (i == 1) {
+          cal.add(Calendar.DAY_OF_MONTH, -1);
+        }
+
+        String stamp1 = sdf.format(cal.getTime());
+
+        String year = String.valueOf(cal.get(Calendar.YEAR));
+        String format1 = "yyyyMMM d HH:mm:ss";
+        String host1 = "ubuntu-11.cloudera.com";
+        String data1 = "some msg";
+
+        // timestamp with 'Z' appended, translates to UTC
+        String msg1 = "<10>" + stamp1 + " " + host1 + " " + data1 + "\n";
+        checkHeader(msg1, year + stamp1, format1, host1, data1, mockClock);
       }
+    }
 
-      String stamp1 = sdf.format(cal.getTime());
-
-      String year = String.valueOf(cal.get(Calendar.YEAR));
-      String format1 = "yyyyMMM d HH:mm:ss";
-      String host1 = "ubuntu-11.cloudera.com";
-      String data1 = "some msg";
 
-      // timestamp with 'Z' appended, translates to UTC
-      String msg1 = "<10>" + stamp1 + " " + host1 + " " + data1 + "\n";
-      checkHeader(msg1, year + stamp1, format1, host1, data1);
-    }
   }
 
   public static void checkHeader(String keepFields, String msg1, String stamp1, String format1,
-                                 String host1, String data1) throws ParseException {
+                                 String host1, String data1, Clock clock) throws ParseException {
     SyslogUtils util;
     if (keepFields == null || keepFields.isEmpty()) {
-      util = new SyslogUtils(SyslogUtils.DEFAULT_SIZE, new HashSet<String>(), false);
+      util = new SyslogUtils(SyslogUtils.DEFAULT_SIZE, new HashSet<String>(), false, clock);
     } else {
       util = new SyslogUtils(SyslogUtils.DEFAULT_SIZE,
                              SyslogUtils.chooseFieldsToKeep(keepFields),
-                             false);
+                             false, clock);
     }
     ChannelBuffer buff = ChannelBuffers.buffer(200);
 
@@ -256,10 +271,26 @@ public class TestSyslogUtils {
     Assert.assertEquals(data1, new String(e.getBody()));
   }
 
+  public static void checkHeader(String keepFields, String msg1, String stamp1, String format1,
+                                 String host1, String data1) throws ParseException {
+    checkHeader(
+            keepFields, msg1, stamp1, format1,
+            host1, data1, Clock.system(Clock.systemDefaultZone().getZone())
+    );
+  }
+
+  public static void checkHeader(String msg1, String stamp1, String format1,
+                                 String host1, String data1, Clock clock) throws ParseException {
+    checkHeader("none", msg1, stamp1, format1, host1, data1, clock);
+  }
+
   // Check headers for when keepFields is "none".
   public static void checkHeader(String msg1, String stamp1, String format1,
                                  String host1, String data1) throws ParseException {
-    checkHeader("none", msg1, stamp1, format1, host1, data1);
+    checkHeader(
+            "none", msg1, stamp1, format1,
+            host1, data1, Clock.system(Clock.systemDefaultZone().getZone())
+    );
   }
 
   /**


[2/7] flume git commit: FLUME-2050. Upgrade to Log4j 2.10.0

Posted by de...@apache.org.
FLUME-2050. Upgrade to Log4j 2.10.0

This closes #181

Reviewers: Ferenc Szabo

(Ralph Goers via Denes Arvay)


Project: http://git-wip-us.apache.org/repos/asf/flume/repo
Commit: http://git-wip-us.apache.org/repos/asf/flume/commit/69c66efe
Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/69c66efe
Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/69c66efe

Branch: refs/heads/trunk
Commit: 69c66efefdcd74904986f2727bdf0d52dd9a75e5
Parents: e4312ad
Author: Ralph Goers <rg...@nextiva.com>
Authored: Thu Nov 2 23:01:58 2017 -0700
Committer: Denes Arvay <de...@apache.org>
Committed: Fri Jan 26 16:22:28 2018 +0100

----------------------------------------------------------------------
 conf/log4j.properties                           |  68 ------
 conf/log4j2.xml                                 |  56 +++++
 flume-ng-auth/pom.xml                           |  29 ++-
 flume-ng-channels/flume-file-channel/pom.xml    |  28 ++-
 .../src/test/resources/log4j.properties         |  25 ---
 .../src/test/resources/log4j2.xml               |  30 +++
 flume-ng-channels/flume-jdbc-channel/pom.xml    |  22 +-
 flume-ng-channels/flume-kafka-channel/pom.xml   |   1 -
 .../src/test/resources/log4j.properties         |  78 -------
 .../src/test/resources/log4j2.xml               |  72 +++++++
 .../flume-spillable-memory-channel/pom.xml      |  22 +-
 flume-ng-clients/flume-ng-log4jappender/pom.xml |   2 +
 flume-ng-configuration/pom.xml                  |  19 +-
 flume-ng-core/pom.xml                           |  13 +-
 .../src/test/resources/log4j.properties         |  24 ---
 flume-ng-core/src/test/resources/log4j2.xml     |  31 +++
 flume-ng-dist/pom.xml                           |  12 ++
 flume-ng-embedded-agent/pom.xml                 |  16 +-
 .../src/test/resources/log4j.properties         |  24 ---
 .../src/test/resources/log4j2.xml               |  31 +++
 .../flume-avro-source/pom.xml                   |  22 +-
 .../flume-thrift-source/pom.xml                 |  22 +-
 .../src/test/resources/log4j.properties         |  25 ---
 .../src/test/resources/log4j2.xml               |  31 +++
 flume-ng-node/pom.xml                           |  18 +-
 .../src/test/resources/log4j.properties         |  24 ---
 flume-ng-node/src/test/resources/log4j2.xml     |  31 +++
 flume-ng-sdk/pom.xml                            |  25 ++-
 .../src/test/resources/log4j.properties         |  24 ---
 flume-ng-sdk/src/test/resources/log4j2.xml      |  31 +++
 flume-ng-sinks/flume-dataset-sink/pom.xml       |  32 ++-
 flume-ng-sinks/flume-hdfs-sink/pom.xml          |  32 ++-
 .../src/test/resources/log4j.properties         |  26 ---
 .../src/test/resources/log4j2.xml               |  33 +++
 flume-ng-sinks/flume-hive-sink/pom.xml          |  62 +++++-
 .../src/test/resources/log4j.properties         |  26 ---
 .../src/test/resources/log4j2.xml               |  33 +++
 flume-ng-sinks/flume-http-sink/pom.xml          |  21 +-
 .../org/apache/flume/sink/http/HttpSink.java    |   5 +-
 .../src/test/resources/log4j.properties         |  28 ---
 .../src/test/resources/log4j2.xml               |  30 +++
 flume-ng-sinks/flume-irc-sink/pom.xml           |  22 +-
 .../flume-ng-elasticsearch-sink/pom.xml         |  22 +-
 .../src/test/resources/log4j.properties         |  25 ---
 .../src/test/resources/log4j2.xml               |  31 +++
 flume-ng-sinks/flume-ng-hbase-sink/pom.xml      |  72 ++++++-
 flume-ng-sinks/flume-ng-kafka-sink/pom.xml      |  24 +++
 .../src/test/resources/log4j.properties         |  78 -------
 .../src/test/resources/log4j2.xml               |  72 +++++++
 .../flume-ng-morphline-solr-sink/pom.xml        |  37 +++-
 .../src/test/resources/log4j.properties         |  34 ---
 .../src/test/resources/log4j2.xml               |  38 ++++
 flume-ng-sources/flume-jms-source/pom.xml       |  22 +-
 flume-ng-sources/flume-kafka-source/pom.xml     |  20 ++
 .../src/test/resources/log4j.properties         |  25 ---
 .../src/test/resources/log4j2.xml               |  31 +++
 flume-ng-sources/flume-scribe-source/pom.xml    |  22 +-
 .../src/test/resources/log4j.properties         |  33 ---
 .../src/test/resources/log4j2.xml               |  37 ++++
 flume-ng-tests/pom.xml                          |  24 ++-
 .../src/test/resources/log4j.properties         |  25 ---
 flume-ng-tests/src/test/resources/log4j2.xml    |  31 +++
 pom.xml                                         | 206 +++++++++++++++++--
 63 files changed, 1445 insertions(+), 670 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/conf/log4j.properties
----------------------------------------------------------------------
diff --git a/conf/log4j.properties b/conf/log4j.properties
deleted file mode 100644
index c948bff..0000000
--- a/conf/log4j.properties
+++ /dev/null
@@ -1,68 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-#
-
-# Define some default values that can be overridden by system properties.
-#
-# For testing, it may also be convenient to specify
-# -Dflume.root.logger=DEBUG,console when launching flume.
-
-#flume.root.logger=DEBUG,console
-flume.root.logger=INFO,LOGFILE
-flume.log.dir=./logs
-flume.log.file=flume.log
-
-log4j.logger.org.apache.flume.lifecycle = INFO
-log4j.logger.org.jboss = WARN
-log4j.logger.org.mortbay = INFO
-log4j.logger.org.apache.avro.ipc.NettyTransceiver = WARN
-log4j.logger.org.apache.hadoop = INFO
-log4j.logger.org.apache.hadoop.hive = ERROR
-
-# Define the root logger to the system property "flume.root.logger".
-log4j.rootLogger=${flume.root.logger}
-
-
-# Stock log4j rolling file appender
-# Default log rotation configuration
-log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
-log4j.appender.LOGFILE.MaxFileSize=100MB
-log4j.appender.LOGFILE.MaxBackupIndex=10
-log4j.appender.LOGFILE.File=${flume.log.dir}/${flume.log.file}
-log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
-log4j.appender.LOGFILE.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss,SSS} %-5p [%t] (%C.%M:%L) %x - %m%n
-
-
-# Warning: If you enable the following appender it will fill up your disk if you don't have a cleanup job!
-# This uses the updated rolling file appender from log4j-extras that supports a reliable time-based rolling policy.
-# See http://logging.apache.org/log4j/companions/extras/apidocs/org/apache/log4j/rolling/TimeBasedRollingPolicy.html
-# Add "DAILY" to flume.root.logger above if you want to use this
-log4j.appender.DAILY=org.apache.log4j.rolling.RollingFileAppender
-log4j.appender.DAILY.rollingPolicy=org.apache.log4j.rolling.TimeBasedRollingPolicy
-log4j.appender.DAILY.rollingPolicy.ActiveFileName=${flume.log.dir}/${flume.log.file}
-log4j.appender.DAILY.rollingPolicy.FileNamePattern=${flume.log.dir}/${flume.log.file}.%d{yyyy-MM-dd}
-log4j.appender.DAILY.layout=org.apache.log4j.PatternLayout
-log4j.appender.DAILY.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss,SSS} %-5p [%t] (%C.%M:%L) %x - %m%n
-
-
-# console
-# Add "console" to flume.root.logger above if you want to use this
-log4j.appender.console=org.apache.log4j.ConsoleAppender
-log4j.appender.console.target=System.err
-log4j.appender.console.layout=org.apache.log4j.PatternLayout
-log4j.appender.console.layout.ConversionPattern=%d (%t) [%p - %l] %m%n

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/conf/log4j2.xml
----------------------------------------------------------------------
diff --git a/conf/log4j2.xml b/conf/log4j2.xml
new file mode 100644
index 0000000..d203a24
--- /dev/null
+++ b/conf/log4j2.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+<Configuration status="ERROR">
+  <Properties>
+    <Property name="LOG_DIR">./logs</Property>
+  </Properties>
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="%d (%t) [%p - %l] %m%n" />
+    </Console>
+    <RollingFile name="LogFile" fileName="${LOG_DIR}/flume.log" filePattern="${LOG_DIR}/archive/flume.log.%d{yyyyMMdd}-%i">
+      <PatternLayout pattern="%d{dd MMM yyyy HH:mm:ss,SSS} %-5p [%t] (%C.%M:%L) %equals{%x}{[]}{} - %m%n" />
+      <Policies>
+        <!-- Roll every night at midnight or when the file reaches 100MB -->
+        <SizeBasedTriggeringPolicy size="100 MB"/>
+        <CronTriggeringPolicy schedule="0 0 0 * * ?"/>
+      </Policies>
+      <DefaultRolloverStrategy min="1" max="20">
+        <Delete basePath="${LOG_DIR}/archive">
+          <!-- Nested conditions: the inner condition is only evaluated on files for which the outer conditions are true. -->
+          <IfFileName glob="flume.log.*">
+            <!-- Only allow 1 GB of files to accumulate -->
+            <IfAccumulatedFileSize exceeds="1 GB"/>
+          </IfFileName>
+        </Delete>
+      </DefaultRolloverStrategy>
+    </RollingFile>
+  </Appenders>
+
+  <Loggers>
+    <Logger name="org.apache.flume.lifecycle" level="info"/>
+    <Logger name="org.jboss" level="WARN"/>
+    <Logger name="org.apache.avro.ipc.NettyTransceiver" level="WARN"/>
+    <Logger name="org.apache.hadoop" level="INFO"/>
+    <Logger name="org.apache.hadoop.hive" level="ERROR"/>
+    <Root level="INFO">
+      <AppenderRef ref="LogFile" />
+    </Root>
+  </Loggers>
+</Configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-auth/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-auth/pom.xml b/flume-ng-auth/pom.xml
index c7c682f..3f47c48 100644
--- a/flume-ng-auth/pom.xml
+++ b/flume-ng-auth/pom.xml
@@ -57,8 +57,23 @@ limitations under the License.
     </dependency>
 
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
     </dependency>
 
     <dependency>
@@ -77,6 +92,16 @@ limitations under the License.
       <artifactId>hadoop-minikdc</artifactId>
       <version>${hadoop2.version}</version>
       <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>log4j</groupId>
+          <artifactId>log4j</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.slf4j</groupId>
+          <artifactId>slf4j-log4j12</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
 
     <dependency>

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-channels/flume-file-channel/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-channels/flume-file-channel/pom.xml b/flume-ng-channels/flume-file-channel/pom.xml
index 05da84d..6e580c9 100644
--- a/flume-ng-channels/flume-file-channel/pom.xml
+++ b/flume-ng-channels/flume-file-channel/pom.xml
@@ -91,8 +91,32 @@
     </dependency>
 
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-jcl</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
       <scope>test</scope>
     </dependency>
 

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-channels/flume-file-channel/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/flume-ng-channels/flume-file-channel/src/test/resources/log4j.properties b/flume-ng-channels/flume-file-channel/src/test/resources/log4j.properties
deleted file mode 100644
index 739ecc8..0000000
--- a/flume-ng-channels/flume-file-channel/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-
-
-log4j.rootLogger = INFO, out
-
-log4j.appender.out = org.apache.log4j.ConsoleAppender
-log4j.appender.out.layout = org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern = %d (%t) [%p - %l] %m%n
-
-log4j.logger.org.apache.flume = DEBUG

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-channels/flume-file-channel/src/test/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/flume-ng-channels/flume-file-channel/src/test/resources/log4j2.xml b/flume-ng-channels/flume-file-channel/src/test/resources/log4j2.xml
new file mode 100644
index 0000000..2aa49a4
--- /dev/null
+++ b/flume-ng-channels/flume-file-channel/src/test/resources/log4j2.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+<Configuration status="OFF">
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="%d (%t) [%p - %l] %m%n" />
+    </Console>
+  </Appenders>
+  <Loggers>
+    <Root level="INFO">
+      <AppenderRef ref="Console" />
+    </Root>
+  </Loggers>
+</Configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-channels/flume-jdbc-channel/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-channels/flume-jdbc-channel/pom.xml b/flume-ng-channels/flume-jdbc-channel/pom.xml
index 7370aa4..16479a4 100644
--- a/flume-ng-channels/flume-jdbc-channel/pom.xml
+++ b/flume-ng-channels/flume-jdbc-channel/pom.xml
@@ -74,8 +74,26 @@ limitations under the License.
       <artifactId>derby</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
       <scope>test</scope>
     </dependency>
   </dependencies>

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-channels/flume-kafka-channel/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-channels/flume-kafka-channel/pom.xml b/flume-ng-channels/flume-kafka-channel/pom.xml
index 6d513dc..1f4a08a 100644
--- a/flume-ng-channels/flume-kafka-channel/pom.xml
+++ b/flume-ng-channels/flume-kafka-channel/pom.xml
@@ -45,7 +45,6 @@ limitations under the License.
     <dependency>
       <groupId>org.apache.kafka</groupId>
       <artifactId>kafka_2.10</artifactId>
-      <version>${kafka.version}</version>
     </dependency>
     <dependency>
       <groupId>org.apache.kafka</groupId>

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-channels/flume-kafka-channel/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/flume-ng-channels/flume-kafka-channel/src/test/resources/log4j.properties b/flume-ng-channels/flume-kafka-channel/src/test/resources/log4j.properties
deleted file mode 100644
index b86600b..0000000
--- a/flume-ng-channels/flume-kafka-channel/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,78 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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.
-
-kafka.logs.dir=target/logs
-
-log4j.rootLogger=INFO, stdout
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=[%d] %p %m (%c)%n
-
-log4j.appender.kafkaAppender=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.kafkaAppender.DatePattern='.'yyyy-MM-dd-HH
-log4j.appender.kafkaAppender.File=${kafka.logs.dir}/server.log
-log4j.appender.kafkaAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.kafkaAppender.layout.ConversionPattern=[%d] %p %m (%c)%n
-
-log4j.appender.stateChangeAppender=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.stateChangeAppender.DatePattern='.'yyyy-MM-dd-HH
-log4j.appender.stateChangeAppender.File=${kafka.logs.dir}/state-change.log
-log4j.appender.stateChangeAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.stateChangeAppender.layout.ConversionPattern=[%d] %p %m (%c)%n
-
-log4j.appender.requestAppender=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.requestAppender.DatePattern='.'yyyy-MM-dd-HH
-log4j.appender.requestAppender.File=${kafka.logs.dir}/kafka-request.log
-log4j.appender.requestAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.requestAppender.layout.ConversionPattern=[%d] %p %m (%c)%n
-
-log4j.appender.cleanerAppender=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.cleanerAppender.DatePattern='.'yyyy-MM-dd-HH
-log4j.appender.cleanerAppender.File=${kafka.logs.dir}/log-cleaner.log
-log4j.appender.cleanerAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.cleanerAppender.layout.ConversionPattern=[%d] %p %m (%c)%n
-
-log4j.appender.controllerAppender=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.controllerAppender.DatePattern='.'yyyy-MM-dd-HH
-log4j.appender.controllerAppender.File=${kafka.logs.dir}/controller.log
-log4j.appender.controllerAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.controllerAppender.layout.ConversionPattern=[%d] %p %m (%c)%n
-
-# Turn on all our debugging info
-#log4j.logger.kafka.producer.async.DefaultEventHandler=DEBUG, kafkaAppender
-#log4j.logger.kafka.client.ClientUtils=DEBUG, kafkaAppender
-#log4j.logger.kafka.perf=DEBUG, kafkaAppender
-#log4j.logger.kafka.perf.ProducerPerformance$ProducerThread=DEBUG, kafkaAppender
-#log4j.logger.org.I0Itec.zkclient.ZkClient=DEBUG
-log4j.logger.kafka=INFO, kafkaAppender
-
-log4j.logger.kafka.network.RequestChannel$=WARN, requestAppender
-log4j.additivity.kafka.network.RequestChannel$=false
-
-#log4j.logger.kafka.network.Processor=TRACE, requestAppender
-#log4j.logger.kafka.server.KafkaApis=TRACE, requestAppender
-#log4j.additivity.kafka.server.KafkaApis=false
-log4j.logger.kafka.request.logger=WARN, requestAppender
-log4j.additivity.kafka.request.logger=false
-
-log4j.logger.kafka.controller=TRACE, controllerAppender
-log4j.additivity.kafka.controller=false
-
-log4j.logger.kafka.log.LogCleaner=INFO, cleanerAppender
-log4j.additivity.kafka.log.LogCleaner=false
-
-log4j.logger.state.change.logger=TRACE, stateChangeAppender
-log4j.additivity.state.change.logger=false

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-channels/flume-kafka-channel/src/test/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/flume-ng-channels/flume-kafka-channel/src/test/resources/log4j2.xml b/flume-ng-channels/flume-kafka-channel/src/test/resources/log4j2.xml
new file mode 100644
index 0000000..1263a38
--- /dev/null
+++ b/flume-ng-channels/flume-kafka-channel/src/test/resources/log4j2.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+<Configuration status="OFF">
+  <Properties>
+    <Property name="kafka.logs.dir">target/logs</Property>
+  </Properties>
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="%d (%t) [%p - %l] %m%n" />
+    </Console>
+    <RollingFile name="kafka" fileName="${kafka.logs.dir}/server.log">
+      <PatternLayout pattern="[%d] %p %m (%c)%n" />
+      <CronTriggeringPolicy schedule="0 0 0 * * ?"/>
+    </RollingFile>
+    <RollingFile name="stateChange" fileName="${kafka.logs.dir}/state-change.log">
+      <PatternLayout pattern="[%d] %p %m (%c)%n" />
+      <CronTriggeringPolicy schedule="0 0 0 * * ?"/>
+    </RollingFile>
+    <RollingFile name="request" fileName="${kafka.logs.dir}/kafka-request.log">
+      <PatternLayout pattern="[%d] %p %m (%c)%n" />
+      <CronTriggeringPolicy schedule="0 0 0 * * ?"/>
+    </RollingFile>
+    <RollingFile name="cleaner" fileName="${kafka.logs.dir}/log-cleaner.log">
+      <PatternLayout pattern="[%d] %p %m (%c)%n" />
+      <CronTriggeringPolicy schedule="0 0 0 * * ?"/>
+    </RollingFile>
+    <RollingFile name="controller" fileName="${kafka.logs.dir}/controller.log">
+      <PatternLayout pattern="[%d] %p %m (%c)%n" />
+      <CronTriggeringPolicy schedule="0 0 0 * * ?"/>
+    </RollingFile>
+  </Appenders>
+
+  <Loggers>
+    <Logger name="kafka" level="info">
+      <AppenderRef ref="kafka"/>
+    </Logger>
+    <Logger name="kafka.network.RequestChannel.*" level="WARN" additivity="false">
+      <AppenderRef ref="request"/>
+    </Logger>
+    <Logger name="kafka.request.logger" level="WARN" additivity="false">
+      <AppenderRef ref="request"/>
+    </Logger>
+    <Logger name="kafka.controller" level="TRACE" additivity="false">
+      <AppenderRef ref="controller"/>
+    </Logger>
+    <Logger name="kafka.log.cleaner" level="INFO" additivity="false">
+      <AppenderRef ref="cleaner"/>
+    </Logger>
+    <Logger name="state.change.logger" level="TRACE" additivity="false">
+      <AppenderRef ref="stateChange"/>
+    </Logger>
+    <Root level="INFO">
+      <AppenderRef ref="Console" />
+    </Root>
+  </Loggers>
+</Configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-channels/flume-spillable-memory-channel/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-channels/flume-spillable-memory-channel/pom.xml b/flume-ng-channels/flume-spillable-memory-channel/pom.xml
index e2ea393..29a3819 100644
--- a/flume-ng-channels/flume-spillable-memory-channel/pom.xml
+++ b/flume-ng-channels/flume-spillable-memory-channel/pom.xml
@@ -97,8 +97,26 @@
     </dependency>
 
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
       <scope>test</scope>
     </dependency>
 

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-clients/flume-ng-log4jappender/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-clients/flume-ng-log4jappender/pom.xml b/flume-ng-clients/flume-ng-log4jappender/pom.xml
index 3731814..4d25c2b 100644
--- a/flume-ng-clients/flume-ng-log4jappender/pom.xml
+++ b/flume-ng-clients/flume-ng-log4jappender/pom.xml
@@ -67,6 +67,8 @@ limitations under the License.
     <dependency>
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
+      <version>1.2.17</version>
+      <scope>compile</scope>
     </dependency>
 
     <dependency>

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-configuration/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-configuration/pom.xml b/flume-ng-configuration/pom.xml
index 6a30840..e431fc8 100644
--- a/flume-ng-configuration/pom.xml
+++ b/flume-ng-configuration/pom.xml
@@ -48,8 +48,23 @@ limitations under the License.
     </dependency>
 
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
     </dependency>
 
     <dependency>

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-core/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-core/pom.xml b/flume-ng-core/pom.xml
index 44d9ef6..3d72aba 100644
--- a/flume-ng-core/pom.xml
+++ b/flume-ng-core/pom.xml
@@ -301,13 +301,18 @@ limitations under the License.
     </dependency>
 
     <dependency>
-      <groupId>log4j</groupId>
-      <artifactId>log4j</artifactId>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
     </dependency>
 
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
     </dependency>
 
     <dependency>

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-core/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/flume-ng-core/src/test/resources/log4j.properties b/flume-ng-core/src/test/resources/log4j.properties
deleted file mode 100644
index 361158d..0000000
--- a/flume-ng-core/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-
-log4j.rootLogger = INFO, out
-
-log4j.appender.out = org.apache.log4j.ConsoleAppender
-log4j.appender.out.layout = org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern = %d (%t) [%p - %l] %m%n
-
-log4j.logger.org.apache.flume = DEBUG

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-core/src/test/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/flume-ng-core/src/test/resources/log4j2.xml b/flume-ng-core/src/test/resources/log4j2.xml
new file mode 100644
index 0000000..5676916
--- /dev/null
+++ b/flume-ng-core/src/test/resources/log4j2.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+<Configuration status="OFF">
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="%d (%t) [%p - %l] %m%n" />
+    </Console>
+  </Appenders>
+  <Loggers>
+    <Logger name="org.apache.flume" level="DEBUG"/>
+    <Root level="DEBUG">
+      <AppenderRef ref="Console" />
+    </Root>
+  </Loggers>
+</Configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-dist/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-dist/pom.xml b/flume-ng-dist/pom.xml
index 330118e..b3b6faa 100644
--- a/flume-ng-dist/pom.xml
+++ b/flume-ng-dist/pom.xml
@@ -199,11 +199,23 @@
     <dependency>
       <groupId>org.apache.flume.flume-ng-clients</groupId>
       <artifactId>flume-ng-log4jappender</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>log4j</groupId>
+          <artifactId>log4j</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.apache.flume.flume-ng-clients</groupId>
       <artifactId>flume-ng-log4jappender</artifactId>
       <classifier>jar-with-dependencies</classifier>
+      <exclusions>
+        <exclusion>
+          <groupId>log4j</groupId>
+          <artifactId>log4j</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.apache.flume</groupId>

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-embedded-agent/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-embedded-agent/pom.xml b/flume-ng-embedded-agent/pom.xml
index 1d65768..a99f129 100644
--- a/flume-ng-embedded-agent/pom.xml
+++ b/flume-ng-embedded-agent/pom.xml
@@ -69,13 +69,25 @@ limitations under the License.
     </dependency>
 
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
       <!-- only used for tests -->
       <optional>true</optional>
     </dependency>
 
     <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+      <optional>true</optional>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <optional>true</optional>
+    </dependency>
+
+    <dependency>
       <groupId>org.mockito</groupId>
       <artifactId>mockito-all</artifactId>
       <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-embedded-agent/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/flume-ng-embedded-agent/src/test/resources/log4j.properties b/flume-ng-embedded-agent/src/test/resources/log4j.properties
deleted file mode 100644
index 361158d..0000000
--- a/flume-ng-embedded-agent/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-
-log4j.rootLogger = INFO, out
-
-log4j.appender.out = org.apache.log4j.ConsoleAppender
-log4j.appender.out.layout = org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern = %d (%t) [%p - %l] %m%n
-
-log4j.logger.org.apache.flume = DEBUG

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-embedded-agent/src/test/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/flume-ng-embedded-agent/src/test/resources/log4j2.xml b/flume-ng-embedded-agent/src/test/resources/log4j2.xml
new file mode 100644
index 0000000..fbc44b4
--- /dev/null
+++ b/flume-ng-embedded-agent/src/test/resources/log4j2.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+<Configuration status="OFF">
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="%d (%t) [%p - %l] %m%n" />
+    </Console>
+  </Appenders>
+  <Loggers>
+    <Logger name="org.apache.flume" level="DEBUG"/>
+    <Root level="INFO">
+      <AppenderRef ref="Console" />
+    </Root>
+  </Loggers>
+</Configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-legacy-sources/flume-avro-source/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-legacy-sources/flume-avro-source/pom.xml b/flume-ng-legacy-sources/flume-avro-source/pom.xml
index e9cfab7..c5fb68e 100644
--- a/flume-ng-legacy-sources/flume-avro-source/pom.xml
+++ b/flume-ng-legacy-sources/flume-avro-source/pom.xml
@@ -115,8 +115,26 @@ limitations under the License.
     </dependency>
 
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
       <scope>test</scope>
     </dependency>
 

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-legacy-sources/flume-thrift-source/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-legacy-sources/flume-thrift-source/pom.xml b/flume-ng-legacy-sources/flume-thrift-source/pom.xml
index 194e41e..ce84145 100644
--- a/flume-ng-legacy-sources/flume-thrift-source/pom.xml
+++ b/flume-ng-legacy-sources/flume-thrift-source/pom.xml
@@ -150,8 +150,26 @@ limitations under the License.
     </dependency>
 
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
       <scope>test</scope>
     </dependency>
 

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-legacy-sources/flume-thrift-source/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/flume-ng-legacy-sources/flume-thrift-source/src/test/resources/log4j.properties b/flume-ng-legacy-sources/flume-thrift-source/src/test/resources/log4j.properties
deleted file mode 100644
index 9036aca..0000000
--- a/flume-ng-legacy-sources/flume-thrift-source/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-
-
-log4j.rootLogger = DEBUG, out
-
-log4j.appender.out = org.apache.log4j.ConsoleAppender
-log4j.appender.out.layout = org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern = %d (%t) [%p - %l] %m%n
-
-log4j.logger.org.apache.flume = DEBUG

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-legacy-sources/flume-thrift-source/src/test/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/flume-ng-legacy-sources/flume-thrift-source/src/test/resources/log4j2.xml b/flume-ng-legacy-sources/flume-thrift-source/src/test/resources/log4j2.xml
new file mode 100644
index 0000000..5676916
--- /dev/null
+++ b/flume-ng-legacy-sources/flume-thrift-source/src/test/resources/log4j2.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+<Configuration status="OFF">
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="%d (%t) [%p - %l] %m%n" />
+    </Console>
+  </Appenders>
+  <Loggers>
+    <Logger name="org.apache.flume" level="DEBUG"/>
+    <Root level="DEBUG">
+      <AppenderRef ref="Console" />
+    </Root>
+  </Loggers>
+</Configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-node/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-node/pom.xml b/flume-ng-node/pom.xml
index 6cf5364..83faadd 100644
--- a/flume-ng-node/pom.xml
+++ b/flume-ng-node/pom.xml
@@ -103,18 +103,18 @@
     </dependency>
 
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
     </dependency>
 
     <dependency>
-      <groupId>log4j</groupId>
-      <artifactId>log4j</artifactId>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
     </dependency>
 
     <dependency>
-      <groupId>log4j</groupId>
-      <artifactId>apache-log4j-extras</artifactId>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
     </dependency>
 
     <dependency>
@@ -153,6 +153,12 @@
     <dependency>
       <groupId>org.apache.curator</groupId>
       <artifactId>curator-framework</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>log4j</groupId>
+          <artifactId>log4j</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
 
   <dependency>

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-node/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/flume-ng-node/src/test/resources/log4j.properties b/flume-ng-node/src/test/resources/log4j.properties
deleted file mode 100644
index 5d38311..0000000
--- a/flume-ng-node/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-
-log4j.rootCategory = INFO, out
-
-log4j.appender.out = org.apache.log4j.ConsoleAppender
-log4j.appender.out.layout = org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern = %d (%t) [%p - %l] %m%n
-
-log4j.logger.org.apache.flume = DEBUG

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-node/src/test/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/flume-ng-node/src/test/resources/log4j2.xml b/flume-ng-node/src/test/resources/log4j2.xml
new file mode 100644
index 0000000..fbc44b4
--- /dev/null
+++ b/flume-ng-node/src/test/resources/log4j2.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+<Configuration status="OFF">
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="%d (%t) [%p - %l] %m%n" />
+    </Console>
+  </Appenders>
+  <Loggers>
+    <Logger name="org.apache.flume" level="DEBUG"/>
+    <Root level="INFO">
+      <AppenderRef ref="Console" />
+    </Root>
+  </Loggers>
+</Configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sdk/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-sdk/pom.xml b/flume-ng-sdk/pom.xml
index fdad52b..658abce 100644
--- a/flume-ng-sdk/pom.xml
+++ b/flume-ng-sdk/pom.xml
@@ -203,10 +203,27 @@ limitations under the License.
     </dependency>
 
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
-      <!-- only used for tests -->
-      <optional>true</optional>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
+      <scope>test</scope>
     </dependency>
 
     <dependency>

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sdk/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/flume-ng-sdk/src/test/resources/log4j.properties b/flume-ng-sdk/src/test/resources/log4j.properties
deleted file mode 100644
index 361158d..0000000
--- a/flume-ng-sdk/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-
-log4j.rootLogger = INFO, out
-
-log4j.appender.out = org.apache.log4j.ConsoleAppender
-log4j.appender.out.layout = org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern = %d (%t) [%p - %l] %m%n
-
-log4j.logger.org.apache.flume = DEBUG

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sdk/src/test/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/flume-ng-sdk/src/test/resources/log4j2.xml b/flume-ng-sdk/src/test/resources/log4j2.xml
new file mode 100644
index 0000000..fbc44b4
--- /dev/null
+++ b/flume-ng-sdk/src/test/resources/log4j2.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+<Configuration status="OFF">
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="%d (%t) [%p - %l] %m%n" />
+    </Console>
+  </Appenders>
+  <Loggers>
+    <Logger name="org.apache.flume" level="DEBUG"/>
+    <Root level="INFO">
+      <AppenderRef ref="Console" />
+    </Root>
+  </Loggers>
+</Configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sinks/flume-dataset-sink/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-sinks/flume-dataset-sink/pom.xml b/flume-ng-sinks/flume-dataset-sink/pom.xml
index 1b0c325..30cca81 100644
--- a/flume-ng-sinks/flume-dataset-sink/pom.xml
+++ b/flume-ng-sinks/flume-dataset-sink/pom.xml
@@ -125,11 +125,39 @@ limitations under the License.
       <artifactId>hadoop-minicluster</artifactId>
       <version>${hadoop2.version}</version>
       <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>log4j</groupId>
+          <artifactId>log4j</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.slf4j</groupId>
+          <artifactId>slf4j-log4j12</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
 
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
       <scope>test</scope>
     </dependency>
 

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sinks/flume-hdfs-sink/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-sinks/flume-hdfs-sink/pom.xml b/flume-ng-sinks/flume-hdfs-sink/pom.xml
index f821be2..f51cfef 100644
--- a/flume-ng-sinks/flume-hdfs-sink/pom.xml
+++ b/flume-ng-sinks/flume-hdfs-sink/pom.xml
@@ -73,8 +73,26 @@ limitations under the License.
     </dependency>
 
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
       <scope>test</scope>
     </dependency>
 
@@ -187,6 +205,16 @@ limitations under the License.
           <groupId>org.apache.hadoop</groupId>
           <artifactId>hadoop-minicluster</artifactId>
           <scope>test</scope>
+          <exclusions>
+            <exclusion>
+              <groupId>log4j</groupId>
+              <artifactId>log4j</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>org.slf4j</groupId>
+              <artifactId>slf4j-log4j12</artifactId>
+            </exclusion>
+          </exclusions>
         </dependency>
 
       </dependencies>

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sinks/flume-hdfs-sink/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/flume-ng-sinks/flume-hdfs-sink/src/test/resources/log4j.properties b/flume-ng-sinks/flume-hdfs-sink/src/test/resources/log4j.properties
deleted file mode 100644
index 252b5ea..0000000
--- a/flume-ng-sinks/flume-hdfs-sink/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-
-log4j.rootLogger = INFO, out
-
-log4j.appender.out = org.apache.log4j.ConsoleAppender
-log4j.appender.out.layout = org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern = %d (%t) [%p - %l] %m%n
-
-log4j.logger.org.apache.flume = DEBUG
-log4j.logger.org.apache.hadoop = WARN
-log4j.logger.org.mortbay = WARN

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sinks/flume-hdfs-sink/src/test/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/flume-ng-sinks/flume-hdfs-sink/src/test/resources/log4j2.xml b/flume-ng-sinks/flume-hdfs-sink/src/test/resources/log4j2.xml
new file mode 100644
index 0000000..91a23f8
--- /dev/null
+++ b/flume-ng-sinks/flume-hdfs-sink/src/test/resources/log4j2.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+<Configuration status="OFF">
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="%d (%t) [%p - %l] %m%n" />
+    </Console>
+  </Appenders>
+  <Loggers>
+    <Logger name="org.apache.flume" level="DEBUG"/>
+    <Logger name="org.apache.hadoop" level="WARN"/>
+    <Logger name="org.mortbay" level="WARN"/>
+    <Root level="INFO">
+      <AppenderRef ref="Console" />
+    </Root>
+  </Loggers>
+</Configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sinks/flume-hive-sink/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-sinks/flume-hive-sink/pom.xml b/flume-ng-sinks/flume-hive-sink/pom.xml
index 7cc518e..11a97da 100644
--- a/flume-ng-sinks/flume-hive-sink/pom.xml
+++ b/flume-ng-sinks/flume-hive-sink/pom.xml
@@ -80,6 +80,16 @@ limitations under the License.
           <artifactId>hadoop-mapreduce-client-core</artifactId>
           <scope>test</scope>
           <version>${hadoop.version}</version>
+          <exclusions>
+            <exclusion>
+              <groupId>log4j</groupId>
+              <artifactId>log4j</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>org.slf4j</groupId>
+              <artifactId>slf4j-log4j12</artifactId>
+            </exclusion>
+          </exclusions>
         </dependency>
       </dependencies>
     </profile>
@@ -104,6 +114,16 @@ limitations under the License.
           <artifactId>hadoop-mapreduce-client-core</artifactId>
           <scope>test</scope>
           <version>${hadoop.version}</version>
+          <exclusions>
+            <exclusion>
+              <groupId>log4j</groupId>
+              <artifactId>log4j</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>org.slf4j</groupId>
+              <artifactId>slf4j-log4j12</artifactId>
+            </exclusion>
+          </exclusions>
         </dependency>
       </dependencies>
     </profile>
@@ -138,8 +158,26 @@ limitations under the License.
     </dependency>
 
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
       <scope>test</scope>
     </dependency>
 
@@ -154,12 +192,32 @@ limitations under the License.
       <artifactId>hive-hcatalog-core</artifactId>
       <scope>provided</scope>
       <version>${hive.version}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>log4j</groupId>
+          <artifactId>log4j</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.slf4j</groupId>
+          <artifactId>slf4j-log4j12</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
 
     <dependency>
       <groupId>org.apache.hive</groupId>
       <artifactId>hive-cli</artifactId>
       <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>log4j</groupId>
+          <artifactId>log4j</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.slf4j</groupId>
+          <artifactId>slf4j-log4j12</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
 
     <!--temporary - really belongs to hive-streaming : roshan -->

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sinks/flume-hive-sink/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/flume-ng-sinks/flume-hive-sink/src/test/resources/log4j.properties b/flume-ng-sinks/flume-hive-sink/src/test/resources/log4j.properties
deleted file mode 100644
index 252b5ea..0000000
--- a/flume-ng-sinks/flume-hive-sink/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-
-log4j.rootLogger = INFO, out
-
-log4j.appender.out = org.apache.log4j.ConsoleAppender
-log4j.appender.out.layout = org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern = %d (%t) [%p - %l] %m%n
-
-log4j.logger.org.apache.flume = DEBUG
-log4j.logger.org.apache.hadoop = WARN
-log4j.logger.org.mortbay = WARN

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sinks/flume-hive-sink/src/test/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/flume-ng-sinks/flume-hive-sink/src/test/resources/log4j2.xml b/flume-ng-sinks/flume-hive-sink/src/test/resources/log4j2.xml
new file mode 100644
index 0000000..91a23f8
--- /dev/null
+++ b/flume-ng-sinks/flume-hive-sink/src/test/resources/log4j2.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+<Configuration status="OFF">
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="%d (%t) [%p - %l] %m%n" />
+    </Console>
+  </Appenders>
+  <Loggers>
+    <Logger name="org.apache.flume" level="DEBUG"/>
+    <Logger name="org.apache.hadoop" level="WARN"/>
+    <Logger name="org.mortbay" level="WARN"/>
+    <Root level="INFO">
+      <AppenderRef ref="Console" />
+    </Root>
+  </Loggers>
+</Configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sinks/flume-http-sink/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-sinks/flume-http-sink/pom.xml b/flume-ng-sinks/flume-http-sink/pom.xml
index 52b038a..687a02b 100644
--- a/flume-ng-sinks/flume-http-sink/pom.xml
+++ b/flume-ng-sinks/flume-http-sink/pom.xml
@@ -101,8 +101,25 @@ limitations under the License.
     </dependency>
 
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
       <scope>test</scope>
     </dependency>
 

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sinks/flume-http-sink/src/main/java/org/apache/flume/sink/http/HttpSink.java
----------------------------------------------------------------------
diff --git a/flume-ng-sinks/flume-http-sink/src/main/java/org/apache/flume/sink/http/HttpSink.java b/flume-ng-sinks/flume-http-sink/src/main/java/org/apache/flume/sink/http/HttpSink.java
index b9c42ed..8fd2e4c 100644
--- a/flume-ng-sinks/flume-http-sink/src/main/java/org/apache/flume/sink/http/HttpSink.java
+++ b/flume-ng-sinks/flume-http-sink/src/main/java/org/apache/flume/sink/http/HttpSink.java
@@ -27,7 +27,8 @@ import org.apache.flume.Transaction;
 import org.apache.flume.conf.Configurable;
 import org.apache.flume.instrumentation.SinkCounter;
 import org.apache.flume.sink.AbstractSink;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 import java.io.IOException;
 import java.io.OutputStream;
@@ -48,7 +49,7 @@ import java.util.Map;
 public class HttpSink extends AbstractSink implements Configurable {
 
   /** Class logger. */
-  private static final Logger LOG = Logger.getLogger(HttpSink.class);
+  private static final Logger LOG = LogManager.getLogger(HttpSink.class);
 
   /** Lowest valid HTTP status code. */
   private static final int HTTP_STATUS_CONTINUE = 100;

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sinks/flume-http-sink/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/flume-ng-sinks/flume-http-sink/src/test/resources/log4j.properties b/flume-ng-sinks/flume-http-sink/src/test/resources/log4j.properties
deleted file mode 100644
index 783022d..0000000
--- a/flume-ng-sinks/flume-http-sink/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements.  See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership.  The ASF licenses this file
-* to you 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.
-*/
-log4j.rootLogger = ALL, stdout
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.Target=System.out
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-
-log4j.appender.flume = org.apache.flume.clients.log4jappender.Log4jAppender
-log4j.appender.flume.Hostname = 127.0.0.1
-log4j.appender.flume.Port = 4141
-log4j.appender.flume.layout=org.apache.log4j.PatternLayout

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sinks/flume-http-sink/src/test/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/flume-ng-sinks/flume-http-sink/src/test/resources/log4j2.xml b/flume-ng-sinks/flume-http-sink/src/test/resources/log4j2.xml
new file mode 100644
index 0000000..d539bdb
--- /dev/null
+++ b/flume-ng-sinks/flume-http-sink/src/test/resources/log4j2.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+<Configuration status="OFF">
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="%m%n" />
+    </Console>
+  </Appenders>
+  <Loggers>
+    <Root level="ALL">
+      <AppenderRef ref="Console" />
+    </Root>
+  </Loggers>
+</Configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sinks/flume-irc-sink/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-sinks/flume-irc-sink/pom.xml b/flume-ng-sinks/flume-irc-sink/pom.xml
index f43071d..0f40c8e 100644
--- a/flume-ng-sinks/flume-irc-sink/pom.xml
+++ b/flume-ng-sinks/flume-irc-sink/pom.xml
@@ -73,8 +73,26 @@ limitations under the License.
     </dependency>
 
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
       <scope>test</scope>
     </dependency>
 

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sinks/flume-ng-elasticsearch-sink/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-sinks/flume-ng-elasticsearch-sink/pom.xml b/flume-ng-sinks/flume-ng-elasticsearch-sink/pom.xml
index 10bde66..1df26b8 100644
--- a/flume-ng-sinks/flume-ng-elasticsearch-sink/pom.xml
+++ b/flume-ng-sinks/flume-ng-elasticsearch-sink/pom.xml
@@ -68,8 +68,26 @@
     </dependency>
 
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
       <scope>test</scope>
     </dependency>
 

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sinks/flume-ng-elasticsearch-sink/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/flume-ng-sinks/flume-ng-elasticsearch-sink/src/test/resources/log4j.properties b/flume-ng-sinks/flume-ng-elasticsearch-sink/src/test/resources/log4j.properties
deleted file mode 100644
index 9036aca..0000000
--- a/flume-ng-sinks/flume-ng-elasticsearch-sink/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-
-
-log4j.rootLogger = DEBUG, out
-
-log4j.appender.out = org.apache.log4j.ConsoleAppender
-log4j.appender.out.layout = org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern = %d (%t) [%p - %l] %m%n
-
-log4j.logger.org.apache.flume = DEBUG

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sinks/flume-ng-elasticsearch-sink/src/test/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/flume-ng-sinks/flume-ng-elasticsearch-sink/src/test/resources/log4j2.xml b/flume-ng-sinks/flume-ng-elasticsearch-sink/src/test/resources/log4j2.xml
new file mode 100644
index 0000000..5676916
--- /dev/null
+++ b/flume-ng-sinks/flume-ng-elasticsearch-sink/src/test/resources/log4j2.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+<Configuration status="OFF">
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="%d (%t) [%p - %l] %m%n" />
+    </Console>
+  </Appenders>
+  <Loggers>
+    <Logger name="org.apache.flume" level="DEBUG"/>
+    <Root level="DEBUG">
+      <AppenderRef ref="Console" />
+    </Root>
+  </Loggers>
+</Configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sinks/flume-ng-hbase-sink/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-sinks/flume-ng-hbase-sink/pom.xml b/flume-ng-sinks/flume-ng-hbase-sink/pom.xml
index 1184275..0f8af71 100644
--- a/flume-ng-sinks/flume-ng-hbase-sink/pom.xml
+++ b/flume-ng-sinks/flume-ng-hbase-sink/pom.xml
@@ -68,8 +68,26 @@
     </dependency>
 
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
       <scope>test</scope>
     </dependency>
 
@@ -197,12 +215,32 @@
           <groupId>org.apache.hadoop</groupId>
           <artifactId>hadoop-minicluster</artifactId>
           <scope>test</scope>
+          <exclusions>
+            <exclusion>
+              <groupId>log4j</groupId>
+              <artifactId>log4j</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>org.slf4j</groupId>
+              <artifactId>slf4j-log4j12</artifactId>
+            </exclusion>
+          </exclusions>
         </dependency>
 
         <dependency>
           <groupId>org.apache.hbase</groupId>
           <artifactId>hbase-client</artifactId>
           <optional>true</optional>
+          <exclusions>
+            <exclusion>
+              <groupId>log4j</groupId>
+              <artifactId>log4j</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>org.slf4j</groupId>
+              <artifactId>slf4j-log4j12</artifactId>
+            </exclusion>
+          </exclusions>
         </dependency>
 
         <dependency>
@@ -236,17 +274,47 @@
           <groupId>org.apache.hbase</groupId>
           <artifactId>hbase-common</artifactId>
           <optional>true</optional>
+          <exclusions>
+            <exclusion>
+              <groupId>log4j</groupId>
+              <artifactId>log4j</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>org.slf4j</groupId>
+              <artifactId>slf4j-log4j12</artifactId>
+            </exclusion>
+          </exclusions>
         </dependency>
         <dependency>
           <groupId>org.apache.hbase</groupId>
           <artifactId>hbase-testing-util</artifactId>
           <scope>test</scope>
+          <exclusions>
+            <exclusion>
+              <groupId>log4j</groupId>
+              <artifactId>log4j</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>org.slf4j</groupId>
+              <artifactId>slf4j-log4j12</artifactId>
+            </exclusion>
+          </exclusions>
         </dependency>
 
         <dependency>
           <groupId>org.apache.zookeeper</groupId>
           <artifactId>zookeeper</artifactId>
           <scope>test</scope>
+          <exclusions>
+            <exclusion>
+              <groupId>log4j</groupId>
+              <artifactId>log4j</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>org.slf4j</groupId>
+              <artifactId>slf4j-log4j12</artifactId>
+            </exclusion>
+          </exclusions>
         </dependency>
       </dependencies>
     </profile>

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sinks/flume-ng-kafka-sink/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-sinks/flume-ng-kafka-sink/pom.xml b/flume-ng-sinks/flume-ng-kafka-sink/pom.xml
index e4cad81..39dd3bd 100644
--- a/flume-ng-sinks/flume-ng-kafka-sink/pom.xml
+++ b/flume-ng-sinks/flume-ng-kafka-sink/pom.xml
@@ -86,6 +86,30 @@
       <version>${kafka.version}</version>
     </dependency>
 
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
   </dependencies>
 
 </project>

http://git-wip-us.apache.org/repos/asf/flume/blob/69c66efe/flume-ng-sinks/flume-ng-kafka-sink/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/flume-ng-sinks/flume-ng-kafka-sink/src/test/resources/log4j.properties b/flume-ng-sinks/flume-ng-kafka-sink/src/test/resources/log4j.properties
deleted file mode 100644
index b86600b..0000000
--- a/flume-ng-sinks/flume-ng-kafka-sink/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,78 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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.
-
-kafka.logs.dir=target/logs
-
-log4j.rootLogger=INFO, stdout
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=[%d] %p %m (%c)%n
-
-log4j.appender.kafkaAppender=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.kafkaAppender.DatePattern='.'yyyy-MM-dd-HH
-log4j.appender.kafkaAppender.File=${kafka.logs.dir}/server.log
-log4j.appender.kafkaAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.kafkaAppender.layout.ConversionPattern=[%d] %p %m (%c)%n
-
-log4j.appender.stateChangeAppender=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.stateChangeAppender.DatePattern='.'yyyy-MM-dd-HH
-log4j.appender.stateChangeAppender.File=${kafka.logs.dir}/state-change.log
-log4j.appender.stateChangeAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.stateChangeAppender.layout.ConversionPattern=[%d] %p %m (%c)%n
-
-log4j.appender.requestAppender=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.requestAppender.DatePattern='.'yyyy-MM-dd-HH
-log4j.appender.requestAppender.File=${kafka.logs.dir}/kafka-request.log
-log4j.appender.requestAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.requestAppender.layout.ConversionPattern=[%d] %p %m (%c)%n
-
-log4j.appender.cleanerAppender=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.cleanerAppender.DatePattern='.'yyyy-MM-dd-HH
-log4j.appender.cleanerAppender.File=${kafka.logs.dir}/log-cleaner.log
-log4j.appender.cleanerAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.cleanerAppender.layout.ConversionPattern=[%d] %p %m (%c)%n
-
-log4j.appender.controllerAppender=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.controllerAppender.DatePattern='.'yyyy-MM-dd-HH
-log4j.appender.controllerAppender.File=${kafka.logs.dir}/controller.log
-log4j.appender.controllerAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.controllerAppender.layout.ConversionPattern=[%d] %p %m (%c)%n
-
-# Turn on all our debugging info
-#log4j.logger.kafka.producer.async.DefaultEventHandler=DEBUG, kafkaAppender
-#log4j.logger.kafka.client.ClientUtils=DEBUG, kafkaAppender
-#log4j.logger.kafka.perf=DEBUG, kafkaAppender
-#log4j.logger.kafka.perf.ProducerPerformance$ProducerThread=DEBUG, kafkaAppender
-#log4j.logger.org.I0Itec.zkclient.ZkClient=DEBUG
-log4j.logger.kafka=INFO, kafkaAppender
-
-log4j.logger.kafka.network.RequestChannel$=WARN, requestAppender
-log4j.additivity.kafka.network.RequestChannel$=false
-
-#log4j.logger.kafka.network.Processor=TRACE, requestAppender
-#log4j.logger.kafka.server.KafkaApis=TRACE, requestAppender
-#log4j.additivity.kafka.server.KafkaApis=false
-log4j.logger.kafka.request.logger=WARN, requestAppender
-log4j.additivity.kafka.request.logger=false
-
-log4j.logger.kafka.controller=TRACE, controllerAppender
-log4j.additivity.kafka.controller=false
-
-log4j.logger.kafka.log.LogCleaner=INFO, cleanerAppender
-log4j.additivity.kafka.log.LogCleaner=false
-
-log4j.logger.state.change.logger=TRACE, stateChangeAppender
-log4j.additivity.state.change.logger=false


[6/7] flume git commit: FLUME-3115. Update netty library

Posted by de...@apache.org.
FLUME-3115. Update netty library

This change upgrades the netty library to 3.10.6 and also adds netty-all 4.1.17

This closes #155

Reviewers: Miklos Csanady

(Ferenc Szabo via Denes Arvay)


Project: http://git-wip-us.apache.org/repos/asf/flume/repo
Commit: http://git-wip-us.apache.org/repos/asf/flume/commit/286c2442
Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/286c2442
Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/286c2442

Branch: refs/heads/trunk
Commit: 286c2442444c9ed3bcb07f330d9d06947163e0c6
Parents: 31d1a57
Author: Ferenc Szabo <fs...@cloudera.com>
Authored: Fri Aug 18 15:06:02 2017 +0200
Committer: Denes Arvay <de...@apache.org>
Committed: Fri Jan 26 16:23:26 2018 +0100

----------------------------------------------------------------------
 pom.xml | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flume/blob/286c2442/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 2b0cba6..0cd174c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -96,7 +96,8 @@ limitations under the License.
     <mvn-site-plugin.version>3.3</mvn-site-plugin.version>
     <mvn-sphinx-plugin>1.0.2</mvn-sphinx-plugin>
     <mvn-surefire-plugin.version>2.20.1</mvn-surefire-plugin.version>
-    <netty.version>3.9.4.Final</netty.version>
+    <netty.version>3.10.6.Final</netty.version>
+    <netty-all.version>4.1.17.Final</netty-all.version>
     <protobuf.version>2.5.0</protobuf.version>
     <rat.version>0.11</rat.version>
     <snappy-java.version>1.1.4</snappy-java.version>
@@ -1619,6 +1620,12 @@ limitations under the License.
       </dependency>
 
       <dependency>
+        <groupId>io.netty</groupId>
+        <artifactId>netty-all</artifactId>
+        <version>${netty-all.version}</version>
+      </dependency>
+
+      <dependency>
         <groupId>org.apache.solr</groupId>
         <artifactId>solr-cell</artifactId>
         <version>${solr-global.version}</version>


[7/7] flume git commit: FLUME-3158: Upgrade surefire version and config

Posted by de...@apache.org.
FLUME-3158: Upgrade surefire version and config

Set surefire version to the latest and configure it
to rerun failed tests.
This way the flaky tests will not break the build as often.

This closes #182

Reviewers: Ferenc Szabo

(Miklos Csanady via Ferenc Szabo)


Project: http://git-wip-us.apache.org/repos/asf/flume/repo
Commit: http://git-wip-us.apache.org/repos/asf/flume/commit/e3a0f8b2
Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/e3a0f8b2
Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/e3a0f8b2

Branch: refs/heads/trunk
Commit: e3a0f8b29243298541aaaa3fc51fdfa82623dbe1
Parents: 5a70cd7
Author: Miklos Csanady <mi...@cloudera.com>
Authored: Tue Nov 21 11:27:53 2017 +0100
Committer: Denes Arvay <de...@apache.org>
Committed: Fri Jan 26 16:23:26 2018 +0100

----------------------------------------------------------------------
 flume-ng-sinks/flume-ng-morphline-solr-sink/pom.xml |  5 -----
 pom.xml                                             | 10 +++++-----
 2 files changed, 5 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flume/blob/e3a0f8b2/flume-ng-sinks/flume-ng-morphline-solr-sink/pom.xml
----------------------------------------------------------------------
diff --git a/flume-ng-sinks/flume-ng-morphline-solr-sink/pom.xml b/flume-ng-sinks/flume-ng-morphline-solr-sink/pom.xml
index 84ddf94..202e4fd 100644
--- a/flume-ng-sinks/flume-ng-morphline-solr-sink/pom.xml
+++ b/flume-ng-sinks/flume-ng-morphline-solr-sink/pom.xml
@@ -32,7 +32,6 @@ limitations under the License.
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <solr.version>${solr-global.version}</solr.version>
     <solr.expected.version>${solr-global.version}</solr.expected.version> <!-- sanity check to verify we actually run against the expected version rather than some outdated version -->
-    <surefire.version>${mvn-surefire-plugin-old-morphline.version}</surefire.version>
   </properties>
 
   <dependencies>
@@ -126,13 +125,9 @@ limitations under the License.
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
-        <version>${surefire.version}</version>
         <configuration>
           <argLine>-Dtests.locale=en_us</argLine>
           <redirectTestOutputToFile>true</redirectTestOutputToFile>
-          <systemPropertyVariables>
-            <!--<solr.expected.version>${solr.expected.version}</solr.expected.version>-->
-          </systemPropertyVariables>
         </configuration>
       </plugin>
 

http://git-wip-us.apache.org/repos/asf/flume/blob/e3a0f8b2/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 14a7e89..3904b15 100644
--- a/pom.xml
+++ b/pom.xml
@@ -95,9 +95,7 @@ limitations under the License.
     <mvn-project-info-reports-plugin.version>2.4</mvn-project-info-reports-plugin.version>
     <mvn-site-plugin.version>3.3</mvn-site-plugin.version>
     <mvn-sphinx-plugin>1.0.2</mvn-sphinx-plugin>
-    <mvn-surefire-plugin.version>2.14.1</mvn-surefire-plugin.version>
-    <mvn-surefire-plugin-old.version>2.12.3</mvn-surefire-plugin-old.version>
-    <mvn-surefire-plugin-old-morphline.version>2.12.4</mvn-surefire-plugin-old-morphline.version>
+    <mvn-surefire-plugin.version>2.20.1</mvn-surefire-plugin.version>
     <netty.version>3.9.4.Final</netty.version>
     <protobuf.version>2.5.0</protobuf.version>
     <rat.version>0.11</rat.version>
@@ -918,9 +916,11 @@ limitations under the License.
         <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-surefire-plugin</artifactId>
-          <version>${mvn-surefire-plugin-old.version}</version>
+          <version>${mvn-surefire-plugin.version}</version>
           <configuration>
-            <forkMode>always</forkMode>
+            <reuseForks>false</reuseForks>
+            <forkCount>1</forkCount>
+            <rerunFailingTestsCount>10</rerunFailingTestsCount>
             <forkedProcessTimeoutInSeconds>900</forkedProcessTimeoutInSeconds>
             <redirectTestOutputToFile>true</redirectTestOutputToFile>
             <includes>


[4/7] flume git commit: FLUME-3194 upgrade derby to the latest version

Posted by de...@apache.org.
FLUME-3194 upgrade derby to the latest version

Current derby version contains security vulnerabilities.
This update will upgrade to a later version.

This closes #184

Reviewers: Ferenc Szabo

(Miklos Csanady via Ferenc Szabo)


Project: http://git-wip-us.apache.org/repos/asf/flume/repo
Commit: http://git-wip-us.apache.org/repos/asf/flume/commit/93510c64
Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/93510c64
Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/93510c64

Branch: refs/heads/trunk
Commit: 93510c642a3ed6ee2280c3d9ab2688ddca5d620a
Parents: e3a0f8b
Author: Miklos Csanady <mi...@cloudera.com>
Authored: Tue Dec 5 14:27:11 2017 +0100
Committer: Denes Arvay <de...@apache.org>
Committed: Fri Jan 26 16:23:26 2018 +0100

----------------------------------------------------------------------
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flume/blob/93510c64/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 3904b15..2b0cba6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -61,7 +61,7 @@ limitations under the License.
     <commons-io.version>2.1</commons-io.version>
     <commons-lang.version>2.5</commons-lang.version>
     <curator.version>2.6.0</curator.version>
-    <derby.version>10.11.1.1</derby.version>
+    <derby.version>10.14.1.0</derby.version>
     <elasticsearch.version>0.90.1</elasticsearch.version>
     <fasterxml.jackson.version>2.8.9</fasterxml.jackson.version>
     <fest-reflect.version>1.4</fest-reflect.version>