You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2021/01/19 22:11:36 UTC
[lucene-solr] branch branch_8x updated: SOLR-15081: Metrics for
core: isLeader, replicaState (#2198)
This is an automated email from the ASF dual-hosted git repository.
dsmiley pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/branch_8x by this push:
new 37545c0 SOLR-15081: Metrics for core: isLeader, replicaState (#2198)
37545c0 is described below
commit 37545c0da762ec2437cd982c7d40dbe9075ecf0c
Author: David Smiley <ds...@salesforce.com>
AuthorDate: Tue Jan 19 16:43:39 2021 -0500
SOLR-15081: Metrics for core: isLeader, replicaState (#2198)
Note that getLastPublished returns an Enum type. TextWriter.writeVal should probably support Enums, which would simplify this code.
(cherry picked from commit a233ed2fd1bc7e0f6366f74d33ec21007aec90bc)
---
solr/CHANGES.txt | 7 +++---
.../src/java/org/apache/solr/core/SolrCore.java | 29 ++++++++--------------
2 files changed, 14 insertions(+), 22 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 9918bf8..ba91686 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -14,13 +14,12 @@ New Features
Improvements
---------------------
-
-* SOLR-15079: Block Collapse - Faster collapse code when groups are co-located via Block Join style nested doc indexing.
- Used by default when field=_root_, or explicitly requsted for other fields via hint=block. (Joel Bernstein, hossman)
+* SOLR-15081: Metrics for a core: add SolrCloud "isLeader" and "replicaState". (David Smiley)
Optimizations
---------------------
-(No changes)
+* SOLR-15079: Block Collapse - Faster collapse code when groups are co-located via Block Join style nested doc indexing.
+ Used by default when field=_root_, or explicitly requested for other fields via hint=block. (Joel Bernstein, hossman)
Bug Fixes
---------------------
diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java
index 7ac37f8..6c67e57 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -1205,26 +1205,19 @@ public final class SolrCore implements SolrInfoBean, SolrMetricProducer, Closeab
parentContext.gauge(this, () -> isClosed() ? parentContext.nullString() : getIndexDir(), true, "indexDir", Category.CORE.toString());
parentContext.gauge(this, () -> isClosed() ? parentContext.nullNumber() : getIndexSize(), true, "sizeInBytes", Category.INDEX.toString());
parentContext.gauge(this, () -> isClosed() ? parentContext.nullString() : NumberUtils.readableSize(getIndexSize()), true, "size", Category.INDEX.toString());
- if (coreContainer != null) {
- final CloudDescriptor cd = getCoreDescriptor().getCloudDescriptor();
- if (cd != null) {
- parentContext.gauge(this, () -> {
- if (cd.getCollectionName() != null) {
- return cd.getCollectionName();
- } else {
- return parentContext.nullString();
- }
- }, true, "collection", Category.CORE.toString());
- parentContext.gauge(this, () -> {
- if (cd.getShardId() != null) {
- return cd.getShardId();
- } else {
- return parentContext.nullString();
- }
- }, true, "shard", Category.CORE.toString());
- }
+ final CloudDescriptor cd = getCoreDescriptor().getCloudDescriptor();
+ if (cd != null) {
+ parentContext.gauge(this, cd::getCollectionName, true, "collection", Category.CORE.toString());
+ parentContext.gauge(this, cd::getShardId, true, "shard", Category.CORE.toString());
+ parentContext.gauge(this, cd::isLeader, true, "isLeader", Category.CORE.toString());
+ parentContext.gauge(this,
+ () -> String.valueOf(cd.getLastPublished()),
+ true,
+ "replicaState",
+ Category.CORE.toString());
}
+
// initialize disk total / free metrics
Path dataDirPath = Paths.get(dataDir);
File dataDirFile = dataDirPath.toFile();