Skip to content

Commit

Permalink
FIR-32836: log is simplified now - no lombok in log
Browse files Browse the repository at this point in the history
  • Loading branch information
alexradzin committed May 5, 2024
1 parent 5941dff commit 7e8abd2
Show file tree
Hide file tree
Showing 54 changed files with 198 additions and 586 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ dependencies {
implementation 'net.jodah:expiringmap:0.5.11'
implementation 'org.apache.commons:commons-text:1.12.0'
implementation 'org.lz4:lz4-java:1.8.0'
implementation 'org.slf4j:jul-to-slf4j:2.0.13'

implementation fileTree(dir: 'libs', includes: ['*.jar'])

Expand Down
1 change: 0 additions & 1 deletion lombok.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
lombok.anyConstructor.addConstructorProperties = true
config.stopBubbling = true
lombok.addLombokGeneratedAnnotation = true
lombok.log.custom.declaration = com.firebolt.jdbc.log.FireboltLogger com.firebolt.jdbc.util.LoggerUtil.getLogger(NAME)
2 changes: 0 additions & 2 deletions src/integrationTest/java/integration/IntegrationTest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package integration;

import com.firebolt.jdbc.client.HttpClientConfig;
import lombok.CustomLog;
import lombok.SneakyThrows;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.TestInstance;
Expand All @@ -17,7 +16,6 @@
import static com.firebolt.jdbc.connection.FireboltConnectionUserPassword.SYSTEM_ENGINE_NAME;
import static org.junit.jupiter.api.Assertions.assertNotNull;

@CustomLog
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@Tag("common")
public abstract class IntegrationTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.firebolt.jdbc.type.FireboltDataType;
import com.firebolt.jdbc.type.array.FireboltArray;
import integration.IntegrationTest;
import lombok.CustomLog;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -27,7 +26,6 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;

@CustomLog
class PreparedStatementArrayTest extends IntegrationTest {
enum PreparedStatementValueSetter {
ARRAY {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import integration.ConnectionInfo;
import integration.IntegrationTest;
import lombok.Builder;
import lombok.CustomLog;
import lombok.EqualsAndHashCode;
import lombok.Value;
import org.junit.jupiter.api.AfterEach;
Expand All @@ -33,7 +32,6 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -51,7 +49,6 @@
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

@CustomLog
class PreparedStatementTest extends IntegrationTest {

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.firebolt.jdbc.statement.FireboltStatement;
import integration.EnvironmentCondition;
import integration.IntegrationTest;
import lombok.CustomLog;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
Expand All @@ -17,13 +16,15 @@
import java.sql.SQLException;
import java.sql.Statement;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;

import static integration.EnvironmentCondition.Attribute.databaseVersion;
import static integration.EnvironmentCondition.Comparison.GE;
import static org.junit.jupiter.api.Assertions.assertEquals;

@CustomLog
class StatementCancelTest extends IntegrationTest {
private static final Logger log = Logger.getLogger(StatementCancelTest.class.getName());

@BeforeEach
void beforeEach() {
Expand Down Expand Up @@ -91,11 +92,11 @@ private void verifyThatNoMoreRecordsAreAdded(Connection connection, String table
// data is available.
long waitForResultTime = insertTime / 2;
long waitForResultDelay = waitForResultTime / 10;
log.info("verifyThatNoMoreRecordsAreAdded insertTime={}, waitForResultTime={}", insertTime, waitForResultTime);
log.log(Level.INFO, "verifyThatNoMoreRecordsAreAdded insertTime={0}, waitForResultTime={0}", new Object[] {insertTime, waitForResultTime});
int count0;
int i = 0;
for (count0 = count(connection, tableName); i < 10; count0 = count(connection, tableName), i++) {
log.info("verifyThatNoMoreRecordsAreAdded count0={}", count0);
log.log(Level.INFO, "verifyThatNoMoreRecordsAreAdded count0={0}", count0);
if (count0 > 0) {
break;
}
Expand All @@ -108,7 +109,7 @@ private void verifyThatNoMoreRecordsAreAdded(Connection connection, String table
int count1 = count(connection, tableName);
Thread.sleep(insertTime); // waiting to see if more records are being added
int count2 = count(connection, tableName);
log.info("verifyThatNoMoreRecordsAreAdded count1={}, count2={}", count1, count2);
log.log(Level.INFO, "verifyThatNoMoreRecordsAreAdded count1={0}, count2={1}", new Object[] {count1, count2});
assertEquals(count1, count2);
}

Expand Down
2 changes: 0 additions & 2 deletions src/integrationTest/java/integration/tests/StatementTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import integration.ConnectionInfo;
import integration.IntegrationTest;
import kotlin.collections.ArrayDeque;
import lombok.CustomLog;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -42,7 +41,6 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

@CustomLog
class StatementTest extends IntegrationTest {

@BeforeEach
Expand Down
17 changes: 9 additions & 8 deletions src/integrationTest/java/integration/tests/SystemEngineTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import integration.ConnectionInfo;
import integration.EnvironmentCondition;
import integration.IntegrationTest;
import lombok.CustomLog;
import org.junit.Assert;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
Expand All @@ -33,6 +32,8 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Stream;

import static java.lang.String.format;
Expand All @@ -45,7 +46,6 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

@CustomLog
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class SystemEngineTest extends IntegrationTest {

Expand All @@ -59,12 +59,14 @@ public class SystemEngineTest extends IntegrationTest {
private static final String TABLE1 = TABLE + "_1";
private static final String TABLE2 = TABLE + "_2";

private static final Logger log = Logger.getLogger(SystemEngineTest.class.getName());

@BeforeAll
void beforeAll() {
try {
executeStatementFromFile("/statements/system/ddl.sql", getSystemEngineName());
} catch (Exception e) {
log.warn("Could not execute statement", e);
log.log(Level.WARNING, "Could not execute statement", e);
}
}

Expand All @@ -73,7 +75,7 @@ void afterAll() {
try {
executeStatementFromFile("/statements/system/cleanup.sql", getSystemEngineName());
} catch (Exception e) {
log.warn("Could not execute statement", e);
log.log(Level.WARNING, "Could not execute statement", e);
}
}

Expand Down Expand Up @@ -153,7 +155,7 @@ void useDatabase(String entityType) throws SQLException {
try (Statement statement = connection.createStatement()) {
statement.executeUpdate(query);
} catch (SQLException e) { // catch just in case to do our best to clean everything even if test has failed
log.warn("Cannot perform query {}", query, e);
log.log(Level.WARNING, "Cannot perform query " + query, e);
}
}
}
Expand Down Expand Up @@ -273,9 +275,8 @@ void shouldExecuteEngineManagementQueries() throws SQLException {
format("DROP DATABASE %s", SECOND_DATABASE_NAME)}) {
try (Statement statement = connection.createStatement()) {
statement.executeUpdate(query);
} catch (
SQLException e) { // catch just in case to do our best to clean everything even if test has failed
log.warn("Cannot perform query {}", query, e);
} catch (SQLException e) { // catch just in case to do our best to clean everything even if test has failed
log.log(Level.WARNING, "Cannot perform query " + query, e);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/integrationTest/java/integration/tests/TimeoutTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import com.firebolt.jdbc.connection.FireboltConnection;
import integration.EnvironmentCondition;
import integration.EnvironmentCondition.Comparison;
import integration.IntegrationTest;
import lombok.CustomLog;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
Expand All @@ -16,16 +14,18 @@
import java.sql.Statement;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;

import static integration.EnvironmentCondition.Attribute.databaseVersion;
import static integration.EnvironmentCondition.Comparison.GE;
import static java.lang.String.format;
import static org.junit.jupiter.api.Assertions.assertTrue;

@CustomLog
class TimeoutTest extends IntegrationTest {
private static final int MIN_TIME_SECONDS = 350;
private static final Map<Integer, Long> SERIES_SIZE = Map.of(1, 80000000000L, 2, 180000000000L);
private static final Logger log = Logger.getLogger(TimeoutTest.class.getName());
private long startTime;

@BeforeEach
Expand All @@ -37,7 +37,7 @@ void before() {
void after() {
long endTime = System.nanoTime();
long elapsedTimeSeconds = (endTime - startTime) / 1_000_000_000;
log.info("Time elapsed: {} seconds", elapsedTimeSeconds);
log.log(Level.INFO, "Time elapsed: {0} seconds", elapsedTimeSeconds);
assertTrue(elapsedTimeSeconds > MIN_TIME_SECONDS, format("Test is too short. It took %d but should take at least %d seconds", elapsedTimeSeconds, MIN_TIME_SECONDS));
}

Expand Down
2 changes: 0 additions & 2 deletions src/integrationTest/java/integration/tests/TimestampTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.firebolt.jdbc.testutils.AssertionUtil;
import integration.IntegrationTest;
import io.zonky.test.db.postgres.embedded.EmbeddedPostgres;
import lombok.CustomLog;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -37,7 +36,6 @@
import static java.sql.Types.TIMESTAMP_WITH_TIMEZONE;
import static org.junit.jupiter.api.Assertions.assertEquals;

@CustomLog
@DefaultTimeZone("UTC")
class TimestampTest extends IntegrationTest {
private static final TimeZone UTC_TZ = TimeZone.getTimeZone("UTC");
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/com/firebolt/FireboltDriver.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
package com.firebolt;

import com.firebolt.jdbc.connection.FireboltConnection;
import com.firebolt.jdbc.exception.FireboltSQLFeatureNotSupportedException;
import com.firebolt.jdbc.util.LoggerUtil;
import com.firebolt.jdbc.util.PropertyUtil;
import com.firebolt.jdbc.util.VersionUtil;
import lombok.CustomLog;

import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverPropertyInfo;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.Properties;
import java.util.logging.Logger;

@CustomLog
public class FireboltDriver implements Driver {

public static final String JDBC_FIREBOLT = "jdbc:firebolt:";
private static Logger root;
private static final Logger log;

static {
try {
java.sql.DriverManager.registerDriver(new FireboltDriver());
root = LoggerUtil.getRootLogger();
log = Logger.getLogger(FireboltDriver.class.getName());
log.info("Firebolt Driver registered");
} catch (SQLException ex) {
throw new RuntimeException("Cannot register the driver");
Expand Down Expand Up @@ -59,7 +60,7 @@ public boolean jdbcCompliant() {
}

@Override
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
throw new FireboltSQLFeatureNotSupportedException();
public Logger getParentLogger() {
return root;
}
}
9 changes: 5 additions & 4 deletions src/main/java/com/firebolt/jdbc/client/FireboltClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.firebolt.jdbc.exception.FireboltException;
import com.firebolt.jdbc.resultset.compress.LZ4InputStream;
import com.firebolt.jdbc.util.CloseableUtil;
import lombok.CustomLog;
import lombok.Getter;
import lombok.NonNull;
import okhttp3.Call;
Expand All @@ -28,6 +27,8 @@
import java.util.Map.Entry;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;

import static java.lang.String.format;
Expand All @@ -36,13 +37,13 @@
import static java.util.Optional.ofNullable;

@Getter
@CustomLog
public abstract class FireboltClient {

private static final String HEADER_AUTHORIZATION = "Authorization";
private static final String HEADER_AUTHORIZATION_BEARER_PREFIX_VALUE = "Bearer ";
private static final String HEADER_USER_AGENT = "User-Agent";
private static final String HEADER_PROTOCOL_VERSION = "Firebolt-Protocol-Version";
private static final Logger log = Logger.getLogger(FireboltClient.class.getName());
private final OkHttpClient httpClient;
private final String headerUserAgentValue;
protected final FireboltConnection connection;
Expand Down Expand Up @@ -169,7 +170,7 @@ private String extractErrorMessage(Response response, boolean isCompress) throws
try {
entityBytes = response.body() != null ? response.body().bytes() : null;
} catch (IOException e) {
log.warn("Could not parse response containing the error message from Firebolt", e);
log.log(Level.WARNING, "Could not parse response containing the error message from Firebolt", e);
String errorResponseMessage = format("Server failed to execute query%ninternal error:%n%s",
getInternalErrorWithHeadersText(response));
throw new FireboltException(errorResponseMessage, response.code(), e);
Expand All @@ -184,7 +185,7 @@ private String extractErrorMessage(Response response, boolean isCompress) throws
return new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)).lines()
.collect(Collectors.joining("\n")) + "\n";
} catch (Exception e) {
log.warn("Could not decompress error from server");
log.log(Level.WARNING, "Could not decompress error from server");
}
}
return new String(entityBytes, StandardCharsets.UTF_8);
Expand Down
14 changes: 6 additions & 8 deletions src/main/java/com/firebolt/jdbc/client/HttpClientConfig.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
package com.firebolt.jdbc.client;

import com.firebolt.jdbc.client.config.OkHttpClientCreator;
import com.firebolt.jdbc.connection.settings.FireboltProperties;
import okhttp3.OkHttpClient;

import java.io.IOException;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.util.logging.Logger;

import com.firebolt.jdbc.client.config.OkHttpClientCreator;
import com.firebolt.jdbc.connection.settings.FireboltProperties;

import lombok.CustomLog;
import okhttp3.OkHttpClient;

@CustomLog
public class HttpClientConfig {

private static final Logger log = Logger.getLogger(HttpClientConfig.class.getName());
private static OkHttpClient instance;

private HttpClientConfig() {
Expand Down
Loading

0 comments on commit 7e8abd2

Please sign in to comment.