Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
/*
* 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.
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
package org.opensearch.common.util;
import org.apache.lucene.util.RamUsageEstimator;
import org.opensearch.common.recycler.AbstractRecyclerC;
import org.opensearch.common.recycler.Recycler;
import org.opensearch.common.settings.Setting;
import org.opensearch.common.settings.Setting.Property;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.unit.ByteSizeValue;
import org.opensearch.common.util.concurrent.OpenSearchExecutors;
import java.util.Arrays;
import java.util.Locale;
import static org.opensearch.common.recycler.Recyclers.concurrent;
import static org.opensearch.common.recycler.Recyclers.concurrentDeque;
import static org.opensearch.common.recycler.Recyclers.dequeFactory;
import static org.opensearch.common.recycler.Recyclers.none;
/** A recycler of fixed-size pages. */
public class PageCacheRecycler {
public static final Setting TYPE_SETTING = new Setting<>(
"cache.recycler.page.type",
Type.CONCURRENT.name(),
Type::parse,
Property.NodeScope
);
public static final Setting LIMIT_HEAP_SETTING = Setting.memorySizeSetting(
"cache.recycler.page.limit.heap",
"10%",
Property.NodeScope
);
public static final Setting WEIGHT_BYTES_SETTING = Setting.doubleSetting(
"cache.recycler.page.weight.bytes",
1d,
0d,
Property.NodeScope
);
public static final Setting WEIGHT_LONG_SETTING = Setting.doubleSetting(
"cache.recycler.page.weight.longs",
1d,
0d,
Property.NodeScope
);
public static final Setting WEIGHT_INT_SETTING = Setting.doubleSetting(
"cache.recycler.page.weight.ints",
1d,
0d,
Property.NodeScope
);
// object pages are less useful to us so we give them a lower weight by default
public static final Setting WEIGHT_OBJECTS_SETTING = Setting.doubleSetting(
"cache.recycler.page.weight.objects",
0.1d,
0d,
Property.NodeScope
);
/** Page size in bytes: 16KB */
public static final int PAGE_SIZE_IN_BYTES = 1 << 14;
public static final int OBJECT_PAGE_SIZE = PAGE_SIZE_IN_BYTES / RamUsageEstimator.NUM_BYTES_OBJECT_REF;
public static final int LONG_PAGE_SIZE = PAGE_SIZE_IN_BYTES / Long.BYTES;
public static final int INT_PAGE_SIZE = PAGE_SIZE_IN_BYTES / Integer.BYTES;
public static final int BYTE_PAGE_SIZE = PAGE_SIZE_IN_BYTES;
private final Recycler bytePage;
private final Recycler intPage;
private final Recycler longPage;
private final Recycler