Java Code Examples for org.elasticsearch.index.engine.Engine#onSettingsChanged()

The following examples show how to use org.elasticsearch.index.engine.Engine#onSettingsChanged() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IndexShard.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
/**
 * Change the indexing and translog buffer sizes.  If {@code IndexWriter} is currently using more than
 * the new buffering indexing size then we do a refresh to free up the heap.
 */
public void updateBufferSize(ByteSizeValue shardIndexingBufferSize, ByteSizeValue shardTranslogBufferSize) {

    final EngineConfig config = engineConfig;
    final ByteSizeValue preValue = config.getIndexingBufferSize();

    config.setIndexingBufferSize(shardIndexingBufferSize);

    Engine engine = engineUnsafe();
    if (engine == null) {
        logger.debug("updateBufferSize: engine is not initialized yet; skipping");
        return;
    }

    // update engine if it is already started.
    if (preValue.bytes() != shardIndexingBufferSize.bytes()) {
        // so we push changes these changes down to IndexWriter:
        engine.onSettingsChanged();

        long iwBytesUsed = engine.indexWriterRAMBytesUsed();

        String message = LoggerMessageFormat.format("updating index_buffer_size from [{}] to [{}]; IndexWriter now using [{}] bytes",
                preValue, shardIndexingBufferSize, iwBytesUsed);

        if (iwBytesUsed > shardIndexingBufferSize.bytes()) {
            // our allowed buffer was changed to less than we are currently using; we ask IW to refresh
            // so it clears its buffers (otherwise it won't clear until the next indexing/delete op)
            logger.debug(message + "; now refresh to clear IndexWriter memory");

            // TODO: should IW have an API to move segments to disk, but not refresh?  Its flush method is protected...
            try {
                refresh("update index buffer");
            } catch (Throwable e) {
                logger.warn("failed to refresh after decreasing index buffer", e);
            }
        } else {
            logger.debug(message);
        }
    }
    engine.getTranslog().updateBuffer(shardTranslogBufferSize);
}
 
Example 2
Source File: IndexShard.java    From crate with Apache License 2.0 4 votes vote down vote up
public void onSettingsChanged() {
    Engine engineOrNull = getEngineOrNull();
    if (engineOrNull != null) {
        engineOrNull.onSettingsChanged();
    }
}