dsmiley commented on code in PR #1485:
URL: https://github.com/apache/solr/pull/1485#discussion_r1146295091


##########
solr/core/src/java/org/apache/solr/cloud/api/collections/SplitShardCmd.java:
##########
@@ -873,42 +873,85 @@ public static void checkDiskSpace(
       SolrIndexSplitter.SplitMethod method,
       SolrCloudManager cloudManager)
       throws SolrException {
+
     // check that enough disk space is available on the parent leader node
     // otherwise the actual index splitting will always fail
-    NodeStateProvider nodeStateProvider = cloudManager.getNodeStateProvider();
-    Map<String, Object> nodeValues =
-        nodeStateProvider.getNodeValues(
-            parentShardLeader.getNodeName(), 
Collections.singletonList(ImplicitSnitch.DISK));
-    Map<String, Map<String, List<Replica>>> infos =
-        nodeStateProvider.getReplicaInfo(
-            parentShardLeader.getNodeName(), 
Collections.singletonList(CORE_IDX.metricsAttribute));
-    if (infos.get(collection) == null || infos.get(collection).get(shard) == 
null) {
+
+    ModifiableSolrParams params;
+    String metricName;
+    GenericSolrRequest req;
+    SolrResponse rsp;
+
+    metricName =
+        new StringBuilder("solr.core.")
+            .append(collection)
+            .append(".")
+            .append(shard)
+            .append(".")
+            .append(Utils.parseMetricsReplicaName(collection, 
parentShardLeader.getCoreName()))
+            .append(":INDEX.sizeInBytes")
+            .toString();
+
+    params = new ModifiableSolrParams();
+    params.add("key", metricName);
+
+    req = new GenericSolrRequest(SolrRequest.METHOD.GET, "/admin/metrics", 
params);
+    try {
+      rsp = cloudManager.request(req);
+    } catch (Exception e) {
+      log.error("Error occurred while checking the disk space of the node");
+      return;
+    }
+
+    if (rsp.getResponse() == null) {
       log.warn("cannot verify information for parent shard leader");
       return;
     }
-    // find the leader
-    List<Replica> lst = infos.get(collection).get(shard);
-    Double indexSize = null;
-    for (Replica info : lst) {
-      if (info.getCoreName().equals(parentShardLeader.getCoreName())) {
-        Number size = (Number) info.get(CORE_IDX.metricsAttribute);
-        if (size == null) {
-          log.warn("cannot verify information for parent shard leader");
-          return;
-        }
-        indexSize = (Double) CORE_IDX.convertVal(size);
-        break;
-      }
+
+    NamedList<Object> response = rsp.getResponse();
+    Object value = response.findRecursive("metrics", metricName);
+    if (value == null) {
+      log.warn("cannot verify information for parent shard leader");
+      return;
+    }
+
+    Number size = (Number) value;
+    if (size == null) {
+      log.warn("cannot verify information for parent shard leader");
+      return;
     }
-    if (indexSize == null) {
-      log.warn("missing replica information for parent shard leader");
+    double indexSize = size.doubleValue();
+
+    metricName = "solr.node:CONTAINER.fs.usableSpace";
+    params = new ModifiableSolrParams();
+    params.add("key", metricName);
+
+    req = new GenericSolrRequest(SolrRequest.METHOD.GET, "/admin/metrics", 
params);

Review Comment:
   
https://solr.apache.org/guide/solr/latest/deployment-guide/metrics-reporting.html#metrics-api



-- 
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.

To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to