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.params.SolrParams;
|
||||||
import org.apache.solr.common.util.NamedList;
|
import org.apache.solr.common.util.NamedList;
|
||||||
import org.apache.solr.common.util.SimpleOrderedMap;
|
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.admin.ShowFileRequestHandler;
|
||||||
import org.apache.solr.handler.component.DebugComponent;
|
import org.apache.solr.handler.component.DebugComponent;
|
||||||
import org.apache.solr.handler.component.FacetComponent;
|
import org.apache.solr.handler.component.FacetComponent;
|
||||||
|
@ -236,8 +237,8 @@ public final class SolrCore implements SolrInfoMBean {
|
||||||
Directory dir = null;
|
Directory dir = null;
|
||||||
try {
|
try {
|
||||||
dir = getDirectoryFactory().get(getDataDir(), getSolrConfig().indexConfig.lockType);
|
dir = getDirectoryFactory().get(getDataDir(), getSolrConfig().indexConfig.lockType);
|
||||||
if (dir.fileExists("index.properties")){
|
if (dir.fileExists(SnapPuller.INDEX_PROPERTIES)){
|
||||||
final IndexInput input = dir.openInput("index.properties", IOContext.DEFAULT);
|
final IndexInput input = dir.openInput(SnapPuller.INDEX_PROPERTIES, IOContext.DEFAULT);
|
||||||
|
|
||||||
final InputStream is = new PropertiesInputStream(input);
|
final InputStream is = new PropertiesInputStream(input);
|
||||||
try {
|
try {
|
||||||
|
@ -249,7 +250,7 @@ public final class SolrCore implements SolrInfoMBean {
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Unable to load index.properties", e);
|
log.error("Unable to load " + SnapPuller.INDEX_PROPERTIES, e);
|
||||||
} finally {
|
} finally {
|
||||||
IOUtils.closeQuietly(is);
|
IOUtils.closeQuietly(is);
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ import org.slf4j.LoggerFactory;
|
||||||
* @since solr 1.4
|
* @since solr 1.4
|
||||||
*/
|
*/
|
||||||
public class SnapPuller {
|
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());
|
private static final Logger LOG = LoggerFactory.getLogger(SnapPuller.class.getName());
|
||||||
|
|
||||||
|
@ -845,33 +845,33 @@ public class SnapPuller {
|
||||||
Directory dir = null;
|
Directory dir = null;
|
||||||
try {
|
try {
|
||||||
dir = solrCore.getDirectoryFactory().get(solrCore.getDataDir(), solrCore.getSolrConfig().indexConfig.lockType);
|
dir = solrCore.getDirectoryFactory().get(solrCore.getDataDir(), solrCore.getSolrConfig().indexConfig.lockType);
|
||||||
if (dir.fileExists("index.properties")){
|
if (dir.fileExists(SnapPuller.INDEX_PROPERTIES)){
|
||||||
final IndexInput input = dir.openInput("index.properties", DirectoryFactory.IOCONTEXT_NO_CACHE);
|
final IndexInput input = dir.openInput(SnapPuller.INDEX_PROPERTIES, DirectoryFactory.IOCONTEXT_NO_CACHE);
|
||||||
|
|
||||||
final InputStream is = new PropertiesInputStream(input);
|
final InputStream is = new PropertiesInputStream(input);
|
||||||
try {
|
try {
|
||||||
p.load(is);
|
p.load(is);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("Unable to load index.properties", e);
|
LOG.error("Unable to load " + SnapPuller.INDEX_PROPERTIES, e);
|
||||||
} finally {
|
} finally {
|
||||||
IOUtils.closeQuietly(is);
|
IOUtils.closeQuietly(is);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
dir.deleteFile("index.properties");
|
dir.deleteFile(SnapPuller.INDEX_PROPERTIES);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// no problem
|
// 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);
|
p.put("index", tmpIdxDirName);
|
||||||
OutputStream os = null;
|
OutputStream os = null;
|
||||||
try {
|
try {
|
||||||
os = new PropertiesOutputStream(out);
|
os = new PropertiesOutputStream(out);
|
||||||
p.store(os, "index properties");
|
p.store(os, SnapPuller.INDEX_PROPERTIES);
|
||||||
dir.sync(Collections.singleton(INDEX_PEROPERTIES));
|
dir.sync(Collections.singleton(INDEX_PROPERTIES));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
|
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
|
||||||
"Unable to write index.properties", e);
|
"Unable to write " + SnapPuller.INDEX_PROPERTIES, e);
|
||||||
} finally {
|
} finally {
|
||||||
IOUtils.closeQuietly(os);
|
IOUtils.closeQuietly(os);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.util.Version;
|
import org.apache.lucene.util.Version;
|
||||||
import org.apache.solr.common.SolrException;
|
import org.apache.solr.common.SolrException;
|
||||||
import org.apache.solr.common.params.CommonParams;
|
import org.apache.solr.common.params.CommonParams;
|
||||||
|
import org.apache.solr.handler.SnapPuller;
|
||||||
import org.apache.solr.util.AbstractSolrTestCase;
|
import org.apache.solr.util.AbstractSolrTestCase;
|
||||||
import org.apache.solr.util.TestHarness;
|
import org.apache.solr.util.TestHarness;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
|
@ -90,7 +91,7 @@ public class TestArbitraryIndexDir extends AbstractSolrTestCase{
|
||||||
assertU(adoc("id", String.valueOf(1),
|
assertU(adoc("id", String.valueOf(1),
|
||||||
"name", "name"+String.valueOf(1)));
|
"name", "name"+String.valueOf(1)));
|
||||||
//create a new index dir and index.properties file
|
//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();
|
Properties p = new Properties();
|
||||||
File newDir = new File(h.getCore().getDataDir() + "index_temp");
|
File newDir = new File(h.getCore().getDataDir() + "index_temp");
|
||||||
newDir.mkdirs();
|
newDir.mkdirs();
|
||||||
|
@ -101,7 +102,7 @@ public class TestArbitraryIndexDir extends AbstractSolrTestCase{
|
||||||
p.store(os, "index properties");
|
p.store(os, "index properties");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
|
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
|
||||||
"Unable to write index.properties", e);
|
"Unable to write " + SnapPuller.INDEX_PROPERTIES, e);
|
||||||
} finally {
|
} finally {
|
||||||
if (os != null) os.close();
|
if (os != null) os.close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue