From 3124a4debdeae794cd64b4d0e8b78d23aad73c5e Mon Sep 17 00:00:00 2001 From: markrmiller Date: Fri, 19 Feb 2016 19:08:11 -0500 Subject: [PATCH] SOLR-8693: Improve ZkStateReader logging. --- solr/CHANGES.txt | 2 ++ .../solr/common/cloud/ZkStateReader.java | 28 +++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 42c57c1fa56..a57f8e53776 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -286,6 +286,8 @@ Other Changes * SOLR-8677: Prevent shards containing invalid characters from being created. Checks added server-side and in SolrJ. (Shai Erera, Jason Gerlowski, Anshum Gupta) +* SOLR-8693: Improve ZkStateReader logging. (Scott Blum via Mark Miller) + ======================= 5.5.0 ======================= Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java index 910b47e0407..a904f3ea4b0 100644 --- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java +++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java @@ -29,6 +29,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.TreeSet; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; @@ -420,11 +421,21 @@ public class ZkStateReader implements Closeable { this.clusterState = new ClusterState(liveNodes, result, legacyClusterStateVersion); LOG.debug("clusterStateSet: version [{}] legacy [{}] interesting [{}] watched [{}] lazy [{}] total [{}]", clusterState.getZkClusterStateVersion(), - legacyCollectionStates.keySet(), - interestingCollections, - watchedCollectionStates.keySet(), - lazyCollectionStates.keySet(), - clusterState.getCollections()); + legacyCollectionStates.keySet().size(), + interestingCollections.size(), + watchedCollectionStates.keySet().size(), + lazyCollectionStates.keySet().size(), + clusterState.getCollectionStates().size()); + + if (LOG.isTraceEnabled()) { + LOG.trace("clusterStateSet: version [{}] legacy [{}] interesting [{}] watched [{}] lazy [{}] total [{}]", + clusterState.getZkClusterStateVersion(), + legacyCollectionStates.keySet(), + interestingCollections, + watchedCollectionStates.keySet(), + lazyCollectionStates.keySet(), + clusterState.getCollectionStates()); + } } /** @@ -533,17 +544,22 @@ public class ZkStateReader implements Closeable { Set newLiveNodes; try { List nodeList = zkClient.getChildren(LIVE_NODES_ZKNODE, watcher, true); - LOG.debug("Updating live nodes from ZooKeeper... [{}]", nodeList.size()); newLiveNodes = new HashSet<>(nodeList); } catch (KeeperException.NoNodeException e) { newLiveNodes = emptySet(); } + Set oldLiveNodes; synchronized (getUpdateLock()) { + oldLiveNodes = this.liveNodes; this.liveNodes = newLiveNodes; if (clusterState != null) { clusterState.setLiveNodes(newLiveNodes); } } + LOG.info("Updated live nodes from ZooKeeper... ({}) -> ({})", oldLiveNodes.size(), newLiveNodes.size()); + if (LOG.isDebugEnabled()) { + LOG.debug("Updated live nodes from ZooKeeper... {} -> {}", new TreeSet<>(oldLiveNodes), new TreeSet<>(newLiveNodes)); + } } /**