Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Remove unnecessary loggings in statement handlers #2469

Merged
merged 7 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
KodaiD marked this conversation as resolved.
Show resolved Hide resolved
}
}

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");
KodaiD marked this conversation as resolved.
Show resolved Hide resolved
}
}

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
Loading