handle null Engine.Operation.getTranslogLocation in IndexingMemoryController
This commit is contained in:
parent
1afc9b7e56
commit
dea3678ef9
|
@ -32,6 +32,7 @@ import org.elasticsearch.index.engine.FlushNotAllowedEngineException;
|
|||
import org.elasticsearch.index.shard.IndexShard;
|
||||
import org.elasticsearch.index.shard.IndexShardState;
|
||||
import org.elasticsearch.index.shard.IndexingOperationListener;
|
||||
import org.elasticsearch.index.translog.Translog;
|
||||
import org.elasticsearch.monitor.jvm.JvmInfo;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
|
||||
|
@ -89,7 +90,6 @@ public class IndexingMemoryController extends AbstractComponent implements Index
|
|||
this(settings, threadPool, indexServices, JvmInfo.jvmInfo().getMem().getHeapMax().bytes());
|
||||
}
|
||||
|
||||
// for testing
|
||||
IndexingMemoryController(Settings settings, ThreadPool threadPool, Iterable<IndexShard> indexServices, long jvmMemoryInBytes) {
|
||||
super(settings);
|
||||
this.indexShards = indexServices;
|
||||
|
@ -205,12 +205,20 @@ public class IndexingMemoryController extends AbstractComponent implements Index
|
|||
|
||||
@Override
|
||||
public void postIndex(Engine.Index index, boolean created) {
|
||||
bytesWritten(index.getTranslogLocation().size);
|
||||
recordOperationBytes(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postDelete(Engine.Delete delete) {
|
||||
bytesWritten(delete.getTranslogLocation().size);
|
||||
recordOperationBytes(delete);
|
||||
}
|
||||
|
||||
private void recordOperationBytes(Engine.Operation op) {
|
||||
Translog.Location loc = op.getTranslogLocation();
|
||||
// This can be null on (harmless) version conflict during recovery:
|
||||
if (loc != null) {
|
||||
bytesWritten(loc.size);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class ShardAndBytesUsed implements Comparable<ShardAndBytesUsed> {
|
||||
|
|
|
@ -347,4 +347,16 @@ public class SimpleQueryStringIT extends ESIntegTestCase {
|
|||
assertHitCount(searchResponse, 1L);
|
||||
assertSearchHits(searchResponse, "1");
|
||||
}
|
||||
|
||||
public void testSimpleQueryStringUsesFieldAnalyzer() throws Exception {
|
||||
client().prepareIndex("test", "type1", "1").setSource("foo", 123, "bar", "abc").get();
|
||||
client().prepareIndex("test", "type1", "2").setSource("foo", 234, "bar", "bcd").get();
|
||||
|
||||
refresh();
|
||||
|
||||
SearchResponse searchResponse = client().prepareSearch().setQuery(
|
||||
simpleQueryStringQuery("123").field("foo").field("bar")).get();
|
||||
assertHitCount(searchResponse, 1L);
|
||||
assertSearchHits(searchResponse, "1");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue