Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
public abstract class BaseHttpClusterStateProvider implements ClusterStateProvider {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

protected static final String SYS_PROP_CACHE_TIMEOUT_SECONDS = "solr.solrj.cache.timeout.sec";

private String urlScheme;
private List<URL> configuredNodes;
volatile Set<String> liveNodes; // initially null then never null
Expand All @@ -65,7 +67,7 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid
long aliasesTimestamp = 0;

// the liveNodes and aliases cache will be invalidated after 5 secs
private int cacheTimeout = EnvUtils.getPropertyAsInteger("solr.solrj.cache.timeout.sec", 5);
private int cacheTimeout = EnvUtils.getPropertyAsInteger(SYS_PROP_CACHE_TIMEOUT_SECONDS, 5);

volatile boolean liveNodeReloadingScheduled = false;
private final ScheduledExecutorService liveNodeReloadingService =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.solr.client.solrj.impl;

import static org.apache.solr.client.solrj.impl.BaseHttpClusterStateProvider.SYS_PROP_CACHE_TIMEOUT_SECONDS;
import static org.apache.solr.client.solrj.impl.CloudSolrClient.RouteResponse;

import java.io.IOException;
Expand Down Expand Up @@ -256,6 +257,14 @@ public void testAliasHandling() throws Exception {
@Test
@LogLevel("org.apache.solr.servlet.HttpSolrCall=DEBUG")
public void testHttpCspPerf() throws Exception {
// This ensures CH2SC is caching cluster status by counting the number of logged calls to the
// admin endpoint. Too many calls to CLUSTERSTATUS might mean insufficient caching and
// performance regressions!

// BaseHttpClusterStateProvider has a background job that pre-fetches data from CLUSTERSTATUS
// on timed intervals. This can pollute this test, so we set the interval very high to
// prevent it from running.
System.setProperty(SYS_PROP_CACHE_TIMEOUT_SECONDS, "" + Integer.MAX_VALUE);

String collectionName = "HTTPCSPTEST";
CollectionAdminRequest.createCollection(collectionName, "conf", 2, 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.solr.client.solrj.impl;

import static org.apache.solr.client.solrj.impl.BaseHttpClusterStateProvider.SYS_PROP_CACHE_TIMEOUT_SECONDS;
import static org.apache.solr.common.util.URLUtil.getNodeNameForBaseUrl;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.equalTo;
Expand Down Expand Up @@ -84,7 +85,7 @@ public static void setupCluster() throws Exception {
.resolve("conf"))
.configure();
cluster.waitForAllNodes(30);
System.setProperty("solr.solrj.cache.timeout.sec", "1");
System.setProperty(SYS_PROP_CACHE_TIMEOUT_SECONDS, "1");
}

@After
Expand Down