Skip to content

Commit

Permalink
Remove unnecessary loggings in statement handlers (#2469)
Browse files Browse the repository at this point in the history
  • Loading branch information
KodaiD committed Jan 22, 2025
1 parent 850bccc commit 4cbf7e6
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public void handle(List<? extends Mutation> mutations)
CoreError.CASSANDRA_OPERATION_FAILED_IN_BATCH.buildMessage(writeType), e);
}
} catch (RuntimeException e) {
logger.warn(e.getMessage(), e);
throw new RetriableExecutionException(
CoreError.CASSANDRA_ERROR_OCCURRED_IN_BATCH.buildMessage(e.getMessage()), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@
import com.scalar.db.exception.storage.RetriableExecutionException;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.ThreadSafe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** An abstraction for handler classes for mutate statements */
@ThreadSafe
public abstract class MutateStatementHandler extends StatementHandler {
private static final Logger logger = LoggerFactory.getLogger(MutateStatementHandler.class);

public MutateStatementHandler(Session session) {
super(session);
}
Expand All @@ -48,7 +44,6 @@ public ResultSet handle(Operation operation) throws ExecutionException {
}
return results;
} catch (WriteTimeoutException e) {
logger.warn("Write timeout happened during mutate operation", e);
if (e.getWriteType() == WriteType.CAS) {
// retry needs to be done if applications need to do the operation exactly
throw new RetriableExecutionException(
Expand All @@ -71,7 +66,6 @@ public ResultSet handle(Operation operation) throws ExecutionException {
CoreError.CASSANDRA_WRITE_TIMEOUT_WITH_OTHER_WRITE_TYPE_IN_MUTATION.buildMessage(), e);
}
} catch (RuntimeException e) {
logger.warn(e.getMessage(), e);
throw new RetriableExecutionException(
CoreError.CASSANDRA_ERROR_OCCURRED_IN_MUTATION.buildMessage(e.getMessage()), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
import java.util.stream.IntStream;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.ThreadSafe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* A handler class for select statement
Expand All @@ -43,8 +41,6 @@
*/
@ThreadSafe
public class SelectStatementHandler extends StatementHandler {
private static final Logger logger = LoggerFactory.getLogger(SelectStatementHandler.class);

/**
* Constructs {@code SelectStatementHandler} with the specified {@code Session}
*
Expand All @@ -60,7 +56,6 @@ public ResultSet handle(Operation operation) throws ExecutionException {
try {
return handleInternal(operation);
} catch (RuntimeException e) {
logger.error(e.getMessage(), e);
throw new ExecutionException(
CoreError.CASSANDRA_ERROR_OCCURRED_IN_SELECTION.buildMessage(e.getMessage()), e);
}
Expand Down Expand Up @@ -294,8 +289,7 @@ private Ordering getOrdering(Scan.Ordering ordering) {
case DESC:
return QueryBuilder.desc(quoteIfNecessary(ordering.getColumnName()));
default:
logger.warn("Unsupported ordering specified. Using Order.ASC");
return QueryBuilder.asc(quoteIfNecessary(ordering.getColumnName()));
throw new AssertionError("Unsupported ordering is specified: " + ordering.getOrder());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@
import com.scalar.db.exception.storage.ExecutionException;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.ThreadSafe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** A handler class for statements */
@ThreadSafe
public abstract class StatementHandler {
private static final Logger logger = LoggerFactory.getLogger(StatementHandler.class);
protected final Session session;
protected final StatementCache cache;

Expand Down Expand Up @@ -119,8 +116,7 @@ public static ConsistencyLevel convert(Operation operation, Consistency consiste
return ConsistencyLevel.QUORUM;
}
default:
logger.warn("Unsupported consistency is specified. SEQUENTIAL is being used instead");
return ConsistencyLevel.QUORUM;
throw new AssertionError("Unsupported consistency is specified: " + consistency);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import java.util.ArrayList;
import java.util.List;
import javax.annotation.concurrent.ThreadSafe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* A handler for a batch
Expand All @@ -22,7 +20,6 @@
*/
@ThreadSafe
public class BatchHandler {
private static final Logger logger = LoggerFactory.getLogger(BatchHandler.class);
private static final String MUTATION_STORED_PROCEDURE = "mutate.js";
private final CosmosClient client;
private final TableMetadataManager metadataManager;
Expand Down Expand Up @@ -88,7 +85,6 @@ private void executeStoredProcedure(
}

private void throwException(CosmosException exception) throws ExecutionException {
logger.error(exception.getMessage(), exception);
int statusCode = exception.getSubStatusCode();

if (statusCode == CosmosErrorCode.PRECONDITION_FAILED.get()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@
import java.util.ArrayList;
import java.util.List;
import javax.annotation.concurrent.ThreadSafe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** An abstraction for handler classes for mutate statements */
@ThreadSafe
public abstract class MutateStatementHandler extends StatementHandler {
private static final Logger logger = LoggerFactory.getLogger(MutateStatementHandler.class);
private static final String MUTATION_STORED_PROCEDURE = "mutate.js";

public MutateStatementHandler(CosmosClient client, TableMetadataManager metadataManager) {
Expand Down Expand Up @@ -60,7 +57,6 @@ protected void executeStoredProcedure(Mutation mutation, TableMetadata tableMeta
}

private void throwException(CosmosException exception) throws ExecutionException {
logger.error(exception.getMessage());
int statusCode = exception.getSubStatusCode();

if (statusCode == CosmosErrorCode.PRECONDITION_FAILED.get()) {
Expand Down

0 comments on commit 4cbf7e6

Please sign in to comment.