lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [lucene-solr] 16/36: Initial integration with SolrIndexSearcher caches.
Date Wed, 18 Dec 2019 16:38:54 GMT
This is an automated email from the ASF dual-hosted git repository.

ab pushed a commit to branch jira/solr-13579
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit 1f742686feba3cf5a3db0fb94892a89d083d4a6b
Author: Andrzej Bialecki <ab@apache.org>
AuthorDate: Tue Jul 23 20:42:07 2019 +0200

    Initial integration with SolrIndexSearcher caches.
---
 .../java/org/apache/solr/core/CoreContainer.java   |  27 ++--
 .../solr/handler/admin/ResourceManagerHandler.java |  18 +--
 .../solr/managed/DefaultResourceManager.java       |  35 ++++-
 .../solr/managed/DefaultResourceManagerPool.java   |  12 +-
 .../apache/solr/managed/ManagedMetricProducer.java |   5 -
 .../org/apache/solr/managed/ManagedResource.java   |  27 ++--
 .../apache/solr/managed/NoOpResourceManager.java   | 141 +++++++++++++++++++++
 .../java/org/apache/solr/managed/ResourceId.java   |  63 +++++++++
 .../org/apache/solr/managed/ResourceManager.java   | 103 ++++++++++++++-
 .../apache/solr/managed/ResourceManagerPlugin.java |   4 +-
 .../apache/solr/managed/ResourceManagerPool.java   |   2 +-
 .../solr/managed/plugins/CacheManagerPlugin.java   |  30 ++---
 .../java/org/apache/solr/search/FastLRUCache.java  |  21 +++
 .../src/java/org/apache/solr/search/LFUCache.java  |  21 +++
 .../src/java/org/apache/solr/search/LRUCache.java  |  20 +++
 .../src/java/org/apache/solr/search/SolrCache.java |  19 +--
 .../org/apache/solr/search/SolrIndexSearcher.java  |   9 ++
 17 files changed, 470 insertions(+), 87 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
index d350e12..5da961b 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -99,6 +99,7 @@ import org.apache.solr.handler.component.ShardHandlerFactory;
 import org.apache.solr.logging.LogWatcher;
 import org.apache.solr.logging.MDCLoggingContext;
 import org.apache.solr.managed.DefaultResourceManager;
+import org.apache.solr.managed.NoOpResourceManager;
 import org.apache.solr.managed.ResourceManager;
 import org.apache.solr.managed.plugins.CacheManagerPlugin;
 import org.apache.solr.metrics.SolrCoreMetricManager;
@@ -616,17 +617,6 @@ public class CoreContainer {
 
     metricManager = new SolrMetricManager(loader, cfg.getMetricsConfig());
 
-    resourceManager = new DefaultResourceManager(loader, TimeSource.NANO_TIME);
-    // TODO: get the config from solr.xml?
-    resourceManager.init(new PluginInfo("resourceManager", Collections.emptyMap()));
-    // TODO: create default pools from solr.xml?
-    try {
-      resourceManager.createPool(ResourceManager.SEARCHER_CACHE_POOL, CacheManagerPlugin.TYPE,
-          Collections.singletonMap("maxRamMB", 500), Collections.emptyMap());
-    } catch (Exception e) {
-      log.warn("failed to create default searcherCache pool,, disabling", e);
-    }
-
     coreContainerWorkExecutor = MetricUtils.instrumentedExecutorService(
         coreContainerWorkExecutor, null,
         metricManager.registry(SolrMetricManager.getRegistryName(SolrInfoBean.Group.node)),
@@ -677,6 +667,21 @@ public class CoreContainer {
 
     createMetricsHistoryHandler();
 
+    Map<String, Object> resManConfig = new HashMap<>();
+    Map<String, Object> poolConfigs = new HashMap<>(DefaultResourceManager.DEFAULT_NODE_POOLS);
+    resManConfig.put(DefaultResourceManager.POOL_CONFIGS_PARAM, poolConfigs);
+    if (isZooKeeperAware()) {
+      Map<String, Object> clusterProps = getZkController().getZkStateReader().getClusterProperties();
+      poolConfigs.putAll((Map<String, Object>)clusterProps.getOrDefault(DefaultResourceManager.POOL_CONFIGS_PARAM,
Collections.emptyMap()));
+    }
+    try {
+      resourceManager = ResourceManager.load(loader, TimeSource.NANO_TIME, DefaultResourceManager.class,
+          new PluginInfo("resourceManager", Collections.emptyMap()), poolConfigs);
+    } catch (Exception e) {
+      log.warn("Resource manager initialization error - disabling!", e);
+      resourceManager = NoOpResourceManager.INSTANCE;
+    }
+
     resourceManagerHandler = new ResourceManagerHandler(resourceManager);
     containerHandlers.put(RESOURCE_MANAGER_PATH, resourceManagerHandler);
     resourceManagerHandler.initializeMetrics(metricManager, SolrInfoBean.Group.node.toString(),
metricTag, RESOURCE_MANAGER_PATH);
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/ResourceManagerHandler.java
b/solr/core/src/java/org/apache/solr/handler/admin/ResourceManagerHandler.java
index 596672d..e76dbc7 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/ResourceManagerHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/ResourceManagerHandler.java
@@ -135,8 +135,8 @@ public class ResourceManagerHandler extends RequestHandlerBase implements
Permis
           result.add(p, perPool);
           perPool.add("type", pool.getType());
           perPool.add("size", pool.getResources().size());
-          perPool.add("limits", pool.getPoolLimits());
-          perPool.add("args", pool.getArgs());
+          perPool.add("poolLimits", pool.getPoolLimits());
+          perPool.add("poolParams", pool.getParams());
           perPool.add("resources", pool.getResources().keySet());
         });
         break;
@@ -147,8 +147,8 @@ public class ResourceManagerHandler extends RequestHandlerBase implements
Permis
         }
         result.add("type", pool.getType());
         result.add("size", pool.getResources().size());
-        result.add("limits", pool.getPoolLimits());
-        result.add("args", pool.getArgs());
+        result.add("poolLimits", pool.getPoolLimits());
+        result.add("poolParams", pool.getParams());
         result.add("resources", pool.getResources().keySet());
         try {
           pool.getCurrentValues();
@@ -242,7 +242,7 @@ public class ResourceManagerHandler extends RequestHandlerBase implements
Permis
           result.add(n, perRes);
           perRes.add("class", resource.getClass().getName());
           perRes.add("types", resource.getManagedResourceTypes());
-          perRes.add("managedLimits", resource.getManagedLimits());
+          perRes.add("resourceLimits", resource.getResourceLimits());
         });
         break;
       case STATUS:
@@ -252,7 +252,7 @@ public class ResourceManagerHandler extends RequestHandlerBase implements
Permis
         }
         result.add("class", resource.getClass().getName());
         result.add("types", resource.getManagedResourceTypes());
-        result.add("managedLimits", resource.getManagedLimits());
+        result.add("resourceLimits", resource.getResourceLimits());
         try {
           result.add("monitoredValues", resource.getMonitoredValues(Collections.emptySet()));
         } catch (Exception e) {
@@ -265,14 +265,14 @@ public class ResourceManagerHandler extends RequestHandlerBase implements
Permis
         if (resource1 == null) {
           throw new SolrException(SolrException.ErrorCode.NOT_FOUND, "Resource '" + resName
+ " not found in pool '" + poolName + "'.");
         }
-        result.add("managedLimits", resource1.getManagedLimits());
+        result.add("resourceLimits", resource1.getResourceLimits());
         break;
       case SETLIMITS:
         ManagedResource resource2 = pool.getResources().get(resName);
         if (resource2 == null) {
           throw new SolrException(SolrException.ErrorCode.NOT_FOUND, "Resource '" + resName
+ " not found in pool '" + poolName + "'.");
         }
-        Map<String, Object> currentLimits = new HashMap<>(resource2.getManagedLimits());
+        Map<String, Object> currentLimits = new HashMap<>(resource2.getResourceLimits());
         Map<String, Object> newLimits = getMap(params, LIMIT_PREFIX_PARAM);
         newLimits.forEach((k, v) -> {
           if (v == null) {
@@ -281,7 +281,7 @@ public class ResourceManagerHandler extends RequestHandlerBase implements
Permis
             currentLimits.put(k, v);
           }
         });
-        resource2.setManagedLimits(newLimits);
+        resource2.setResourceLimits(newLimits);
         result.add("success", newLimits);
         break;
       case DELETE:
diff --git a/solr/core/src/java/org/apache/solr/managed/DefaultResourceManager.java b/solr/core/src/java/org/apache/solr/managed/DefaultResourceManager.java
index e8c9c99..df211b3 100644
--- a/solr/core/src/java/org/apache/solr/managed/DefaultResourceManager.java
+++ b/solr/core/src/java/org/apache/solr/managed/DefaultResourceManager.java
@@ -20,17 +20,21 @@ 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.plugins.CacheManagerPlugin;
+import org.apache.solr.search.SolrCache;
 import org.apache.solr.util.DefaultSolrThreadFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -43,12 +47,26 @@ import org.slf4j.LoggerFactory;
 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 = 30;
 
+  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, CacheManagerPlugin.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<>();
@@ -67,6 +85,7 @@ public class DefaultResourceManager extends ResourceManager {
   protected ResourceManagerPluginFactory resourceManagerPluginFactory;
   protected SolrResourceLoader loader;
 
+
   public DefaultResourceManager(SolrResourceLoader loader, TimeSource timeSource) {
     this.loader = loader;
     this.timeSource = timeSource;
@@ -77,7 +96,7 @@ public class DefaultResourceManager extends ResourceManager {
         new DefaultSolrThreadFactory(getClass().getSimpleName()));
     scheduledThreadPoolExecutor.setRemoveOnCancelPolicy(true);
     scheduledThreadPoolExecutor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
-    // TODO: make configurable
+    // TODO: make configurable based on plugin info
     resourceManagerPluginFactory = new DefaultResourceManagerPluginFactory(loader);
     log.info("Resource manager initialized.");
   }
@@ -127,7 +146,7 @@ public class DefaultResourceManager extends ResourceManager {
   }
 
   @Override
-  public void modifyPoolLimits(String name, Map<String, Object> poolLimits) throws
Exception {
+  public void setPoolLimits(String name, Map<String, Object> poolLimits) throws Exception
{
     ensureActive();
     ResourceManagerPool pool = resourcePools.get(name);
     if (pool == null) {
@@ -162,7 +181,7 @@ public class DefaultResourceManager extends ResourceManager {
         return;
       }
       if (otherPool.getType().equals(type)) {
-        throw new IllegalArgumentException("Resource " + managedResource.getResourceName()
+
+        throw new IllegalArgumentException("Resource " + managedResource.getResourceId()
+
             " is already managed in another pool (" +
             otherPool.getName() + ") of the same type " + type);
       }
@@ -171,6 +190,16 @@ public class DefaultResourceManager extends ResourceManager {
   }
 
   @Override
+  public boolean removeResource(String poolName, String resourceId) {
+    ensureActive();
+    ResourceManagerPool pool = resourcePools.get(poolName);
+    if (pool == null) {
+      throw new IllegalArgumentException("Pool '" + poolName + "' doesn't exist.");
+    }
+    return pool.removeResource(resourceId);
+  }
+
+  @Override
   public void close() throws IOException {
     synchronized (this) {
       isClosed = true;
diff --git a/solr/core/src/java/org/apache/solr/managed/DefaultResourceManagerPool.java b/solr/core/src/java/org/apache/solr/managed/DefaultResourceManagerPool.java
index 3295ef6..ace9da4 100644
--- a/solr/core/src/java/org/apache/solr/managed/DefaultResourceManagerPool.java
+++ b/solr/core/src/java/org/apache/solr/managed/DefaultResourceManagerPool.java
@@ -76,7 +76,7 @@ public class DefaultResourceManagerPool implements ResourceManagerPool {
   }
 
   @Override
-  public Map<String, Object> getArgs() {
+  public Map<String, Object> getParams() {
     return args;
   }
 
@@ -84,12 +84,12 @@ public class DefaultResourceManagerPool implements ResourceManagerPool
{
   public void addResource(ManagedResource managedResource) {
     Collection<String> types = managedResource.getManagedResourceTypes();
     if (!types.contains(type)) {
-      log.debug("Pool type '" + type + "' is not supported by the resource " + managedResource.getResourceName());
+      log.debug("Pool type '" + type + "' is not supported by the resource " + managedResource.getResourceId());
       return;
     }
-    ManagedResource existing = resources.putIfAbsent(managedResource.getResourceName(), managedResource);
+    ManagedResource existing = resources.putIfAbsent(managedResource.getResourceId().toString(),
managedResource);
     if (existing != null) {
-      throw new IllegalArgumentException("Resource '" + managedResource.getResourceName()
+ "' already exists in pool '" + name + "' !");
+      throw new IllegalArgumentException("Resource '" + managedResource.getResourceId() +
"' already exists in pool '" + name + "' !");
     }
   }
 
@@ -111,9 +111,9 @@ public class DefaultResourceManagerPool implements ResourceManagerPool
{
       Map<String, Map<String, Object>> currentValues = new HashMap<>();
       for (ManagedResource resource : resources.values()) {
         try {
-          currentValues.put(resource.getResourceName(), resource.getMonitoredValues(resourceManagerPlugin.getMonitoredTags()));
+          currentValues.put(resource.getResourceId().toString(), resource.getMonitoredValues(resourceManagerPlugin.getMonitoredParams()));
         } catch (Exception e) {
-          log.warn("Error getting managed values from " + resource.getResourceName(), e);
+          log.warn("Error getting managed values from " + resource.getResourceId(), e);
         }
       }
       // calculate totals
diff --git a/solr/core/src/java/org/apache/solr/managed/ManagedMetricProducer.java b/solr/core/src/java/org/apache/solr/managed/ManagedMetricProducer.java
index 00167ab6..891c1d8 100644
--- a/solr/core/src/java/org/apache/solr/managed/ManagedMetricProducer.java
+++ b/solr/core/src/java/org/apache/solr/managed/ManagedMetricProducer.java
@@ -44,9 +44,4 @@ public interface ManagedMetricProducer extends SolrInfoBean, ManagedResource
{
     });
     return result;
   }
-
-  @Override
-  default String getResourceName() {
-    return getName();
-  }
 }
diff --git a/solr/core/src/java/org/apache/solr/managed/ManagedResource.java b/solr/core/src/java/org/apache/solr/managed/ManagedResource.java
index 7ace1e1..d943384 100644
--- a/solr/core/src/java/org/apache/solr/managed/ManagedResource.java
+++ b/solr/core/src/java/org/apache/solr/managed/ManagedResource.java
@@ -30,9 +30,10 @@ public interface ManagedResource {
   Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
   /**
-   * Unique name of this resource.
+   * Unique name of this resource. By convention id-s form a dot-separated hierarchy that
+   * follows the naming of metric registries and metric names.
    */
-  String getResourceName();
+  ResourceId getResourceId();
 
   /**
    * Returns types of management plugins supported by this resource. This must always
@@ -41,38 +42,38 @@ public interface ManagedResource {
   Collection<String> getManagedResourceTypes();
 
   /**
-   * Set values of managed limits.
+   * Set values of managed resource limits.
    * @param limits map of limit names and values
    */
-  default void setManagedLimits(Map<String, Object> limits) {
+  default void setResourceLimits(Map<String, Object> limits) {
     if (limits == null) {
       return;
     }
     limits.forEach((key, value) -> {
       try {
-        setManagedLimit(key, value);
+        setResourceLimit(key, value);
       } catch (Exception e) {
-        log.warn("Exception setting managed limit on {}: key={}, value={}, exception={}",
-            getResourceName(), key, value, e);
+        log.warn("Exception setting resource limit on {}: key={}, value={}, exception={}",
+            getResourceId(), key, value, e);
       }
     });
   }
 
   /**
-   * Set value of a managed limit.
+   * Set value of a managed resource limit.
    * @param key limit name
    * @param value limit value
    */
-  void setManagedLimit(String key, Object value) throws Exception;
+  void setResourceLimit(String key, Object value) throws Exception;
 
   /**
-   * Returns current values of managed limits.
-   * @return map where keys are controlled tags and values are current limits
+   * Returns current values of managed resource limits.
+   * @return map where keys are controlled parameters and values are current values of limits
    */
-  Map<String, Object> getManagedLimits();
+  Map<String, Object> getResourceLimits();
 
   /**
-   * Returns monitored values that are used for calculating optimal settings of managed limits.
+   * Returns monitored values that are used for calculating optimal settings of managed resource
limits.
    * @param tags selected monitored tags, empty collection to return all monitored values
    * @return map of tags to current values.
    */
diff --git a/solr/core/src/java/org/apache/solr/managed/NoOpResourceManager.java b/solr/core/src/java/org/apache/solr/managed/NoOpResourceManager.java
new file mode 100644
index 0000000..08546aa
--- /dev/null
+++ b/solr/core/src/java/org/apache/solr/managed/NoOpResourceManager.java
@@ -0,0 +1,141 @@
+/*
+ * 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.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ *
+ */
+public class NoOpResourceManager extends ResourceManager {
+  public static final String NOOP = "--noop--";
+
+  public static final NoOpResourceManager INSTANCE = new NoOpResourceManager();
+
+  private static final class NoOpResourcePool implements ResourceManagerPool {
+    static NoOpResourcePool INSTANCE = new NoOpResourcePool();
+
+    @Override
+    public String getName() {
+      return NOOP;
+    }
+
+    @Override
+    public String getType() {
+      return NOOP;
+    }
+
+    @Override
+    public void addResource(ManagedResource managedResource) {
+
+    }
+
+    @Override
+    public boolean removeResource(String name) {
+      return false;
+    }
+
+    @Override
+    public Map<String, ManagedResource> getResources() {
+      return Collections.emptyMap();
+    }
+
+    @Override
+    public Map<String, Map<String, Object>> getCurrentValues() throws InterruptedException
{
+      return Collections.emptyMap();
+    }
+
+    @Override
+    public Map<String, Float> getTotalValues() throws InterruptedException {
+      return Collections.emptyMap();
+    }
+
+    @Override
+    public Map<String, Object> getPoolLimits() {
+      return Collections.emptyMap();
+    }
+
+    @Override
+    public Map<String, Object> getParams() {
+      return Collections.emptyMap();
+    }
+
+    @Override
+    public void setPoolLimits(Map<String, Object> poolLimits) {
+
+    }
+
+    @Override
+    public void close() throws IOException {
+
+    }
+
+    @Override
+    public void run() {
+
+    }
+  }
+
+  @Override
+  protected void doInit() throws Exception {
+
+  }
+
+  @Override
+  public void createPool(String name, String type, Map<String, Object> poolLimits,
Map<String, Object> args) throws Exception {
+
+  }
+
+  @Override
+  public Collection<String> listPools() {
+    return Collections.singleton(NoOpResourcePool.INSTANCE.getName());
+  }
+
+  @Override
+  public ResourceManagerPool getPool(String name) {
+    return NoOpResourcePool.INSTANCE;
+  }
+
+  @Override
+  public void setPoolLimits(String name, Map<String, Object> poolLimits) throws Exception
{
+
+  }
+
+  @Override
+  public void removePool(String name) throws Exception {
+
+  }
+
+  @Override
+  public void addResource(String pool, ManagedResource managedResource) throws Exception
{
+
+  }
+
+  @Override
+  public boolean removeResource(String pool, String resourceId) {
+    return false;
+  }
+
+  @Override
+  public void close() throws IOException {
+
+  }
+}
diff --git a/solr/core/src/java/org/apache/solr/managed/ResourceId.java b/solr/core/src/java/org/apache/solr/managed/ResourceId.java
new file mode 100644
index 0000000..81b7a80
--- /dev/null
+++ b/solr/core/src/java/org/apache/solr/managed/ResourceId.java
@@ -0,0 +1,63 @@
+/*
+ * 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.util.Arrays;
+
+import org.apache.solr.metrics.SolrMetricManager;
+
+/**
+ * Hierarchical resource id.
+ */
+public class ResourceId {
+  private final String name;
+  private final String[] path;
+  private final String id;
+
+  public ResourceId(String name, String... path) {
+    this.name = name;
+    this.path = path;
+    this.id = SolrMetricManager.mkName(name, path);
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public String[] getPath() {
+    return path;
+  }
+
+  public String toString() {
+    return id;
+  }
+
+  public ResourceId of(String fullName) {
+    if (fullName == null || fullName.isEmpty()) {
+      return null;
+    }
+    String[] parts = fullName.split("\\.");
+    if (parts.length > 1) {
+      String name = parts[parts.length - 1];
+      String[] path = Arrays.copyOfRange(parts, 0, parts.length - 1);
+      return new ResourceId(name, path);
+    } else {
+      return new ResourceId(parts[0]);
+    }
+  }
+}
diff --git a/solr/core/src/java/org/apache/solr/managed/ResourceManager.java b/solr/core/src/java/org/apache/solr/managed/ResourceManager.java
index bd2e924..43054fe 100644
--- a/solr/core/src/java/org/apache/solr/managed/ResourceManager.java
+++ b/solr/core/src/java/org/apache/solr/managed/ResourceManager.java
@@ -14,35 +14,97 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.apache.solr.managed;
 
 import java.lang.invoke.MethodHandles;
 import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.solr.common.SolrCloseable;
+import org.apache.solr.common.params.CommonParams;
 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.schema.FieldType;
 import org.apache.solr.util.SolrPluginUtils;
 import org.apache.solr.util.plugin.PluginInfoInitialized;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Base class for a resource managemer. It uses a flat model where there are named
+ * Base class for a resource management. It uses a flat model where there are named
  * resource pools of a given type, each pool with its own defined resource limits. Resources
can be added
  * to a pool for the management of a specific aspect of that resource using {@link ResourceManagerPlugin}.
  */
 public abstract class ResourceManager implements SolrCloseable, PluginInfoInitialized {
   private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
-  public static final String SEARCHER_CACHE_POOL = "searcherCache";
+  public static final String RESOURCE_MANAGER_PARAM = "resourceManager";
+  public static final String POOL_CONFIGS_PARAM = "poolConfigs";
+  public static final String POOL_LIMITS_PARAM = "poolLimits";
+  public static final String POOL_PARAMS_PARAM = "poolParams";
 
   protected PluginInfo pluginInfo;
   protected boolean isClosed = false;
   protected boolean enabled = true;
   protected boolean initialized = false;
 
+  /**
+   * Create a resource manager and optionally create configured pools.
+   * @param loader SolrResourceLoader instance
+   * @param timeSource time source instance
+   * @param resourceManagerClass implementation class for the resource manager
+   * @param pluginInfo resource manager plugin info
+   * @param config resource manager and pool configurations
+   */
+  public static ResourceManager load(SolrResourceLoader loader, TimeSource timeSource,
+                           Class<? extends ResourceManager> resourceManagerClass, PluginInfo
pluginInfo,
+                           Map<String, Object> config) throws Exception {
+    Map<String, Object> managerOverrides = (Map<String, Object>)config.getOrDefault(RESOURCE_MANAGER_PARAM,
Collections.emptyMap());
+    if (!managerOverrides.isEmpty()) {
+      Map<String, Object> pluginMap = new HashMap<>();
+      pluginInfo.toMap(pluginMap);
+      pluginMap.putAll(managerOverrides);
+      if (pluginMap.containsKey(FieldType.CLASS_NAME)) {
+        resourceManagerClass = loader.findClass((String)pluginMap.get(FieldType.CLASS_NAME),
ResourceManager.class);
+      }
+      pluginInfo = new PluginInfo(pluginInfo.type, pluginMap);
+    }
+
+    ResourceManager resourceManager = loader.newInstance(
+        resourceManagerClass.getName(),
+        resourceManagerClass,
+        null,
+        new Class[]{SolrResourceLoader.class, TimeSource.class},
+        new Object[]{loader, timeSource});
+    resourceManager.init(pluginInfo);
+    Map<String, Object> poolConfigs = (Map<String, Object>)config.get(POOL_CONFIGS_PARAM);
+    if (poolConfigs != null) {
+      for (String poolName : poolConfigs.keySet()) {
+        Map<String, Object> params = (Map<String, Object>)poolConfigs.get(poolName);
+        if (params == null || params.isEmpty()) {
+          throw new IllegalArgumentException("Pool '" + poolName + "' configuration missing:
" + poolConfigs);
+        }
+        String type = (String)params.get(CommonParams.TYPE);
+        if (type == null || type.isBlank()) {
+          throw new IllegalArgumentException("Pool '" + poolName + "' type is missing: "
+ params);
+        }
+        Map<String, Object> poolLimits = (Map<String, Object>)params.getOrDefault(POOL_LIMITS_PARAM,
Collections.emptyMap());
+        Map<String, Object> poolParams = (Map<String, Object>)params.getOrDefault(POOL_PARAMS_PARAM,
Collections.emptyMap());
+        try {
+          resourceManager.createPool(poolName, type, poolLimits, poolParams);
+        } catch (Exception e) {
+          log.warn("Failed to create resource manager pool '" + poolName + "'", e);
+        }
+      }
+    }
+    return resourceManager;
+  }
+
   @Override
   public void init(PluginInfo info) {
     if (info != null) {
@@ -81,6 +143,28 @@ public abstract class ResourceManager implements SolrCloseable, PluginInfoInitia
 
   protected abstract void doInit() throws Exception;
 
+  public void updatePoolConfigs(Map<String, Object> newPoolConfigs) throws Exception
{
+    if (newPoolConfigs == null || newPoolConfigs.isEmpty()) {
+      return;
+    }
+
+    for (Map.Entry<String, Object> entry : newPoolConfigs.entrySet()) {
+      String poolName = entry.getKey();
+      Map<String, Object> params = (Map<String, Object>)entry.getValue();
+      ResourceManagerPool pool = getPool(poolName);
+      if (pool == null) {
+        log.warn("Cannot update config - pool '" + poolName + "' not found.");
+        continue;
+      }
+      String type = (String)params.get(CommonParams.TYPE);
+      if (type == null || type.isBlank()) {
+        throw new IllegalArgumentException("Pool '" + poolName + "' type is missing: " +
params);
+      }
+      Map<String, Object> poolLimits = (Map<String, Object>)params.getOrDefault(POOL_LIMITS_PARAM,
Collections.emptyMap());
+      pool.setPoolLimits(poolLimits);
+    }
+  }
+
   /**
    * Create a named resource management pool.
    * @param name pool name
@@ -99,11 +183,12 @@ public abstract class ResourceManager implements SolrCloseable, PluginInfoInitia
   public abstract ResourceManagerPool getPool(String name);
 
   /**
-   * Modify pool limits.
+   * Modify pool limits of an existing pool.
    * @param name existing pool name
-   * @param poolLimits new pool limits
+   * @param poolLimits new pool limits. By convention only the values present in this map
will be modified,
+   *                   all other limits will remain unchanged. In order to remove a limit
use null value.
    */
-  public abstract void modifyPoolLimits(String name, Map<String, Object> poolLimits)
throws Exception;
+  public abstract void setPoolLimits(String name, Map<String, Object> poolLimits) throws
Exception;
 
   /**
    * Remove pool. This also stops the management of resources registered with that pool.
@@ -133,6 +218,14 @@ public abstract class ResourceManager implements SolrCloseable, PluginInfoInitia
    */
   public abstract void addResource(String pool, ManagedResource managedResource) throws Exception;
 
+  /**
+   * Remove a managed resource from a pool.
+   * @param pool existing pool name.
+   * @param resourceId resource id to remove
+   * @return true if a resource was actually registered and has been removed
+   */
+  public abstract boolean removeResource(String pool, String resourceId);
+
   protected void ensureActive() {
     if (isClosed()) {
       throw new IllegalStateException("Already closed.");
diff --git a/solr/core/src/java/org/apache/solr/managed/ResourceManagerPlugin.java b/solr/core/src/java/org/apache/solr/managed/ResourceManagerPlugin.java
index feb35a1..f531c46 100644
--- a/solr/core/src/java/org/apache/solr/managed/ResourceManagerPlugin.java
+++ b/solr/core/src/java/org/apache/solr/managed/ResourceManagerPlugin.java
@@ -33,12 +33,12 @@ public interface ResourceManagerPlugin {
    * Name of monitored parameters that {@link ManagedResource}-s managed by this plugin
    * are expected to support.
    */
-  Collection<String> getMonitoredTags();
+  Collection<String> getMonitoredParams();
   /**
    * Name of controlled parameters that {@link ManagedResource}-s managed by this plugin
    * are expected to support.
    */
-  Collection<String> getControlledTags();
+  Collection<String> getControlledParams();
 
   /**
    * Manage resources in a pool. This method is called periodically by {@link ResourceManager},
diff --git a/solr/core/src/java/org/apache/solr/managed/ResourceManagerPool.java b/solr/core/src/java/org/apache/solr/managed/ResourceManagerPool.java
index 453e293..cf32d40 100644
--- a/solr/core/src/java/org/apache/solr/managed/ResourceManagerPool.java
+++ b/solr/core/src/java/org/apache/solr/managed/ResourceManagerPool.java
@@ -40,7 +40,7 @@ public interface ResourceManagerPool extends Runnable, Closeable {
   Map<String, Object> getPoolLimits();
 
   /** Get parameters specified during creation. */
-  Map<String, Object> getArgs();
+  Map<String, Object> getParams();
 
   /**
    * Pool limits are defined using controlled tags.
diff --git a/solr/core/src/java/org/apache/solr/managed/plugins/CacheManagerPlugin.java b/solr/core/src/java/org/apache/solr/managed/plugins/CacheManagerPlugin.java
index 5adf7ef..1524d89 100644
--- a/solr/core/src/java/org/apache/solr/managed/plugins/CacheManagerPlugin.java
+++ b/solr/core/src/java/org/apache/solr/managed/plugins/CacheManagerPlugin.java
@@ -16,8 +16,8 @@ import org.slf4j.LoggerFactory;
  * the management of {@link org.apache.solr.search.SolrCache} instances.
  * <p>This plugin calculates the total size and maxRamMB of all registered cache instances
  * and adjusts each cache's limits so that the aggregated values again fit within the pool
limits.</p>
- * <p>In order to avoid thrashing the plugin uses a dead zone (by default {@link #DEFAULT_DEAD_ZONE}),
- * which can be adjusted using configuration parameter {@link #DEAD_ZONE}. If monitored values
don't
+ * <p>In order to avoid thrashing the plugin uses a dead zone (by default {@link #DEFAULT_DEAD_BAND}),
+ * which can be adjusted using configuration parameter {@link #DEAD_BAND}. If monitored values
don't
  * exceed the limits +/- the dead zone no action is taken.</p>
  */
 public class CacheManagerPlugin extends AbstractResourceManagerPlugin {
@@ -30,8 +30,8 @@ public class CacheManagerPlugin extends AbstractResourceManagerPlugin {
   public static final String RAM_BYTES_USED_TAG = "ramBytesUsed";
   public static final String MAX_RAM_MB_TAG = "maxRamMB";
 
-  public static final String DEAD_ZONE = "deadZone";
-  public static final float DEFAULT_DEAD_ZONE = 0.1f;
+  public static final String DEAD_BAND = "deadBand";
+  public static final float DEFAULT_DEAD_BAND = 0.1f;
 
   private static final Map<String, String> controlledToMonitored = new HashMap<>();
 
@@ -51,15 +51,15 @@ public class CacheManagerPlugin extends AbstractResourceManagerPlugin
{
       SIZE_TAG
   );
 
-  private float deadZone = DEFAULT_DEAD_ZONE;
+  private float deadBand = DEFAULT_DEAD_BAND;
 
   @Override
-  public Collection<String> getMonitoredTags() {
+  public Collection<String> getMonitoredParams() {
     return MONITORED_TAGS;
   }
 
   @Override
-  public Collection<String> getControlledTags() {
+  public Collection<String> getControlledParams() {
     return CONTROLLED_TAGS;
   }
 
@@ -70,11 +70,11 @@ public class CacheManagerPlugin extends AbstractResourceManagerPlugin
{
 
   @Override
   public void init(Map<String, Object> params) {
-    String deadZoneStr = String.valueOf(params.getOrDefault(DEAD_ZONE, DEFAULT_DEAD_ZONE));
+    String deadBandStr = String.valueOf(params.getOrDefault(DEAD_BAND, DEFAULT_DEAD_BAND));
     try {
-      deadZone = Float.parseFloat(deadZoneStr);
+      deadBand = Float.parseFloat(deadBandStr);
     } catch (Exception e) {
-      log.warn("Invalid deadZone parameter value '" + deadZoneStr + "', using default " +
DEFAULT_DEAD_ZONE);
+      log.warn("Invalid deadBand parameter value '" + deadBandStr + "', using default " +
DEFAULT_DEAD_BAND);
     }
   }
 
@@ -102,15 +102,15 @@ public class CacheManagerPlugin extends AbstractResourceManagerPlugin
{
       }
       float totalDelta = poolLimitValue - totalValue;
 
-      // dead zone to avoid thrashing
-      if (Math.abs(totalDelta / poolLimitValue) < deadZone) {
+      // dead band to avoid thrashing
+      if (Math.abs(totalDelta / poolLimitValue) < deadBand) {
         return;
       }
 
       float changeRatio = poolLimitValue / totalValue;
       // modify current limits by the changeRatio
       pool.getResources().forEach((name, resource) -> {
-        Map<String, Object> resourceLimits = resource.getManagedLimits();
+        Map<String, Object> resourceLimits = resource.getResourceLimits();
         Object limit = resourceLimits.get(poolLimitName);
         if (limit == null || !(limit instanceof Number)) {
           return;
@@ -121,10 +121,10 @@ public class CacheManagerPlugin extends AbstractResourceManagerPlugin
{
         }
         float newLimit = currentResourceLimit * changeRatio;
         try {
-          resource.setManagedLimit(poolLimitName, newLimit);
+          resource.setResourceLimit(poolLimitName, newLimit);
         } catch (Exception e) {
           log.warn("Failed to set managed limit " + poolLimitName +
-              " from " + currentResourceLimit + " to " + newLimit + " on " + resource.getResourceName(),
e);
+              " from " + currentResourceLimit + " to " + newLimit + " on " + resource.getResourceId(),
e);
         }
       });
     });
diff --git a/solr/core/src/java/org/apache/solr/search/FastLRUCache.java b/solr/core/src/java/org/apache/solr/search/FastLRUCache.java
index 8f19729..539cd05 100644
--- a/solr/core/src/java/org/apache/solr/search/FastLRUCache.java
+++ b/solr/core/src/java/org/apache/solr/search/FastLRUCache.java
@@ -20,6 +20,8 @@ import com.codahale.metrics.MetricRegistry;
 import org.apache.lucene.util.Accountable;
 import org.apache.lucene.util.RamUsageEstimator;
 import org.apache.solr.common.SolrException;
+import org.apache.solr.managed.ResourceId;
+import org.apache.solr.managed.plugins.CacheManagerPlugin;
 import org.apache.solr.metrics.MetricsMap;
 import org.apache.solr.metrics.SolrMetricManager;
 import org.apache.solr.util.ConcurrentLRUCache;
@@ -27,6 +29,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.lang.invoke.MethodHandles;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.List;
@@ -79,6 +83,7 @@ public class FastLRUCache<K, V> extends SolrCacheBase implements SolrCache<K,V>,
   private MetricsMap cacheMap;
   private Set<String> metricNames = ConcurrentHashMap.newKeySet();
   private MetricRegistry registry;
+  private ResourceId resourceId;
 
   @Override
   public Object init(Map args, Object persistence, CacheRegenerator regenerator) {
@@ -305,6 +310,7 @@ public class FastLRUCache<K, V> extends SolrCacheBase implements
SolrCache<K,V>,
       }
     });
     manager.registerGauge(this, registryName, cacheMap, tag, true, scope, getCategory().toString());
+    resourceId = new ResourceId(tag, registryName, getCategory().toString(), scope);
   }
 
 
@@ -343,6 +349,21 @@ public class FastLRUCache<K, V> extends SolrCacheBase implements
SolrCache<K,V>,
   }
 
   @Override
+  public Map<String, Object> getMonitoredValues(Collection<String> tags) throws
Exception {
+    return cacheMap.getValue();
+  }
+
+  @Override
+  public ResourceId getResourceId() {
+    return resourceId;
+  }
+
+  @Override
+  public Collection<String> getManagedResourceTypes() {
+    return Collections.singleton(CacheManagerPlugin.TYPE);
+  }
+
+  @Override
   public void setResourceLimit(String limitName, Object val) {
     if (CLEANUP_THREAD_PARAM.equals(limitName)) {
       Boolean value;
diff --git a/solr/core/src/java/org/apache/solr/search/LFUCache.java b/solr/core/src/java/org/apache/solr/search/LFUCache.java
index 37ef4c6..5750247 100644
--- a/solr/core/src/java/org/apache/solr/search/LFUCache.java
+++ b/solr/core/src/java/org/apache/solr/search/LFUCache.java
@@ -17,6 +17,8 @@
 package org.apache.solr.search;
 
 import java.lang.invoke.MethodHandles;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.List;
@@ -29,6 +31,8 @@ import com.codahale.metrics.MetricRegistry;
 import org.apache.lucene.util.Accountable;
 import org.apache.lucene.util.RamUsageEstimator;
 import org.apache.solr.common.SolrException;
+import org.apache.solr.managed.ResourceId;
+import org.apache.solr.managed.plugins.CacheManagerPlugin;
 import org.apache.solr.metrics.MetricsMap;
 import org.apache.solr.metrics.SolrMetricManager;
 import org.apache.solr.util.ConcurrentLFUCache;
@@ -80,6 +84,7 @@ public class LFUCache<K, V> implements SolrCache<K, V>, Accountable
{
   private MetricsMap cacheMap;
   private Set<String> metricNames = ConcurrentHashMap.newKeySet();
   private MetricRegistry registry;
+  private ResourceId resourceId;
 
   private int sizeLimit;
   private int minSizeLimit;
@@ -312,6 +317,7 @@ public class LFUCache<K, V> implements SolrCache<K, V>, Accountable
{
       }
     });
     manager.registerGauge(this, registryName, cacheMap, tag, true, scope, getCategory().toString());
+    resourceId = new ResourceId(tag, registryName, getCategory().toString(), scope);
   }
 
   // for unit tests only
@@ -346,6 +352,11 @@ public class LFUCache<K, V> implements SolrCache<K, V>, Accountable
{
   }
 
   @Override
+  public ResourceId getResourceId() {
+    return resourceId;
+  }
+
+  @Override
   public Map<String, Object> getResourceLimits() {
     Map<String, Object> limits = new HashMap<>();
     limits.put(SIZE_PARAM, cache.getStats().getCurrentSize());
@@ -359,6 +370,16 @@ public class LFUCache<K, V> implements SolrCache<K, V>, Accountable
{
   }
 
   @Override
+  public Map<String, Object> getMonitoredValues(Collection<String> tags) throws
Exception {
+    return cacheMap.getValue();
+  }
+
+  @Override
+  public Collection<String> getManagedResourceTypes() {
+    return Collections.singleton(CacheManagerPlugin.TYPE);
+  }
+
+  @Override
   public synchronized void setResourceLimit(String limitName, Object val) {
     if (TIME_DECAY_PARAM.equals(limitName) || CLEANUP_THREAD_PARAM.equals(limitName)) {
       Boolean value;
diff --git a/solr/core/src/java/org/apache/solr/search/LRUCache.java b/solr/core/src/java/org/apache/solr/search/LRUCache.java
index 3bd5f00..535c2f0 100644
--- a/solr/core/src/java/org/apache/solr/search/LRUCache.java
+++ b/solr/core/src/java/org/apache/solr/search/LRUCache.java
@@ -18,6 +18,7 @@ package org.apache.solr.search;
 
 import java.lang.invoke.MethodHandles;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.Iterator;
@@ -32,6 +33,8 @@ import org.apache.lucene.util.Accountable;
 import org.apache.lucene.util.Accountables;
 import org.apache.lucene.util.RamUsageEstimator;
 import org.apache.solr.common.SolrException;
+import org.apache.solr.managed.ResourceId;
+import org.apache.solr.managed.plugins.CacheManagerPlugin;
 import org.apache.solr.metrics.MetricsMap;
 import org.apache.solr.metrics.SolrMetricManager;
 import org.slf4j.Logger;
@@ -78,6 +81,7 @@ public class LRUCache<K,V> extends SolrCacheBase implements SolrCache<K,V>,
Acco
   private MetricRegistry registry;
   private int sizeLimit;
   private int initialSize;
+  private ResourceId resourceId;
 
   private long maxRamBytes = Long.MAX_VALUE;
   // The synchronization used for the map will be used to update this,
@@ -335,6 +339,7 @@ public class LRUCache<K,V> extends SolrCacheBase implements SolrCache<K,V>,
Acco
       res.put("cumulative_evictionsRamUsage", stats.evictionsRamUsage.longValue());
     });
     manager.registerGauge(this, registryName, cacheMap, tag, true, scope, getCategory().toString());
+    resourceId = new ResourceId(tag, registryName, getCategory().toString(), scope);
   }
 
   // for unit tests only
@@ -375,6 +380,21 @@ public class LRUCache<K,V> extends SolrCacheBase implements SolrCache<K,V>,
Acco
   }
 
   @Override
+  public Map<String, Object> getMonitoredValues(Collection<String> tags) throws
Exception {
+    return cacheMap.getValue();
+  }
+
+  @Override
+  public ResourceId getResourceId() {
+    return resourceId;
+  }
+
+  @Override
+  public Collection<String> getManagedResourceTypes() {
+    return Collections.singleton(CacheManagerPlugin.TYPE);
+  }
+
+  @Override
   public void setResourceLimit(String limitName, Object val) {
     if (!(val instanceof Number)) {
       try {
diff --git a/solr/core/src/java/org/apache/solr/search/SolrCache.java b/solr/core/src/java/org/apache/solr/search/SolrCache.java
index 2cf49da..14fbb82 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrCache.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrCache.java
@@ -17,6 +17,7 @@
 package org.apache.solr.search;
 
 import org.apache.solr.core.SolrInfoBean;
+import org.apache.solr.managed.ManagedResource;
 import org.apache.solr.metrics.SolrMetricProducer;
 
 import java.util.Map;
@@ -25,7 +26,7 @@ import java.util.Map;
 /**
  * Primary API for dealing with Solr's internal caches.
  */
-public interface SolrCache<K,V> extends SolrInfoBean, SolrMetricProducer {
+public interface SolrCache<K,V> extends SolrInfoBean, SolrMetricProducer, ManagedResource
{
 
   String SIZE_PARAM = "size";
   String MAX_RAM_MB_PARAM = "maxRamMB";
@@ -129,20 +130,4 @@ public interface SolrCache<K,V> extends SolrInfoBean, SolrMetricProducer
{
   /** Frees any non-memory resources */
   public void close();
 
-  /** Report current resource limits. */
-  public Map<String, Object> getResourceLimits();
-
-  /** Set resource limits. */
-  default void setResourceLimits(Map<String, Object> limits) throws Exception {
-    if (limits == null || limits.isEmpty()) {
-      return;
-    }
-    for (Map.Entry<String, Object> entry : limits.entrySet()) {
-      setResourceLimit(entry.getKey(), entry.getValue());
-    }
-  }
-
-  /** Set a named resource limit. */
-  public void setResourceLimit(String limitName, Object value) throws Exception;
-
 }
diff --git a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
index 8b121e0..561136e 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
@@ -67,6 +67,8 @@ import org.apache.solr.core.SolrConfig;
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.core.SolrInfoBean;
 import org.apache.solr.index.SlowCompositeReaderWrapper;
+import org.apache.solr.managed.DefaultResourceManager;
+import org.apache.solr.managed.ResourceManager;
 import org.apache.solr.metrics.SolrMetricManager;
 import org.apache.solr.metrics.SolrMetricProducer;
 import org.apache.solr.request.LocalSolrQueryRequest;
@@ -424,9 +426,15 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,
SolrI
       infoRegistry.put(cache.name(), cache);
     }
     metricManager = core.getCoreContainer().getMetricManager();
+    ResourceManager resourceManager = core.getCoreContainer().getResourceManager();
     registryName = core.getCoreMetricManager().getRegistryName();
     for (SolrCache cache : cacheList) {
       cache.initializeMetrics(metricManager, registryName, core.getMetricTag(), SolrMetricManager.mkName(cache.name(),
STATISTICS_KEY));
+      try {
+        resourceManager.addResource(DefaultResourceManager.NODE_SEARCHER_CACHE_POOL, cache);
+      } catch (Exception e) {
+        log.warn("Exception adding cache '" + cache.getResourceId() + "' to the resource
manager pool", e);
+      }
     }
     initializeMetrics(metricManager, registryName, core.getMetricTag(), STATISTICS_KEY);
     registerTime = new Date();
@@ -471,6 +479,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,
SolrI
     }
 
     for (SolrCache cache : cacheList) {
+      core.getCoreContainer().getResourceManager().removeResource(DefaultResourceManager.NODE_SEARCHER_CACHE_POOL,
cache.getResourceId().toString());
       cache.close();
     }
 


Mime
View raw message