This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 2cd0bdc09a58089b041097c79515f8782629c768 Author: LanKhuat <[email protected]> AuthorDate: Fri Mar 27 15:43:19 2020 +0700 JAMES-3117 Remove logging in all healthChecks. --- .../james/backends/cassandra/utils/CassandraHealthCheck.java | 6 +----- .../org/apache/james/backends/es/ElasticSearchHealthCheck.java | 7 +------ .../apache/james/backends/rabbitmq/RabbitMQHealthCheck.java | 10 ++-------- .../james/mailbox/events/EventDeadLettersHealthCheck.java | 7 +------ .../main/java/org/apache/james/GuiceLifecycleHealthCheck.java | 4 ---- .../api/projections/MessageFastViewProjectionHealthCheck.java | 4 ---- .../java/org/apache/james/jpa/healthcheck/JPAHealthCheck.java | 10 +--------- 7 files changed, 6 insertions(+), 42 deletions(-) diff --git a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/utils/CassandraHealthCheck.java b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/utils/CassandraHealthCheck.java index cc78894..d184e30 100644 --- a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/utils/CassandraHealthCheck.java +++ b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/utils/CassandraHealthCheck.java @@ -24,8 +24,6 @@ import javax.inject.Inject; import org.apache.james.core.healthcheck.ComponentName; import org.apache.james.core.healthcheck.HealthCheck; import org.apache.james.core.healthcheck.Result; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import com.datastax.driver.core.Session; @@ -35,7 +33,6 @@ import com.datastax.driver.core.Session; */ public class CassandraHealthCheck implements HealthCheck { - private static final Logger LOGGER = LoggerFactory.getLogger(CassandraHealthCheck.class); private static final ComponentName COMPONENT_NAME = new ComponentName("Cassandra backend"); private static final String SAMPLE_QUERY = "SELECT NOW() FROM system.local"; @@ -59,8 +56,7 @@ public class CassandraHealthCheck implements HealthCheck { session.execute(SAMPLE_QUERY); return Result.healthy(COMPONENT_NAME); } catch (Exception e) { - LOGGER.error("Error checking cassandra backend", e); - return Result.unhealthy(COMPONENT_NAME, e.getMessage()); + return Result.unhealthy(COMPONENT_NAME, "Error checking Cassandra backend", e); } } } diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchHealthCheck.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchHealthCheck.java index 6182f01..89037e7 100644 --- a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchHealthCheck.java +++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchHealthCheck.java @@ -32,14 +32,11 @@ import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.Requests; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import com.google.common.annotations.VisibleForTesting; public class ElasticSearchHealthCheck implements HealthCheck { - private static final Logger LOGGER = LoggerFactory.getLogger(ElasticSearchHealthCheck.class); private static final ComponentName COMPONENT_NAME = new ComponentName("ElasticSearch Backend"); private final Set<IndexName> indexNames; @@ -69,8 +66,7 @@ public class ElasticSearchHealthCheck implements HealthCheck { return toHealthCheckResult(response); } catch (IOException e) { - LOGGER.error("Error while contacting cluster", e); - return Result.unhealthy(COMPONENT_NAME, "Error while contacting cluster. Check James server logs."); + return Result.unhealthy(COMPONENT_NAME, "Error while contacting cluster", e); } } @@ -81,7 +77,6 @@ public class ElasticSearchHealthCheck implements HealthCheck { case YELLOW: return Result.healthy(COMPONENT_NAME); case RED: - LOGGER.error("ElasticSearchCluster return RED status"); return Result.unhealthy(COMPONENT_NAME, response.getClusterName() + " status is RED"); default: throw new NotImplementedException("Un-handled ElasticSearch cluster status"); diff --git a/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/RabbitMQHealthCheck.java b/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/RabbitMQHealthCheck.java index c50f99e..09a03df 100644 --- a/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/RabbitMQHealthCheck.java +++ b/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/RabbitMQHealthCheck.java @@ -24,11 +24,8 @@ import javax.inject.Inject; import org.apache.james.core.healthcheck.ComponentName; import org.apache.james.core.healthcheck.HealthCheck; import org.apache.james.core.healthcheck.Result; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class RabbitMQHealthCheck implements HealthCheck { - private static final Logger LOGGER = LoggerFactory.getLogger(RabbitMQHealthCheck.class); private static final ComponentName COMPONENT_NAME = new ComponentName("RabbitMQ backend"); private final SimpleConnectionPool connectionPool; @@ -51,13 +48,10 @@ public class RabbitMQHealthCheck implements HealthCheck { if (connectionPool.tryConnection() && rabbitChannelPoolImpl.tryChannel()) { return Result.healthy(COMPONENT_NAME); } else { - String message = "The created connection was not opened"; - LOGGER.error("Unhealthy RabbitMQ instances: {}", message); - return Result.unhealthy(COMPONENT_NAME, message); + return Result.unhealthy(COMPONENT_NAME, "The created connection was not opened"); } } catch (Exception e) { - LOGGER.error("Unhealthy RabbitMQ instances: could not establish a connection", e); - return Result.unhealthy(COMPONENT_NAME, e.getMessage()); + return Result.unhealthy(COMPONENT_NAME, "Unhealthy RabbitMQ instances: could not establish a connection", e); } } } diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventDeadLettersHealthCheck.java b/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventDeadLettersHealthCheck.java index 50a0a8b..8fc1b1b 100644 --- a/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventDeadLettersHealthCheck.java +++ b/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventDeadLettersHealthCheck.java @@ -24,11 +24,8 @@ import javax.inject.Inject; import org.apache.james.core.healthcheck.ComponentName; import org.apache.james.core.healthcheck.HealthCheck; import org.apache.james.core.healthcheck.Result; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class EventDeadLettersHealthCheck implements HealthCheck { - private static final Logger LOGGER = LoggerFactory.getLogger(EventDeadLettersHealthCheck.class); private static final ComponentName COMPONENT_NAME = new ComponentName("EventDeadLettersHealthCheck"); private final EventDeadLetters eventDeadLetters; @@ -49,14 +46,12 @@ public class EventDeadLettersHealthCheck implements HealthCheck { boolean containEvents = eventDeadLetters.containEvents().block(); if (containEvents) { - LOGGER.warn("EventDeadLetters is not empty"); return Result.degraded(COMPONENT_NAME, "EventDeadLetters contain events. This might indicate transient failure on mailbox event processing."); } return Result.healthy(COMPONENT_NAME); } catch (Exception e) { - LOGGER.error("EventDeadLettersHealthCheck threw an exception", e); - return Result.unhealthy(COMPONENT_NAME, e.getMessage()); + return Result.unhealthy(COMPONENT_NAME, "Error checking EventDeadLettersHealthCheck", e); } } } diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceLifecycleHealthCheck.java b/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceLifecycleHealthCheck.java index 2ee8e9e..b7a6fe4 100644 --- a/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceLifecycleHealthCheck.java +++ b/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceLifecycleHealthCheck.java @@ -24,11 +24,8 @@ import javax.inject.Inject; import org.apache.james.core.healthcheck.ComponentName; import org.apache.james.core.healthcheck.HealthCheck; import org.apache.james.core.healthcheck.Result; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class GuiceLifecycleHealthCheck implements HealthCheck { - private static final Logger LOGGER = LoggerFactory.getLogger(GuiceLifecycleHealthCheck.class); private final IsStartedProbe probe; @Inject @@ -46,7 +43,6 @@ public class GuiceLifecycleHealthCheck implements HealthCheck { if (probe.isStarted()) { return Result.healthy(componentName()); } else { - LOGGER.error("James server is not started"); return Result.unhealthy(componentName(), "James server is not started."); } } diff --git a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/projections/MessageFastViewProjectionHealthCheck.java b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/projections/MessageFastViewProjectionHealthCheck.java index b2877ad..de18851 100644 --- a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/projections/MessageFastViewProjectionHealthCheck.java +++ b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/projections/MessageFastViewProjectionHealthCheck.java @@ -29,12 +29,9 @@ import org.apache.james.core.healthcheck.HealthCheck; import org.apache.james.core.healthcheck.Result; import org.apache.james.metrics.api.Metric; import org.apache.james.metrics.api.MetricFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class MessageFastViewProjectionHealthCheck implements HealthCheck { - private static final Logger LOGGER = LoggerFactory.getLogger(MessageFastViewProjectionHealthCheck.class); private static final ComponentName COMPONENT_NAME = new ComponentName("MessageFastViewProjection"); private static final double MAXIMUM_MISS_PERCENTAGE_ACCEPTED = 10; @@ -67,7 +64,6 @@ public class MessageFastViewProjectionHealthCheck implements HealthCheck { long totalCount = hitCount + missCount; double missCountPercentage = missCount * 100.0d / totalCount; if (missCountPercentage > MAXIMUM_MISS_PERCENTAGE_ACCEPTED) { - LOGGER.warn("MessageFastViewProjection missCountPercentage exceeded the threshold"); return Result.degraded(COMPONENT_NAME, String.format("retrieveMissCount percentage %s%% (%d/%d) is higher than the threshold %s%%", missCountPercentage, missCount, totalCount, MAXIMUM_MISS_PERCENTAGE_ACCEPTED)); diff --git a/server/data/data-jpa/src/main/java/org/apache/james/jpa/healthcheck/JPAHealthCheck.java b/server/data/data-jpa/src/main/java/org/apache/james/jpa/healthcheck/JPAHealthCheck.java index 81bc728..8cd1706 100644 --- a/server/data/data-jpa/src/main/java/org/apache/james/jpa/healthcheck/JPAHealthCheck.java +++ b/server/data/data-jpa/src/main/java/org/apache/james/jpa/healthcheck/JPAHealthCheck.java @@ -27,13 +27,9 @@ import javax.persistence.EntityManagerFactory; import org.apache.james.core.healthcheck.ComponentName; import org.apache.james.core.healthcheck.HealthCheck; import org.apache.james.core.healthcheck.Result; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - public class JPAHealthCheck implements HealthCheck { - private static final Logger LOGGER = LoggerFactory.getLogger(JPAHealthCheck.class); private final EntityManagerFactory entityManagerFactory; @Inject @@ -48,18 +44,14 @@ public class JPAHealthCheck implements HealthCheck { @Override public Result check() { - LOGGER.debug("Checking if EntityManager is created successfully"); try { if (entityManagerFactory.createEntityManager().isOpen()) { - LOGGER.debug("EntityManager can execute queries, the connection is healthy"); return healthy(componentName()); } } catch (IllegalStateException stateException) { - LOGGER.debug("EntityManagerFactory or EntityManager threw an IllegalStateException, the connection is unhealthy"); - return unhealthy(componentName(), stateException.getMessage()); + return unhealthy(componentName(), "EntityManagerFactory or EntityManager thrown an IllegalStateException, the connection is unhealthy", stateException); } - LOGGER.error("EntityManager is not open, the connection is unhealthy"); return unhealthy(componentName(), "entityManager is not open"); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
