[Logging] added trace logging to TransportShardSingleOperationAction

And enabled them on SimpleRecoveryTests.testSimpleRecovery
This commit is contained in:
Boaz Leskes 2014-07-04 21:10:52 +02:00
parent 54790eea10
commit 536930c751
3 changed files with 12 additions and 2 deletions

View File

@ -305,6 +305,6 @@ public class GetRequest extends SingleShardOperationRequest<GetRequest> {
@Override @Override
public String toString() { public String toString() {
return "[" + index + "][" + type + "][" + id + "]: routing [" + routing + "]"; return "get [" + index + "][" + type + "][" + id + "]: routing [" + routing + "]";
} }
} }

View File

@ -107,6 +107,9 @@ public abstract class TransportShardSingleOperationAction<Request extends Single
this.listener = listener; this.listener = listener;
ClusterState clusterState = clusterService.state(); ClusterState clusterState = clusterService.state();
if (logger.isTraceEnabled()) {
logger.trace("executing [{}] based on cluster state version [{}]", request, clusterState.version());
}
nodes = clusterState.nodes(); nodes = clusterState.nodes();
ClusterBlockException blockException = checkGlobalBlock(clusterState, request); ClusterBlockException blockException = checkGlobalBlock(clusterState, request);
if (blockException != null) { if (blockException != null) {
@ -151,8 +154,10 @@ public abstract class TransportShardSingleOperationAction<Request extends Single
listener.onFailure(failure); listener.onFailure(failure);
return; return;
} }
if (shardRouting.currentNodeId().equals(nodes.localNodeId())) { if (shardRouting.currentNodeId().equals(nodes.localNodeId())) {
if (logger.isTraceEnabled()) {
logger.trace("executing [{}] on shard [{}]", request, shardRouting.shardId());
}
try { try {
if (request.operationThreaded()) { if (request.operationThreaded()) {
request.beforeLocalFork(); request.beforeLocalFork();
@ -260,6 +265,9 @@ public abstract class TransportShardSingleOperationAction<Request extends Single
@Override @Override
public void messageReceived(final ShardSingleOperationRequest request, final TransportChannel channel) throws Exception { public void messageReceived(final ShardSingleOperationRequest request, final TransportChannel channel) throws Exception {
if (logger.isTraceEnabled()) {
logger.trace("executing [{}] on shard [{}]", request.request(), request.shardId());
}
Response response = shardOperation(request.request(), request.shardId()); Response response = shardOperation(request.request(), request.shardId());
channel.sendResponse(response); channel.sendResponse(response);
} }

View File

@ -25,6 +25,7 @@ import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.junit.Test; import org.junit.Test;
import static org.elasticsearch.client.Requests.*; import static org.elasticsearch.client.Requests.*;
@ -49,6 +50,7 @@ public class SimpleRecoveryTests extends ElasticsearchIntegrationTest {
} }
@Test @Test
@TestLogging(value = "cluster.service:TRACE,action.get:TRACE")
public void testSimpleRecovery() throws Exception { public void testSimpleRecovery() throws Exception {
assertAcked(prepareCreate("test", 1).execute().actionGet(5000)); assertAcked(prepareCreate("test", 1).execute().actionGet(5000));