Previously added logging in TransportRefreshAction caused NPE if search shards had errors (or was not yet started/assigned)

Better formatting for logging in TransportRefreshAction
This commit is contained in:
Boaz Leskes 2013-09-02 21:53:00 +02:00
parent a48c437ffb
commit 7307e37efe
2 changed files with 12 additions and 5 deletions

View File

@ -113,7 +113,7 @@ public class TransportRefreshAction extends TransportBroadcastOperationAction<Re
protected ShardRefreshResponse shardOperation(ShardRefreshRequest request) throws ElasticSearchException {
IndexShard indexShard = indicesService.indexServiceSafe(request.index()).shardSafe(request.shardId());
indexShard.refresh(new Engine.Refresh().force(request.force()));
logger.debug("Refresh request executed for {}. Force: [{}].", indexShard.shardId(), request.force());
logger.debug("{} Refresh request executed. Force: [{}].", indexShard.shardId(), request.force());
return new ShardRefreshResponse(request.index(), request.shardId());
}

View File

@ -390,13 +390,20 @@ public abstract class TransportSearchTypeAction extends TransportAction<SearchRe
final void innerMoveToSecondPhase() throws Exception {
if (logger.isDebugEnabled()) {
StringBuilder sb = new StringBuilder();
boolean hadOne = false;
for (int i = 0; i < firstResults.length(); i++) {
SearchShardTarget shard = firstResults.get(i).shardTarget();
if (i > 0) {
FirstResult result = firstResults.get(i);
if (result == null) {
continue; // failure
}
if (hadOne) {
sb.append(",");
} else {
hadOne = true;
}
sb.append(shard);
sb.append(result.shardTarget());
}
logger.debug("Moving to second phase, based on results from: {}", sb);
}
moveToSecondPhase();