You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ko...@apache.org on 2013/05/17 02:28:54 UTC
svn commit: r1483620 - in /lucene/dev/trunk/solr: CHANGES.txt
core/src/java/org/apache/solr/handler/SnapPuller.java
Author: koji
Date: Fri May 17 00:28:54 2013
New Revision: 1483620
URL: http://svn.apache.org/r1483620
Log:
SOLR-4751: fix replication problem of files in sub directory of conf
Modified:
lucene/dev/trunk/solr/CHANGES.txt
lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/SnapPuller.java
Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1483620&r1=1483619&r2=1483620&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Fri May 17 00:28:54 2013
@@ -184,7 +184,9 @@ Bug Fixes
* SOLR-4829: Fix transaction log leaks (a failure to clean up some old logs)
on a shard leader, or when unexpected exceptions are thrown during log
recovery. (Steven Bower, Mark Miller, yonik)
-
+
+* SOLR-4751: Fix replication problem of files in sub directory of conf directory.
+ (Minoru Osuka via Koji)
Other Changes
----------------------
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/SnapPuller.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/SnapPuller.java?rev=1483620&r1=1483619&r2=1483620&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/SnapPuller.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/SnapPuller.java Fri May 17 00:28:54 2013
@@ -798,21 +798,53 @@ public class SnapPuller {
}
/**
+ * Make file list
+ */
+ private List<File> makeTmpConfDirFileList(File dir, List<File> fileList) {
+ File[] files = dir.listFiles();
+ for (File file : files) {
+ if (file.isFile()) {
+ fileList.add(file);
+ } else if (file.isDirectory()) {
+ fileList = makeTmpConfDirFileList(file, fileList);
+ }
+ }
+ return fileList;
+ }
+
+ /**
* The conf files are copied to the tmp dir to the conf dir. A backup of the old file is maintained
*/
private void copyTmpConfFiles2Conf(File tmpconfDir) {
+ boolean status = false;
File confDir = new File(solrCore.getResourceLoader().getConfigDir());
- for (File file : tmpconfDir.listFiles()) {
- File oldFile = new File(confDir, file.getName());
+ for (File file : makeTmpConfDirFileList(tmpconfDir, new ArrayList<File>())) {
+ File oldFile = new File(confDir, file.getPath().substring(tmpconfDir.getPath().length(), file.getPath().length()));
+ if (!oldFile.getParentFile().exists()) {
+ status = oldFile.getParentFile().mkdirs();
+ if (status) {
+ } else {
+ throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
+ "Unable to mkdirs: " + oldFile.getParentFile());
+ }
+ }
if (oldFile.exists()) {
- File backupFile = new File(confDir, oldFile.getName() + "." + getDateAsStr(new Date(oldFile.lastModified())));
- boolean status = oldFile.renameTo(backupFile);
+ File backupFile = new File(oldFile.getPath() + "." + getDateAsStr(new Date(oldFile.lastModified())));
+ if (!backupFile.getParentFile().exists()) {
+ status = backupFile.getParentFile().mkdirs();
+ if (status) {
+ } else {
+ throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
+ "Unable to mkdirs: " + backupFile.getParentFile());
+ }
+ }
+ status = oldFile.renameTo(backupFile);
if (!status) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
"Unable to rename: " + oldFile + " to: " + backupFile);
}
}
- boolean status = file.renameTo(oldFile);
+ status = file.renameTo(oldFile);
if (status) {
} else {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,