You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ja...@apache.org on 2021/03/26 16:43:05 UTC

[lucene] 02/03: Optimized FreeDiskVariable

This is an automated email from the ASF dual-hosted git repository.

janhoy pushed a commit to tag history/branches/lucene-solr/jira/solr14275
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit 97833376a1de98c46b2de33357e0ab58c624fbc3
Author: noble <no...@apache.org>
AuthorDate: Mon Mar 30 13:22:46 2020 +1100

    Optimized FreeDiskVariable
---
 .../solr/client/solrj/cloud/autoscaling/FreeDiskVariable.java  |  7 +++++++
 .../solr/client/solrj/cloud/autoscaling/PerClauseData.java     |  1 +
 .../org/apache/solr/client/solrj/cloud/autoscaling/Row.java    | 10 +++++++++-
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/FreeDiskVariable.java b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/FreeDiskVariable.java
index 2193ea3..ddc6e1a 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/FreeDiskVariable.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/FreeDiskVariable.java
@@ -148,6 +148,13 @@ public class FreeDiskVariable extends VariableBase {
   @Override
   public void projectAddReplica(Cell cell, ReplicaInfo ri, Consumer<Row.OperationInfo> ops, boolean strictMode) {
     //go through other replicas of this shard and copy the index size value into this
+    if(cell.getRow().session.perClauseData != null){
+      PerClauseData.ShardDetails sd = cell.getRow().session.perClauseData.getShardDetails(ri.getCollection(), ri.getShard());
+      if(sd.indexSize == null) return;
+      Double currFreeDisk = cell.val == null ? 0.0d : (Double) cell.val;
+      cell.val = currFreeDisk - sd.indexSize;
+      return;
+    }
     for (Row row : cell.getRow().session.matrix) {
       row.forEachReplica(replicaInfo -> {
         if (ri != replicaInfo &&
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/PerClauseData.java b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/PerClauseData.java
index 5e152b8..cc815ba 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/PerClauseData.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/PerClauseData.java
@@ -91,6 +91,7 @@ public class PerClauseData implements ReflectMapWriter, Cloneable {
   public static class ShardDetails implements ReflectMapWriter, Cloneable {
     final String coll;
     final String shard;
+    Double indexSize;
     ReplicaCount replicas = new ReplicaCount();
 
     public Map<Clause, Map<String, ReplicaCount>> values = new HashMap<>();
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/Row.java b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/Row.java
index 9c69c02..a288815 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/Row.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/Row.java
@@ -41,6 +41,7 @@ import org.apache.solr.common.util.Utils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.apache.solr.client.solrj.cloud.autoscaling.Variable.Type.CORE_IDX;
 import static org.apache.solr.common.params.CoreAdminParams.NODE;
 
 /**
@@ -400,7 +401,14 @@ public class Row implements MapWriter {
 
   void initPerClauseData() {
     if(session== null || session.perClauseData == null) return;
-    forEachReplica(it -> session.perClauseData.getShardDetails(it.getCollection(), it.getShard()).replicas.increment(it.getType()));
+    forEachReplica(it -> {
+      PerClauseData.ShardDetails shardDetails = session.perClauseData.getShardDetails(it.getCollection(), it.getShard());
+      shardDetails.replicas.increment(it.getType());
+      Number idxSize = (Number) it.getVariable(CORE_IDX.tagName);
+      if(idxSize != null){
+        shardDetails.indexSize = idxSize.doubleValue();
+      }
+    });
     for (Clause clause : session.expandedClauses) {
       if(clause.put == Clause.Put.ON_EACH) continue;
       if(clause.dataGrouping == Clause.DataGrouping.SHARD || clause.dataGrouping == Clause.DataGrouping.COLL) {