From 1209d9f95f57df76f9276a865aacea301f1766da Mon Sep 17 00:00:00 2001 From: Costin Leau Date: Tue, 1 Sep 2015 13:01:56 +0300 Subject: [PATCH] Improve error and debug message Polish code relates #512 (cherry picked from commit b7d3e595c69de6210433e33f8df6a9e10a9bbf6f) --- .../asciidoc/core/configuration.adoc | 4 +++- .../hadoop/rest/InitializationUtils.java | 19 ++++++++++--------- .../hadoop/serialization/dto/Node.java | 8 +++----- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/docs/src/reference/asciidoc/core/configuration.adoc b/docs/src/reference/asciidoc/core/configuration.adoc index 8021e83f0..f83705e75 100644 --- a/docs/src/reference/asciidoc/core/configuration.adoc +++ b/docs/src/reference/asciidoc/core/configuration.adoc @@ -299,8 +299,10 @@ WARN main mr.EsInputFormat - Field(s) [naem, adress] not found Whether to discovery the nodes within the {es} cluster or only to use the ones given in `es.nodes` for metadata queries. Note that this setting only applies during start-up; afterwards when reading and writing, {eh} uses the target index shards (and their hosting nodes) unless +es.nodes.client.only+ is enabled. `es.nodes.client.only` (default false):: -Whether to use {es} {ref}/modules-node.html[client nodes] (or _load-balancers_). When enabled, {eh} will route _all_ its requests (after nodes discovery, if enabled) through the _client_ nodes within the cluster. Note this typically significantly reduces the node parallelism and thus it is disabled by default. +Whether to use {es} {ref}/modules-node.html[client nodes] (or _load-balancers_). When enabled, {eh} will route _all_ its requests (after nodes discovery, if enabled) through the _client_ nodes within the cluster. Note this typically significantly reduces the node parallelism and thus it is disabled by default. Enabling it also +disables `es.nodes.data.only` (since a client node is a non-data node). +added[2.1.2] `es.nodes.data.only` (default true):: Whether to use {es} {ref}/modules-node.html[data nodes] only. When enabled, {eh} will route _all_ its requests (after nodes discovery, if enabled) through the _data_ nodes within the cluster. The purpose of this configuration setting is to avoid overwhelming non-data nodes as these tend to be "smaller" nodes. This is enabled by default. diff --git a/mr/src/main/java/org/elasticsearch/hadoop/rest/InitializationUtils.java b/mr/src/main/java/org/elasticsearch/hadoop/rest/InitializationUtils.java index 7069277a6..33c82231e 100644 --- a/mr/src/main/java/org/elasticsearch/hadoop/rest/InitializationUtils.java +++ b/mr/src/main/java/org/elasticsearch/hadoop/rest/InitializationUtils.java @@ -77,9 +77,10 @@ public static void filterNonClientNodesIfNeeded(Settings settings, Log log) { RestClient bootstrap = new RestClient(settings); try { + String message = "Client-only routing specified but no client nodes with HTTP-enabled available"; List clientNodes = bootstrap.getHttpClientNodes(); if (clientNodes.isEmpty()) { - throw new EsHadoopIllegalArgumentException("Client-only routing specified but no client nodes with HTTP-enabled were found in the cluster..."); + throw new EsHadoopIllegalArgumentException(message); } if (log.isDebugEnabled()) { log.debug(String.format("Found client nodes %s", clientNodes)); @@ -93,12 +94,12 @@ public static void filterNonClientNodesIfNeeded(Settings settings, Log log) { } if (ddNodes.isEmpty()) { - String message = "Client-only routing specified but no client nodes with HTTP-enabled available; "; + if (settings.getNodesDiscovery()) { - message += String.format("looks like the client nodes discovered have been removed; is the cluster in a stable state? %s", clientNodes); + message += String.format("; looks like the client nodes discovered have been removed; is the cluster in a stable state? %s", clientNodes); } else { - message += String.format("node discovery is disabled and none of nodes specified fits the criterion %s", SettingsUtils.discoveredOrDeclaredNodes(settings)); + message += String.format("; node discovery is disabled and none of nodes specified fits the criterion %s", SettingsUtils.discoveredOrDeclaredNodes(settings)); } throw new EsHadoopIllegalArgumentException(message); } @@ -110,15 +111,16 @@ public static void filterNonClientNodesIfNeeded(Settings settings, Log log) { } public static void filterNonDataNodesIfNeeded(Settings settings, Log log) { - if (!settings.getNodesDataOnly()) { + if (!settings.getNodesDataOnly() || settings.getNodesClientOnly()) { return; } RestClient bootstrap = new RestClient(settings); try { + String message = "No data nodes with HTTP-enabled available"; List dataNodes = bootstrap.getHttpDataNodes(); if (dataNodes.isEmpty()) { - throw new EsHadoopIllegalArgumentException("Data node only routing specified but no data nodes with HTTP-enabled were found in the cluster..."); + throw new EsHadoopIllegalArgumentException(message); } if (log.isDebugEnabled()) { log.debug(String.format("Found data nodes %s", dataNodes)); @@ -132,12 +134,11 @@ public static void filterNonDataNodesIfNeeded(Settings settings, Log log) { } if (ddNodes.isEmpty()) { - String message = "Data node only routing specified but no data nodes with HTTP-enabled available; "; if (settings.getNodesDiscovery()) { - message += String.format("looks like the data nodes discovered have been removed; is the cluster in a stable state? %s", dataNodes); + message += String.format("; looks like the data nodes discovered have been removed; is the cluster in a stable state? %s", dataNodes); } else { - message += String.format("node discovery is disabled and none of nodes specified fits the criterion %s", SettingsUtils.discoveredOrDeclaredNodes(settings)); + message += String.format("; node discovery is disabled and none of nodes specified fits the criterion %s", SettingsUtils.discoveredOrDeclaredNodes(settings)); } throw new EsHadoopIllegalArgumentException(message); } diff --git a/mr/src/main/java/org/elasticsearch/hadoop/serialization/dto/Node.java b/mr/src/main/java/org/elasticsearch/hadoop/serialization/dto/Node.java index 4076260be..1b9136964 100644 --- a/mr/src/main/java/org/elasticsearch/hadoop/serialization/dto/Node.java +++ b/mr/src/main/java/org/elasticsearch/hadoop/serialization/dto/Node.java @@ -41,10 +41,7 @@ public Node(String id, Map data) { attributes = (Map) data.get("attributes"); if (attributes != null) { isClient = ("false".equals(attributes.get("data")) && "false".equals(attributes.get("master"))); - } - - if (attributes != null) { - isData = !"false".equals((attributes.get("data"))); + isData = !"false".equals(attributes.get("data")); } if (!hasHttp) { @@ -117,7 +114,8 @@ else if (!id.equals(other.id)) public String toString() { StringBuilder builder = new StringBuilder(); builder.append("Node[id=").append(id).append(", name=").append(name).append(", ipAddress=").append(ipAddress) - .append(", httpPort=").append(httpPort).append("]"); + .append(", httpPort=").append(httpPort).append(", isClient=").append(isClient).append(", isData=").append(isData) + .append("]"); return builder.toString(); } } \ No newline at end of file