Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace log4j with slf4j #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,38 @@
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.32</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.14.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<gpudb-api.version>7.1.4.0</gpudb-api.version>
</properties>
Expand Down
121 changes: 2 additions & 119 deletions api/src/main/java/com/gpudb/GPUdbBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
Expand All @@ -62,15 +61,10 @@
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.xerial.snappy.Snappy;



/**
* Base class for the GPUdb API that provides general functionality not specific
* to any particular GPUdb request. This class is never instantiated directly;
Expand Down Expand Up @@ -161,7 +155,6 @@ public static final class Options {
private long intraClusterFailoverTimeout = DEFAULT_INTRA_CLUSTER_FAILOVER_TIMEOUT_MS;
private int maxTotalConnections = DEFAULT_MAX_TOTAL_CONNECTIONS;
private int maxConnectionsPerHost = DEFAULT_MAX_CONNECTIONS_PER_HOST;
private Level loggingLevel = GPUdbLogger.DEFAULT_LOGGING_LEVEL;

/**
* No-argument constructor needed for the copy constructor.
Expand Down Expand Up @@ -194,7 +187,6 @@ public Options( Options other ) {
this.intraClusterFailoverTimeout = other.intraClusterFailoverTimeout;
this.maxTotalConnections = other.maxTotalConnections;
this.maxConnectionsPerHost = other.maxConnectionsPerHost;
this.loggingLevel = other.loggingLevel;
this.initialConnectionAttemptTimeout = other.initialConnectionAttemptTimeout;
this.connectionInactivityValidationTimeout = other.connectionInactivityValidationTimeout;

Expand Down Expand Up @@ -317,7 +309,7 @@ public boolean getDisableAutoDiscovery() {
* @return the inter-cluster failover order
*
* @see #setHAFailoverOrder(HAFailoverOrder)
* @see GPUdbBase#HAFailoverOrder
* @see GPUdbBase#haFailoverOrder
*/
public HAFailoverOrder getHAFailoverOrder() {
return this.haFailoverOrder;
Expand Down Expand Up @@ -500,26 +492,6 @@ public long getIntraClusterFailoverTimeout() {
return this.intraClusterFailoverTimeout;
}


/**
* Gets the logging level that will be used by the API. By default,
* logging is turned off; but if logging properties are provided
* by the user, those properties will be respected. If the user sets
* the logging level explicitly (and it is not the default log level),
* then the programmatically set level will be used instead of the
* one set in the properties file.
*
* @return the logging level
*
* @see #setLoggingLevel(String)
* @see #setLoggingLevel(Level)
*/
public Level getLoggingLevel() {
return this.loggingLevel;
}



/**
* Sets the URL of the primary cluster to use amongst the HA clusters.
* This cluster will always be used first. It can be part of the URLs
Expand Down Expand Up @@ -743,7 +715,7 @@ public Options setDisableAutoDiscovery(boolean value) {
* @return the current {@link Options} instance
*
* @see #getDisableAutoDiscovery()
* @see GPUdbBase#HAFailoverOrder
* @see GPUdbBase#haFailoverOrder
*/
public Options setHAFailoverOrder(HAFailoverOrder value) {
this.haFailoverOrder = value;
Expand Down Expand Up @@ -1043,83 +1015,6 @@ public Options setIntraClusterFailoverTimeout(long value) {
this.intraClusterFailoverTimeout = value;
return this;
}


/**
* Sets the logging level that will be used by the API.
* Supported values:
* <ul>
* <li> ALL
* <li> DEBUG
* <li> ERROR
* <li> FATAL
* <li> INFO
* <li> OFF (the default)
* <li> TRACE
* <li> TRACE_INT
* <li> WARN
* </ul>
*
* If `OFF` is given, and if logging properties are provided by the user
* (via log4j.properties or other files), those properties will be
* respected. If the user set logging level is not the default log
* level, i.e. `OFF`), then the programmatically set level will be used
* instead of the one set in the properties file.
*
* @return the current {@link Options} instance
*
* @see #getLoggingLevel()
*/
public Options setLoggingLevel(String value) throws GPUdbException {

// Parse the level
Level level = Level.toLevel( value );

// Ensure a valid level was given
if ( (level == Level.DEBUG)
&& !value.equalsIgnoreCase( "DEBUG" ) ) {
// The user didn't give debug, but Level returned it
// (which it does when it can't parse the given value)
String errorMsg = ( "Must provide a valid logging level "
+ "(please see documentation); given: '"
+ value + "'" );
throw new GPUdbException( errorMsg );
}

this.loggingLevel = level;
return this;
}

/**
* Sets the logging level that will be used by the API.
* Supported values:
* <ul>
* <li> Level.ALL
* <li> Level.DEBUG
* <li> Level.ERROR
* <li> Level.FATAL
* <li> Level.INFO
* <li> Level.OFF (the default)
* <li> Level.TRACE
* <li> Level.TRACE_INT
* <li> Level.WARN
* </ul>
*
* If `OFF` is given, and if logging properties are provided by the user
* (via log4j.properties or other files), those properties will be
* respected. If the user set logging level is not the default log
* level, i.e. `OFF`), then the programmatically set level will be used
* instead of the one set in the properties file.
*
* @return the current {@link Options} instance
*
* @see #getLoggingLevel()
*/
public Options setLoggingLevel(Level value) {
this.loggingLevel = value;
return this;
}

} // end class Options


Expand Down Expand Up @@ -2085,10 +1980,6 @@ public String toString() {
protected GPUdbBase(String url, Options options) throws GPUdbException {
urlLock = new Object();

// Initialize the logger before anything else. This MUST be donce
// before any logging happens!
GPUdbLogger.initializeLogger( options.getLoggingLevel() );

if ( url == null ) {
String errorMsg = ( "Must provide a non-null and non-empty "
+ "string for the URL; given null" );
Expand Down Expand Up @@ -2118,10 +2009,6 @@ protected GPUdbBase(String url, Options options) throws GPUdbException {
protected GPUdbBase(URL url, Options options) throws GPUdbException {
urlLock = new Object();

// Initialize the logger before anything else. This MUST be donce
// before any logging happens!
GPUdbLogger.initializeLogger( options.getLoggingLevel() );

if ( url == null ) {
String errorMsg = "Must provide at least one URL; gave none!";
GPUdbLogger.error( errorMsg );
Expand All @@ -2136,10 +2023,6 @@ protected GPUdbBase(URL url, Options options) throws GPUdbException {
protected GPUdbBase(List<URL> urls, Options options) throws GPUdbException {
urlLock = new Object();

// Initialize the logger before anything else. This MUST be donce
// before any logging happens!
GPUdbLogger.initializeLogger( options.getLoggingLevel() );

if ( urls.isEmpty() ) {
String errorMsg = "Must provide at least one URL; gave none!";
GPUdbLogger.error( errorMsg );
Expand Down
Loading