From 0dec8f9415a9d97a93870a416e96366db60a72fa Mon Sep 17 00:00:00 2001 From: Gregory Chanan Date: Fri, 29 Apr 2016 11:29:24 -0700 Subject: [PATCH 1/3] SOLR-9047: zkcli should allow alternative locations for log4j configuration --- solr/CHANGES.txt | 2 ++ solr/server/scripts/cloud-scripts/zkcli.bat | 8 +++++++- solr/server/scripts/cloud-scripts/zkcli.sh | 8 +++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 0f8842872bc..b0716bf75ef 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -224,6 +224,8 @@ Other Changes * SOLR-9037: Replace multiple "/replication" strings with one static constant. (Christine Poerschke) +* SOLR-9047: zkcli should allow alternative locations for log4j configuration (Gregory Chanan) + ================== 6.0.0 ================== Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release diff --git a/solr/server/scripts/cloud-scripts/zkcli.bat b/solr/server/scripts/cloud-scripts/zkcli.bat index 933e8a3a44a..b4b96930819 100644 --- a/solr/server/scripts/cloud-scripts/zkcli.bat +++ b/solr/server/scripts/cloud-scripts/zkcli.bat @@ -9,4 +9,10 @@ REM Find location of this script set SDIR=%~dp0 if "%SDIR:~-1%"=="\" set SDIR=%SDIR:~0,-1% -"%JVM%" -Dlog4j.configuration="file:%SDIR%\log4j.properties" -classpath "%SDIR%\..\..\solr-webapp\webapp\WEB-INF\lib\*;%SDIR%\..\..\lib\ext\*" org.apache.solr.cloud.ZkCLI %* +if defined LOG4J_PROPS ( + set "LOG4J_CONFIG=file:%LOG4J_PROPS%" +) else ( + set "LOG4J_CONFIG=file:%SDIR%\log4j.properties" +) + +"%JVM%" -Dlog4j.configuration="%LOG4J_PROPS%" -classpath "%SDIR%\..\..\solr-webapp\webapp\WEB-INF\lib\*;%SDIR%\..\..\lib\ext\*" org.apache.solr.cloud.ZkCLI %* diff --git a/solr/server/scripts/cloud-scripts/zkcli.sh b/solr/server/scripts/cloud-scripts/zkcli.sh index 15b5392d2e5..d049be0ff46 100755 --- a/solr/server/scripts/cloud-scripts/zkcli.sh +++ b/solr/server/scripts/cloud-scripts/zkcli.sh @@ -9,5 +9,11 @@ JVM="java" sdir="`dirname \"$0\"`" -PATH=$JAVA_HOME/bin:$PATH $JVM -Dlog4j.configuration=file:$sdir/log4j.properties -classpath "$sdir/../../solr-webapp/webapp/WEB-INF/lib/*:$sdir/../../lib/ext/*" org.apache.solr.cloud.ZkCLI ${1+"$@"} +if [ -n "$LOG4J_PROPS" ]; then + log4j_config="file:$LOG4J_PROPS" +else + log4j_config="file:$sdir/log4j.properties" +fi + +PATH=$JAVA_HOME/bin:$PATH $JVM -Dlog4j.configuration=$log4j_config -classpath "$sdir/../../solr-webapp/webapp/WEB-INF/lib/*:$sdir/../../lib/ext/*" org.apache.solr.cloud.ZkCLI ${1+"$@"} From 6e2d80d3a8f4434499bbeee81afa47a52252c143 Mon Sep 17 00:00:00 2001 From: Gregory Chanan Date: Fri, 29 Apr 2016 14:58:54 -0700 Subject: [PATCH 2/3] SOLR-9047: fix windows script --- solr/server/scripts/cloud-scripts/zkcli.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solr/server/scripts/cloud-scripts/zkcli.bat b/solr/server/scripts/cloud-scripts/zkcli.bat index b4b96930819..2e7e75deaa5 100644 --- a/solr/server/scripts/cloud-scripts/zkcli.bat +++ b/solr/server/scripts/cloud-scripts/zkcli.bat @@ -15,4 +15,4 @@ if defined LOG4J_PROPS ( set "LOG4J_CONFIG=file:%SDIR%\log4j.properties" ) -"%JVM%" -Dlog4j.configuration="%LOG4J_PROPS%" -classpath "%SDIR%\..\..\solr-webapp\webapp\WEB-INF\lib\*;%SDIR%\..\..\lib\ext\*" org.apache.solr.cloud.ZkCLI %* +"%JVM%" -Dlog4j.configuration="%LOG4J_CONFIG%" -classpath "%SDIR%\..\..\solr-webapp\webapp\WEB-INF\lib\*;%SDIR%\..\..\lib\ext\*" org.apache.solr.cloud.ZkCLI %* From 3b9aa4d5cc42083aab8957e61327a90cbc267de3 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Sat, 30 Apr 2016 16:16:24 -0400 Subject: [PATCH 3/3] Improve exception message so you see expected/actual if lock file is messed with --- .../src/java/org/apache/lucene/store/NativeFSLockFactory.java | 4 ++-- .../src/java/org/apache/lucene/store/SimpleFSLockFactory.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/store/NativeFSLockFactory.java b/lucene/core/src/java/org/apache/lucene/store/NativeFSLockFactory.java index 70270146ffa..4f17d951a6f 100644 --- a/lucene/core/src/java/org/apache/lucene/store/NativeFSLockFactory.java +++ b/lucene/core/src/java/org/apache/lucene/store/NativeFSLockFactory.java @@ -176,7 +176,7 @@ public final class NativeFSLockFactory extends FSLockFactory { // if it differs, someone deleted our lock file (and we are ineffective) FileTime ctime = Files.readAttributes(path, BasicFileAttributes.class).creationTime(); if (!creationTime.equals(ctime)) { - throw new AlreadyClosedException("Underlying file changed by an external force at " + creationTime + ", (lock=" + this + ")"); + throw new AlreadyClosedException("Underlying file changed by an external force at " + ctime + ", (lock=" + this + ")"); } } @@ -199,7 +199,7 @@ public final class NativeFSLockFactory extends FSLockFactory { @Override public String toString() { - return "NativeFSLock(path=" + path + ",impl=" + lock + ",ctime=" + creationTime + ")"; + return "NativeFSLock(path=" + path + ",impl=" + lock + ",creationTime=" + creationTime + ")"; } } } diff --git a/lucene/core/src/java/org/apache/lucene/store/SimpleFSLockFactory.java b/lucene/core/src/java/org/apache/lucene/store/SimpleFSLockFactory.java index f0b9683f5ed..101ff5e234f 100644 --- a/lucene/core/src/java/org/apache/lucene/store/SimpleFSLockFactory.java +++ b/lucene/core/src/java/org/apache/lucene/store/SimpleFSLockFactory.java @@ -111,7 +111,7 @@ public final class SimpleFSLockFactory extends FSLockFactory { // if it differs, someone deleted our lock file (and we are ineffective) FileTime ctime = Files.readAttributes(path, BasicFileAttributes.class).creationTime(); if (!creationTime.equals(ctime)) { - throw new AlreadyClosedException("Underlying file changed by an external force at " + creationTime + ", (lock=" + this + ")"); + throw new AlreadyClosedException("Underlying file changed by an external force at " + ctime + ", (lock=" + this + ")"); } } @@ -144,7 +144,7 @@ public final class SimpleFSLockFactory extends FSLockFactory { @Override public String toString() { - return "SimpleFSLock(path=" + path + ",ctime=" + creationTime + ")"; + return "SimpleFSLock(path=" + path + ",creationTime=" + creationTime + ")"; } } }