You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by cp...@apache.org on 2017/02/28 16:21:51 UTC
lucene-solr:jira/solr-9045: SOLR-9045: add 'on your own if
customising' style comments
Repository: lucene-solr
Updated Branches:
refs/heads/jira/solr-9045 0d6d4d484 -> e6b5edd5d
SOLR-9045: add 'on your own if customising' style comments
Also made RecoveryStrategy methods final to reduce customisation potential.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/e6b5edd5
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/e6b5edd5
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/e6b5edd5
Branch: refs/heads/jira/solr-9045
Commit: e6b5edd5d29384d52b3063549103277ef353ba24
Parents: 0d6d4d4
Author: Christine Poerschke <cp...@apache.org>
Authored: Tue Feb 28 16:15:26 2017 +0000
Committer: Christine Poerschke <cp...@apache.org>
Committed: Tue Feb 28 16:15:26 2017 +0000
----------------------------------------------------------------------
.../org/apache/solr/cloud/RecoveryStrategy.java | 46 ++++++++++++--------
.../conf/solrconfig-customrecoverystrategy.xml | 4 ++
.../core/ConfigureRecoveryStrategyTest.java | 16 ++++++-
3 files changed, 47 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e6b5edd5/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
index c238ebb..b99e739 100644
--- a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
+++ b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
@@ -68,6 +68,11 @@ import org.apache.zookeeper.KeeperException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * This class may change in future and customisations are not supported
+ * between versions in terms of API or back compat behaviour.
+ * @lucene.experimental
+ */
public class RecoveryStrategy extends Thread implements Closeable {
public static class Builder implements NamedListInitializedPlugin {
@@ -124,41 +129,41 @@ public class RecoveryStrategy extends Thread implements Closeable {
coreZkNodeName = cd.getCloudDescriptor().getCoreNodeName();
}
- public int getWaitForUpdatesWithStaleStatePauseMilliSeconds() {
+ final public int getWaitForUpdatesWithStaleStatePauseMilliSeconds() {
return waitForUpdatesWithStaleStatePauseMilliSeconds;
}
- public void setWaitForUpdatesWithStaleStatePauseMilliSeconds(int waitForUpdatesWithStaleStatePauseMilliSeconds) {
+ final public void setWaitForUpdatesWithStaleStatePauseMilliSeconds(int waitForUpdatesWithStaleStatePauseMilliSeconds) {
this.waitForUpdatesWithStaleStatePauseMilliSeconds = waitForUpdatesWithStaleStatePauseMilliSeconds;
}
- public int getMaxRetries() {
+ final public int getMaxRetries() {
return maxRetries;
}
- public void setMaxRetries(int maxRetries) {
+ final public void setMaxRetries(int maxRetries) {
this.maxRetries = maxRetries;
}
- public int getStartingRecoveryDelayMilliSeconds() {
+ final public int getStartingRecoveryDelayMilliSeconds() {
return startingRecoveryDelayMilliSeconds;
}
- public void setStartingRecoveryDelayMilliSeconds(int startingRecoveryDelayMilliSeconds) {
+ final public void setStartingRecoveryDelayMilliSeconds(int startingRecoveryDelayMilliSeconds) {
this.startingRecoveryDelayMilliSeconds = startingRecoveryDelayMilliSeconds;
}
- public boolean getRecoveringAfterStartup() {
+ final public boolean getRecoveringAfterStartup() {
return recoveringAfterStartup;
}
- public void setRecoveringAfterStartup(boolean recoveringAfterStartup) {
+ final public void setRecoveringAfterStartup(boolean recoveringAfterStartup) {
this.recoveringAfterStartup = recoveringAfterStartup;
}
// make sure any threads stop retrying
@Override
- public void close() {
+ final public void close() {
close = true;
if (prevSendPreRecoveryHttpUriRequest != null) {
prevSendPreRecoveryHttpUriRequest.abort();
@@ -166,7 +171,7 @@ public class RecoveryStrategy extends Thread implements Closeable {
LOG.warn("Stopping recovery for core=[{}] coreNodeName=[{}]", coreName, coreZkNodeName);
}
- private void recoveryFailed(final SolrCore core,
+ final private void recoveryFailed(final SolrCore core,
final ZkController zkController, final String baseUrl,
final String shardZkNodeName, final CoreDescriptor cd) throws KeeperException, InterruptedException {
SolrException.log(LOG, "Recovery failed - I give up.");
@@ -178,11 +183,16 @@ public class RecoveryStrategy extends Thread implements Closeable {
}
}
+ /**
+ * This method may change in future and customisations are not supported
+ * between versions in terms of API or back compat behaviour.
+ * @lucene.experimental
+ */
protected String getReplicateLeaderUrl(ZkNodeProps leaderprops) {
return new ZkCoreNodeProps(leaderprops).getCoreUrl();
}
- private void replicate(String nodeName, SolrCore core, ZkNodeProps leaderprops)
+ final private void replicate(String nodeName, SolrCore core, ZkNodeProps leaderprops)
throws SolrServerException, IOException {
final String leaderUrl = getReplicateLeaderUrl(leaderprops);
@@ -242,7 +252,7 @@ public class RecoveryStrategy extends Thread implements Closeable {
}
- private void commitOnLeader(String leaderUrl) throws SolrServerException,
+ final private void commitOnLeader(String leaderUrl) throws SolrServerException,
IOException {
try (HttpSolrClient client = new HttpSolrClient.Builder(leaderUrl).build()) {
client.setConnectionTimeout(30000);
@@ -256,7 +266,7 @@ public class RecoveryStrategy extends Thread implements Closeable {
}
@Override
- public void run() {
+ final public void run() {
// set request info for logging
try (SolrCore core = cc.getCore(coreName)) {
@@ -285,7 +295,7 @@ public class RecoveryStrategy extends Thread implements Closeable {
}
// TODO: perhaps make this grab a new core each time through the loop to handle core reloads?
- public void doRecovery(SolrCore core) throws KeeperException, InterruptedException {
+ final public void doRecovery(SolrCore core) throws KeeperException, InterruptedException {
boolean replayed = false;
boolean successfulRecovery = false;
@@ -576,7 +586,7 @@ public class RecoveryStrategy extends Thread implements Closeable {
LOG.info("Finished recovery process, successful=[{}]", Boolean.toString(successfulRecovery));
}
- private Future<RecoveryInfo> replay(SolrCore core)
+ final private Future<RecoveryInfo> replay(SolrCore core)
throws InterruptedException, ExecutionException {
Future<RecoveryInfo> future = core.getUpdateHandler().getUpdateLog().applyBufferedUpdates();
if (future == null) {
@@ -598,7 +608,7 @@ public class RecoveryStrategy extends Thread implements Closeable {
return future;
}
- private void cloudDebugLog(SolrCore core, String op) {
+ final private void cloudDebugLog(SolrCore core, String op) {
if (!LOG.isDebugEnabled()) {
return;
}
@@ -617,11 +627,11 @@ public class RecoveryStrategy extends Thread implements Closeable {
}
}
- public boolean isClosed() {
+ final public boolean isClosed() {
return close;
}
- private void sendPrepRecoveryCmd(String leaderBaseUrl, String leaderCoreName, Slice slice)
+ final private void sendPrepRecoveryCmd(String leaderBaseUrl, String leaderCoreName, Slice slice)
throws SolrServerException, IOException, InterruptedException, ExecutionException {
try (HttpSolrClient client = new HttpSolrClient.Builder(leaderBaseUrl).build()) {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e6b5edd5/solr/core/src/test-files/solr/collection1/conf/solrconfig-customrecoverystrategy.xml
----------------------------------------------------------------------
diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig-customrecoverystrategy.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig-customrecoverystrategy.xml
index f2339b8..d43ed29 100644
--- a/solr/core/src/test-files/solr/collection1/conf/solrconfig-customrecoverystrategy.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/solrconfig-customrecoverystrategy.xml
@@ -21,6 +21,10 @@
<luceneMatchVersion>${tests.luceneMatchVersion:LATEST}</luceneMatchVersion>
<xi:include href="solrconfig.snippet.randomindexconfig.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<requestHandler name="standard" class="solr.StandardRequestHandler"></requestHandler>
+ <!--
+ The RecoveryStrategy and RecoveryStrategy.Builder classes may change in future and customisations
+ are not supported between versions in terms of API or back compat behaviour.
+ -->
<recoveryStrategy class="org.apache.solr.core.ConfigureRecoveryStrategyTest$CustomRecoveryStrategyBuilder">
<str name="alternativeBaseUrlProp">recovery_base_url</str>
</recoveryStrategy>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e6b5edd5/solr/core/src/test/org/apache/solr/core/ConfigureRecoveryStrategyTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/core/ConfigureRecoveryStrategyTest.java b/solr/core/src/test/org/apache/solr/core/ConfigureRecoveryStrategyTest.java
index 3f99b2a..80032af 100644
--- a/solr/core/src/test/org/apache/solr/core/ConfigureRecoveryStrategyTest.java
+++ b/solr/core/src/test/org/apache/solr/core/ConfigureRecoveryStrategyTest.java
@@ -16,6 +16,9 @@
*/
package org.apache.solr.core;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.cloud.RecoveryStrategy;
import org.apache.solr.common.cloud.ZkCoreNodeProps;
@@ -59,7 +62,18 @@ public class ConfigureRecoveryStrategyTest extends SolrTestCaseJ4 {
assertEquals("recoveryStrategyBuilder is wrong class (name)",
expectedClassName, recoveryStrategyBuilder.getClass().getName());
-}
+ }
+
+ public void testAlmostAllMethodsAreFinal() throws Exception {
+ for (Method m : RecoveryStrategy.class.getDeclaredMethods()) {
+ final String methodName = m.getName();
+ if ("getReplicateLeaderUrl".equals(methodName)) {
+ assertFalse(m.toString(), Modifier.isFinal(m.getModifiers()));
+ } else {
+ assertTrue(m.toString(), Modifier.isFinal(m.getModifiers()));
+ }
+ }
+ }
static public class CustomRecoveryStrategy extends RecoveryStrategy {