From 61afd0a46a141a2ce405d598d64d4464e6405612 Mon Sep 17 00:00:00 2001 From: Gian Merlino Date: Fri, 14 Dec 2012 18:13:57 -0800 Subject: [PATCH] Merger: De-parameterize alert messages --- .../merger/coordinator/RemoteTaskRunner.java | 20 +++++++++-------- .../merger/coordinator/exec/TaskConsumer.java | 22 +++++-------------- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/merger/src/main/java/com/metamx/druid/merger/coordinator/RemoteTaskRunner.java b/merger/src/main/java/com/metamx/druid/merger/coordinator/RemoteTaskRunner.java index 35fe72db968..2a235b88d86 100644 --- a/merger/src/main/java/com/metamx/druid/merger/coordinator/RemoteTaskRunner.java +++ b/merger/src/main/java/com/metamx/druid/merger/coordinator/RemoteTaskRunner.java @@ -211,10 +211,10 @@ public class RemoteTaskRunner implements TaskRunner } else { Duration durSinceLastTerminate = new Duration(new DateTime(), lastTerminateTime); if (durSinceLastTerminate.isLongerThan(config.getMaxScalingDuration())) { - log.makeAlert( - "It has been %d millis since last scheduled termination but nodes remain", - durSinceLastTerminate.getMillis() - ).emit(); + log.makeAlert("Worker node termination taking too long") + .addData("millisSinceLastTerminate", durSinceLastTerminate.getMillis()) + .addData("terminatingCount", currentlyTerminating.size()) + .emit(); } log.info( @@ -330,7 +330,9 @@ public class RemoteTaskRunner implements TaskRunner log.info("Registering retry for failed task[%s]", task.getId()); if (retryPolicy.hasExceededRetryThreshold()) { - log.makeAlert("Task [%s] has failed[%d] times, giving up!", task.getId(), retryPolicy.getNumRetries()) + log.makeAlert("Task exceeded maximum retry count") + .addData("task", task.getId()) + .addData("retryCount", retryPolicy.getNumRetries()) .emit(); return; } @@ -542,10 +544,10 @@ public class RemoteTaskRunner implements TaskRunner } else { Duration durSinceLastProvision = new Duration(new DateTime(), lastProvisionTime); if (durSinceLastProvision.isLongerThan(config.getMaxScalingDuration())) { - log.makeAlert( - "It has been %d millis since last scheduled provision but nodes remain", - durSinceLastProvision.getMillis() - ).emit(); + log.makeAlert("Worker node provisioning taking too long") + .addData("millisSinceLastProvision", durSinceLastProvision.getMillis()) + .addData("provisioningCount", currentlyProvisioning.size()) + .emit(); } log.info( diff --git a/merger/src/main/java/com/metamx/druid/merger/coordinator/exec/TaskConsumer.java b/merger/src/main/java/com/metamx/druid/merger/coordinator/exec/TaskConsumer.java index 201bfdf338d..ed7ac9f3f25 100644 --- a/merger/src/main/java/com/metamx/druid/merger/coordinator/exec/TaskConsumer.java +++ b/merger/src/main/java/com/metamx/druid/merger/coordinator/exec/TaskConsumer.java @@ -20,11 +20,9 @@ package com.metamx.druid.merger.coordinator.exec; import com.google.common.base.Throwables; -import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.metamx.common.lifecycle.LifecycleStart; import com.metamx.common.lifecycle.LifecycleStop; -import com.metamx.common.logger.Logger; import com.metamx.druid.client.DataSegment; import com.metamx.druid.merger.common.TaskStatus; import com.metamx.druid.merger.common.task.Task; @@ -35,12 +33,9 @@ import com.metamx.druid.merger.coordinator.TaskQueue; import com.metamx.druid.merger.coordinator.TaskRunner; import com.metamx.druid.merger.coordinator.VersionedTaskWrapper; import com.metamx.emitter.EmittingLogger; -import com.metamx.emitter.service.AlertEvent; import com.metamx.emitter.service.ServiceEmitter; import com.metamx.emitter.service.ServiceMetricEvent; -import java.util.concurrent.ExecutorService; - public class TaskConsumer implements Runnable { private final TaskQueue queue; @@ -242,17 +237,12 @@ public class TaskConsumer implements Runnable emitter.emit(builder.build("indexer/segment/bytes", bytes)); if (status.isFailure()) { - emitter.emit( - new AlertEvent.Builder().build( - String.format("Failed to index: %s", task.getDataSource()), - ImmutableMap.builder() - .put("task", task.getId()) - .put("type", task.getType().toString()) - .put("dataSource", task.getDataSource()) - .put("interval", task.getInterval()) - .build() - ) - ); + log.makeAlert("Failed to index") + .addData("task", task.getId()) + .addData("type", task.getType().toString()) + .addData("dataSource", task.getDataSource()) + .addData("interval", task.getInterval()) + .emit(); } log.info(