From 8c25be6dee4f4c33ed5d737b1be14b31e3de319f Mon Sep 17 00:00:00 2001 From: kimchy Date: Fri, 20 Aug 2010 16:36:25 +0300 Subject: [PATCH] better exception message with primary not started exception on index/delete/delete_by_query apis --- .../action/PrimaryNotStartedActionException.java | 2 +- .../ping/replication/ShardReplicationPingRequest.java | 2 +- .../gateway/snapshot/ShardGatewaySnapshotRequest.java | 2 +- .../org/elasticsearch/action/delete/DeleteRequest.java | 2 +- .../action/deletebyquery/ShardDeleteByQueryRequest.java | 8 +++++++- .../java/org/elasticsearch/action/index/IndexRequest.java | 8 +++++++- .../TransportShardReplicationOperationAction.java | 4 ++-- 7 files changed, 20 insertions(+), 8 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/PrimaryNotStartedActionException.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/PrimaryNotStartedActionException.java index 25df2ccce27..7ac51fe923e 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/PrimaryNotStartedActionException.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/PrimaryNotStartedActionException.java @@ -35,6 +35,6 @@ public class PrimaryNotStartedActionException extends ElasticSearchException { if (shardId == null) { return message; } - return "[" + shardId.index() + "][" + shardId.id() + "]" + message; + return "[" + shardId.index().name() + "][" + shardId.id() + "] " + message; } } \ No newline at end of file diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/ShardReplicationPingRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/ShardReplicationPingRequest.java index 82b3310eac1..aa9454d935d 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/ShardReplicationPingRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/ShardReplicationPingRequest.java @@ -77,6 +77,6 @@ public class ShardReplicationPingRequest extends ShardReplicationOperationReques } @Override public String toString() { - return "[" + index + "][" + shardId + "]"; + return "replication_ping {[" + index + "][" + shardId + "]}"; } } \ No newline at end of file diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/ShardGatewaySnapshotRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/ShardGatewaySnapshotRequest.java index 0a55b337f22..9d3bdb11c7b 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/ShardGatewaySnapshotRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/ShardGatewaySnapshotRequest.java @@ -60,6 +60,6 @@ class ShardGatewaySnapshotRequest extends ShardReplicationOperationRequest { } @Override public String toString() { - return "[" + index + "][" + shardId + "]"; + return "gateway_snapshot {[" + index + "][" + shardId + "]}"; } } \ No newline at end of file diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/delete/DeleteRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/delete/DeleteRequest.java index df2bab8fd82..5a3dd254f23 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/delete/DeleteRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/delete/DeleteRequest.java @@ -167,6 +167,6 @@ public class DeleteRequest extends ShardReplicationOperationRequest { } @Override public String toString() { - return "[" + index + "][" + type + "][" + id + "]"; + return "delete {[" + index + "][" + type + "][" + id + "]}"; } } \ No newline at end of file diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/deletebyquery/ShardDeleteByQueryRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/deletebyquery/ShardDeleteByQueryRequest.java index ab3a21c5a36..52604e42230 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/deletebyquery/ShardDeleteByQueryRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/deletebyquery/ShardDeleteByQueryRequest.java @@ -120,6 +120,12 @@ public class ShardDeleteByQueryRequest extends ShardReplicationOperationRequest } @Override public String toString() { - return "[" + index + "]" + Arrays.toString(types) + ", query [" + Unicode.fromBytes(querySource) + "]"; + String sSource = "_na_"; + try { + sSource = Unicode.fromBytes(querySource); + } catch (Exception e) { + // ignore + } + return "delete_by_query {[" + index + "]" + Arrays.toString(types) + ", query [" + sSource + "]}"; } } \ No newline at end of file diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/index/IndexRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/index/IndexRequest.java index fa0cd39acf2..c4e07246cf2 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/index/IndexRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/index/IndexRequest.java @@ -413,6 +413,12 @@ public class IndexRequest extends ShardReplicationOperationRequest { } @Override public String toString() { - return "[" + index + "][" + type + "][" + id + "], source[" + Unicode.fromBytes(source, sourceOffset, sourceLength) + "]"; + String sSource = "_na_"; + try { + sSource = Unicode.fromBytes(source, sourceOffset, sourceLength); + } catch (Exception e) { + // ignore + } + return "index {[" + index + "][" + type + "][" + id + "], source[" + sSource + "]}"; } } \ No newline at end of file diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/support/replication/TransportShardReplicationOperationAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/support/replication/TransportShardReplicationOperationAction.java index 9c11a3b9d42..92e4bb5e795 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/support/replication/TransportShardReplicationOperationAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/support/replication/TransportShardReplicationOperationAction.java @@ -316,7 +316,7 @@ public abstract class TransportShardReplicationOperationAction