From cd0b9f13805affcc91a2cba42b176bb9031378eb Mon Sep 17 00:00:00 2001 From: Xiaoyu Yao Date: Tue, 24 Jul 2018 10:16:53 -0700 Subject: [PATCH] HDDS-282. Consolidate logging in scm/container-service. Contributed by Elek Marton. --- .../common/statemachine/EndpointStateMachine.java | 4 ++-- .../common/states/endpoint/RegisterEndpointTask.java | 3 +-- .../statemachine/background/BlockDeletingService.java | 8 +++++--- .../org/apache/hadoop/hdds/server/events/EventQueue.java | 3 +-- .../org/apache/hadoop/hdds/server/events/TypedEvent.java | 6 ++++-- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/EndpointStateMachine.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/EndpointStateMachine.java index 7e85923d31..fb32a05642 100644 --- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/EndpointStateMachine.java +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/EndpointStateMachine.java @@ -203,11 +203,11 @@ public void logIfNeeded(Exception ex) { this.incMissed(); if (this.getMissedCount() % getLogWarnInterval(conf) == 0) { - LOG.warn("Unable to communicate to SCM server at {}. We have not been " + + LOG.error("Unable to communicate to SCM server at {}. We have not been " + "able to communicate to this SCM server for past {} seconds.", this.getAddress().getHostString() + ":" + this.getAddress().getPort(), this.getMissedCount() * getScmHeartbeatInterval( - this.conf)); + this.conf), ex); } } diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/endpoint/RegisterEndpointTask.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/endpoint/RegisterEndpointTask.java index b3d2b62009..25af4a1d1e 100644 --- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/endpoint/RegisterEndpointTask.java +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/endpoint/RegisterEndpointTask.java @@ -125,8 +125,7 @@ public EndpointStateMachine.EndPointStates call() throws Exception { rpcEndPoint.setState(nextState); rpcEndPoint.zeroMissedCount(); } catch (IOException ex) { - rpcEndPoint.logIfNeeded(ex - ); + rpcEndPoint.logIfNeeded(ex); } finally { rpcEndPoint.unlock(); } diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/statemachine/background/BlockDeletingService.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/statemachine/background/BlockDeletingService.java index 4a572cac24..51eed7ff9e 100644 --- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/statemachine/background/BlockDeletingService.java +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/statemachine/background/BlockDeletingService.java @@ -119,9 +119,11 @@ public BackgroundTaskQueue getTasks() { // configured. containers = containerSet.chooseContainerForBlockDeletion( containerLimitPerInterval, containerDeletionPolicy); - LOG.info("Plan to choose {} containers for block deletion, " - + "actually returns {} valid containers.", - containerLimitPerInterval, containers.size()); + if (containers.size() > 0) { + LOG.info("Plan to choose {} containers for block deletion, " + + "actually returns {} valid containers.", + containerLimitPerInterval, containers.size()); + } for(ContainerData container : containers) { BlockDeletingTask containerTask = diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/events/EventQueue.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/events/EventQueue.java index 7e29223461..f93c54bbc1 100644 --- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/events/EventQueue.java +++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/events/EventQueue.java @@ -155,8 +155,7 @@ public > void fireEvent( } } else { - throw new IllegalArgumentException( - "No event handler registered for event " + event); + LOG.warn("No event handler registered for event " + event); } } diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/events/TypedEvent.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/events/TypedEvent.java index 62e24194fd..27bba3ab6b 100644 --- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/events/TypedEvent.java +++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/events/TypedEvent.java @@ -50,7 +50,9 @@ public String getName() { @Override public String toString() { - return "TypedEvent{" + "payloadType=" + payloadType + ", name='" + name - + '\'' + '}'; + return "TypedEvent{" + + "payloadType=" + payloadType.getSimpleName() + + ", name='" + name + '\'' + + '}'; } }