parent
d866321c55
commit
31d1e6cfe7
|
@ -160,7 +160,9 @@ public class IndexFieldDataService extends AbstractIndexComponent implements Ind
|
||||||
}
|
}
|
||||||
|
|
||||||
IndexFieldDataCache cache;
|
IndexFieldDataCache cache;
|
||||||
String cacheType = type.getSettings().get("cache", indexSettings.get("index.fielddata.cache", "resident"));
|
// we default to node level cache, which in turn defaults to be unbounded
|
||||||
|
// this means changing the node level settings is simple, just set the bounds there
|
||||||
|
String cacheType = type.getSettings().get("cache", indexSettings.get("index.fielddata.cache", "node"));
|
||||||
if ("resident".equals(cacheType)) {
|
if ("resident".equals(cacheType)) {
|
||||||
cache = new IndexFieldDataCache.Resident(index, fieldNames, type, this);
|
cache = new IndexFieldDataCache.Resident(index, fieldNames, type, this);
|
||||||
} else if ("soft".equals(cacheType)) {
|
} else if ("soft".equals(cacheType)) {
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class IndicesFieldDataCache extends AbstractComponent implements RemovalL
|
||||||
@Inject
|
@Inject
|
||||||
public IndicesFieldDataCache(Settings settings) {
|
public IndicesFieldDataCache(Settings settings) {
|
||||||
super(settings);
|
super(settings);
|
||||||
this.size = componentSettings.get("size", "40%");
|
this.size = componentSettings.get("size", "-1");
|
||||||
this.expire = componentSettings.getAsTime("expire", null);
|
this.expire = componentSettings.getAsTime("expire", null);
|
||||||
computeSizeInBytes();
|
computeSizeInBytes();
|
||||||
buildCache();
|
buildCache();
|
||||||
|
@ -62,17 +62,22 @@ public class IndicesFieldDataCache extends AbstractComponent implements RemovalL
|
||||||
private void buildCache() {
|
private void buildCache() {
|
||||||
CacheBuilder<Key, AtomicFieldData> cacheBuilder = CacheBuilder.newBuilder()
|
CacheBuilder<Key, AtomicFieldData> cacheBuilder = CacheBuilder.newBuilder()
|
||||||
.removalListener(this);
|
.removalListener(this);
|
||||||
cacheBuilder.maximumWeight(sizeInBytes).weigher(new FieldDataWeigher());
|
if (sizeInBytes > 0) {
|
||||||
|
cacheBuilder.maximumWeight(sizeInBytes).weigher(new FieldDataWeigher());
|
||||||
|
}
|
||||||
// defaults to 4, but this is a busy map for all indices, increase it a bit
|
// defaults to 4, but this is a busy map for all indices, increase it a bit
|
||||||
cacheBuilder.concurrencyLevel(16);
|
cacheBuilder.concurrencyLevel(16);
|
||||||
if (expire != null) {
|
if (expire != null && expire.millis() > 0) {
|
||||||
cacheBuilder.expireAfterAccess(expire.millis(), TimeUnit.MILLISECONDS);
|
cacheBuilder.expireAfterAccess(expire.millis(), TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
logger.debug("using size [{}] [{}], expire [{}]", size, new ByteSizeValue(sizeInBytes), expire);
|
||||||
cache = cacheBuilder.build();
|
cache = cacheBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void computeSizeInBytes() {
|
private void computeSizeInBytes() {
|
||||||
if (size.endsWith("%")) {
|
if (size.equals("-1")) {
|
||||||
|
sizeInBytes = -1;
|
||||||
|
} else if (size.endsWith("%")) {
|
||||||
double percent = Double.parseDouble(size.substring(0, size.length() - 1));
|
double percent = Double.parseDouble(size.substring(0, size.length() - 1));
|
||||||
sizeInBytes = (long) ((percent / 100) * JvmInfo.jvmInfo().getMem().getHeapMax().bytes());
|
sizeInBytes = (long) ((percent / 100) * JvmInfo.jvmInfo().getMem().getHeapMax().bytes());
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue