Skip to content

Commit a4334c6

Browse files
authored
SOLR-17864: Migrate System Properties (part ocho) (#3625)
Align variable name used in supporting files for tests with system property name. Migrate: solr.prs.default enable.update.log zk.server.conf.dir zk.server.data.dir zk.run solr.zk.embedded.host zk.run.only
1 parent 390e11d commit a4334c6

File tree

100 files changed

+251
-223
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+251
-223
lines changed

gradle/ide/eclipse/run-solr-cloud.launch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.jetty.start.Main"/>
1717
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="--module=http"/>
1818
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="@ECLIPSEPROJECTNAME@"/>
19-
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms512m &#13;&#10;-Djetty.port=8983&#13;&#10;-DSTOP.PORT=7983 &#13;&#10;-DSTOP.KEY=solrrock&#13;&#10;-Dlog4j.configurationFile=&quot;file:${workspace_loc:@ECLIPSEPROJECTNAME@}/solr/server/resources/log4j2.xml&quot;&#13;&#10;-Djetty.home=&quot;${workspace_loc:@ECLIPSEPROJECTNAME@}/eclipse-build/solr-server&quot;&#13;&#10;-Djetty.base=&quot;${workspace_loc:@ECLIPSEPROJECTNAME@}/eclipse-build/solr-server&quot;&#13;&#10;-Dsolr.log=&quot;${workspace_loc:@ECLIPSEPROJECTNAME@}/eclipse-build&quot;&#13;&#10;-Dsolr.logs.dir=&quot;${workspace_loc:@ECLIPSEPROJECTNAME@}/eclipse-build&quot;&#13;&#10;-Dsolr.solr.home=&quot;${workspace_loc:@ECLIPSEPROJECTNAME@}/eclipse-build/solr-server/solr&quot;&#13;&#10;-DzkRun"/>
19+
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms512m &#13;&#10;-Djetty.port=8983&#13;&#10;-DSTOP.PORT=7983 &#13;&#10;-DSTOP.KEY=solrrock&#13;&#10;-Dlog4j.configurationFile=&quot;file:${workspace_loc:@ECLIPSEPROJECTNAME@}/solr/server/resources/log4j2.xml&quot;&#13;&#10;-Djetty.home=&quot;${workspace_loc:@ECLIPSEPROJECTNAME@}/eclipse-build/solr-server&quot;&#13;&#10;-Djetty.base=&quot;${workspace_loc:@ECLIPSEPROJECTNAME@}/eclipse-build/solr-server&quot;&#13;&#10;-Dsolr.log=&quot;${workspace_loc:@ECLIPSEPROJECTNAME@}/eclipse-build&quot;&#13;&#10;-Dsolr.logs.dir=&quot;${workspace_loc:@ECLIPSEPROJECTNAME@}/eclipse-build&quot;&#13;&#10;-Dsolr.solr.home=&quot;${workspace_loc:@ECLIPSEPROJECTNAME@}/eclipse-build/solr-server/solr&quot;&#13;&#10;-Dsolr.zookeeper.server.enabled=true"/>
2020
</launchConfiguration>

solr/benchmark/src/resources/configs/cloud-minimal/conf/solrconfig.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
<autoCommit>
6969
<maxTime>${autoCommit.maxTime:60000}</maxTime>
7070
</autoCommit>
71-
<updateLog class="${ulog:solr.UpdateLog}" enable="${enable.update.log:true}"/>
71+
<updateLog class="${ulog:solr.UpdateLog}" enable="${solr.index.updatelog.enabled:true}"/>
7272
</updateHandler>
7373

7474
<requestHandler name="/select" class="solr.SearchHandler">
@@ -109,4 +109,3 @@
109109
</query>
110110

111111
</config>
112-

solr/bin/solr

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -960,10 +960,6 @@ if [ -n "${SOLR_JETTY_HOST:-}" ]; then
960960
SCRIPT_SOLR_OPTS+=("-Dsolr.jetty.host=$SOLR_JETTY_HOST")
961961
fi
962962

963-
if [ -n "${SOLR_ZK_EMBEDDED_HOST:-}" ]; then
964-
SCRIPT_SOLR_OPTS+=("-Dsolr.zk.embedded.host=$SOLR_ZK_EMBEDDED_HOST")
965-
fi
966-
967963
: "${STOP_PORT:=$((SOLR_PORT - 1000))}"
968964

969965
if [ "$SCRIPT_CMD" == "start" ] || [ "$SCRIPT_CMD" == "restart" ] ; then
@@ -1081,10 +1077,10 @@ if [ "${SOLR_MODE:-}" == 'solrcloud' ]; then
10811077
exit 1
10821078
fi
10831079
if $verbose ; then
1084-
echo "Configuring SolrCloud to launch an embedded Zookeeper using -DzkRun"
1080+
echo "Configuring SolrCloud to launch an embedded Zookeeper using -Dsolr.zookeeper.server.enabled"
10851081
fi
10861082

1087-
CLOUD_MODE_OPTS+=('-DzkRun')
1083+
CLOUD_MODE_OPTS+=('-Dsolr.zookeeper.server.enabled=true')
10881084
fi
10891085

10901086
if [ -n "${ZK_CREATE_CHROOT:-}" ]; then

solr/bin/solr.cmd

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -881,10 +881,6 @@ IF DEFINED SOLR_JETTY_HOST (
881881
set "SCRIPT_SOLR_OPTS=%SCRIPT_SOLR_OPTS% -Dsolr.jetty.host=%SOLR_JETTY_HOST%"
882882
)
883883

884-
IF DEFINED SOLR_ZK_EMBEDDED_HOST (
885-
set "SCRIPT_SOLR_OPTS=%SCRIPT_SOLR_OPTS% -Dsolr.zk.embedded.host=%SOLR_ZK_EMBEDDED_HOST%"
886-
)
887-
888884
REM Make sure Solr is not running using netstat
889885
For /f "tokens=2,5" %%j in ('netstat -aon ^| find "TCP " ^| find ":0 " ^| find ":%SOLR_PORT% "') do (
890886
IF NOT "%%k"=="0" (
@@ -927,8 +923,8 @@ IF "%SOLR_MODE%"=="solrcloud" (
927923
set "SCRIPT_ERROR=ZK_HOST is not set and Solr port is %SOLR_PORT%, which would result in an invalid embedded Zookeeper port!"
928924
goto err
929925
)
930-
IF "%verbose%"=="1" echo Configuring SolrCloud to launch an embedded Zookeeper using -DzkRun
931-
set "CLOUD_MODE_OPTS=!CLOUD_MODE_OPTS! -DzkRun"
926+
IF "%verbose%"=="1" echo Configuring SolrCloud to launch an embedded Zookeeper using -Dsolr.zookeeper.server.enabled
927+
set "CLOUD_MODE_OPTS=!CLOUD_MODE_OPTS! -Dsolr.zookeeper.server.enabled=true"
932928
)
933929

934930
IF NOT "%ZK_CREATE_CHROOT%"=="" (

solr/bin/solr.in.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ REM environments where security is not a concern, 0.0.0.0 can be used to allow
127127
REM Solr to accept connections on all network interfaces.
128128
REM set SOLR_JETTY_HOST=127.0.0.1
129129
REM Sets the network interface the Embedded ZK binds to.
130-
REM set SOLR_ZK_EMBEDDED_HOST=127.0.0.1
130+
REM set SOLR_ZOOKEEPER_EMBEDDED_HOST=127.0.0.1
131131

132132
REM Restrict access to solr by IP address.
133133
REM Specify a comma-separated list of addresses or networks, for example:

solr/bin/solr.in.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
# Solr to accept connections on all network interfaces.
153153
#SOLR_JETTY_HOST="127.0.0.1"
154154
# Sets the network interface the Embedded ZK binds to.
155-
#SOLR_ZK_EMBEDDED_HOST="127.0.0.1"
155+
#SOLR_ZOOKEEPER_EMBEDDED_HOST="127.0.0.1"
156156

157157
# Enables HTTPS. It is implictly true if you set SOLR_SSL_KEY_STORE. Use this config
158158
# to enable https module with custom jetty configuration.

solr/core/src/java/org/apache/solr/cloud/SolrZkServer.java

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.util.Properties;
2727
import java.util.concurrent.atomic.AtomicReference;
2828
import org.apache.solr.common.SolrException;
29+
import org.apache.solr.common.util.EnvUtils;
2930
import org.apache.solr.servlet.SolrDispatchFilter;
3031
import org.apache.solr.util.AddressUtils;
3132
import org.apache.zookeeper.server.ServerConfig;
@@ -41,19 +42,19 @@ public class SolrZkServer {
4142

4243
public static final String ZK_WHITELIST_PROPERTY = "zookeeper.4lw.commands.whitelist";
4344

44-
String zkRun;
45+
boolean zkRun = false;
4546
String zkHost;
4647

4748
int solrPort;
4849
Properties props;
4950
SolrZkServerProps zkProps;
5051

51-
private Thread zkThread; // the thread running a zookeeper server, only if zkRun is set
52+
private Thread zkThread; // the thread running a zookeeper server, only if zkRun is true
5253

5354
private Path dataHome; // o.a.zookeeper.**.QuorumPeerConfig needs a File not a Path
5455
private String confHome;
5556

56-
public SolrZkServer(String zkRun, String zkHost, Path dataHome, String confHome, int solrPort) {
57+
public SolrZkServer(boolean zkRun, String zkHost, Path dataHome, String confHome, int solrPort) {
5758
this.zkRun = zkRun;
5859
this.zkHost = zkHost;
5960
this.dataHome = dataHome;
@@ -62,12 +63,18 @@ public SolrZkServer(String zkRun, String zkHost, Path dataHome, String confHome,
6263
}
6364

6465
public String getClientString() {
65-
if (zkHost != null) return zkHost;
66+
if (zkHost != null) {
67+
return zkHost;
68+
}
6669

67-
if (zkProps == null) return null;
70+
if (zkProps == null) {
71+
return null;
72+
}
6873

6974
// if the string wasn't passed as zkHost, then use the standalone server we started
70-
if (zkRun == null) return null;
75+
if (!zkRun) {
76+
return null;
77+
}
7178

7279
InetSocketAddress addr = zkProps.getClientPortAddress();
7380
String hostName;
@@ -110,13 +117,15 @@ public void parseConfig() {
110117
// This is the address that the embedded Zookeeper will bind to. Like Solr, it defaults to
111118
// "127.0.0.1".
112119
props.setProperty(
113-
"clientPortAddress", System.getProperty("solr.zk.embedded.host", "127.0.0.1"));
120+
"clientPortAddress", EnvUtils.getProperty("solr.zookeeper.embedded.host", "127.0.0.1"));
114121
if (props.getProperty("clientPort") == null) {
115122
props.setProperty("clientPort", Integer.toString(solrPort + 1000));
116123
}
117124
zkProps.parseProperties(props);
118125
} catch (QuorumPeerConfig.ConfigException | IOException e) {
119-
if (zkRun != null) throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
126+
if (zkRun) {
127+
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
128+
}
120129
}
121130
}
122131

@@ -125,7 +134,9 @@ public Map<Long, QuorumPeer.QuorumServer> getServers() {
125134
}
126135

127136
public void start() {
128-
if (zkRun == null) return;
137+
if (!zkRun) {
138+
return;
139+
}
129140

130141
if (System.getProperty(ZK_WHITELIST_PROPERTY) == null) {
131142
System.setProperty(ZK_WHITELIST_PROPERTY, "ruok, mntr, conf");
@@ -192,7 +203,9 @@ public void start() {
192203
}
193204

194205
public void stop() {
195-
if (zkRun == null) return;
206+
if (!zkRun) {
207+
return;
208+
}
196209
zkThread.interrupt();
197210
}
198211
}
@@ -203,7 +216,7 @@ class SolrZkServerProps extends QuorumPeerConfig {
203216
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
204217

205218
String solrPort; // port that Solr is listening on
206-
String zkRun;
219+
boolean zkRun;
207220

208221
/**
209222
* Parse a ZooKeeper configuration file
@@ -232,13 +245,15 @@ public static Properties getProperties(Path configPath) throws ConfigException {
232245
// Given zkHost=localhost:1111,localhost:2222 this will inject
233246
// server.0=localhost:1112:1113
234247
// server.1=localhost:2223:2224
235-
public static void injectServers(Properties props, String zkRun, String zkHost) {
248+
public static void injectServers(Properties props, boolean zkRun, String zkHost) {
236249

237250
// if clientPort not already set, use zkRun
238-
if (zkRun != null && props.getProperty("clientPort") == null) {
239-
int portIdx = zkRun.lastIndexOf(':');
251+
if (zkRun && props.getProperty("clientPort") == null) {
252+
// int portIdx = zkRun.lastIndexOf(':');
253+
int portIdx = "".lastIndexOf(':');
240254
if (portIdx > 0) {
241-
String portStr = zkRun.substring(portIdx + 1);
255+
// String portStr = zkRun.substring(portIdx + 1);
256+
String portStr = "".substring(portIdx + 1);
242257
props.setProperty("clientPort", portStr);
243258
}
244259
}

0 commit comments

Comments
 (0)