From 1d67a7dc71e50fb8a8ba66c5c2488530cf2b0879 Mon Sep 17 00:00:00 2001 From: Mark Robert Miller Date: Wed, 22 Feb 2012 14:32:53 +0000 Subject: [PATCH] expand skip recovery option a bit (used by tests) git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1292313 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/java/org/apache/solr/cloud/ZkController.java | 10 ++++++---- .../org/apache/solr/update/DefaultSolrCoreState.java | 7 +++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.java index b5f4225f8bc..1d8de7b2c49 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java +++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java @@ -21,7 +21,6 @@ import java.io.File; import java.io.IOException; import java.net.InetAddress; import java.net.MalformedURLException; -import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -77,6 +76,7 @@ public final class ZkController { private final static Pattern URL_POST = Pattern.compile("https?://(.*)"); private final static Pattern URL_PREFIX = Pattern.compile("(https?://).*"); + private final boolean SKIP_AUTO_RECOVERY = Boolean.getBoolean("solrcloud.skip.autorecovery"); // package private for tests @@ -104,7 +104,6 @@ public final class ZkController { private LeaderElector overseerElector; - private boolean SKIP_AUTO_RECOVERY = Boolean.getBoolean("solrcloud.skip.autorecovery"); // this can be null in which case recovery will be inactive private CoreContainer cc; @@ -633,7 +632,10 @@ public final class ZkController { final String shardZkNodeName, String shardId, ZkNodeProps leaderProps, SolrCore core, CoreContainer cc) throws InterruptedException, KeeperException, IOException, ExecutionException { - + if (SKIP_AUTO_RECOVERY) { + log.warn("Skipping recovery according to sys prop solrcloud.skip.autorecovery"); + return false; + } boolean doRecovery = true; if (!isLeader) { @@ -641,7 +643,7 @@ public final class ZkController { doRecovery = false; } - if (doRecovery && !SKIP_AUTO_RECOVERY) { + if (doRecovery) { log.info("Core needs to recover:" + core.getName()); core.getUpdateHandler().getSolrCoreState().doRecovery(core); return true; diff --git a/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java b/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java index 8ad8b56d7ac..2bc40d7043a 100644 --- a/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java +++ b/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java @@ -30,6 +30,8 @@ import org.slf4j.LoggerFactory; public final class DefaultSolrCoreState extends SolrCoreState { public static Logger log = LoggerFactory.getLogger(DefaultSolrCoreState.class); + private final boolean SKIP_AUTO_RECOVERY = Boolean.getBoolean("solrcloud.skip.autorecovery"); + private final Object recoveryLock = new Object(); private int refCnt = 1; private SolrIndexWriter indexWriter = null; @@ -112,6 +114,11 @@ public final class DefaultSolrCoreState extends SolrCoreState { @Override public void doRecovery(SolrCore core) { + if (SKIP_AUTO_RECOVERY) { + log.warn("Skipping recovery according to sys prop solrcloud.skip.autorecovery"); + return; + } + cancelRecovery(); synchronized (recoveryLock) { while (recoveryRunning) {