Skip to content

Commit

Permalink
Removed tracing from YdbValidator
Browse files Browse the repository at this point in the history
  • Loading branch information
alex268 committed Oct 14, 2024
1 parent 1e83223 commit 137a037
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 59 deletions.
57 changes: 1 addition & 56 deletions jdbc/src/main/java/tech/ydb/jdbc/context/YdbValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.function.Supplier;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.google.common.base.Stopwatch;

import tech.ydb.core.Issue;
import tech.ydb.core.Result;
Expand All @@ -23,16 +19,8 @@
* @author Aleksandr Gorshenin
*/
public class YdbValidator {
@SuppressWarnings("NonConstantLogger")
private final Logger logger;
private final boolean isDebug;
private final List<Issue> issues = new ArrayList<>();

public YdbValidator(Logger logger) {
this.logger = logger;
this.isDebug = logger.isLoggable(Level.FINE);
}

public SQLWarning toSQLWarnings() {
SQLWarning firstWarning = null;
SQLWarning warning = null;
Expand Down Expand Up @@ -62,48 +50,6 @@ public void clearWarnings() {
}

public void execute(String msg, Supplier<CompletableFuture<Status>> fn) throws SQLException {
if (!isDebug) {
runImpl(msg, fn);
return;
}

logger.finest(msg);
Stopwatch sw = Stopwatch.createStarted();

try {
runImpl(msg, fn);
logger.log(Level.FINEST, "[{0}] OK ", sw.stop());
} catch (SQLException ex) {
logger.log(Level.FINE, "[{0}] {1} ", new Object[] {sw.stop(), ex.getMessage()});
throw ex;
} catch (Exception ex) {
logger.log(Level.WARNING, "ERROR ", ex);
throw ex;
}
}

public <R> R call(String msg, Supplier<CompletableFuture<Result<R>>> fn) throws SQLException {
if (!isDebug) {
return callImpl(msg, fn);
}

logger.finest(msg);
Stopwatch sw = Stopwatch.createStarted();

try {
R value = callImpl(msg, fn);
logger.log(Level.FINEST, "[{0}] OK ", sw.stop());
return value;
} catch (SQLException ex) {
logger.log(Level.FINE, "[{0}] FAIL {1} ", new Object[] {sw.stop(), ex.getMessage()});
throw ex;
} catch (Exception ex) {
logger.log(Level.WARNING, "ERROR ", ex);
throw ex;
}
}

private void runImpl(String msg, Supplier<CompletableFuture<Status>> fn) throws SQLException {
Status status = fn.get().join();
addStatusIssues(status);

Expand All @@ -113,7 +59,7 @@ private void runImpl(String msg, Supplier<CompletableFuture<Status>> fn) throws
}
}

private <R> R callImpl(String msg, Supplier<CompletableFuture<Result<R>>> fn) throws SQLException {
public <R> R call(String msg, Supplier<CompletableFuture<Result<R>>> fn) throws SQLException {
try {
Result<R> result = fn.get().join();
addStatusIssues(result.getStatus());
Expand All @@ -122,5 +68,4 @@ private <R> R callImpl(String msg, Supplier<CompletableFuture<Result<R>>> fn) th
throw ExceptionFactory.createException("Cannot call '" + msg + "' with " + ex.getStatus(), ex);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public abstract class BaseYdbStatement implements YdbStatement {

public BaseYdbStatement(Logger logger, YdbConnection connection, int resultSetType, boolean isPoolable) {
this.connection = Objects.requireNonNull(connection);
this.validator = new YdbValidator(logger);
this.validator = new YdbValidator();
this.resultSetType = resultSetType;
this.isPoolable = isPoolable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class YdbConnectionImpl implements YdbConnection {
public YdbConnectionImpl(YdbContext context) throws SQLException {
this.ctx = context;

this.validator = new YdbValidator(LOGGER);
this.validator = new YdbValidator();
this.executor = ctx.createExecutor();
this.ctx.register();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class YdbDatabaseMetaDataImpl implements YdbDatabaseMetaData {
public YdbDatabaseMetaDataImpl(YdbConnection connection) {
this.connection = Objects.requireNonNull(connection);
this.executor = new SchemeExecutor(connection.getCtx());
this.validator = new YdbValidator(LOGGER);
this.validator = new YdbValidator();
}

@Override
Expand Down

0 comments on commit 137a037

Please sign in to comment.