diff --git a/solr/core/src/test/org/apache/solr/cloud/overseer/ZkStateWriterTest.java b/solr/core/src/test/org/apache/solr/cloud/overseer/ZkStateWriterTest.java index deca8b02f5a..86aac4d1224 100644 --- a/solr/core/src/test/org/apache/solr/cloud/overseer/ZkStateWriterTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/overseer/ZkStateWriterTest.java @@ -16,6 +16,10 @@ */ package org.apache.solr.cloud.overseer; +import java.lang.invoke.MethodHandles; +import java.util.HashMap; +import java.util.Map; + import org.apache.lucene.util.IOUtils; import org.apache.solr.SolrTestCaseJ4; import org.apache.solr.cloud.AbstractZkTestCase; @@ -31,12 +35,13 @@ import org.apache.solr.common.cloud.SolrZkClient; import org.apache.solr.common.cloud.ZkStateReader; import org.apache.solr.common.util.Utils; import org.apache.zookeeper.KeeperException; - -import java.util.HashMap; -import java.util.Map; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ZkStateWriterTest extends SolrTestCaseJ4 { + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + public void testZkStateWriterBatching() throws Exception { String zkDir = createTempDir("testZkStateWriterBatching").toFile().getAbsolutePath(); @@ -319,6 +324,7 @@ public class ZkStateWriterTest extends SolrTestCaseJ4 { // get the most up-to-date state reader.forceUpdateCollection("c2"); state = reader.getClusterState(); + log.info("Cluster state: {}", state); assertTrue(state.hasCollection("c2")); assertEquals(sharedClusterStateVersion, (int) state.getZkClusterStateVersion()); assertEquals(stateFormat2Version + 1, state.getCollection("c2").getZNodeVersion()); diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java b/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java index a6bbd731fff..af6f9bec613 100644 --- a/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java +++ b/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java @@ -16,6 +16,24 @@ */ package org.apache.solr.common.cloud; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; +import java.io.Closeable; +import java.io.File; +import java.io.IOException; +import java.io.StringReader; +import java.io.StringWriter; +import java.lang.invoke.MethodHandles; +import java.nio.charset.StandardCharsets; +import java.nio.file.Path; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.regex.Pattern; + import org.apache.commons.io.FileUtils; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.common.SolrException; @@ -38,25 +56,6 @@ import org.apache.zookeeper.data.Stat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; - -import java.io.Closeable; -import java.io.File; -import java.io.IOException; -import java.io.StringReader; -import java.io.StringWriter; -import java.lang.invoke.MethodHandles; -import java.nio.charset.StandardCharsets; -import java.nio.file.Path; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.regex.Pattern; - /** * * All Solr ZooKeeper interactions should go through this class rather than 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 f106b9c8612..8b3beb447c4 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 @@ -290,6 +290,7 @@ public class ZkStateReader implements Closeable { synchronized (getUpdateLock()) { if (clusterState == null) { + LOG.info("ClusterState watchers have not been initialized"); return; } @@ -297,6 +298,7 @@ public class ZkStateReader implements Closeable { if (ref == null || legacyCollectionStates.containsKey(collection)) { // We either don't know anything about this collection (maybe it's new?) or it's legacy. // First update the legacy cluster state. + LOG.info("Checking legacy cluster state for collection {}", collection); refreshLegacyClusterState(null); if (!legacyCollectionStates.containsKey(collection)) { // No dice, see if a new collection just got created. @@ -307,6 +309,7 @@ public class ZkStateReader implements Closeable { } } } else if (ref.isLazilyLoaded()) { + LOG.info("Refreshing lazily-loaded state for collection {}", collection); if (ref.get() != null) { return; } @@ -314,6 +317,7 @@ public class ZkStateReader implements Closeable { refreshLegacyClusterState(null); } else if (watchedCollectionStates.containsKey(collection)) { // Exists as a watched collection, force a refresh. + LOG.info("Forcing refresh of watched collection state for {}", collection); DocCollection newState = fetchCollectionState(collection, null); if (updateWatchedCollection(collection, newState)) { constructState(Collections.singletonMap(collection, newState));