add logging with a reason why the cache is cleared (filter and field)

This commit is contained in:
Shay Banon 2012-05-01 16:36:05 +03:00
parent d01f925000
commit 771225ccc9
9 changed files with 23 additions and 20 deletions

View File

@ -122,15 +122,15 @@ public class TransportClearIndicesCacheAction extends TransportBroadcastOperatio
boolean clearedAtLeastOne = false;
if (request.filterCache()) {
clearedAtLeastOne = true;
service.cache().filter().clear();
service.cache().filter().clear("api");
}
if (request.fieldDataCache()) {
clearedAtLeastOne = true;
if (request.fields() == null || request.fields().length == 0) {
service.cache().fieldData().clear();
service.cache().fieldData().clear("api");
} else {
for (String field : request.fields()) {
service.cache().fieldData().clear(field);
service.cache().fieldData().clear("api", field);
}
}
}
@ -146,10 +146,10 @@ public class TransportClearIndicesCacheAction extends TransportBroadcastOperatio
if (request.fields() != null && request.fields().length > 0) {
// only clear caches relating to the specified fields
for (String field : request.fields()) {
service.cache().fieldData().clear(field);
service.cache().fieldData().clear("api", field);
}
} else {
service.cache().clear();
service.cache().clear("api");
}
}
service.cache().invalidateCache();

View File

@ -138,9 +138,9 @@ public class IndexCache extends AbstractIndexComponent implements CloseableCompo
bloomCache.clear(reader);
}
public void clear() {
filterCache.clear();
fieldDataCache.clear();
public void clear(String reason) {
filterCache.clear(reason);
fieldDataCache.clear(reason);
idCache.clear();
queryParserCache.clear();
bloomCache.clear();

View File

@ -36,9 +36,9 @@ public interface FieldDataCache extends IndexComponent, CloseableComponent {
String type();
void clear(String fieldName);
void clear(String reason, String fieldName);
void clear();
void clear(String reason);
void clear(IndexReader reader);

View File

@ -54,12 +54,12 @@ public class NoneFieldDataCache extends AbstractIndexComponent implements FieldD
}
@Override
public void clear(String fieldName) {
public void clear(String reason, String fieldName) {
}
@Override
public void clear() {
public void clear(String reason) {
}
@Override

View File

@ -125,7 +125,7 @@ public class ResidentFieldDataCache extends AbstractConcurrentMapFieldDataCache
ResidentFieldDataCache.this.expire = expire;
}
if (changed) {
clear();
clear("update_settings");
}
}
}

View File

@ -53,18 +53,20 @@ public abstract class AbstractConcurrentMapFieldDataCache extends AbstractIndexC
@Override
public void close() throws ElasticSearchException {
clear();
clear("close");
}
@Override
public void clear(String fieldName) {
public void clear(String reason, String fieldName) {
logger.debug("clearing field [{}] cache, reason [{}]", fieldName, reason);
for (Map.Entry<Object, Cache<String, FieldData>> entry : cache.entrySet()) {
entry.getValue().invalidate(fieldName);
}
}
@Override
public void clear() {
public void clear(String reason) {
logger.debug("full cache clear, reason [{}]", reason);
cache.clear();
}

View File

@ -47,7 +47,7 @@ public interface FilterCache extends IndexComponent, CloseableComponent {
void clear(IndexReader reader);
void clear();
void clear(String reason);
EntriesStats entriesStats();

View File

@ -60,7 +60,7 @@ public class NoneFilterCache extends AbstractIndexComponent implements FilterCac
}
@Override
public void clear() {
public void clear(String reason) {
// nothing to do here
}

View File

@ -70,12 +70,13 @@ public class WeightedFilterCache extends AbstractIndexComponent implements Filte
@Override
public void close() throws ElasticSearchException {
clear();
clear("close");
indicesFilterCache.removeRemovalListener(index.name());
}
@Override
public void clear() {
public void clear(String reason) {
logger.debug("full cache clear, reason [{}]", reason);
for (Object readerKey : seenReaders.keySet()) {
Boolean removed = seenReaders.remove(readerKey);
if (removed == null) {