diff --git a/pom.xml b/pom.xml
index 752ce4501..b367969a7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
mariadb-java-client
jar
mariadb-java-client
- 1.2.0
+ 1.2.1-SNAPSHOT
JDBC driver for MariaDB and MySQL
https://mariadb.com/kb/en/mariadb/about-mariadb-connector-j/
@@ -236,6 +236,17 @@
4.12
test
+
+ ch.qos.logback
+ logback-classic
+ 1.1.3
+ test
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.12
+
net.java.dev.jna
jna
diff --git a/src/main/java/org/mariadb/jdbc/Driver.java b/src/main/java/org/mariadb/jdbc/Driver.java
index 0ddde8cb1..69b875f88 100644
--- a/src/main/java/org/mariadb/jdbc/Driver.java
+++ b/src/main/java/org/mariadb/jdbc/Driver.java
@@ -53,6 +53,8 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
import org.mariadb.jdbc.internal.common.QueryException;
import org.mariadb.jdbc.internal.common.Utils;
import org.mariadb.jdbc.internal.mysql.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.lang.reflect.Proxy;
import java.sql.Connection;
@@ -62,14 +64,11 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
import java.sql.SQLFeatureNotSupportedException;
import java.util.Properties;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.logging.Logger;
+
public final class Driver implements java.sql.Driver {
- /**
- * the logger.
- */
- private static final Logger log = Logger.getLogger(Driver.class.getName());
+ private final static Logger log = LoggerFactory.getLogger(Driver.class);
static {
try {
@@ -90,7 +89,7 @@ public final class Driver implements java.sql.Driver {
*/
public Connection connect(final String url, final Properties props) throws SQLException {
- log.finest("Connecting to: " + url);
+ log.debug("Connecting to: " + url);
try {
JDBCUrl jdbcUrl = JDBCUrl.parse(url, props);
if (jdbcUrl.getHostAddresses() == null) {
@@ -159,7 +158,7 @@ public boolean jdbcCompliant() {
return false;
}
- public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+ public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException {
// TODO Auto-generated method stub
return null;
}
diff --git a/src/main/java/org/mariadb/jdbc/MySQLDataSource.java b/src/main/java/org/mariadb/jdbc/MySQLDataSource.java
index 190c91553..e33e05c4f 100644
--- a/src/main/java/org/mariadb/jdbc/MySQLDataSource.java
+++ b/src/main/java/org/mariadb/jdbc/MySQLDataSource.java
@@ -56,6 +56,7 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
import org.mariadb.jdbc.internal.common.UrlHAMode;
import org.mariadb.jdbc.internal.common.Utils;
import org.mariadb.jdbc.internal.mysql.*;
+import org.slf4j.LoggerFactory;
import javax.sql.*;
@@ -71,7 +72,7 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
public class MySQLDataSource implements DataSource, ConnectionPoolDataSource, XADataSource {
- private final static Logger log = Logger.getLogger(MySQLDataSource.class.getName());
+ private final static org.slf4j.Logger log = LoggerFactory.getLogger(MySQLDataSource.class);
private final JDBCUrl jdbcUrl;
@@ -271,7 +272,7 @@ public Connection getConnection() throws SQLException {
public Connection getConnection(final String username, final String password) throws SQLException {
jdbcUrl.setUsername(username);
jdbcUrl.setPassword(password);
- log.finest("connection : " +jdbcUrl.toString());
+ if (log.isDebugEnabled()) log.debug("connection : " +jdbcUrl.toString());
return getConnection();
}
diff --git a/src/main/java/org/mariadb/jdbc/MySQLPreparedStatement.java b/src/main/java/org/mariadb/jdbc/MySQLPreparedStatement.java
index 87428fd35..61591745f 100644
--- a/src/main/java/org/mariadb/jdbc/MySQLPreparedStatement.java
+++ b/src/main/java/org/mariadb/jdbc/MySQLPreparedStatement.java
@@ -52,6 +52,8 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
import org.mariadb.jdbc.internal.common.Utils;
import org.mariadb.jdbc.internal.common.query.*;
import org.mariadb.jdbc.internal.common.query.parameters.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
@@ -64,12 +66,10 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
public class MySQLPreparedStatement extends MySQLStatement implements PreparedStatement {
- private final static Logger log = Logger.getLogger(MySQLPreparedStatement.class.getName());
+ private final static Logger log = LoggerFactory.getLogger(MySQLPreparedStatement.class);
private MySQLParameterizedQuery dQuery;
private String sql;
private boolean useFractionalSeconds;
@@ -82,8 +82,8 @@ public MySQLPreparedStatement(MySQLConnection connection,
this.sql = sql;
useFractionalSeconds =
connection.getProtocol().getOptions().useFractionalSeconds;
- if(log.isLoggable(Level.FINEST)) {
- log.finest("Creating prepared statement for " + sql);
+ if(log.isDebugEnabled()) {
+ log.debug("Creating prepared statement for " + sql);
}
dQuery = new MySQLParameterizedQuery(Utils.nativeSQL(sql, connection.noBackslashEscapes),
connection.noBackslashEscapes);
diff --git a/src/main/java/org/mariadb/jdbc/internal/common/DefaultOptions.java b/src/main/java/org/mariadb/jdbc/internal/common/DefaultOptions.java
index 0fca4d674..76fcfa902 100644
--- a/src/main/java/org/mariadb/jdbc/internal/common/DefaultOptions.java
+++ b/src/main/java/org/mariadb/jdbc/internal/common/DefaultOptions.java
@@ -214,11 +214,6 @@ public enum DefaultOptions {
*/
FAIL_ON_READ_ONLY("failOnReadOnly", Boolean.FALSE, "1.2.0"),
- /**
- * If autoReconnect is enabled, the initial time to wait between re-connect attempts (in seconds, defaults to 2)
- */
- INITIAL_TIMEOUT("initialTimeout", new Integer(2), new Integer(0), Integer.MAX_VALUE, "1.2.0"),
-
/**
* Number of seconds to issue before falling back to master when failed over (when using multi-host failover).
* Whichever condition is met first, 'queriesBeforeRetryMaster' or 'secondsBeforeRetryMaster' will cause an
diff --git a/src/main/java/org/mariadb/jdbc/internal/common/Options.java b/src/main/java/org/mariadb/jdbc/internal/common/Options.java
index f49a7ce52..f790e7597 100644
--- a/src/main/java/org/mariadb/jdbc/internal/common/Options.java
+++ b/src/main/java/org/mariadb/jdbc/internal/common/Options.java
@@ -88,7 +88,6 @@ public class Options {
//HA options
public boolean autoReconnect;
public boolean failOnReadOnly;
- public int initialTimeout;
public int secondsBeforeRetryMaster;
public int queriesBeforeRetryMaster;
public int retriesAllDown;
@@ -132,7 +131,6 @@ public String toString() {
", useOldAliasMetadataBehavior=" + useOldAliasMetadataBehavior +
", autoReconnect=" + autoReconnect +
", failOnReadOnly=" + failOnReadOnly +
- ", initialTimeout=" + initialTimeout +
", secondsBeforeRetryMaster=" + secondsBeforeRetryMaster +
", queriesBeforeRetryMaster=" + queriesBeforeRetryMaster +
", retriesAllDown=" + retriesAllDown +
diff --git a/src/main/java/org/mariadb/jdbc/internal/common/packet/PacketOutputStream.java b/src/main/java/org/mariadb/jdbc/internal/common/packet/PacketOutputStream.java
index 2012ea0fe..da2128180 100644
--- a/src/main/java/org/mariadb/jdbc/internal/common/packet/PacketOutputStream.java
+++ b/src/main/java/org/mariadb/jdbc/internal/common/packet/PacketOutputStream.java
@@ -1,16 +1,15 @@
package org.mariadb.jdbc.internal.common.packet;
-import org.mariadb.jdbc.internal.common.packet.commands.StreamedQueryPacket;
-import org.mariadb.jdbc.internal.common.query.MySQLQuery;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.util.logging.Level;
-import java.util.logging.Logger;
public class PacketOutputStream extends OutputStream {
- private final static Logger log = Logger.getLogger("org.maria.jdbc");
+ private final static Logger log = LoggerFactory.getLogger(PacketOutputStream.class);
private static final int MAX_PACKET_LENGTH = 0x00ffffff;
private static final int SEQNO_OFFSET = 3;
@@ -133,10 +132,10 @@ private void internalFlush() throws IOException {
throw new MaxAllowedPacketException("max_allowed_packet exceeded. wrote " + bytesWritten + ", max_allowed_packet = " +maxAllowedPacket, this.seqNo != 0);
}
baseStream.write(byteBuffer, 0, position);
- if (log.isLoggable(Level.FINEST)) {
+ if (log.isTraceEnabled()) {
byte[] tmp = new byte[Math.min(1000, position)];
System.arraycopy(byteBuffer, 0, tmp, 0, Math.min(1000, position));
- log.finest(new String(tmp));
+ log.trace(new String(tmp));
}
position = HEADER_LENGTH;
diff --git a/src/main/java/org/mariadb/jdbc/internal/mysql/AuroraProtocol.java b/src/main/java/org/mariadb/jdbc/internal/mysql/AuroraProtocol.java
index d8e6c2ebf..193c97d79 100644
--- a/src/main/java/org/mariadb/jdbc/internal/mysql/AuroraProtocol.java
+++ b/src/main/java/org/mariadb/jdbc/internal/mysql/AuroraProtocol.java
@@ -57,15 +57,15 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
import org.mariadb.jdbc.internal.common.queryresults.SelectQueryResult;
import org.mariadb.jdbc.internal.mysql.listener.impl.AuroraListener;
import org.mariadb.jdbc.internal.mysql.listener.tools.SearchFilter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.logging.Level;
-import java.util.logging.Logger;
public class AuroraProtocol extends MastersSlavesProtocol {
- private final static Logger log = Logger.getLogger(AuroraProtocol.class.getName());
+ private final static Logger log = LoggerFactory.getLogger(AuroraProtocol.class);
public AuroraProtocol(final JDBCUrl url, final ReentrantReadWriteLock lock) {
super(url, lock);
@@ -97,7 +97,7 @@ public boolean checkIfMaster() throws QueryException {
return this.masterConnection;
} catch (IOException ioe) {
- log.log(Level.FINEST, "exception during checking if master", ioe);
+ log.trace("exception during checking if master", ioe);
throw new QueryException("could not check the 'innodb_read_only' variable status on " + this.getHostAddress() +
" : " + ioe.getMessage(), -1, SQLExceptionMapper.SQLStates.CONNECTION_EXCEPTION.getSqlState(), ioe);
} finally {
@@ -107,16 +107,16 @@ public boolean checkIfMaster() throws QueryException {
public static void searchProbableMaster(AuroraListener listener, HostAddress probableMaster, Map blacklist, SearchFilter searchFilter) throws QueryException {
- if (log.isLoggable(Level.FINE)) {
- log.fine("searching for master:" + searchFilter.isSearchForMaster() + " replica:" + searchFilter.isSearchForSlave() + " address:" + probableMaster + " blacklist:" + blacklist.keySet());
+ if (log.isDebugEnabled()) {
+ log.debug("searching for master:" + searchFilter.isSearchForMaster() + " replica:" + searchFilter.isSearchForSlave() + " address:" + probableMaster + " blacklist:" + blacklist.keySet());
}
AuroraProtocol protocol = getNewProtocol(listener.getProxy(), listener.getJdbcUrl());
try {
protocol.setHostAddress(probableMaster);
- if (log.isLoggable(Level.FINE)) log.fine("trying to connect to " + protocol.getHostAddress());
+ if (log.isTraceEnabled()) log.trace("trying to connect to " + protocol.getHostAddress());
protocol.connect();
- if (log.isLoggable(Level.FINE)) log.fine("connected to " + protocol.getHostAddress());
+ if (log.isTraceEnabled()) log.trace("connected to " + protocol.getHostAddress());
if (searchFilter.isSearchForMaster() && protocol.isMasterConnection()) {
searchFilter.setSearchForMaster(false);
@@ -127,16 +127,16 @@ public static void searchProbableMaster(AuroraListener listener, HostAddress pro
protocol.setMustBeMasterConnection(false);
listener.foundActiveSecondary(protocol);
} else {
- if (log.isLoggable(Level.FINE))
- log.fine("close connection because unused : " + protocol.getHostAddress());
+ if (log.isDebugEnabled())
+ log.debug("close connection because unused : " + protocol.getHostAddress());
protocol.close();
protocol = getNewProtocol(listener.getProxy(), listener.getJdbcUrl());
}
} catch (QueryException e) {
blacklist.put(protocol.getHostAddress(), System.currentTimeMillis());
- if (log.isLoggable(Level.FINE))
- log.fine("Could not connect to " + protocol.currentHost + " searching for master : " + searchFilter.isSearchForMaster() + " for replica :" + searchFilter.isSearchForSlave() + " error:" + e.getMessage());
+ if (log.isDebugEnabled())
+ log.debug("Could not connect to " + protocol.currentHost + " searching for master : " + searchFilter.isSearchForMaster() + " for replica :" + searchFilter.isSearchForSlave() + " error:" + e.getMessage());
}
}
@@ -150,8 +150,8 @@ public static void searchProbableMaster(AuroraListener listener, HostAddress pro
* @throws QueryException if not found
*/
public static void loop(AuroraListener listener, final List addresses, Map blacklist, SearchFilter searchFilter) throws QueryException {
- if (log.isLoggable(Level.FINE)) {
- log.fine("searching for master:" + searchFilter.isSearchForMaster() + " replica:" + searchFilter.isSearchForSlave() + " addresses:" + addresses );
+ if (log.isDebugEnabled()) {
+ log.debug("searching for master:" + searchFilter.isSearchForMaster() + " replica:" + searchFilter.isSearchForSlave() + " addresses:" + addresses);
}
AuroraProtocol protocol;
@@ -169,25 +169,20 @@ public static void loop(AuroraListener listener, final List address
protocol.setHostAddress(loopAddresses.get(0));
loopAddresses.remove(0);
- if (log.isLoggable(Level.FINE)) log.fine("trying to connect to " + protocol.getHostAddress());
+ if (log.isDebugEnabled()) log.debug("trying to connect to " + protocol.getHostAddress());
protocol.connect();
blacklist.remove(protocol.getHostAddress());
- if (log.isLoggable(Level.FINE)) log.fine("connected to " + (protocol.isMasterConnection()?"primary ":"replica ") + protocol.getHostAddress());
+ if (log.isDebugEnabled()) log.debug("connected to " + (protocol.isMasterConnection()?"primary ":"replica ") + protocol.getHostAddress());
if (searchFilter.isSearchForMaster() && protocol.isMasterConnection()) {
- log.finest("locks -0 : "+protocol.getProxy().lock.getReadHoldCount() + " "+protocol.getProxy().lock.getWriteHoldCount());
if (foundMaster(listener, protocol, searchFilter)) return;
- log.finest("locks -1: "+protocol.getProxy().lock.getReadHoldCount() + " "+protocol.getProxy().lock.getWriteHoldCount());
} else if (searchFilter.isSearchForSlave() && !protocol.isMasterConnection()) {
- log.finest("locks -2: "+protocol.getProxy().lock.getReadHoldCount() + " "+protocol.getProxy().lock.getWriteHoldCount());
if (foundSecondary(listener, protocol, searchFilter)) return;
- log.finest("locks -3: "+protocol.getProxy().lock.getReadHoldCount() + " "+protocol.getProxy().lock.getWriteHoldCount());
HostAddress probableMasterHost = listener.searchByStartName(protocol, listener.getJdbcUrl().getHostAddresses());
if (probableMasterHost != null) {
loopAddresses.remove(probableMasterHost);
AuroraProtocol.searchProbableMaster(listener, probableMasterHost, blacklist, searchFilter);
- log.finest("locks -4: "+protocol.getProxy().lock.getReadHoldCount() + " "+protocol.getProxy().lock.getWriteHoldCount());
if (!searchFilter.isSearchForMaster()) return;
}
} else {
@@ -196,7 +191,7 @@ public static void loop(AuroraListener listener, final List address
} catch (QueryException e) {
lastQueryException = e;
blacklist.put(protocol.getHostAddress(), System.currentTimeMillis());
- if (log.isLoggable(Level.FINE)) log.fine("Could not connect to " + protocol.getHostAddress() + " searching: " + searchFilter + " error: " + e.getMessage());
+ if (log.isDebugEnabled()) log.debug("Could not connect to " + protocol.getHostAddress() + " searching: " + searchFilter + " error: " + e.getMessage());
}
if (!searchFilter.isSearchForMaster() && !searchFilter.isSearchForSlave()) return;
diff --git a/src/main/java/org/mariadb/jdbc/internal/mysql/FailoverProxy.java b/src/main/java/org/mariadb/jdbc/internal/mysql/FailoverProxy.java
index 08a379b98..3db13ee0c 100644
--- a/src/main/java/org/mariadb/jdbc/internal/mysql/FailoverProxy.java
+++ b/src/main/java/org/mariadb/jdbc/internal/mysql/FailoverProxy.java
@@ -52,16 +52,18 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
import org.mariadb.jdbc.internal.SQLExceptionMapper;
import org.mariadb.jdbc.internal.common.QueryException;
import org.mariadb.jdbc.internal.mysql.listener.Listener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.sql.SQLException;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.logging.Logger;
+
public class FailoverProxy implements InvocationHandler {
- private final static Logger log = Logger.getLogger(FailoverProxy.class.getName());
+ private final static Logger log = LoggerFactory.getLogger(FailoverProxy.class);
public final static String METHOD_IS_EXPLICIT_CLOSED = "isExplicitClosed";
public final static String METHOD_GET_OPTIONS = "getOptions";
diff --git a/src/main/java/org/mariadb/jdbc/internal/mysql/MastersSlavesProtocol.java b/src/main/java/org/mariadb/jdbc/internal/mysql/MastersSlavesProtocol.java
index 6806f902e..11aa1925a 100644
--- a/src/main/java/org/mariadb/jdbc/internal/mysql/MastersSlavesProtocol.java
+++ b/src/main/java/org/mariadb/jdbc/internal/mysql/MastersSlavesProtocol.java
@@ -54,16 +54,15 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
import org.mariadb.jdbc.internal.common.QueryException;
import org.mariadb.jdbc.internal.mysql.listener.impl.MastersSlavesListener;
import org.mariadb.jdbc.internal.mysql.listener.tools.SearchFilter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.*;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.logging.Level;
-import java.util.logging.Logger;
public class MastersSlavesProtocol extends MySQLProtocol {
- private static Logger log = Logger.getLogger(MastersSlavesProtocol.class.getName());
-
+ private final static Logger log = LoggerFactory.getLogger(MastersSlavesProtocol.class);
boolean masterConnection = false;
boolean mustBeMasterConnection = false;
@@ -82,8 +81,8 @@ public MastersSlavesProtocol(final JDBCUrl url, final ReentrantReadWriteLock loc
* @throws QueryException if not found
*/
public static void loop(MastersSlavesListener listener, final List addresses, Map blacklist, SearchFilter searchFilter) throws QueryException {
- if (log.isLoggable(Level.FINE)) {
- log.fine("searching for master:" + searchFilter.isSearchForMaster() + " replica:" + searchFilter.isSearchForSlave() + " addresses:" + addresses );
+ if (log.isDebugEnabled()) {
+ log.debug("searching for master:" + searchFilter.isSearchForMaster() + " replica:" + searchFilter.isSearchForSlave() + " addresses:" + addresses);
}
MastersSlavesProtocol protocol;
@@ -101,15 +100,12 @@ public static void loop(MastersSlavesListener listener, final List
protocol.setHostAddress(loopAddresses.get(0));
loopAddresses.remove(0);
- if (log.isLoggable(Level.FINE)) log.fine("trying to connect to " + protocol.getHostAddress());
- log.finest("log **1 " + protocol.getProxy().lock.getReadLockCount()+ " " + protocol.getProxy().lock.getWriteHoldCount());
+ if (log.isDebugEnabled()) log.debug("trying to connect to " + protocol.getHostAddress());
protocol.connect();
- log.finest("log **2 " + protocol.getProxy().lock.getReadLockCount()+ " " + protocol.getProxy().lock.getWriteHoldCount());
blacklist.remove(protocol.getHostAddress());
- if (log.isLoggable(Level.FINE)) log.fine("connected to " + (protocol.isMasterConnection()?"primary ":"replica ") + protocol.getHostAddress());
+ if (log.isDebugEnabled()) log.debug("connected to " + (protocol.isMasterConnection()?"primary ":"replica ") + protocol.getHostAddress());
- log.finest("log **3 " + protocol.getProxy().lock.getReadLockCount()+ " " + protocol.getProxy().lock.getWriteHoldCount());
if (searchFilter.isSearchForMaster() && protocol.isMasterConnection()) {
if (foundMaster(listener, protocol, searchFilter)) return;
} else if (searchFilter.isSearchForSlave() && !protocol.isMasterConnection()) {
@@ -117,12 +113,11 @@ public static void loop(MastersSlavesListener listener, final List
} else {
protocol.close();
}
- log.finest("log **4 " + protocol.getProxy().lock.getReadLockCount()+ " " + protocol.getProxy().lock.getWriteHoldCount());
} catch (QueryException e) {
lastQueryException = e;
blacklist.put(protocol.getHostAddress(), System.currentTimeMillis());
- if (log.isLoggable(Level.FINE)) log.fine("Could not connect to " + protocol.getHostAddress() + " searching: " + searchFilter + " error: " + e.getMessage());
+ if (log.isDebugEnabled()) log.debug("Could not connect to " + protocol.getHostAddress() + " searching: " + searchFilter + " error: " + e.getMessage());
}
if (!searchFilter.isSearchForMaster() && !searchFilter.isSearchForSlave()) return;
diff --git a/src/main/java/org/mariadb/jdbc/internal/mysql/MySQLProtocol.java b/src/main/java/org/mariadb/jdbc/internal/mysql/MySQLProtocol.java
index 44500278c..314ea8dd1 100644
--- a/src/main/java/org/mariadb/jdbc/internal/mysql/MySQLProtocol.java
+++ b/src/main/java/org/mariadb/jdbc/internal/mysql/MySQLProtocol.java
@@ -68,6 +68,8 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
import org.mariadb.jdbc.internal.mysql.listener.tools.SearchFilter;
import org.mariadb.jdbc.internal.mysql.packet.MySQLGreetingReadPacket;
import org.mariadb.jdbc.internal.mysql.packet.commands.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.net.SocketFactory;
import javax.net.ssl.*;
@@ -86,10 +88,6 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
import java.sql.Connection;
import java.util.*;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-
class MyX509TrustManager implements X509TrustManager {
boolean trustServerCeritifcate;
@@ -154,7 +152,8 @@ public X509Certificate[] getAcceptedIssuers() {
}
public class MySQLProtocol implements Protocol {
- private final static Logger log = Logger.getLogger(MySQLProtocol.class.getName());
+
+ private final static Logger log = LoggerFactory.getLogger(MySQLProtocol.class);
protected final ReentrantReadWriteLock lock;
private boolean connected = false;
private boolean explicitClosed = false;
@@ -235,7 +234,7 @@ private void connect(String host, int port) throws QueryException, IOException{
try {
socketFactory = (SocketFactory) (Class.forName(socketFactoryName).newInstance());
} catch (Exception sfex){
- log.fine("Failed to create socket factory " + socketFactoryName);
+ log.debug("Failed to create socket factory " + socketFactoryName);
socketFactory = SocketFactory.getDefault();
}
} else {
@@ -270,7 +269,7 @@ private void connect(String host, int port) throws QueryException, IOException{
if (jdbcUrl.getOptions().tcpSndBuf != null) socket.setSendBufferSize(jdbcUrl.getOptions().tcpSndBuf);
if (jdbcUrl.getOptions().tcpAbortiveClose) socket.setSoLinger(true, 0);
} catch (Exception e) {
- if (log.isLoggable(Level.FINE))log.fine("Failed to set socket option: " + e.getLocalizedMessage());
+ if (log.isDebugEnabled())log.debug("Failed to set socket option: " + e.getLocalizedMessage());
}
// Bind the socket to a particular interface if the connection property
@@ -645,8 +644,8 @@ public boolean shouldReconnectWithoutProxy() {
* @throws QueryException if not found
*/
public static void loop(Listener listener, final List addresses, Map blacklist, SearchFilter searchFilter) throws QueryException {
- if (log.isLoggable(Level.FINE)) {
- log.fine("searching for master:" + searchFilter.isSearchForMaster() + " replica:" + searchFilter.isSearchForSlave() + " addresses:" + addresses );
+ if (log.isDebugEnabled()) {
+ log.debug("searching for master:" + searchFilter.isSearchForMaster() + " replica:" + searchFilter.isSearchForSlave() + " addresses:" + addresses);
}
MySQLProtocol protocol;
@@ -663,16 +662,16 @@ public static void loop(Listener listener, final List addresses, Ma
protocol.setHostAddress(loopAddresses.get(0));
loopAddresses.remove(0);
- if (log.isLoggable(Level.FINE)) log.fine("trying to connect to " + protocol.getHostAddress());
+ if (log.isDebugEnabled()) log.debug("trying to connect to " + protocol.getHostAddress());
protocol.connect();
blacklist.remove(protocol.getHostAddress());
- if (log.isLoggable(Level.FINE)) log.fine("connected to primary " + protocol.getHostAddress());
+ if (log.isDebugEnabled()) log.debug("connected to primary " + protocol.getHostAddress());
listener.foundActiveMaster(protocol);
return;
} catch (QueryException e) {
blacklist.put(protocol.getHostAddress(), System.currentTimeMillis());
- if (log.isLoggable(Level.FINE)) log.fine("Could not connect to " + protocol.getHostAddress() + " searching: " + searchFilter + " error: " + e.getMessage());
+ if (log.isDebugEnabled()) log.debug("Could not connect to " + protocol.getHostAddress() + " searching: " + searchFilter + " error: " + e.getMessage());
lastQueryException = e;
}
@@ -747,7 +746,7 @@ protected static void close(PacketFetcher fetcher, PacketOutputStream packetOutp
try {
socket.close();
} catch (IOException e) {
- log.warning("Could not close socket");
+ log.warn("Could not close socket");
}
}
}
@@ -771,11 +770,11 @@ public void close() {
/* eat exception */
}
try {
- if (log.isLoggable(Level.FINEST)) log.finest("Closing connection " + currentHost);
+ if (log.isTraceEnabled()) log.trace("Closing connection " + currentHost);
close(packetFetcher, writer, socket);
} catch (Exception e) {
// socket is closed, so it is ok to ignore exception
- log.fine("got exception " + e + " while closing connection");
+ log.debug("got exception " + e + " while closing connection");
} finally {
this.connected = false;
@@ -821,7 +820,7 @@ private SelectQueryResult createQueryResult(final ResultSetPacket packet, boolea
@Override
public void setCatalog(final String database) throws QueryException {
lock.writeLock().lock();
- log.finest("Selecting db " + database);
+ if (log.isTraceEnabled()) log.trace("Selecting db " + database);
final SelectDBPacket packet = new SelectDBPacket(database);
try {
packet.send(writer);
@@ -903,7 +902,7 @@ public boolean ping() throws QueryException {
final MySQLPingPacket pingPacket = new MySQLPingPacket();
try {
pingPacket.send(writer);
- if (log.isLoggable(Level.FINEST))log.finest("Sent ping packet");
+ if (log.isTraceEnabled())log.trace("Sent ping packet");
final RawPacket rawPacket = packetFetcher.getRawPacket();
return ResultPacketFactory.createResultPacket(rawPacket).getResultType() == ResultPacket.ResultType.OK;
} catch (IOException e) {
@@ -939,7 +938,7 @@ public QueryResult getResult(List dQueries, boolean streaming) throws Que
InputStream is;
if (localInfileInputStream == null) {
LocalInfilePacket localInfilePacket = (LocalInfilePacket) resultPacket;
- if (log.isLoggable(Level.FINEST)) log.finest("sending local file " + localInfilePacket.getFileName());
+ if (log.isTraceEnabled()) log.trace("sending local file " + localInfilePacket.getFileName());
String localInfile = localInfilePacket.getFileName();
try {
@@ -977,9 +976,9 @@ public QueryResult getResult(List dQueries, boolean streaming) throws Que
this.hasWarnings = false;
ErrorPacket ep = (ErrorPacket) resultPacket;
if (dQueries != null && dQueries.size() == 1) {
- log.warning("Could not execute query " + dQueries.get(0) + ": " + ((ErrorPacket) resultPacket).getMessage());
+ log.warn("Could not execute query " + dQueries.get(0) + ": " + ((ErrorPacket) resultPacket).getMessage());
} else {
- log.warning("Got error from server: " + ((ErrorPacket) resultPacket).getMessage());
+ log.warn("Got error from server: " + ((ErrorPacket) resultPacket).getMessage());
}
throw new QueryException(ep.getMessage(), ep.getErrorNumber(), ep.getSqlState());
@@ -992,7 +991,7 @@ public QueryResult getResult(List dQueries, boolean streaming) throws Que
okpacket.getWarnings(),
okpacket.getMessage(),
okpacket.getInsertId());
- if (log.isLoggable(Level.FINEST)) log.finest("OK, " + okpacket.getAffectedRows());
+ if (log.isTraceEnabled()) log.trace("OK, " + okpacket.getAffectedRows());
return updateResult;
case RESULTSET:
this.hasWarnings = false;
@@ -1007,7 +1006,7 @@ public QueryResult getResult(List dQueries, boolean streaming) throws Que
e);
}
default:
- log.severe("Could not parse result..." + resultPacket.getResultType());
+ log.error("Could not parse result..." + resultPacket.getResultType());
throw new QueryException("Could not parse result", (short) -1, SQLExceptionMapper.SQLStates.INTERRUPTED_EXCEPTION.getSqlState());
}
diff --git a/src/main/java/org/mariadb/jdbc/internal/mysql/listener/AbstractMastersListener.java b/src/main/java/org/mariadb/jdbc/internal/mysql/listener/AbstractMastersListener.java
index 952bbeb49..56ace7b5d 100644
--- a/src/main/java/org/mariadb/jdbc/internal/mysql/listener/AbstractMastersListener.java
+++ b/src/main/java/org/mariadb/jdbc/internal/mysql/listener/AbstractMastersListener.java
@@ -59,6 +59,8 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
import org.mariadb.jdbc.internal.mysql.HandleErrorResult;
import org.mariadb.jdbc.internal.mysql.Protocol;
import org.mariadb.jdbc.internal.mysql.listener.tools.SearchFilter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -71,11 +73,10 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+
public abstract class AbstractMastersListener implements Listener {
- private final static Logger log = Logger.getLogger(AbstractMastersListener.class.getName());
+ private final static Logger log = LoggerFactory.getLogger(AbstractMastersListener.class);
/* =========================== Failover variables ========================================= */
public final JDBCUrl jdbcUrl;
@@ -118,7 +119,7 @@ public Map getBlacklist() {
public HandleErrorResult handleFailover(Method method, Object[] args) throws Throwable {
if (explicitClosed) throw new QueryException("Connection has been closed !");
if (setMasterHostFail()) {
- log.warning("SQL Primary node [" + this.currentProtocol.getHostAddress().toString() + "] connection fail ");
+ log.warn("SQL Primary node [" + this.currentProtocol.getHostAddress().toString() + "] connection fail ");
addToBlacklist(currentProtocol.getHostAddress());
}
return primaryFail(method, args);
@@ -130,7 +131,7 @@ public HandleErrorResult handleFailover(Method method, Object[] args) throws Thr
*/
public void addToBlacklist(HostAddress hostAddress) {
if (hostAddress != null) {
- if (log.isLoggable(Level.FINE))log.finest("host " + hostAddress+" added to blacklist");
+ if (log.isTraceEnabled())log.trace("host " + hostAddress+" added to blacklist");
blacklist.put(hostAddress, System.currentTimeMillis());
}
}
@@ -143,7 +144,7 @@ public void resetOldsBlackListHosts() {
Set currentBlackListkeys = new HashSet(blacklist.keySet());
for (HostAddress blackListHost : currentBlackListkeys) {
if (blacklist.get(blackListHost) < currentTime - jdbcUrl.getOptions().loadBalanceBlacklistTimeout * 1000) {
- if (log.isLoggable(Level.FINE)) log.finest("host " + blackListHost+" remove of blacklist");
+ if (log.isTraceEnabled()) log.trace("host " + blackListHost+" remove of blacklist");
blacklist.remove(blackListHost);
}
}
@@ -159,13 +160,13 @@ protected void resetMasterFailoverData() {
protected class FailLoop implements Runnable {
Listener listener;
public FailLoop(Listener listener) {
- log.finest("launched FailLoop");
+ log.trace("launched FailLoop");
this.listener = listener;
}
public void run() {
if (hasHostFail()) {
- if (log.isLoggable(Level.FINEST)) log.finest("failLoop , listener.shouldReconnect() : "+listener.shouldReconnect());
+ if (log.isTraceEnabled()) log.trace("failLoop , listener.shouldReconnect() : "+listener.shouldReconnect());
if (listener.shouldReconnect()) {
try {
if (currentConnectionAttempts.get() >= jdbcUrl.getOptions().failoverLoopRetries)
@@ -176,18 +177,18 @@ public void run() {
//reconnection done !
stopFailover();
} catch (Exception e) {
- log.log(Level.FINEST, "FailLoop search connection failed", e);
+ log.trace("FailLoop search connection failed", e);
}
} else {
if (currentConnectionAttempts.get() > jdbcUrl.getOptions().retriesAllDown) {
- log.fine("stopping failover after too many attemps ("+currentConnectionAttempts+")");
+ if (log.isDebugEnabled()) log.debug("stopping failover after too many attemps ("+currentConnectionAttempts+")");
stopFailover();
}
}
} else {
stopFailover();
}
- log.finest("end launched FailLoop");
+ log.trace("end launched FailLoop");
}
}
@@ -199,7 +200,7 @@ protected void setSessionReadOnly(boolean readOnly) throws QueryException {
protected void stopFailover() {
if (isLooping.compareAndSet(true, false)) {
- log.finest("stopping failover");
+ log.trace("stopping failover");
if (scheduledFailover!=null)scheduledFailover.cancel(false);
}
}
@@ -326,10 +327,6 @@ public int getRetriesAllDown() {
return jdbcUrl.getOptions().retriesAllDown;
}
- public int getInitialTimeout() {
- return jdbcUrl.getOptions().initialTimeout;
- }
-
public boolean isAutoReconnect() {
return jdbcUrl.getOptions().autoReconnect;
}
diff --git a/src/main/java/org/mariadb/jdbc/internal/mysql/listener/AbstractMastersSlavesListener.java b/src/main/java/org/mariadb/jdbc/internal/mysql/listener/AbstractMastersSlavesListener.java
index d0f78a12e..ca1588cfe 100644
--- a/src/main/java/org/mariadb/jdbc/internal/mysql/listener/AbstractMastersSlavesListener.java
+++ b/src/main/java/org/mariadb/jdbc/internal/mysql/listener/AbstractMastersSlavesListener.java
@@ -55,15 +55,17 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
import org.mariadb.jdbc.internal.mysql.HandleErrorResult;
import org.mariadb.jdbc.internal.mysql.Protocol;
import org.mariadb.jdbc.internal.mysql.listener.tools.SearchFilter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.lang.reflect.Method;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
-import java.util.logging.Logger;
+
public abstract class AbstractMastersSlavesListener extends AbstractMastersListener {
- private final static Logger log = Logger.getLogger(AbstractMastersSlavesListener.class.getName());
+ private final static Logger log = LoggerFactory.getLogger(AbstractMastersSlavesListener.class);
/* =========================== Failover variables ========================================= */
private AtomicLong secondaryHostFailTimestamp = new AtomicLong();
@@ -79,14 +81,14 @@ public HandleErrorResult handleFailover(Method method, Object[] args) throws Thr
if (explicitClosed) throw new QueryException("Connection has been closed !");
if (currentProtocol.mustBeMasterConnection()) {
if (setMasterHostFail()) {
- log.warning("SQL Primary node [" + this.currentProtocol.getHostAddress().toString() + "] connection fail ");
+ log.warn("SQL Primary node [" + this.currentProtocol.getHostAddress().toString() + "] connection fail ");
addToBlacklist(currentProtocol.getHostAddress());
if (FailoverProxy.METHOD_EXECUTE_QUERY.equals(method.getName())) queriesSinceFailover.incrementAndGet();
}
return primaryFail(method, args);
} else {
if (setSecondaryHostFail()) {
- log.warning("SQL Secondary node [" + this.currentProtocol.getHostAddress().toString() + "] connection fail ");
+ log.warn("SQL Secondary node [" + this.currentProtocol.getHostAddress().toString() + "] connection fail ");
addToBlacklist(currentProtocol.getHostAddress());
if (FailoverProxy.METHOD_EXECUTE_QUERY.equals(method.getName())) queriesSinceFailover.incrementAndGet();
}
diff --git a/src/main/java/org/mariadb/jdbc/internal/mysql/listener/Listener.java b/src/main/java/org/mariadb/jdbc/internal/mysql/listener/Listener.java
index 313bb4f59..19cc559cd 100644
--- a/src/main/java/org/mariadb/jdbc/internal/mysql/listener/Listener.java
+++ b/src/main/java/org/mariadb/jdbc/internal/mysql/listener/Listener.java
@@ -78,7 +78,6 @@ public interface Listener {
void syncConnection(Protocol from, Protocol to) throws QueryException;
JDBCUrl getJdbcUrl();
void throwFailoverMessage(QueryException queryException, boolean reconnected) throws QueryException;
- int getInitialTimeout();
boolean isAutoReconnect();
int getRetriesAllDown();
boolean isExplicitClosed();
diff --git a/src/main/java/org/mariadb/jdbc/internal/mysql/listener/impl/AuroraListener.java b/src/main/java/org/mariadb/jdbc/internal/mysql/listener/impl/AuroraListener.java
index 38326a443..157846bb0 100644
--- a/src/main/java/org/mariadb/jdbc/internal/mysql/listener/impl/AuroraListener.java
+++ b/src/main/java/org/mariadb/jdbc/internal/mysql/listener/impl/AuroraListener.java
@@ -56,17 +56,18 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
import org.mariadb.jdbc.internal.common.queryresults.SelectQueryResult;
import org.mariadb.jdbc.internal.mysql.*;
import org.mariadb.jdbc.internal.mysql.listener.tools.SearchFilter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.TimeUnit;
-import java.util.logging.Level;
-import java.util.logging.Logger;
public class AuroraListener extends MastersSlavesListener {
- private final static Logger log = Logger.getLogger(AuroraListener.class.getName());
+ private final static Logger log = LoggerFactory.getLogger(AuroraListener.class);
+
public AuroraListener(JDBCUrl jdbcUrl) {
super(jdbcUrl);
@@ -82,7 +83,7 @@ public void initializeConnection() throws QueryException {
try {
reconnectFailedConnection(new SearchFilter(true, true, true));
} catch (QueryException e) {
- log.log(Level.FINEST, "initializeConnection failed", e);
+ log.debug("initializeConnection failed", e);
checkInitialConnection();
throw e;
}
@@ -98,7 +99,7 @@ public void initializeConnection() throws QueryException {
*/
@Override
public void reconnectFailedConnection(SearchFilter searchFilter) throws QueryException {
- if (log.isLoggable(Level.FINEST)) log.finest("search connection searchFilter=" + searchFilter);
+ if (log.isTraceEnabled()) log.trace("search connection searchFilter=" + searchFilter);
currentConnectionAttempts.incrementAndGet();
resetOldsBlackListHosts();
@@ -125,13 +126,13 @@ public void reconnectFailedConnection(SearchFilter searchFilter) throws QueryExc
//loopAddress.add(secondaryProtocol.getHostAddress());
}
if (isMasterHostFail()) {
- log.fine("searching probableMaster");
+ log.debug("searching probableMaster");
HostAddress probableMaster = searchByStartName(secondaryProtocol, loopAddress);
if (probableMaster != null) {
loopAddress.remove(probableMaster);
loopAddress.add(0, probableMaster);
- } else if (log.isLoggable(Level.FINEST)) log.finest("probableMaster not found");
+ } else if (log.isTraceEnabled()) log.trace("probableMaster not found");
}
}
@@ -162,17 +163,17 @@ public HostAddress searchByStartName(Protocol secondaryProtocol, List 0) {
- log.fine("new primary node [" + newMasterProtocol.getHostAddress().toString() + "] connection established after " + (System.currentTimeMillis() - getMasterHostFailTimestamp()));
+ log.debug("new primary node [" + newMasterProtocol.getHostAddress().toString() + "] connection established after " + (System.currentTimeMillis() - getMasterHostFailTimestamp()));
} else
- log.fine("new primary node [" + newMasterProtocol.getHostAddress().toString() + "] connection established");
+ log.debug("new primary node [" + newMasterProtocol.getHostAddress().toString() + "] connection established");
}
resetMasterFailoverData();
if (!isSecondaryHostFail()) stopFailover();
} finally {
proxy.lock.writeLock().unlock();
- log.finest("log $$3 " + proxy.lock.getReadLockCount()+ " " + proxy.lock.getWriteHoldCount());
-
}
}
@@ -285,7 +281,7 @@ public void foundActiveSecondary(Protocol newSecondaryProtocol) {
try {
if (secondaryProtocol != null && !secondaryProtocol.isClosed()) secondaryProtocol.close();
- log.finest("found active secondary connection");
+ log.trace("found active secondary connection");
this.secondaryProtocol = newSecondaryProtocol;
//if asked to be on read only connection, switching to this new connection
@@ -293,16 +289,16 @@ public void foundActiveSecondary(Protocol newSecondaryProtocol) {
try {
syncConnection(currentProtocol, this.secondaryProtocol);
} catch (Exception e) {
- log.log(Level.FINE, "Some error append during connection parameter synchronisation : ", e);
+ log.debug("Some error append during connection parameter synchronisation : ", e);
}
currentProtocol = this.secondaryProtocol;
}
- if (log.isLoggable(Level.FINE)) {
+ if (log.isDebugEnabled()) {
if (getSecondaryHostFailTimestamp() > 0) {
- log.fine("new active secondary node [" + newSecondaryProtocol.getHostAddress().toString() + "] connection established after " + (System.currentTimeMillis() - getSecondaryHostFailTimestamp()));
+ log.debug("new active secondary node [" + newSecondaryProtocol.getHostAddress().toString() + "] connection established after " + (System.currentTimeMillis() - getSecondaryHostFailTimestamp()));
} else
- log.fine("new active secondary node [" + newSecondaryProtocol.getHostAddress().toString() + "] connection established");
+ log.debug("new active secondary node [" + newSecondaryProtocol.getHostAddress().toString() + "] connection established");
}
resetSecondaryFailoverData();
@@ -320,7 +316,7 @@ public void foundActiveSecondary(Protocol newSecondaryProtocol) {
*/
@Override
public void switchReadOnlyConnection(Boolean mustBeReadOnly) throws QueryException {
- if (log.isLoggable(Level.FINEST)) log.fine("switching to mustBeReadOnly = " + mustBeReadOnly + " mode");
+ if (log.isTraceEnabled()) log.trace("switching to mustBeReadOnly = " + mustBeReadOnly + " mode");
if (mustBeReadOnly != currentReadOnlyAsked.get() && currentProtocol.inTransaction()) {
throw new QueryException("Trying to set to read-only mode during a transaction");
@@ -333,16 +329,16 @@ public void switchReadOnlyConnection(Boolean mustBeReadOnly) throws QueryExcepti
proxy.lock.writeLock().lock();
try {
- log.finest("switching to secondary connection");
+ log.trace("switching to secondary connection");
syncConnection(this.masterProtocol, this.secondaryProtocol);
currentProtocol = this.secondaryProtocol;
setSessionReadOnly(true);
- log.finest("current connection is now secondary");
+ log.trace("current connection is now secondary");
return;
} catch (QueryException e) {
- log.log(Level.FINEST, "switching to secondary connection failed", e);
+ log.trace("switching to secondary connection failed", e);
if (setSecondaryHostFail()) {
addToBlacklist(secondaryProtocol.getHostAddress());
}
@@ -360,15 +356,15 @@ public void switchReadOnlyConnection(Boolean mustBeReadOnly) throws QueryExcepti
proxy.lock.writeLock().lock();
try {
- log.finest("switching to master connection");
+ log.trace("switching to master connection");
syncConnection(this.secondaryProtocol, this.masterProtocol);
currentProtocol = this.masterProtocol;
- log.fine("current connection is now master");
+ log.debug("current connection is now master");
return;
} catch (QueryException e) {
- log.log(Level.FINE, "switching to master connection failed", e);
+ log.debug("switching to master connection failed", e);
if (setMasterHostFail()) {
addToBlacklist(masterProtocol.getHostAddress());
}
@@ -379,7 +375,7 @@ public void switchReadOnlyConnection(Boolean mustBeReadOnly) throws QueryExcepti
if (jdbcUrl.getOptions().autoReconnect) {
reconnectFailedConnection(new SearchFilter(false, true, false, true));
//connection established, no need to send Exception !
- log.finest("switching to master connection");
+ log.trace("switching to master connection");
proxy.lock.writeLock().lock();
try {
syncConnection(this.secondaryProtocol, this.masterProtocol);
@@ -387,7 +383,7 @@ public void switchReadOnlyConnection(Boolean mustBeReadOnly) throws QueryExcepti
} finally {
proxy.lock.writeLock().unlock();
}
- log.fine("current connection is now master");
+ log.debug("current connection is now master");
return;
}
launchFailLoopIfNotlaunched(false);
@@ -411,8 +407,8 @@ public HandleErrorResult primaryFail(Method method, Object[] args) throws Throwa
//try to reconnect automatically only time before looping
try {
if (masterProtocol != null && masterProtocol.isConnected() && masterProtocol.ping()) {
- if (log.isLoggable(Level.FINE))
- log.fine("Primary node [" + masterProtocol.getHostAddress().toString() + "] connection re-established");
+ if (log.isDebugEnabled())
+ log.debug("Primary node [" + masterProtocol.getHostAddress().toString() + "] connection re-established");
// if in transaction cannot be sure that the last query has been received by server of not, so rollback.
if (masterProtocol.inTransaction()) {
@@ -437,7 +433,7 @@ public HandleErrorResult primaryFail(Method method, Object[] args) throws Throwa
if (!isSecondaryHostFail()) {
try {
if (this.secondaryProtocol != null && this.secondaryProtocol.ping()) {
- log.finest("switching to secondary connection");
+ log.trace("switching to secondary connection");
syncConnection(masterProtocol, this.secondaryProtocol);
proxy.lock.writeLock().lock();
try {
@@ -449,10 +445,10 @@ public HandleErrorResult primaryFail(Method method, Object[] args) throws Throwa
try {
return relaunchOperation(method, args);
} catch (Exception e) {
- log.log(Level.FINEST, "relaunchOperation failed", e);
+ log.trace("relaunchOperation failed", e);
}
return new HandleErrorResult();
- } else log.finest("ping failed on secondary");
+ } else log.trace("ping failed on secondary");
} catch (Exception e) {
if (setSecondaryHostFail()) addToBlacklist(this.secondaryProtocol.getHostAddress());
if (secondaryProtocol.isConnected()) {
@@ -463,7 +459,7 @@ public HandleErrorResult primaryFail(Method method, Object[] args) throws Throwa
proxy.lock.writeLock().unlock();
}
}
- log.log(Level.FINEST, "ping on secondary failed");
+ log.trace("ping on secondary failed");
}
}
}
@@ -502,12 +498,12 @@ public void reconnect() throws QueryException {
public HandleErrorResult secondaryFail(Method method, Object[] args) throws Throwable {
try {
if (this.secondaryProtocol != null && secondaryProtocol.isConnected() && this.secondaryProtocol.ping()) {
- if (log.isLoggable(Level.FINE))
- log.fine("Secondary node [" + this.secondaryProtocol.getHostAddress().toString() + "] connection re-established");
+ if (log.isDebugEnabled())
+ log.debug("Secondary node [" + this.secondaryProtocol.getHostAddress().toString() + "] connection re-established");
return relaunchOperation(method, args);
}
} catch (Exception e) {
- log.finest("ping fail on secondary");
+ log.trace("ping fail on secondary");
proxy.lock.writeLock().lock();
try {
secondaryProtocol.close();
@@ -522,7 +518,7 @@ public HandleErrorResult secondaryFail(Method method, Object[] args) throws Thro
try {
if (masterProtocol != null) {
this.masterProtocol.ping(); //check that master is on before switching to him
- log.finest("switching to master connection");
+ log.trace("switching to master connection");
syncConnection(secondaryProtocol, masterProtocol);
proxy.lock.writeLock().lock();
try {
@@ -534,7 +530,7 @@ public HandleErrorResult secondaryFail(Method method, Object[] args) throws Thro
return relaunchOperation(method, args); //now that we are on master, relaunched result if the result was not crashing the master
}
} catch (Exception e) {
- log.finest("ping fail on master");
+ log.trace("ping fail on master");
if (setMasterHostFail()) {
addToBlacklist(masterProtocol.getHostAddress());
if (masterProtocol.isConnected()) {
@@ -552,10 +548,10 @@ public HandleErrorResult secondaryFail(Method method, Object[] args) throws Thro
try {
reconnectFailedConnection(new SearchFilter(true, true, true, true));
if (!isSecondaryHostFail()) {
- if (log.isLoggable(Level.FINE))
- log.fine("SQL Secondary node [" + this.masterProtocol.getHostAddress().toString() + "] connection re-established");
+ if (log.isDebugEnabled())
+ log.debug("SQL Secondary node [" + this.masterProtocol.getHostAddress().toString() + "] connection re-established");
} else {
- log.finest("switching to master connection");
+ log.debug("switching to master connection");
syncConnection(this.secondaryProtocol, this.masterProtocol);
proxy.lock.writeLock().lock();
try {
@@ -584,9 +580,9 @@ public PingLoop(MastersSlavesListener listener) {
public void run() {
if (lastQueryTime + jdbcUrl.getOptions().validConnectionTimeout * 1000 < System.currentTimeMillis()) {
- log.finest("PingLoop run ");
+ log.trace("PingLoop run ");
if (!isMasterHostFail()) {
- log.finest("PingLoop run, master not seen failed");
+ log.trace("PingLoop run, master not seen failed");
boolean masterFail = false;
try {
@@ -596,12 +592,12 @@ public void run() {
masterFail = true;
}
} catch (QueryException e) {
- log.log(Level.FINEST, "PingLoop ping to master error", e);
+ log.trace("PingLoop ping to master error", e);
masterFail = true;
}
if (masterFail) {
- log.finest("PingLoop master failed -> will loop to found it");
+ log.trace("PingLoop master failed -> will loop to found it");
if (setMasterHostFail()) {
try {
listener.primaryFail(null, null);
@@ -617,7 +613,7 @@ public void run() {
public void checkIfTypeHaveChanged(SearchFilter searchFilter) throws QueryException {
if (masterProtocol.ping()) {
- log.finest("PingLoop master ping ok");
+ log.trace("PingLoop master ping ok");
}
}
diff --git a/src/test/java/org/mariadb/jdbc/BaseTest.java b/src/test/java/org/mariadb/jdbc/BaseTest.java
index 8dd4d2e24..404d94738 100644
--- a/src/test/java/org/mariadb/jdbc/BaseTest.java
+++ b/src/test/java/org/mariadb/jdbc/BaseTest.java
@@ -7,6 +7,7 @@
import org.junit.runner.Description;
import org.mariadb.jdbc.failover.BaseMultiHostTest;
import org.mariadb.jdbc.internal.mysql.Protocol;
+import org.slf4j.*;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -15,8 +16,6 @@
import java.net.UnknownHostException;
import java.sql.*;
import java.util.*;
-import java.util.logging.*;
-import java.util.logging.Formatter;
/**
* Base util class.
@@ -25,8 +24,7 @@
*/
@Ignore
public class BaseTest {
-
- protected static Logger log = Logger.getLogger("org.mariadb.jdbc");
+ protected final static Logger log = LoggerFactory.getLogger(BaseTest.class);
protected Connection connection;
protected static String connU;
protected static String connURI;
@@ -51,7 +49,7 @@ public static void beforeClassBaseTest() {
username = jdbcUrl.getUsername();
password = jdbcUrl.getPassword();
- log.fine("Properties parsed from JDBC URL - hostname: " + hostname + ", port: " + port + ", database: " + database + ", username: " + username + ", password: " + password);
+ log.debug("Properties parsed from JDBC URL - hostname: " + hostname + ", port: " + port + ", database: " + database + ", username: " + username + ", password: " + password);
setURI();
}
@@ -64,11 +62,11 @@ public void init() throws SQLException {
@Rule
public TestRule watcher = new TestWatcher() {
protected void starting(Description description) {
- log.fine("Starting test: " + description.getMethodName());
+ log.debug("Starting test: " + description.getMethodName());
}
protected void finished(Description description) {
- log.fine("finished test: " + description.getMethodName());
+ log.debug("finished test: " + description.getMethodName());
}
};
diff --git a/src/test/java/org/mariadb/jdbc/BlobTest.java b/src/test/java/org/mariadb/jdbc/BlobTest.java
index 18a873d7b..854134dbf 100644
--- a/src/test/java/org/mariadb/jdbc/BlobTest.java
+++ b/src/test/java/org/mariadb/jdbc/BlobTest.java
@@ -26,7 +26,6 @@
import static org.junit.Assert.assertTrue;
public class BlobTest extends BaseTest {
- static { Logger.getLogger("").setLevel(Level.OFF); }
@Test
public void testPosition() throws SQLException {
byte[] blobContent = new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
diff --git a/src/test/java/org/mariadb/jdbc/CallableStatementTest.java b/src/test/java/org/mariadb/jdbc/CallableStatementTest.java
index 19755448b..346310c6e 100644
--- a/src/test/java/org/mariadb/jdbc/CallableStatementTest.java
+++ b/src/test/java/org/mariadb/jdbc/CallableStatementTest.java
@@ -114,12 +114,12 @@ public void getProcedures() throws SQLException{
ResultSetMetaData md = rs.getMetaData();
for(int i = 1; i <= md.getColumnCount();i++) {
- log.fine(md.getColumnLabel(i));
+ log.debug(md.getColumnLabel(i));
}
while(rs.next()) {
for(int i = 1; i <= rs.getMetaData().getColumnCount();i++) {
- log.fine(rs.getObject(i)+ " ");
+ log.debug(rs.getObject(i)+ " ");
}
}
diff --git a/src/test/java/org/mariadb/jdbc/CatalogTest.java b/src/test/java/org/mariadb/jdbc/CatalogTest.java
index b3cfdfcfa..06ddbb165 100644
--- a/src/test/java/org/mariadb/jdbc/CatalogTest.java
+++ b/src/test/java/org/mariadb/jdbc/CatalogTest.java
@@ -10,7 +10,6 @@
import static org.junit.Assert.assertEquals;
public class CatalogTest extends BaseTest {
- static { Logger.getLogger("").setLevel(Level.FINEST); }
public CatalogTest() {
}
diff --git a/src/test/java/org/mariadb/jdbc/ConnectionPoolTest.java b/src/test/java/org/mariadb/jdbc/ConnectionPoolTest.java
index d3ed27c7e..0088bc0f5 100644
--- a/src/test/java/org/mariadb/jdbc/ConnectionPoolTest.java
+++ b/src/test/java/org/mariadb/jdbc/ConnectionPoolTest.java
@@ -206,7 +206,7 @@ public void run() {
stmt.execute("insert into t3 values('hello" + Thread.currentThread().getId() + "-" + i + "')");
conn.close();
} catch (SQLException e) {
- log.fine(e.getSQLState());
+ log.debug(e.getSQLState());
}
}
}
diff --git a/src/test/java/org/mariadb/jdbc/ConnectionTest.java b/src/test/java/org/mariadb/jdbc/ConnectionTest.java
index 01128c4a9..ac99e35c3 100644
--- a/src/test/java/org/mariadb/jdbc/ConnectionTest.java
+++ b/src/test/java/org/mariadb/jdbc/ConnectionTest.java
@@ -114,7 +114,7 @@ public void networkTimeoutTest() throws SQLException {
try {
securityManager.checkPermission(sqlPermission);
} catch (SecurityException se) {
- log.warning("test 'setNetworkTimeout' skipped due to missing policy");
+ log.warn("test 'setNetworkTimeout' skipped due to missing policy");
return;
}
}
@@ -172,7 +172,7 @@ public void checkMaxAllowedPacket() throws Throwable, SQLException, UnsupportedE
ResultSet rs = statement.executeQuery("show variables like 'max_allowed_packet'");
rs.next();
int maxAllowedPacket = rs.getInt(2);
- log.fine("max_allowed_packet DB" + maxAllowedPacket);
+ log.debug("max_allowed_packet DB" + maxAllowedPacket);
/**Create a SQL packet bigger than maxAllowedPacket**/
StringBuilder sb = new StringBuilder();
@@ -188,7 +188,7 @@ public void checkMaxAllowedPacket() throws Throwable, SQLException, UnsupportedE
statement.executeUpdate("INSERT INTO dummy VALUES " + sb.toString());
fail("The previous statement should throw an SQLException");
} catch (OutOfMemoryError e) {
- log.warning("skip test 'maxAllowedPackedExceptionIsPrettyTest' - not enough memory");
+ log.warn("skip test 'maxAllowedPackedExceptionIsPrettyTest' - not enough memory");
Assume.assumeNoException(e);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("max_allowed_packet"));
@@ -208,10 +208,10 @@ public void checkMaxAllowedPacket() throws Throwable, SQLException, UnsupportedE
preparedStatement.executeBatch();
fail("The previous statement should throw an SQLException");
} catch (OutOfMemoryError e) {
- log.warning("skip second test 'maxAllowedPackedExceptionIsPrettyTest' - not enough memory");
+ log.warn("skip second test 'maxAllowedPackedExceptionIsPrettyTest' - not enough memory");
Assume.assumeNoException(e);
} catch (SQLException e) {
- log.fine("normal SQlExeption "+e.getMessage());
+ log.debug("normal SQlExeption "+e.getMessage());
assertTrue(e.getMessage().contains("max_allowed_packet"));
} catch (Exception e) {
fail("The previous statement should throw an SQLException not a general Exception");
diff --git a/src/test/java/org/mariadb/jdbc/DataSourceTest.java b/src/test/java/org/mariadb/jdbc/DataSourceTest.java
index 38513246f..50ee2df42 100644
--- a/src/test/java/org/mariadb/jdbc/DataSourceTest.java
+++ b/src/test/java/org/mariadb/jdbc/DataSourceTest.java
@@ -107,7 +107,7 @@ public void setPortTest() throws SQLException {
ds.getConnection(username, password);
Assert.fail();
} catch (SQLException e) {
- log.fine("port error : " +e.getMessage());
+ log.debug("port error : " +e.getMessage());
}
}
diff --git a/src/test/java/org/mariadb/jdbc/DatabaseMetadataTest.java b/src/test/java/org/mariadb/jdbc/DatabaseMetadataTest.java
index 208927e72..d7f5afff5 100644
--- a/src/test/java/org/mariadb/jdbc/DatabaseMetadataTest.java
+++ b/src/test/java/org/mariadb/jdbc/DatabaseMetadataTest.java
@@ -14,7 +14,6 @@
public class DatabaseMetadataTest extends BaseTest{
- static { Logger.getLogger("").setLevel(Level.OFF); }
@Before
public void checkSupported() throws SQLException {
diff --git a/src/test/java/org/mariadb/jdbc/DateTest.java b/src/test/java/org/mariadb/jdbc/DateTest.java
index afc23aec7..3e92f4865 100644
--- a/src/test/java/org/mariadb/jdbc/DateTest.java
+++ b/src/test/java/org/mariadb/jdbc/DateTest.java
@@ -24,7 +24,6 @@
import org.junit.Test;
public class DateTest extends BaseTest{
- static { Logger.getLogger("").setLevel(Level.OFF); }
public DateTest() {
@@ -259,7 +258,7 @@ public void serverTimezone() throws Exception {
java.sql.Timestamp ts = rs.getTimestamp(1);
long differenceToGMT = ts.getTime() - now.getTime();
long diff = Math.abs(differenceToGMT - offset);
- log.fine("diff : "+diff);
+ log.trace("diff : "+diff);
assertTrue(diff < 5000); /* query take less than a second but taking in accout server and client time second diff ... */
ps = connection.prepareStatement("select utc_timestamp(), ?");
diff --git a/src/test/java/org/mariadb/jdbc/DriverTest.java b/src/test/java/org/mariadb/jdbc/DriverTest.java
index de439f2ff..dba93aa92 100644
--- a/src/test/java/org/mariadb/jdbc/DriverTest.java
+++ b/src/test/java/org/mariadb/jdbc/DriverTest.java
@@ -21,7 +21,6 @@
public class DriverTest extends BaseTest{
- static { Logger.getLogger("").setLevel(Level.OFF); }
public DriverTest() throws SQLException {
@@ -1150,7 +1149,7 @@ public void testError() throws SQLException {
rs = connection.createStatement().executeQuery(request);
rs.next();
- log.finest(String.valueOf(rs.getString(1).length()));
+ log.trace(String.valueOf(rs.getString(1).length()));
} finally {
}
}
diff --git a/src/test/java/org/mariadb/jdbc/LoadTest.java b/src/test/java/org/mariadb/jdbc/LoadTest.java
index 08df2eb5c..1e458a877 100644
--- a/src/test/java/org/mariadb/jdbc/LoadTest.java
+++ b/src/test/java/org/mariadb/jdbc/LoadTest.java
@@ -20,15 +20,15 @@ public void tm() throws SQLException {
int i;
for(i=0;i<10;i++) {
sum+=this.loadTest(drizConnection);
- log.finest(String.valueOf(i));
+ log.trace(String.valueOf(i));
}
- log.finest(String.valueOf(sum / i));
+ log.trace(String.valueOf(sum / i));
sum = 0;
for(i = 0;i<10;i++) {
sum+=this.loadTest(connection);
- log.finest(String.valueOf(i));
+ log.trace(String.valueOf(i));
}
- log.finest(String.valueOf(sum/i));
+ log.trace(String.valueOf(sum/i));
}
public long loadTest(Connection connection) throws SQLException {
@@ -76,7 +76,7 @@ public void prepareTest() throws SQLException {
ps.execute();
ps.close();
}
- log.fine(String.valueOf(System.currentTimeMillis() - startTime));
+ log.debug(String.valueOf(System.currentTimeMillis() - startTime));
stmt.executeUpdate("drop table if exists loadsofdata2");
stmt.executeUpdate("create table loadsofdata2 (id int not null primary key auto_increment, data blob) engine=innodb");
@@ -89,7 +89,7 @@ public void prepareTest() throws SQLException {
ps.execute();
ps.close();
}
- log.fine(String.valueOf(System.currentTimeMillis() - startTime));
+ log.debug(String.valueOf(System.currentTimeMillis() - startTime));
startTime=System.currentTimeMillis();
for(int i=1; i<10000; i++) {
@@ -100,7 +100,7 @@ public void prepareTest() throws SQLException {
rs.getBytes(2);
ps.close();
}
- log.fine(String.valueOf(System.currentTimeMillis() - startTime));
+ log.debug(String.valueOf(System.currentTimeMillis() - startTime));
startTime=System.currentTimeMillis();
@@ -114,7 +114,7 @@ public void prepareTest() throws SQLException {
}
- log.fine(String.valueOf(System.currentTimeMillis() - startTime));
+ log.debug(String.valueOf(System.currentTimeMillis() - startTime));
}
@@ -145,7 +145,7 @@ public void prepareManyParamsTest() throws SQLException {
}
ps.execute();
}
- log.fine(String.valueOf(System.currentTimeMillis() - startTime));
+ log.debug(String.valueOf(System.currentTimeMillis() - startTime));
stmt.executeUpdate("drop table if exists loadsofdata3");
stmt.executeUpdate("create table loadsofdata3 (id int not null primary key auto_increment,"+sb.toString()+") engine=innodb");
@@ -159,7 +159,7 @@ public void prepareManyParamsTest() throws SQLException {
ps.execute();
}
- log.fine(String.valueOf(System.currentTimeMillis() - startTime));
+ log.debug(String.valueOf(System.currentTimeMillis() - startTime));
}
@Test
@@ -170,7 +170,7 @@ public void benchPrepare() throws SQLException {
for(int i=0; i 0);
assertFalse(statement.getMoreResults());
- log.fine("basicTest end");
+ log.debug("basicTest end");
}
@Test
public void updateTest() throws SQLException {
- log.fine("updateTest begin");
+ log.debug("updateTest begin");
Statement statement = connectionMulti.createStatement();
statement.execute("update t5 set test='a " + System.currentTimeMillis() + "' where id = 2;select * from t2;");
int updateNb = statement.getUpdateCount();
- log.fine("statement.getUpdateCount() " + updateNb);
+ log.debug("statement.getUpdateCount() " + updateNb);
assertTrue(updateNb == 2);
assertTrue(statement.getMoreResults());
ResultSet rs = statement.getResultSet();
@@ -100,12 +98,12 @@ public void updateTest() throws SQLException {
}
assertTrue(count > 0);
assertFalse(statement.getMoreResults());
- log.fine("updateTest end");
+ log.debug("updateTest end");
}
@Test
public void updateTest2() throws SQLException {
- log.fine("updateTest2 begin");
+ log.debug("updateTest2 begin");
Statement statement = connectionMulti.createStatement();
statement.execute("select * from t2;update t5 set test='a " + System.currentTimeMillis() + "' where id = 2;");
ResultSet rs = statement.getResultSet();
@@ -117,14 +115,14 @@ public void updateTest2() throws SQLException {
statement.getMoreResults();
int updateNb = statement.getUpdateCount();
- log.fine("statement.getUpdateCount() " + updateNb);
+ log.debug("statement.getUpdateCount() " + updateNb);
assertEquals(2, updateNb);
- log.fine("updateTest2 end");
+ log.debug("updateTest2 end");
}
@Test
public void selectTest() throws SQLException {
- log.fine("selectTest begin");
+ log.debug("selectTest begin");
Statement statement = connectionMulti.createStatement();
statement.execute("select * from t2;select * from t1;");
ResultSet rs = statement.getResultSet();
@@ -139,12 +137,12 @@ public void selectTest() throws SQLException {
count++;
}
assertTrue(count > 0);
- log.fine("selectTest end");
+ log.debug("selectTest end");
}
@Test
public void setMaxRowsMulti() throws Exception {
- log.fine("setMaxRowsMulti begin");
+ log.debug("setMaxRowsMulti begin");
Statement st = connectionMulti.createStatement();
assertEquals(0, st.getMaxRows());
@@ -172,7 +170,7 @@ public void setMaxRowsMulti() throws Exception {
}
rs.close();
assertEquals(1, cnt);
- log.fine("setMaxRowsMulti end");
+ log.debug("setMaxRowsMulti end");
}
/**
@@ -182,17 +180,17 @@ public void setMaxRowsMulti() throws Exception {
*/
@Test
public void rewriteBatchedStatementsDisabledInsertionTest() throws SQLException {
- log.fine("rewriteBatchedStatementsDisabledInsertionTest begin");
+ log.debug("rewriteBatchedStatementsDisabledInsertionTest begin");
verifyInsertBehaviorBasedOnRewriteBatchedStatements(Boolean.FALSE, 3000);
- log.fine("rewriteBatchedStatementsDisabledInsertionTest end");
+ log.debug("rewriteBatchedStatementsDisabledInsertionTest end");
}
@Test
public void rewriteBatchedStatementsEnabledInsertionTest() throws SQLException {
- log.fine("rewriteBatchedStatementsEnabledInsertionTest begin");
+ log.debug("rewriteBatchedStatementsEnabledInsertionTest begin");
//On batch mode, single insert query will be sent to MariaDB server.
verifyInsertBehaviorBasedOnRewriteBatchedStatements(Boolean.TRUE, 1);
- log.fine("rewriteBatchedStatementsEnabledInsertionTest end");
+ log.debug("rewriteBatchedStatementsEnabledInsertionTest end");
}
private void verifyInsertBehaviorBasedOnRewriteBatchedStatements(Boolean rewriteBatchedStatements, int totalInsertCommands) throws SQLException {
@@ -247,7 +245,7 @@ private int retrieveSessionVariableFromServer(Connection tmpConnection, String v
*/
@Test
public void rewriteBatchedStatementsSemicolon() throws SQLException {
- log.fine("rewriteBatchedStatementsSemicolon begin");
+ log.debug("rewriteBatchedStatementsSemicolon begin");
// set the rewrite batch statements parameter
Properties props = new Properties();
props.setProperty("rewriteBatchedStatements", "true");
@@ -293,7 +291,7 @@ public void rewriteBatchedStatementsSemicolon() throws SQLException {
verifyInsertCount(tmpConnection, 5);
tmpConnection.commit();
} finally {
- log.fine("rewriteBatchedStatementsSemicolon end");
+ log.debug("rewriteBatchedStatementsSemicolon end");
if (tmpConnection != null) tmpConnection.close();
}
}
@@ -319,7 +317,7 @@ private PreparedStatement prepareStatementBatch(Connection tmpConnection, int si
*/
@Test
public void rewriteBatchedStatementsUpdateTest() throws SQLException {
- log.fine("rewriteBatchedStatementsUpdateTest begin");
+ log.debug("rewriteBatchedStatementsUpdateTest begin");
// set the rewrite batch statements parameter
Properties props = new Properties();
props.setProperty("rewriteBatchedStatements", "true");
@@ -349,7 +347,7 @@ public void rewriteBatchedStatementsUpdateTest() throws SQLException {
verifyUpdateCount(tmpConnection, cycles); //1000 update commande launched
assertEquals(cycles * 2, totalUpdates); // 2000 rows updates
} finally {
- log.fine("rewriteBatchedStatementsUpdateTest end");
+ log.debug("rewriteBatchedStatementsUpdateTest end");
if (tmpConnection != null) tmpConnection.close();
}
}
@@ -360,7 +358,7 @@ public void rewriteBatchedStatementsUpdateTest() throws SQLException {
*/
@Test
public void testMultipleExecuteBatch() throws SQLException {
- log.fine("testMultipleExecuteBatch begin");
+ log.debug("testMultipleExecuteBatch begin");
// set the rewrite batch statements parameter
Properties props = new Properties();
props.setProperty("rewriteBatchedStatements", "true");
@@ -391,14 +389,14 @@ public void testMultipleExecuteBatch() throws SQLException {
updateCounts = preparedStatement.executeBatch();
assertEquals(1, updateCounts.length);
} finally {
- log.fine("testMultipleExecuteBatch end");
+ log.debug("testMultipleExecuteBatch end");
if (tmpConnection != null) tmpConnection.close();
}
}
@Test
public void rewriteBatchedStatementsInsertWithDuplicateRecordsTest() throws SQLException {
- log.fine("rewriteBatchedStatementsInsertWithDuplicateRecordsTest begin");
+ log.debug("rewriteBatchedStatementsInsertWithDuplicateRecordsTest begin");
Properties props = new Properties();
props.setProperty("rewriteBatchedStatements", "true");
props.setProperty("allowMultiQueries", "true");
@@ -422,14 +420,14 @@ public void rewriteBatchedStatementsInsertWithDuplicateRecordsTest() throws SQLE
verifyInsertCount(tmpConnection, 1);
verifyUpdateCount(tmpConnection, 0);
} finally {
- log.fine("rewriteBatchedStatementsInsertWithDuplicateRecordsTest end");
+ log.debug("rewriteBatchedStatementsInsertWithDuplicateRecordsTest end");
if (tmpConnection != null) tmpConnection.close();
}
}
@Test
public void updateCountTest() throws SQLException {
- log.fine("updateCountTest begin");
+ log.debug("updateCountTest begin");
Properties props = new Properties();
props.setProperty("rewriteBatchedStatements", "true");
props.setProperty("allowMultiQueries", "true");
@@ -471,13 +469,13 @@ public void updateCountTest() throws SQLException {
sqlUpdate.addBatch();
int[] updateCounts = sqlUpdate.executeBatch();
- log.finest("updateCounts : "+updateCounts.length);
+ log.trace("updateCounts : "+updateCounts.length);
Assert.assertEquals(3, updateCounts.length);
Assert.assertEquals(1, updateCounts[0]);
Assert.assertEquals(0, updateCounts[1]);
Assert.assertEquals(2, updateCounts[2]);
} finally {
- log.fine("updateCountTest end");
+ log.debug("updateCountTest end");
if (tmpConnection != null) tmpConnection.close();
}
}
diff --git a/src/test/java/org/mariadb/jdbc/MySQLDriverTest.java b/src/test/java/org/mariadb/jdbc/MySQLDriverTest.java
index dab532a1e..58822768e 100644
--- a/src/test/java/org/mariadb/jdbc/MySQLDriverTest.java
+++ b/src/test/java/org/mariadb/jdbc/MySQLDriverTest.java
@@ -301,7 +301,7 @@ public void largePreparedQueryWriteCompress() throws SQLException {
Assert.assertTrue(rs.next());
assertEquals(rs.getString(1).length(), i);
rs.close();
- log.finest("i=" +i);
+ log.trace("i=" +i);
}
} finally {
}
diff --git a/src/test/java/org/mariadb/jdbc/ResultSetMetaDataTest.java b/src/test/java/org/mariadb/jdbc/ResultSetMetaDataTest.java
index 83a0d2840..8bd3f5e27 100644
--- a/src/test/java/org/mariadb/jdbc/ResultSetMetaDataTest.java
+++ b/src/test/java/org/mariadb/jdbc/ResultSetMetaDataTest.java
@@ -10,9 +10,6 @@
import static org.junit.Assert.assertEquals;
public class ResultSetMetaDataTest extends BaseTest {
- static {
- Logger.getLogger("").setLevel(Level.OFF);
- }
@Test
public void metaDataTest() throws SQLException {
diff --git a/src/test/java/org/mariadb/jdbc/ResultSetUnsupportedMethodsTest.java b/src/test/java/org/mariadb/jdbc/ResultSetUnsupportedMethodsTest.java
index bd0c909ba..e9e5e1f41 100644
--- a/src/test/java/org/mariadb/jdbc/ResultSetUnsupportedMethodsTest.java
+++ b/src/test/java/org/mariadb/jdbc/ResultSetUnsupportedMethodsTest.java
@@ -11,8 +11,6 @@
public class ResultSetUnsupportedMethodsTest extends BaseTest {
private ResultSet rs;
- static { Logger.getLogger("").setLevel(Level.OFF); }
-
public ResultSetUnsupportedMethodsTest() throws SQLException {
}
diff --git a/src/test/java/org/mariadb/jdbc/UnicodeTest.java b/src/test/java/org/mariadb/jdbc/UnicodeTest.java
index fdc6136f2..fb367e78d 100644
--- a/src/test/java/org/mariadb/jdbc/UnicodeTest.java
+++ b/src/test/java/org/mariadb/jdbc/UnicodeTest.java
@@ -10,7 +10,6 @@
public class UnicodeTest extends BaseTest {
-static { Logger.getLogger("").setLevel(Level.OFF); }
@Test
public void firstTest() throws SQLException {
diff --git a/src/test/java/org/mariadb/jdbc/failover/AuroraFailoverTest.java b/src/test/java/org/mariadb/jdbc/failover/AuroraFailoverTest.java
index dcb3570d1..52dee87bc 100644
--- a/src/test/java/org/mariadb/jdbc/failover/AuroraFailoverTest.java
+++ b/src/test/java/org/mariadb/jdbc/failover/AuroraFailoverTest.java
@@ -31,7 +31,7 @@ public void after() throws SQLException {
connection.close();
assureBlackList(connection);
}
- log.fine("test time : " + (System.currentTimeMillis() - testBeginTime) + "ms");
+ log.debug("test time : " + (System.currentTimeMillis() - testBeginTime) + "ms");
}
@Test
@@ -50,7 +50,7 @@ public void testErrorWriteOnReplica() throws SQLException {
Assert.assertTrue(connection.isReadOnly());
try {
stmt.execute("drop table if exists multinode4");
- log.severe("ERROR - > must not be able to write on slave --> check if you database is start with --read-only");
+ log.error("ERROR - > must not be able to write on slave --> check if you database is start with --read-only");
Assert.fail();
} catch (SQLException e) {
}
@@ -80,12 +80,12 @@ public void randomConnection() throws Throwable {
for (int i = 0; i < 20; i++) {
connection = getNewConnection(false);
int serverId = getServerId(connection);
- log.fine("master server found " + serverId);
+ log.debug("master server found " + serverId);
if (i > 0) Assert.assertTrue(masterId == serverId);
masterId = serverId;
connection.setReadOnly(true);
int replicaId = getServerId(connection);
- log.fine("++++++++++++slave server found " + replicaId);
+ log.debug("++++++++++++slave server found " + replicaId);
MutableInt count = connectionMap.get(String.valueOf(replicaId));
if (count == null) {
connectionMap.put(String.valueOf(replicaId), new MutableInt());
@@ -98,10 +98,10 @@ public void randomConnection() throws Throwable {
Assert.assertTrue(connectionMap.size() >= 2);
for (String key : connectionMap.keySet()) {
Integer connectionCount = connectionMap.get(key).get();
- log.fine(" ++++ Server " + key + " : " + connectionCount + " connections ");
+ log.debug(" ++++ Server " + key + " : " + connectionCount + " connections ");
Assert.assertTrue(connectionCount > 1);
}
- log.fine("randomConnection OK");
+ log.debug("randomConnection OK");
}
@@ -116,7 +116,7 @@ public void failoverSlaveToMaster() throws Throwable {
connection.createStatement().execute("SELECT 1");
int currentServerId = getServerId(connection);
- log.fine("masterServerId = " + masterServerId + "/currentServerId = " + currentServerId);
+ log.debug("masterServerId = " + masterServerId + "/currentServerId = " + currentServerId);
Assert.assertTrue(masterServerId == currentServerId);
Assert.assertFalse(connection.isReadOnly());
@@ -159,7 +159,7 @@ public void pingReconnectAfterRestart() throws Throwable {
boolean loop = true;
while (loop) {
if (!connection.isClosed()) {
- log.fine("reconnection with failover loop after : " + (System.currentTimeMillis() - stoppedTime) + "ms");
+ log.debug("reconnection with failover loop after : " + (System.currentTimeMillis() - stoppedTime) + "ms");
loop = false;
}
if (System.currentTimeMillis() - restartTime > 15 * 1000) Assert.fail();
@@ -204,10 +204,10 @@ public void failoverDuringSlaveSetReadOnly() throws Throwable {
public void failoverSlaveAndMasterWithoutAutoConnect() throws Throwable {
connection = getNewConnection("&retriesAllDown=1", true);
int masterServerId = getServerId(connection);
- log.fine("master server_id = " + masterServerId);
+ log.debug("master server_id = " + masterServerId);
connection.setReadOnly(true);
int firstSlaveId = getServerId(connection);
- log.fine("slave1 server_id = " + firstSlaveId);
+ log.debug("slave1 server_id = " + firstSlaveId);
stopProxy(masterServerId);
stopProxy(firstSlaveId);
@@ -226,12 +226,12 @@ public void reconnectSlaveAndMasterWithAutoConnect() throws Throwable {
//search actual server_id for master and slave
int masterServerId = getServerId(connection);
- log.fine("master server_id = " + masterServerId);
+ log.debug("master server_id = " + masterServerId);
connection.setReadOnly(true);
int firstSlaveId = getServerId(connection);
- log.fine("slave1 server_id = " + firstSlaveId);
+ log.debug("slave1 server_id = " + firstSlaveId);
stopProxy(masterServerId);
stopProxy(firstSlaveId);
@@ -239,7 +239,7 @@ public void reconnectSlaveAndMasterWithAutoConnect() throws Throwable {
//must reconnect to the second slave without error
connection.createStatement().execute("SELECT 1");
int currentSlaveId = getServerId(connection);
- log.fine("currentSlaveId server_id = " + currentSlaveId);
+ log.debug("currentSlaveId server_id = " + currentSlaveId);
Assert.assertTrue(currentSlaveId != firstSlaveId);
Assert.assertTrue(currentSlaveId != masterServerId);
}
@@ -251,12 +251,12 @@ public void failOnSlaveAndMasterWithAutoConnect() throws Throwable {
//search actual server_id for master and slave
int masterServerId = getServerId(connection);
- log.fine("master server_id = " + masterServerId);
+ log.debug("master server_id = " + masterServerId);
connection.setReadOnly(true);
int firstSlaveId = getServerId(connection);
- log.fine("slave1 server_id = " + firstSlaveId);
+ log.debug("slave1 server_id = " + firstSlaveId);
stopProxy(masterServerId);
stopProxy(firstSlaveId);
@@ -264,7 +264,7 @@ public void failOnSlaveAndMasterWithAutoConnect() throws Throwable {
//must reconnect to the second slave without error
connection.createStatement().execute("SELECT 1");
int currentSlaveId = getServerId(connection);
- log.fine("currentSlaveId server_id = " + currentSlaveId);
+ log.debug("currentSlaveId server_id = " + currentSlaveId);
Assert.assertTrue(currentSlaveId != firstSlaveId);
Assert.assertTrue(currentSlaveId != masterServerId);
}
@@ -303,7 +303,7 @@ public void checkReconnectionToMasterAfterQueryNumber() throws Throwable {
for (int i = 1; i < 10; i++) {
try {
st.execute("SELECT 1");
- log.fine("i=" + i);
+ log.debug("i=" + i);
Assert.assertTrue(connection.isReadOnly());
} catch (SQLException e) {
Assert.fail();
@@ -316,11 +316,11 @@ public void checkReconnectionToMasterAfterQueryNumber() throws Throwable {
Thread.sleep(250);
st.execute("SELECT 1");
if (!connection.isReadOnly()) {
- log.fine("reconnection with failover loop after : " + (System.currentTimeMillis() - stoppedTime) + "ms");
+ log.debug("reconnection with failover loop after : " + (System.currentTimeMillis() - stoppedTime) + "ms");
loop = false;
}
} catch (SQLException e) {
- log.fine("not reconnected ... ");
+ log.debug("not reconnected ... ");
}
if (System.currentTimeMillis() - stoppedTime > 20 * 1000) Assert.fail();
}
@@ -388,7 +388,7 @@ public void checkBackOnMasterOnSlaveFail() throws Throwable {
Thread.sleep(250);
try {
if (!connection.isReadOnly()) {
- log.fine("reconnection to master with failover loop after : " + (System.currentTimeMillis() - stoppedTime) + "ms");
+ log.debug("reconnection to master with failover loop after : " + (System.currentTimeMillis() - stoppedTime) + "ms");
loop = false;
}
} catch (SQLException e) {
@@ -432,7 +432,7 @@ public void failoverMasterWithAutoConnectAndTransaction() throws Throwable {
st.execute("insert into multinodeTransaction (id, amount) VALUE (2 , 10)");
Assert.fail();
} catch (SQLException e) {
- log.finest("normal error : " + e.getMessage());
+ log.trace("normal error : " + e.getMessage());
}
restartProxy(masterServerId);
try {
@@ -555,9 +555,9 @@ public void testAccessDeniedErrorCode() throws SQLException {
// ResultSet rs;
// stmt.execute("ALTER SYSTEM SIMULATE 100 PERCENT DISK FAILURE FOR INTERVAL 60 SECOND");
// int initMaster = getServerId(connection);
-// log.fine("master is " + initMaster);
+// log.debug("master is " + initMaster);
// FailoverProxy proxy = getProtocolFromConnection(connection).getProxy();
-// log.fine("lock : "+proxy.lock.getReadHoldCount() + " " + proxy.lock.getWriteHoldCount());
+// log.debug("lock : "+proxy.lock.getReadHoldCount() + " " + proxy.lock.getWriteHoldCount());
// long failInitTime = 0;
// long launchInit = System.currentTimeMillis();
// while (System.currentTimeMillis() - launchInit < 120000) {
@@ -573,16 +573,16 @@ public void testAccessDeniedErrorCode() throws SQLException {
// if (failInitTime != 0 && "OFF".equals(rs.getString(2))) {
// long endFailover = System.currentTimeMillis() - launchInit;
// Assert.assertTrue(initMaster != getServerId(connection));
-// log.fine("End failover after " + endFailover + " new master is " + getServerId(connection));
+// log.debug("End failover after " + endFailover + " new master is " + getServerId(connection));
// //wait 15s for others tests may not be disturb by replica restart
// Thread.sleep(15000);
// return;
// }
// } catch (SQLException e) {
-// log.fine("error : " + e.getMessage());
+// log.debug("error : " + e.getMessage());
// if (failInitTime == 0) {
// failInitTime = System.currentTimeMillis();
-// log.fine("start failover master was " + getServerId(connection));
+// log.debug("start failover master was " + getServerId(connection));
// }
// }
// }
@@ -595,7 +595,7 @@ public void testAccessDeniedErrorCode() throws SQLException {
// Statement stmt = connection.createStatement();
// stmt.execute("ALTER SYSTEM SIMULATE 100 PERCENT DISK FAILURE FOR INTERVAL 35 SECOND");
// int initMaster = getServerId(connection);
-// log.fine("master is " + initMaster);
+// log.debug("master is " + initMaster);
// long launchInit = System.currentTimeMillis();
// while (System.currentTimeMillis() - launchInit < 180000) {
// Thread.sleep(250);
@@ -604,13 +604,13 @@ public void testAccessDeniedErrorCode() throws SQLException {
// //master must change
// if (currentMaster != initMaster) {
// long endFailover = System.currentTimeMillis() - launchInit;
-// log.fine("Master automatically change after failover after " + endFailover + "ms. new master is " + currentMaster);
+// log.debug("Master automatically change after failover after " + endFailover + "ms. new master is " + currentMaster);
//
// //wait 15s for others tests may not be disturb by replica restart
// Thread.sleep(15000);
// return;
// } else {
-// log.fine("++++++++ping in testFailoverMasterPing ");
+// log.debug("++++++++ping in testFailoverMasterPing ");
// }
// }
// Assert.fail();
@@ -634,9 +634,9 @@ public void testAccessDeniedErrorCode() throws SQLException {
// if (connection2SlaveId == connection1SlaveId) connection2.close();
// }
//
-// log.fine("master is " + initMaster);
-// log.fine("connection 1 slave is " + connection1SlaveId);
-// log.fine("connection 2 slave is " + connection2SlaveId);
+// log.debug("master is " + initMaster);
+// log.debug("connection 1 slave is " + connection1SlaveId);
+// log.debug("connection 2 slave is " + connection2SlaveId);
//
// connection.setReadOnly(false);
// connection2.setReadOnly(false);
diff --git a/src/test/java/org/mariadb/jdbc/failover/BaseMultiHostTest.java b/src/test/java/org/mariadb/jdbc/failover/BaseMultiHostTest.java
index 53e4155a1..e66898182 100644
--- a/src/test/java/org/mariadb/jdbc/failover/BaseMultiHostTest.java
+++ b/src/test/java/org/mariadb/jdbc/failover/BaseMultiHostTest.java
@@ -12,13 +12,14 @@
import org.mariadb.jdbc.MySQLConnection;
import org.mariadb.jdbc.internal.common.UrlHAMode;
import org.mariadb.jdbc.internal.mysql.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.lang.reflect.Method;
import java.sql.*;
import java.util.HashMap;
import java.util.List;
-import java.util.logging.*;
/**
* Base util class.
@@ -32,7 +33,7 @@
*/
@Ignore
public class BaseMultiHostTest {
- protected static Logger log = Logger.getLogger("org.mariadb.jdbc");
+ protected final static Logger log = LoggerFactory.getLogger(BaseMultiHostTest.class);
protected static String initialGaleraUrl;
protected static String initialAuroraUrl;
@@ -58,11 +59,11 @@ public enum TestType {
@Rule
public TestRule watcher = new TestWatcher() {
protected void starting(Description description) {
- log.fine("Starting test: " + description.getMethodName());
+ log.debug("Starting test: " + description.getMethodName());
}
protected void finished(Description description) {
- log.fine("finished test: " + description.getMethodName());
+ log.debug("finished test: " + description.getMethodName());
}
};
@@ -99,7 +100,7 @@ private static String createProxies(String tmpUrl, TestType proxyType) {
try {
hostAddress = tmpJdbcUrl.getHostAddresses().get(i);
tcpProxies[i] = new TcpProxy(hostAddress.host, hostAddress.port);
- log.fine("creating socket " + proxyType+" : "+ hostAddress.host + ":" + hostAddress.port + " -> localhost:" + tcpProxies[i].getLocalPort());
+ log.debug("creating socket " + proxyType + " : " + hostAddress.host + ":" + hostAddress.port + " -> localhost:" + tcpProxies[i].getLocalPort());
sockethosts+=",address=(host=localhost)(port="+tcpProxies[i].getLocalPort()+")"+((hostAddress.type != null)?"(type="+hostAddress.type+")":"");
} catch (IOException e) {
e.printStackTrace();
@@ -161,17 +162,17 @@ public static void afterClass() throws SQLException {
}
public void stopProxy(int hostNumber, long millissecond) {
- log.fine("stopping host "+hostNumber);
+ log.debug("stopping host " + hostNumber);
proxySet.get(currentType)[hostNumber - 1].restart(millissecond);
}
public void stopProxy(int hostNumber) {
- log.fine("stopping host "+hostNumber);
+ log.debug("stopping host " + hostNumber);
proxySet.get(currentType)[hostNumber - 1].stop();
}
public void restartProxy(int hostNumber) {
- log.fine("restart host "+hostNumber);
+ log.debug("restart host " + hostNumber);
if (hostNumber != -1) proxySet.get(currentType)[hostNumber - 1].restart();
}
public void assureProxy() {
@@ -210,7 +211,7 @@ public boolean hasSuperPrivilege(Connection connection, String testName) throws
rs.close();
if (superPrivilege)
- log.fine("test '" + testName + "' skipped because user '" + username + "' has SUPER privileges");
+ log.debug("test '" + testName + "' skipped because user '" + username + "' has SUPER privileges");
return superPrivilege;
}
diff --git a/src/test/java/org/mariadb/jdbc/failover/GaleraFailoverTest.java b/src/test/java/org/mariadb/jdbc/failover/GaleraFailoverTest.java
index acd62adb0..fdb082e9c 100644
--- a/src/test/java/org/mariadb/jdbc/failover/GaleraFailoverTest.java
+++ b/src/test/java/org/mariadb/jdbc/failover/GaleraFailoverTest.java
@@ -62,7 +62,7 @@ public void randomConnection() throws Throwable {
for (int i = 0; i < 20; i++) {
connection = getNewConnection(false);
int serverId = getServerId(connection);
- log.fine("master server found " + serverId);
+ log.debug("master server found " + serverId);
MutableInt count = connectionMap.get(String.valueOf(serverId));
if (count == null) {
connectionMap.put(String.valueOf(serverId), new MutableInt());
@@ -75,10 +75,10 @@ public void randomConnection() throws Throwable {
Assert.assertTrue(connectionMap.size() >= 2);
for (String key : connectionMap.keySet()) {
Integer connectionCount = connectionMap.get(key).get();
- log.fine(" ++++ Server " + key + " : " + connectionCount + " connections ");
+ log.debug(" ++++ Server " + key + " : " + connectionCount + " connections ");
Assert.assertTrue(connectionCount > 1);
}
- log.fine("randomConnection OK");
+ log.debug("randomConnection OK");
}
@Test
@@ -100,7 +100,7 @@ public void checkStaticBlacklist() throws Throwable {
//check blacklist size
try {
Protocol protocol = getProtocolFromConnection(connection);
- log.fine("backlist size : " + protocol.getProxy().getListener().getBlacklist().size());
+ log.debug("backlist size : " + protocol.getProxy().getListener().getBlacklist().size());
Assert.assertTrue(protocol.getProxy().getListener().getBlacklist().size() == 1);
//replace proxified HostAddress by normal one
@@ -147,7 +147,7 @@ public void run() {
try {
connection2 = getNewConnection();
int otherServerId = getServerId(connection2);
- log.fine("connected to server " + otherServerId);
+ log.debug("connected to server " + otherServerId);
Assert.assertTrue(otherServerId != firstServerId);
Protocol protocol = getProtocolFromConnection(connection2);
Assert.assertTrue(blacklist.keySet().toArray()[0].equals(protocol.getProxy().getListener().getBlacklist().keySet().toArray()[0]));
@@ -171,17 +171,17 @@ public void run() {
public void testMultiHostWriteOnMaster() throws Throwable {
Assume.assumeTrue(initialGaleraUrl != null);
Connection connection = null;
- log.fine("testMultiHostWriteOnMaster begin");
+ log.debug("testMultiHostWriteOnMaster begin");
try {
connection = getNewConnection();
Statement stmt = connection.createStatement();
stmt.execute("drop table if exists multinode");
stmt.execute("create table multinode (id int not null primary key auto_increment, test VARCHAR(10))");
- log.fine("testMultiHostWriteOnMaster OK");
+ log.debug("testMultiHostWriteOnMaster OK");
} finally {
assureProxy();
assureBlackList(connection);
- log.fine("testMultiHostWriteOnMaster done");
+ log.debug("testMultiHostWriteOnMaster done");
if (connection != null) connection.close();
}
}
@@ -203,7 +203,7 @@ public void pingReconnectAfterRestart() throws Throwable {
boolean loop = true;
while (loop) {
if (!connection.isClosed()) {
- log.fine("reconnection with failover loop after : " + (System.currentTimeMillis() - stoppedTime) + "ms");
+ log.debug("reconnection with failover loop after : " + (System.currentTimeMillis() - stoppedTime) + "ms");
loop = false;
}
if (System.currentTimeMillis() - restartTime > 15 * 1000) Assert.fail();
diff --git a/src/test/java/org/mariadb/jdbc/failover/MonoServerFailoverTest.java b/src/test/java/org/mariadb/jdbc/failover/MonoServerFailoverTest.java
index 9854911e2..f266cf1c0 100644
--- a/src/test/java/org/mariadb/jdbc/failover/MonoServerFailoverTest.java
+++ b/src/test/java/org/mariadb/jdbc/failover/MonoServerFailoverTest.java
@@ -179,7 +179,7 @@ public void failoverDuringStreamStatement() throws Throwable {
try {
while (rs.next()) {
nbRead++;
- log.fine("nbRead = "+nbRead + " rs="+rs.getInt(1));
+ log.debug("nbRead = "+nbRead + " rs="+rs.getInt(1));
}
Assert.fail();
} catch (SQLException e) {
diff --git a/src/test/java/org/mariadb/jdbc/failover/ReplicationFailoverTest.java b/src/test/java/org/mariadb/jdbc/failover/ReplicationFailoverTest.java
index e5a2bcd22..fad90399b 100644
--- a/src/test/java/org/mariadb/jdbc/failover/ReplicationFailoverTest.java
+++ b/src/test/java/org/mariadb/jdbc/failover/ReplicationFailoverTest.java
@@ -33,7 +33,7 @@ public void after() throws SQLException {
assureBlackList(connection);
if (connection != null) connection.close();
- log.fine("test time : "+(System.currentTimeMillis() - testBeginTime) + "ms");
+ log.debug("test time : "+(System.currentTimeMillis() - testBeginTime) + "ms");
}
@Test
@@ -56,7 +56,7 @@ public void testErrorWriteOnSlave() throws SQLException {
Assume.assumeTrue(false);
}
stmt.execute("drop table if exists multinode4");
- log.severe("ERROR - > must not be able to write on slave ");
+ log.error("ERROR - > must not be able to write on slave ");
fail();
} catch (SQLException e) {
}
@@ -69,12 +69,12 @@ public void randomConnection() throws Throwable {
for (int i = 0; i < 20; i++) {
connection = getNewConnection("&retriesAllDown=1", false);
int serverId = getServerId(connection);
- log.fine("master server found " + serverId);
+ log.debug("master server found " + serverId);
if (i > 0) assertTrue(masterId == serverId);
masterId = serverId;
connection.setReadOnly(true);
int replicaId = getServerId(connection);
- log.fine("++++++++++++slave server found " + replicaId);
+ log.debug("++++++++++++slave server found " + replicaId);
MutableInt count = connectionMap.get(String.valueOf(replicaId));
if (count == null) {
connectionMap.put(String.valueOf(replicaId), new MutableInt());
@@ -87,7 +87,7 @@ public void randomConnection() throws Throwable {
assertTrue(connectionMap.size() >= 2);
for (String key : connectionMap.keySet()) {
Integer connectionCount = connectionMap.get(key).get();
- log.fine(" ++++ Server " + key + " : " + connectionCount + " connections ");
+ log.debug(" ++++ Server " + key + " : " + connectionCount + " connections ");
assertTrue(connectionCount > 1);
}
}
@@ -103,7 +103,7 @@ public void failoverSlaveToMaster() throws Throwable {
connection.createStatement().execute("SELECT 1");
int currentServerId = getServerId(connection);
- log.fine("masterServerId = " + masterServerId + "/currentServerId = " + currentServerId);
+ log.debug("masterServerId = " + masterServerId + "/currentServerId = " + currentServerId);
assertTrue(masterServerId == currentServerId);
assertFalse(connection.isReadOnly());
@@ -149,10 +149,10 @@ public void pingReconnectAfterFailover() throws Throwable {
while (loop) {
try {
Thread.sleep(250);
- log.fine("time : " + (System.currentTimeMillis() - stoppedTime) + "ms");
+ log.debug("time : " + (System.currentTimeMillis() - stoppedTime) + "ms");
int currentHost = getServerId(connection);
if (masterServerId == currentHost) {
- log.fine("reconnection with failover loop after : " + (System.currentTimeMillis() - stoppedTime) + "ms");
+ log.debug("reconnection with failover loop after : " + (System.currentTimeMillis() - stoppedTime) + "ms");
assertTrue((System.currentTimeMillis() - stoppedTime) > 5 * 1000);
loop = false;
}
@@ -188,10 +188,10 @@ public void failoverDuringSlaveSetReadOnly() throws Throwable {
public void changeSlave() throws Throwable {
connection = getNewConnection("&retriesAllDown=1", true);
int masterServerId = getServerId(connection);
- log.fine("master server_id = " + masterServerId);
+ log.debug("master server_id = " + masterServerId);
connection.setReadOnly(true);
int firstSlaveId = getServerId(connection);
- log.fine("slave1 server_id = " + firstSlaveId);
+ log.debug("slave1 server_id = " + firstSlaveId);
stopProxy(masterServerId);
stopProxy(firstSlaveId);
@@ -207,10 +207,10 @@ public void changeSlave() throws Throwable {
public void masterWithoutFailover() throws Throwable {
connection = getNewConnection("&retriesAllDown=1", true);
int masterServerId = getServerId(connection);
- log.fine("master server_id = " + masterServerId);
+ log.debug("master server_id = " + masterServerId);
connection.setReadOnly(true);
int firstSlaveId = getServerId(connection);
- log.fine("slave1 server_id = " + firstSlaveId);
+ log.debug("slave1 server_id = " + firstSlaveId);
connection.setReadOnly(false);
stopProxy(masterServerId);
@@ -230,12 +230,12 @@ public void failoverSlaveAndMasterWithAutoConnect() throws Throwable {
//search actual server_id for master and slave
int masterServerId = getServerId(connection);
- log.fine("master server_id = " + masterServerId);
+ log.debug("master server_id = " + masterServerId);
connection.setReadOnly(true);
int firstSlaveId = getServerId(connection);
- log.fine("slave1 server_id = " + firstSlaveId);
+ log.debug("slave1 server_id = " + firstSlaveId);
stopProxy(masterServerId);
stopProxy(firstSlaveId);
@@ -243,7 +243,7 @@ public void failoverSlaveAndMasterWithAutoConnect() throws Throwable {
//must reconnect to the second slave without error
connection.createStatement().execute("SELECT 1");
int currentSlaveId = getServerId(connection);
- log.fine("currentSlaveId server_id = " + currentSlaveId);
+ log.debug("currentSlaveId server_id = " + currentSlaveId);
assertTrue(currentSlaveId != firstSlaveId);
assertTrue(currentSlaveId != masterServerId);
}
@@ -280,7 +280,7 @@ public void checkReconnectionToMasterAfterQueryNumber() throws Throwable {
for (int i = 1; i < 10; i++) {
try {
st.execute("SELECT 1");
- log.fine("i=" + i);
+ log.debug("i=" + i);
assertTrue(connection.isReadOnly());
} catch (SQLException e) {
fail();
@@ -289,7 +289,7 @@ public void checkReconnectionToMasterAfterQueryNumber() throws Throwable {
Thread.sleep(5000);
long startTime = System.currentTimeMillis();
connection.setReadOnly(false);
- log.fine(" time = " + (System.currentTimeMillis() - startTime));
+ log.debug(" time = " + (System.currentTimeMillis() - startTime));
assertTrue(System.currentTimeMillis() - startTime < 4000);
}
@@ -357,7 +357,7 @@ public void checkBackOnMasterOnSlaveFail() throws Throwable {
Thread.sleep(250);
try {
if (!connection.isReadOnly()) {
- log.fine("reconnection to master with failover loop after : " + (System.currentTimeMillis() - stoppedTime) + "ms");
+ log.debug("reconnection to master with failover loop after : " + (System.currentTimeMillis() - stoppedTime) + "ms");
assertTrue((System.currentTimeMillis() - stoppedTime) > 10 * 1000);
loop = false;
}
diff --git a/src/test/java/org/mariadb/jdbc/failover/TcpProxy.java b/src/test/java/org/mariadb/jdbc/failover/TcpProxy.java
index 64ea86b75..1c2f0e5c7 100644
--- a/src/test/java/org/mariadb/jdbc/failover/TcpProxy.java
+++ b/src/test/java/org/mariadb/jdbc/failover/TcpProxy.java
@@ -1,16 +1,15 @@
package org.mariadb.jdbc.failover;
-import java.io.*;
-import java.net.ServerSocket;
-import java.net.Socket;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
import java.util.concurrent.Executors;
-import java.util.concurrent.RunnableScheduledFuture;
-import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
-import java.util.logging.Logger;
+
public class TcpProxy {
- protected static Logger log = Logger.getLogger("org.maria.jdbc");
+ protected final static Logger log = LoggerFactory.getLogger(TcpProxy.class);
String host;
int remoteport;
@@ -36,8 +35,10 @@ public void restart() {
Executors.newSingleThreadExecutor().execute(socket);
try {
Thread.sleep(10);
- }catch(InterruptedException e) {}
+ } catch (InterruptedException e) {
+ }
}
+
public void assureProxyOk() {
if (socket.isClosed()) {
restart();
diff --git a/src/test/java/org/mariadb/jdbc/failover/TcpProxySocket.java b/src/test/java/org/mariadb/jdbc/failover/TcpProxySocket.java
index b68f8619a..a20dc166c 100644
--- a/src/test/java/org/mariadb/jdbc/failover/TcpProxySocket.java
+++ b/src/test/java/org/mariadb/jdbc/failover/TcpProxySocket.java
@@ -1,16 +1,15 @@
package org.mariadb.jdbc.failover;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.*;
import java.net.BindException;
import java.net.ServerSocket;
import java.net.Socket;
-import java.util.concurrent.Executors;
-import java.util.concurrent.RunnableScheduledFuture;
-import java.util.concurrent.TimeUnit;
-import java.util.logging.Logger;
public class TcpProxySocket implements Runnable {
- protected static Logger log = Logger.getLogger("org.maria.jdbc");
+ protected final static Logger log = LoggerFactory.getLogger(TcpProxySocket.class);
String host;
int remoteport;
@@ -86,7 +85,7 @@ public void run() {
try {
while ((bytes_read = from_client.read(request)) != -1) {
to_server.write(request, 0, bytes_read);
- log.finest(bytes_read + "to_server--->" + new String(request, "UTF-8") + "<---");
+ log.trace(bytes_read + "to_server--->" + new String(request, "UTF-8") + "<---");
to_server.flush();
}
} catch (IOException e) {
@@ -101,7 +100,7 @@ public void run() {
while ((bytes_read = from_server.read(reply)) != -1) {
try {
Thread.sleep(1);
- log.finest(bytes_read + " to_client--->" + new String(reply, "UTF-8") + "<---");
+ log.trace(bytes_read + " to_client--->" + new String(reply, "UTF-8") + "<---");
} catch (InterruptedException e) {
e.printStackTrace();
}
diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml
new file mode 100644
index 000000000..9a12cd565
--- /dev/null
+++ b/src/test/resources/logback.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file