forked from elastic/elasticsearch
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added an indices level field data cache listener that always gets inv…
…oked and updates indices statistics and services about field data loading and unloading. Moved the circuit breaker memory reducing logic to the IndicesFieldDataCacheListener, so it always reduces the memory used when field data gets unloaded, this fixes a issue where the circuit breaker didn't get reduced when segments where no shardId could be resolved get cleared up. Also made sure that exceptions in the percolator service are bubbled up properly. Closes elastic#5588
- Loading branch information
Showing
8 changed files
with
129 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/java/org/elasticsearch/indices/fielddata/cache/IndicesFieldDataCacheListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.indices.fielddata.cache; | ||
|
||
import org.elasticsearch.common.Nullable; | ||
import org.elasticsearch.common.inject.Inject; | ||
import org.elasticsearch.index.fielddata.AtomicFieldData; | ||
import org.elasticsearch.index.fielddata.FieldDataType; | ||
import org.elasticsearch.index.fielddata.IndexFieldDataCache; | ||
import org.elasticsearch.index.mapper.FieldMapper; | ||
import org.elasticsearch.indices.fielddata.breaker.CircuitBreakerService; | ||
|
||
/** | ||
* A {@link IndexFieldDataCache.Listener} implementation that updates indices (node) level statistics / service about | ||
* field data entries being loaded and unloaded. | ||
* | ||
* Currently it only decrements the memory used in the {@link CircuitBreakerService}. | ||
*/ | ||
public class IndicesFieldDataCacheListener implements IndexFieldDataCache.Listener { | ||
|
||
private final CircuitBreakerService circuitBreakerService; | ||
|
||
@Inject | ||
public IndicesFieldDataCacheListener(CircuitBreakerService circuitBreakerService) { | ||
this.circuitBreakerService = circuitBreakerService; | ||
} | ||
|
||
@Override | ||
public void onLoad(FieldMapper.Names fieldNames, FieldDataType fieldDataType, AtomicFieldData fieldData) { | ||
} | ||
|
||
@Override | ||
public void onUnload(FieldMapper.Names fieldNames, FieldDataType fieldDataType, boolean wasEvicted, long sizeInBytes, @Nullable AtomicFieldData fieldData) { | ||
assert sizeInBytes > 0 : "When reducing circuit breaker, it should be adjusted with a positive number and not [" + sizeInBytes + "]"; | ||
circuitBreakerService.getBreaker().addWithoutBreaking(-sizeInBytes); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.