Skip to content

Commit

Permalink
Improve error and debug message
Browse files Browse the repository at this point in the history
Polish code

relates #512

(cherry picked from commit b7d3e59)
  • Loading branch information
costin committed Sep 1, 2015
1 parent 71321ec commit 1209d9f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
4 changes: 3 additions & 1 deletion docs/src/reference/asciidoc/core/configuration.adoc
Expand Up @@ -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.

Expand Down
Expand Up @@ -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<String> 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));
Expand All @@ -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);
}
Expand All @@ -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<String> 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));
Expand All @@ -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);
}
Expand Down
Expand Up @@ -41,10 +41,7 @@ public Node(String id, Map<String, Object> data) {
attributes = (Map<String, Object>) 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) {
Expand Down Expand Up @@ -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();
}
}

0 comments on commit 1209d9f

Please sign in to comment.