better exception message with primary not started exception on index/delete/delete_by_query apis

This commit is contained in:
kimchy 2010-08-20 16:36:25 +03:00
parent 07285d81d1
commit 8c25be6dee
7 changed files with 20 additions and 8 deletions

View File

@ -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;
}
}

View File

@ -77,6 +77,6 @@ public class ShardReplicationPingRequest extends ShardReplicationOperationReques
}
@Override public String toString() {
return "[" + index + "][" + shardId + "]";
return "replication_ping {[" + index + "][" + shardId + "]}";
}
}

View File

@ -60,6 +60,6 @@ class ShardGatewaySnapshotRequest extends ShardReplicationOperationRequest {
}
@Override public String toString() {
return "[" + index + "][" + shardId + "]";
return "gateway_snapshot {[" + index + "][" + shardId + "]}";
}
}

View File

@ -167,6 +167,6 @@ public class DeleteRequest extends ShardReplicationOperationRequest {
}
@Override public String toString() {
return "[" + index + "][" + type + "][" + id + "]";
return "delete {[" + index + "][" + type + "][" + id + "]}";
}
}

View File

@ -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 + "]}";
}
}

View File

@ -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 + "]}";
}
}

View File

@ -316,7 +316,7 @@ public abstract class TransportShardReplicationOperationAction<Request extends S
}
// we should never get here, but here we go
if (!foundPrimary) {
final PrimaryNotStartedActionException failure = new PrimaryNotStartedActionException(shards.shardId(), "Primary not found");
final PrimaryNotStartedActionException failure = new PrimaryNotStartedActionException(shards.shardId(), request.toString());
if (request.listenerThreaded()) {
threadPool.execute(new Runnable() {
@Override public void run() {
@ -361,7 +361,7 @@ public abstract class TransportShardReplicationOperationAction<Request extends S
return;
}
clusterService.remove(this);
final PrimaryNotStartedActionException failure = new PrimaryNotStartedActionException(shardId, "Timeout waiting for [" + timeValue + "]");
final PrimaryNotStartedActionException failure = new PrimaryNotStartedActionException(shardId, "Timeout waiting for [" + timeValue + "], request: " + request.toString());
if (request.listenerThreaded()) {
threadPool.execute(new Runnable() {
@Override public void run() {