sigram commented on a change in pull request #1100: SOLR-13579: Create resource management API URL: https://github.com/apache/lucene-solr/pull/1100#discussion_r365719144
########## File path: solr/core/src/java/org/apache/solr/managed/DefaultResourceManager.java ########## @@ -0,0 +1,231 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.apache.solr.managed; + +import java.io.IOException; +import java.lang.invoke.MethodHandles; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +import org.apache.solr.common.params.CommonParams; +import org.apache.solr.common.util.ExecutorUtil; +import org.apache.solr.common.util.IOUtils; +import org.apache.solr.common.util.TimeSource; +import org.apache.solr.core.PluginInfo; +import org.apache.solr.core.SolrResourceLoader; +import org.apache.solr.managed.types.CacheManagerPool; +import org.apache.solr.search.SolrCache; +import org.apache.solr.util.DefaultSolrThreadFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Default implementation of {@link ResourceManager}. + * <p>Resource pools managed by this implementation are run periodically, each according to + * its schedule defined by {@link #SCHEDULE_DELAY_SECONDS_PARAM} parameter during the pool creation.</p> + */ +public class DefaultResourceManager extends ResourceManager { + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + + public static final String SCHEDULE_DELAY_SECONDS_PARAM = "scheduleDelaySeconds"; + public static final String MAX_NUM_POOLS_PARAM = "maxNumPools"; + + public static final int DEFAULT_MAX_POOLS = 100; + public static final int DEFAULT_SCHEDULE_DELAY_SECONDS = 10; + + public static final String NODE_SEARCHER_CACHE_POOL = "nodeSearcherCachePool"; + + public static final Map<String, Map<String, Object>> DEFAULT_NODE_POOLS = new HashMap<>(); + + static { + Map<String, Object> params = new HashMap<>(); + params.put(CommonParams.TYPE, CacheManagerPool.TYPE); + // unlimited RAM + params.put(SolrCache.MAX_RAM_MB_PARAM, -1L); + DEFAULT_NODE_POOLS.put(NODE_SEARCHER_CACHE_POOL, params); + } + + + protected int maxNumPools = DEFAULT_MAX_POOLS; + + protected Map<String, ResourceManagerPool> resourcePools = new ConcurrentHashMap<>(); + + + private TimeSource timeSource; + + /** + * Thread pool for scheduling the pool runs. + */ + private ScheduledThreadPoolExecutor scheduledThreadPoolExecutor; + + protected boolean isClosed = false; + protected boolean enabled = true; Review comment: This is modified in superclass `setEnabled(Boolean)`, which in turn is invoked by `PluginUtils.invokeSetters`. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org