lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [lucene-solr] 14/36: Small fixes and improvements.
Date Wed, 18 Dec 2019 16:38:52 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 0876676ea869930b123d9e22caf86751e4443a40
Author: Andrzej Bialecki <ab@apache.org>
AuthorDate: Thu Jul 18 18:49:22 2019 +0200

    Small fixes and improvements.
---
 solr/core/src/java/org/apache/solr/core/CoreContainer.java       | 8 ++++++++
 .../org/apache/solr/handler/admin/ResourceManagerHandler.java    | 8 ++++----
 .../java/org/apache/solr/managed/DefaultResourceManagerPool.java | 9 +++++++--
 solr/core/src/java/org/apache/solr/managed/ResourceManager.java  | 2 ++
 4 files changed, 21 insertions(+), 6 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 b68e701..7f27ac9 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -100,6 +100,7 @@ import org.apache.solr.logging.LogWatcher;
 import org.apache.solr.logging.MDCLoggingContext;
 import org.apache.solr.managed.DefaultResourceManager;
 import org.apache.solr.managed.ResourceManager;
+import org.apache.solr.managed.plugins.CacheManagerPlugin;
 import org.apache.solr.metrics.SolrCoreMetricManager;
 import org.apache.solr.metrics.SolrMetricManager;
 import org.apache.solr.metrics.SolrMetricProducer;
@@ -616,6 +617,13 @@ public class CoreContainer {
     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,
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 bd65132..596672d 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
@@ -45,7 +45,6 @@ public class ResourceManagerHandler extends RequestHandlerBase implements
Permis
   private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
   public static final String POOL_PARAM = "pool";
-  public static final String RESOURCE_PARAM = "resource";
   public static final String LIMIT_PREFIX_PARAM = "limit.";
   public static final String ARG_PREFIX_PARAM = "arg.";
   public static final String POOL_ACTION_PARAM = "poolAction";
@@ -138,6 +137,7 @@ public class ResourceManagerHandler extends RequestHandlerBase implements
Permis
           perPool.add("size", pool.getResources().size());
           perPool.add("limits", pool.getPoolLimits());
           perPool.add("args", pool.getArgs());
+          perPool.add("resources", pool.getResources().keySet());
         });
         break;
       case STATUS:
@@ -151,7 +151,7 @@ public class ResourceManagerHandler extends RequestHandlerBase implements
Permis
         result.add("args", pool.getArgs());
         result.add("resources", pool.getResources().keySet());
         try {
-          result.add("currentValues", pool.getCurrentValues());
+          pool.getCurrentValues();
           result.add("totalValues", pool.getTotalValues());
         } catch (Exception e) {
           log.warn("Error getting current values from pool " + name, e);
@@ -230,9 +230,9 @@ public class ResourceManagerHandler extends RequestHandlerBase implements
Permis
     if (pool == null) {
       throw new SolrException(SolrException.ErrorCode.NOT_FOUND, "Pool '" + poolName + "'
not found.");
     }
-    String resName = params.get(RESOURCE_PARAM);
+    String resName = params.get(CommonParams.NAME);
     if ((resName == null || resName.isBlank()) && op != ResOp.LIST) {
-      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Missing '" + RESOURCE_PARAM
+ "' parameter.");
+      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Missing '" + CommonParams.NAME
+ "' parameter.");
     }
     NamedList<Object> result = new SimpleOrderedMap<>();
     switch (op) {
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 aada8c2..3295ef6 100644
--- a/solr/core/src/java/org/apache/solr/managed/DefaultResourceManagerPool.java
+++ b/solr/core/src/java/org/apache/solr/managed/DefaultResourceManagerPool.java
@@ -123,11 +123,16 @@ public class DefaultResourceManagerPool implements ResourceManagerPool
{
         if (!(v instanceof Number)) {
           return;
         }
+        Float val = ((Number)v).floatValue();
+        // -1 and MAX_VALUE are our special guard values
+        if (val < 0 || val.longValue() == Long.MAX_VALUE || val.longValue() == Integer.MAX_VALUE)
{
+          return;
+        }
         Float total = newTotalValues.get(k);
         if (total == null) {
-          newTotalValues.put(k, ((Number)v).floatValue());
+          newTotalValues.put(k, val);
         } else {
-          newTotalValues.put(k, total + ((Number)v).floatValue());
+          newTotalValues.put(k, total + val);
         }
       }));
       totalValues = newTotalValues;
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 aaeedbf..bd2e924 100644
--- a/solr/core/src/java/org/apache/solr/managed/ResourceManager.java
+++ b/solr/core/src/java/org/apache/solr/managed/ResourceManager.java
@@ -36,6 +36,8 @@ import org.slf4j.LoggerFactory;
 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";
+
   protected PluginInfo pluginInfo;
   protected boolean isClosed = false;
   protected boolean enabled = true;


Mime
View raw message