Skip to content
Permalink
Browse files
Changed logger implementation from log4j to slf4j w/ logback
  • Loading branch information
agozhiy committed May 5, 2022
1 parent fd0c903 commit 3261cf599c42301b495a3677d791eb074e4f40fd
Showing 14 changed files with 149 additions and 56 deletions.
@@ -0,0 +1,64 @@
<?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>

<!-- Direct log messages to ./drill.log.timestamp file -->
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logs/drill.log.%d{yyyy-MM-dd-HH}</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n</pattern>
</encoder>
</appender>

<!-- Direct log messages to stdout -->
<appender name="Drill" class="ch.qos.logback.core.ConsoleAppender">
<Target>System.out</Target>
<encoder>
<pattern>%m%n</pattern>
</encoder>
</appender>

<!-- Direct log messages to stdout -->
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<Target>System.out</Target>
<encoder>
<pattern>%m%n</pattern>
</encoder>
</appender>


<logger name="org.apache.zookeeper" level="WARN"/>

<logger name="DrillTestLogger" additivity="false" level="INFO">
<appender-ref ref="file"/>
<appender-ref ref="Drill"/>
</logger>

<logger name="org.apache.curator" level="WARN"/>

<!-- Root logger option -->
<root level="ERROR">
<appender-ref ref="stdout"/>
</root>

</configuration>
@@ -7,7 +7,8 @@
<version>1.0.0-SNAPSHOT</version>
<properties>
<testng.version>6.4</testng.version>
<log4j.version>1.2.17</log4j.version>
<slf4j.version>1.7.26</slf4j.version>
<logback.version>1.2.9</logback.version>
<jackson.version>2.10.0</jackson.version>
<guava.version>30.1.1-jre</guava.version>
<drill.version>2.0.0-SNAPSHOT</drill.version>
@@ -38,21 +39,46 @@
<groupId>org.ojai</groupId>
<artifactId>ojai</artifactId>
<version>1.1</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.14</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<artifactId>log4j</artifactId>
<groupId>log4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>apache-log4j-extras</artifactId>
<version>${log4j.version}</version>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
@@ -92,6 +118,10 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<artifactId>log4j</artifactId>
<groupId>log4j</groupId>
</exclusion>
<exclusion>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
@@ -19,7 +19,9 @@

import com.google.common.collect.Queues;
import com.google.common.annotations.VisibleForTesting;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
@@ -29,7 +31,7 @@
import java.util.Queue;

public class ConnectionPool implements AutoCloseable {
private static final Logger LOG = Logger.getLogger("DrillTestLogger");
private static final Logger LOG = LoggerFactory.getLogger("DrillTestLogger");
private final Map<String, Queue<Connection>> connections;
private Properties connectionProperties;

@@ -17,17 +17,19 @@
*/
package org.apache.drill.test.framework;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.SQLException;
import java.sql.DatabaseMetaData;

import org.apache.log4j.Logger;

/**
* Retrieves DataBase MetaData.
*/

public class DBMetaData {
private static final Logger LOG = Logger.getLogger("DrillTestLogger");
private static final Logger LOG = LoggerFactory.getLogger("DrillTestLogger");
private DatabaseMetaData md = null;
public DBMetaData(DatabaseMetaData md) {
this.md = md;
@@ -9,7 +9,8 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.typesafe.config.ConfigFactory;
import com.typesafe.config.ConfigRenderOptions;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;
@@ -24,7 +25,7 @@
* Represents a Drill RM Resource Pool configuration.
*/
public class DrillRMConfig implements DrillConfigRenderer {
private static final Logger LOG = Logger.getLogger(DrillRMConfig.class);
private static final Logger LOG = LoggerFactory.getLogger(DrillRMConfig.class);
//Resource Pool Configurations
public static final String RESOURCE_POOL_NAME_KEY = "pool_name";
public static final String MEMORY_KEY = "memory";
@@ -20,10 +20,11 @@
import com.google.common.base.Stopwatch;
import com.google.common.collect.Lists;
import org.apache.drill.test.framework.TestCaseModeler.TestMatrix;
import org.apache.drill.test.framework.TestVerifier.PlanVerificationException;
import org.apache.drill.test.framework.TestVerifier.TestStatus;
import org.apache.drill.test.framework.TestVerifier.VerificationException;
import org.apache.drill.test.framework.TestVerifier.PlanVerificationException;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.BufferedWriter;
import java.io.File;
@@ -33,14 +34,13 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.atomic.AtomicBoolean;

public class DrillTestJdbc implements DrillTest {
private static final Logger LOG = Logger.getLogger("DrillTestLogger");
private static final Logger LOG = LoggerFactory.getLogger("DrillTestLogger");
private static final String LINE_BREAK = "------------------------------------------------------------------------";

private ConnectionPool connectionPool;
@@ -248,7 +248,7 @@ private void executeQuery(String query) throws IOException, SQLException {
}

LOG.debug("Result set data types:");
LOG.debug(Utils.getTypesInStrings(columnTypes));
LOG.debug(Utils.getTypesInStrings(columnTypes).toString());

if (resultSet != null) {
while (resultSet.next()) {
@@ -258,7 +258,7 @@ private void executeQuery(String query) throws IOException, SQLException {
}
}
} catch (IllegalArgumentException | IllegalAccessException | IOException e1) {
LOG.warn(e1);
LOG.warn(e1.getMessage(), e1);
} finally {
doneProcessingResultSet.set(true);
if (resultSet != null) {
@@ -322,7 +322,7 @@ private void executeLimitZeroQuery(String query) throws IOException, SQLExceptio
: new VerificationException(exception + "\n" + msg);
}
} catch (IllegalArgumentException | IllegalAccessException e1) {
LOG.warn(e1);
LOG.warn(e1.getMessage(), e1);
} finally {
if (resultSet != null) resultSet.close();
if (writer != null) writer.close();
@@ -23,7 +23,8 @@
import org.apache.drill.test.framework.TestVerifier.TestStatus;
import org.apache.drill.test.framework.TestVerifier.VerificationException;
import org.apache.drill.test.framework.TestVerifier.PlanVerificationException;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.BufferedReader;
import java.io.BufferedWriter;
@@ -42,7 +43,7 @@
import java.util.concurrent.atomic.AtomicBoolean;

public class DrillTestOdbc implements DrillTest{
private static final Logger LOG = Logger.getLogger("DrillTestLogger");
private static final Logger LOG = LoggerFactory.getLogger("DrillTestLogger");
private String query = null;
private String outputFilename;
private volatile TestStatus testStatus = TestStatus.PENDING;
@@ -18,28 +18,15 @@
package org.apache.drill.test.framework;

import com.google.common.base.Stopwatch;
import com.google.common.collect.Lists;
import org.apache.drill.test.framework.TestCaseModeler.TestMatrix;
import org.apache.drill.test.framework.TestVerifier.TestStatus;
import org.apache.drill.test.framework.TestVerifier.VerificationException;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.atomic.AtomicBoolean;

public class DrillTestScript implements DrillTest {
private static final Logger LOG = Logger.getLogger("DrillTestLogger");
private static final Logger LOG = LoggerFactory.getLogger("DrillTestLogger");
private String query;
private String outputFilename;
private volatile TestStatus testStatus = TestStatus.PENDING;
@@ -77,7 +64,7 @@ public void run() {
try {

cmdConsOut = Utils.execCmd(command);
LOG.info(cmdConsOut);
LOG.info(cmdConsOut.toString());

switch (cmdConsOut.exitCode) {
case 0:
@@ -30,9 +30,10 @@
import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapred.FileAlreadyExistsException;
import org.apache.log4j.Logger;
import org.ojai.Document;
import org.ojai.json.Json;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.BufferedReader;
import java.io.BufferedWriter;
@@ -59,7 +60,7 @@
import java.util.Set;

public class TestDriver {
private static final Logger LOG = Logger.getLogger("DrillTestLogger");
private static final Logger LOG = LoggerFactory.getLogger("DrillTestLogger");
private Connection connection = null;
public static String commitId, version;
private String[] injectionKeys = {"DRILL_VERSION"};
@@ -680,7 +681,7 @@ public void setup() throws IOException, InterruptedException, URISyntaxException
injections.put(injectionKeys[i], version);
break;
default:
LOG.fatal("Injection parameter not recognized!");
LOG.error("Injection parameter not recognized!");
}
}
connectionPool.releaseConnection(connection);
@@ -1064,7 +1065,7 @@ private void runGenerateScript(DataSource datasource) {
CmdConsOut cmdConsOut;
try {
cmdConsOut = Utils.execCmd(command);
LOG.debug(cmdConsOut);
LOG.debug(cmdConsOut.toString());
} catch (Exception e) {
cmdConsOut = new CmdConsOut();
cmdConsOut.cmd = command;
@@ -1131,7 +1132,7 @@ private void queryMemoryUsage() throws IOException, SQLException {
}

LOG.debug("Result set data types:");
LOG.debug(Utils.getTypesInStrings(types));
LOG.debug(Utils.getTypesInStrings(types).toString());

if (resultSet != null) {
while (resultSet.next()) {
@@ -42,15 +42,16 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.collect.Lists;
import org.apache.drill.test.framework.TestCaseModeler.TestMatrix;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Verification of drill tests by comparing actual query output with expected
* query result set.
*
*/
public class TestVerifier {
private static final Logger LOG = Logger.getLogger("DrillTestLogger");
private static final Logger LOG = LoggerFactory.getLogger("DrillTestLogger");
private static final int MAX_MISMATCH_SIZE = 10;
public TestStatus testStatus = TestStatus.PENDING;
private int mapSize = 0;

0 comments on commit 3261cf5

Please sign in to comment.