murblanc commented on a change in pull request #2133:
URL: https://github.com/apache/lucene-solr/pull/2133#discussion_r547940278



##########
File path: 
solr/core/src/java/org/apache/solr/cluster/placement/impl/AttributeFetcherImpl.java
##########
@@ -197,32 +148,78 @@ public AttributeValues fetchAttributes() {
       }
     }
 
-    return new AttributeValuesImpl(nodeToCoreCount,
-        nodeToDiskType,
-        nodeToFreeDisk,
-        nodeToTotalDisk,
-        nodeToHeapUsage,
-        nodeToSystemLoadAverage,
-        syspropSnitchToNodeToValue,
-        metricSnitchToNodeToValue);
+    for (Node node : nodeToReplicaInternalTags.keySet()) {
+      Set<String> tags = nodeToReplicaInternalTags.get(node);
+      Map<String, Map<String, List<Replica>>> infos = 
cloudManager.getNodeStateProvider().getReplicaInfo(node.getName(), tags);
+      infos.entrySet().stream()
+          .filter(entry -> 
requestedCollectionNamesMetrics.containsKey(entry.getKey()))
+          .forEach(entry -> {
+            CollectionMetricsBuilder collectionMetricsBuilder = 
collectionMetricsBuilders
+                .computeIfAbsent(entry.getKey(), c -> new 
CollectionMetricsBuilder());
+            entry.getValue().forEach((shardName, replicas) -> {
+              CollectionMetricsBuilder.ShardMetricsBuilder shardMetricsBuilder 
=
+                  collectionMetricsBuilder.getShardMetricsBuilders()
+                  .computeIfAbsent(shardName, s -> new 
CollectionMetricsBuilder.ShardMetricsBuilder());
+              replicas.forEach(replica -> {
+                CollectionMetricsBuilder.ReplicaMetricsBuilder 
replicaMetricsBuilder =
+                    shardMetricsBuilder.getReplicaMetricsBuilders()
+                    .computeIfAbsent(replica.getName(), n -> new 
CollectionMetricsBuilder.ReplicaMetricsBuilder());
+                replicaMetricsBuilder.setLeader(replica.isLeader());
+                if (replica.isLeader()) {
+                  shardMetricsBuilder.setLeaderMetrics(replicaMetricsBuilder);
+                }
+                Set<ReplicaMetric<?>> requestedMetrics = 
requestedCollectionNamesMetrics.get(replica.getCollection());
+                if (requestedMetrics == null) {
+                  throw new RuntimeException("impossible error");
+                }
+                requestedMetrics.forEach(metric -> {
+                  replicaMetricsBuilder.addMetric(metric, 
replica.get(metric.getInternalName()));
+                });
+              });
+            });
+          });
+    }
+
+
+    Map<String, CollectionMetrics> collectionMetrics = new HashMap<>();
+    collectionMetricsBuilders.forEach((name, builder) -> 
collectionMetrics.put(name, builder.build()));
+
+    return new AttributeValuesImpl(systemSnitchToNodeToValue,
+        metricSnitchToNodeToValue, collectionMetrics);
   }
 
-  private static SolrInfoBean.Group 
getGroupFromMetricRegistry(NodeMetricRegistry registry) {
+  private static SolrInfoBean.Group 
getGroupFromMetricRegistry(NodeMetric.Registry registry) {
     switch (registry) {
       case SOLR_JVM:
         return SolrInfoBean.Group.jvm;
       case SOLR_NODE:
         return SolrInfoBean.Group.node;
+      case SOLR_JETTY:
+        return SolrInfoBean.Group.jetty;
       default:
         throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, 
"Unsupported registry value " + registry);

Review comment:
       If we do add a `NULL` or `UNDEFINED` `Registry` enum value, it's ok to 
handle it as `default` here and throw exception (although it getting all the 
way to here likely denotes a bug in our code).




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



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

Reply via email to