better logging

trace log the low level details on recovery
This commit is contained in:
Shay Banon 2013-09-13 22:46:04 +02:00
parent 056a678fa8
commit d6a3fc09f0
4 changed files with 21 additions and 15 deletions

View File

@ -28,7 +28,6 @@ else
JAVA=`which java` JAVA=`which java`
fi fi
# this is a poor mans getopt replacement
# real getopt cannot be used because we need to hand options over to the PluginManager # real getopt cannot be used because we need to hand options over to the PluginManager
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
case $1 in case $1 in

View File

@ -189,6 +189,8 @@ public class IndexShardGatewayService extends AbstractIndexShardComponent implem
recoveryStatus.updateStage(RecoveryStatus.Stage.DONE); recoveryStatus.updateStage(RecoveryStatus.Stage.DONE);
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("recovery completed from [{}], took [{}]", shardGateway, timeValueMillis(recoveryStatus.time()));
} else if (logger.isTraceEnabled()) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("recovery completed from ").append(shardGateway).append(", took [").append(timeValueMillis(recoveryStatus.time())).append("]\n"); sb.append("recovery completed from ").append(shardGateway).append(", took [").append(timeValueMillis(recoveryStatus.time())).append("]\n");
sb.append(" index : files [").append(recoveryStatus.index().numberOfFiles()).append("] with total_size [").append(new ByteSizeValue(recoveryStatus.index().totalSize())).append("], took[").append(TimeValue.timeValueMillis(recoveryStatus.index().time())).append("]\n"); sb.append(" index : files [").append(recoveryStatus.index().numberOfFiles()).append("] with total_size [").append(new ByteSizeValue(recoveryStatus.index().totalSize())).append("], took[").append(TimeValue.timeValueMillis(recoveryStatus.index().time())).append("]\n");
@ -196,7 +198,7 @@ public class IndexShardGatewayService extends AbstractIndexShardComponent implem
sb.append(" : reusing_files [").append(recoveryStatus.index().numberOfReusedFiles()).append("] with total_size [").append(new ByteSizeValue(recoveryStatus.index().reusedTotalSize())).append("]\n"); sb.append(" : reusing_files [").append(recoveryStatus.index().numberOfReusedFiles()).append("] with total_size [").append(new ByteSizeValue(recoveryStatus.index().reusedTotalSize())).append("]\n");
sb.append(" start : took [").append(TimeValue.timeValueMillis(recoveryStatus.start().time())).append("], check_index [").append(timeValueMillis(recoveryStatus.start().checkIndexTime())).append("]\n"); sb.append(" start : took [").append(TimeValue.timeValueMillis(recoveryStatus.start().time())).append("], check_index [").append(timeValueMillis(recoveryStatus.start().checkIndexTime())).append("]\n");
sb.append(" translog : number_of_operations [").append(recoveryStatus.translog().currentTranslogOperations()).append("], took [").append(TimeValue.timeValueMillis(recoveryStatus.translog().time())).append("]"); sb.append(" translog : number_of_operations [").append(recoveryStatus.translog().currentTranslogOperations()).append("], took [").append(TimeValue.timeValueMillis(recoveryStatus.translog().time())).append("]");
logger.debug(sb.toString()); logger.trace(sb.toString());
} }
listener.onRecoveryDone(); listener.onRecoveryDone();
scheduleSnapshotIfNeeded(); scheduleSnapshotIfNeeded();

View File

@ -61,7 +61,7 @@ public class NoneIndexShardGateway extends AbstractIndexShardComponent implement
@Override @Override
public void recover(boolean indexShouldExists, RecoveryStatus recoveryStatus) throws IndexShardGatewayRecoveryException { public void recover(boolean indexShouldExists, RecoveryStatus recoveryStatus) throws IndexShardGatewayRecoveryException {
recoveryStatus().index().startTime(System.currentTimeMillis()); recoveryStatus.index().startTime(System.currentTimeMillis());
// in the none case, we simply start the shard // in the none case, we simply start the shard
// clean the store, there should be nothing there... // clean the store, there should be nothing there...
try { try {

View File

@ -47,8 +47,11 @@ import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.*; import org.elasticsearch.transport.*;
import java.util.*; import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set;
import static org.elasticsearch.common.unit.TimeValue.timeValueMillis; import static org.elasticsearch.common.unit.TimeValue.timeValueMillis;
@ -217,6 +220,8 @@ public class RecoveryTarget extends AbstractComponent {
} }
stopWatch.stop(); stopWatch.stop();
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("recovery completed from [{}], took [{}]", request.shardId(), request.sourceNode(), stopWatch.totalTime());
} else if (logger.isTraceEnabled()) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append('[').append(request.shardId().index().name()).append(']').append('[').append(request.shardId().id()).append("] "); sb.append('[').append(request.shardId().index().name()).append(']').append('[').append(request.shardId().id()).append("] ");
sb.append("recovery completed from ").append(request.sourceNode()).append(", took[").append(stopWatch.totalTime()).append("]\n"); sb.append("recovery completed from ").append(request.sourceNode()).append(", took[").append(stopWatch.totalTime()).append("]\n");
@ -230,7 +235,7 @@ public class RecoveryTarget extends AbstractComponent {
.append("\n"); .append("\n");
sb.append(" phase3: recovered [").append(recoveryResponse.phase3Operations).append("]").append(" transaction log operations") sb.append(" phase3: recovered [").append(recoveryResponse.phase3Operations).append("]").append(" transaction log operations")
.append(", took [").append(timeValueMillis(recoveryResponse.phase3Time)).append("]"); .append(", took [").append(timeValueMillis(recoveryResponse.phase3Time)).append("]");
logger.debug(sb.toString()); logger.trace(sb.toString());
} }
removeAndCleanOnGoingRecovery(recoveryStatus); removeAndCleanOnGoingRecovery(recoveryStatus);
listener.onRecoveryDone(); listener.onRecoveryDone();