mirror of https://github.com/apache/lucene.git
SOLR-3911: fix properties file name misspelling and use constant for file name everywhere
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1420231 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f2d1557c5d
commit
932300fd3b
|
@ -68,6 +68,7 @@ import org.apache.solr.common.params.CommonParams.EchoParamStyle;
|
|||
import org.apache.solr.common.params.SolrParams;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.common.util.SimpleOrderedMap;
|
||||
import org.apache.solr.handler.SnapPuller;
|
||||
import org.apache.solr.handler.admin.ShowFileRequestHandler;
|
||||
import org.apache.solr.handler.component.DebugComponent;
|
||||
import org.apache.solr.handler.component.FacetComponent;
|
||||
|
@ -236,8 +237,8 @@ public final class SolrCore implements SolrInfoMBean {
|
|||
Directory dir = null;
|
||||
try {
|
||||
dir = getDirectoryFactory().get(getDataDir(), getSolrConfig().indexConfig.lockType);
|
||||
if (dir.fileExists("index.properties")){
|
||||
final IndexInput input = dir.openInput("index.properties", IOContext.DEFAULT);
|
||||
if (dir.fileExists(SnapPuller.INDEX_PROPERTIES)){
|
||||
final IndexInput input = dir.openInput(SnapPuller.INDEX_PROPERTIES, IOContext.DEFAULT);
|
||||
|
||||
final InputStream is = new PropertiesInputStream(input);
|
||||
try {
|
||||
|
@ -249,7 +250,7 @@ public final class SolrCore implements SolrInfoMBean {
|
|||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("Unable to load index.properties", e);
|
||||
log.error("Unable to load " + SnapPuller.INDEX_PROPERTIES, e);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(is);
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ import org.slf4j.LoggerFactory;
|
|||
* @since solr 1.4
|
||||
*/
|
||||
public class SnapPuller {
|
||||
private static final String INDEX_PEROPERTIES = "index.peroperties";
|
||||
public static final String INDEX_PROPERTIES = "index.properties";
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(SnapPuller.class.getName());
|
||||
|
||||
|
@ -845,33 +845,33 @@ public class SnapPuller {
|
|||
Directory dir = null;
|
||||
try {
|
||||
dir = solrCore.getDirectoryFactory().get(solrCore.getDataDir(), solrCore.getSolrConfig().indexConfig.lockType);
|
||||
if (dir.fileExists("index.properties")){
|
||||
final IndexInput input = dir.openInput("index.properties", DirectoryFactory.IOCONTEXT_NO_CACHE);
|
||||
if (dir.fileExists(SnapPuller.INDEX_PROPERTIES)){
|
||||
final IndexInput input = dir.openInput(SnapPuller.INDEX_PROPERTIES, DirectoryFactory.IOCONTEXT_NO_CACHE);
|
||||
|
||||
final InputStream is = new PropertiesInputStream(input);
|
||||
try {
|
||||
p.load(is);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Unable to load index.properties", e);
|
||||
LOG.error("Unable to load " + SnapPuller.INDEX_PROPERTIES, e);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(is);
|
||||
}
|
||||
}
|
||||
try {
|
||||
dir.deleteFile("index.properties");
|
||||
dir.deleteFile(SnapPuller.INDEX_PROPERTIES);
|
||||
} catch (IOException e) {
|
||||
// no problem
|
||||
}
|
||||
final IndexOutput out = dir.createOutput("index.properties", DirectoryFactory.IOCONTEXT_NO_CACHE);
|
||||
final IndexOutput out = dir.createOutput(SnapPuller.INDEX_PROPERTIES, DirectoryFactory.IOCONTEXT_NO_CACHE);
|
||||
p.put("index", tmpIdxDirName);
|
||||
OutputStream os = null;
|
||||
try {
|
||||
os = new PropertiesOutputStream(out);
|
||||
p.store(os, "index properties");
|
||||
dir.sync(Collections.singleton(INDEX_PEROPERTIES));
|
||||
p.store(os, SnapPuller.INDEX_PROPERTIES);
|
||||
dir.sync(Collections.singleton(INDEX_PROPERTIES));
|
||||
} catch (Exception e) {
|
||||
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
|
||||
"Unable to write index.properties", e);
|
||||
"Unable to write " + SnapPuller.INDEX_PROPERTIES, e);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(os);
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.apache.lucene.store.Directory;
|
|||
import org.apache.lucene.util.Version;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.handler.SnapPuller;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.util.TestHarness;
|
||||
import org.junit.AfterClass;
|
||||
|
@ -90,7 +91,7 @@ public class TestArbitraryIndexDir extends AbstractSolrTestCase{
|
|||
assertU(adoc("id", String.valueOf(1),
|
||||
"name", "name"+String.valueOf(1)));
|
||||
//create a new index dir and index.properties file
|
||||
File idxprops = new File(h.getCore().getDataDir() + "index.properties");
|
||||
File idxprops = new File(h.getCore().getDataDir() + SnapPuller.INDEX_PROPERTIES);
|
||||
Properties p = new Properties();
|
||||
File newDir = new File(h.getCore().getDataDir() + "index_temp");
|
||||
newDir.mkdirs();
|
||||
|
@ -101,7 +102,7 @@ public class TestArbitraryIndexDir extends AbstractSolrTestCase{
|
|||
p.store(os, "index properties");
|
||||
} catch (Exception e) {
|
||||
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
|
||||
"Unable to write index.properties", e);
|
||||
"Unable to write " + SnapPuller.INDEX_PROPERTIES, e);
|
||||
} finally {
|
||||
if (os != null) os.close();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue