SOLR-4751: fix replication problem of files in sub directory of conf

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1480988 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Koji Sekiguchi 2013-05-10 12:07:29 +00:00
parent 15317f5200
commit 1ce5ec4b99
2 changed files with 21 additions and 3 deletions

View File

@ -154,6 +154,9 @@ Bug Fixes
range in cluster state. This happens when numShards is not a power of two range in cluster state. This happens when numShards is not a power of two
and router is compositeId. (shalin) and router is compositeId. (shalin)
* SOLR-4751: Fix replication problem of files in sub directory of conf directory.
(Minoru Osuka via Koji Sekiguchi)
Other Changes Other Changes
---------------------- ----------------------

View File

@ -797,15 +797,30 @@ public class SnapPuller {
return true; return true;
} }
/**
* 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 * 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) { private void copyTmpConfFiles2Conf(File tmpconfDir) {
File confDir = new File(solrCore.getResourceLoader().getConfigDir()); File confDir = new File(solrCore.getResourceLoader().getConfigDir());
for (File file : tmpconfDir.listFiles()) { for (File file : makeTmpConfDirFileList(tmpconfDir, new ArrayList<File>())) {
File oldFile = new File(confDir, file.getName()); File oldFile = new File(confDir, file.getPath().substring(tmpconfDir.getPath().length(), file.getPath().length()));
if (oldFile.exists()) { if (oldFile.exists()) {
File backupFile = new File(confDir, oldFile.getName() + "." + getDateAsStr(new Date(oldFile.lastModified()))); File backupFile = new File(oldFile.getPath() + "." + getDateAsStr(new Date(oldFile.lastModified())));
boolean status = oldFile.renameTo(backupFile); boolean status = oldFile.renameTo(backupFile);
if (!status) { if (!status) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,