enable use of solrcore.properties for property substitution of solrconfig.xml

- move setting of system property solr.directoryFactory=solr.MMapDirectoryFactory to solrcore.properties
- add check of os.arch for 64bit system, if it fails use default/solrcore.x86.properties (if exists) as solrcore.properties
 
reason: on 32bit MMapDirectoryFactory may fail with.....
Caused by: java.io.IOException: Map failed
	at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:849)
	at org.apache.lucene.store.MMapDirectory.map(MMapDirectory.java:283)
pull/1/head
reger 12 years ago
parent f7e887bf49
commit 8a7fcb391d

@ -0,0 +1,11 @@
## Solr solrconfig.xml System property substitution
##
## This is the default property file for 64bit system architectures
##
## depending on system architecture one default property file is copied to core/conf directory
## is system architecture is 64bit property file solrcore.properties is copied to core/conf/solrcore.properties
## otherwise if exists property file solrcore.x86.properties is copied to core/conf/solrcore.properties
#
# The DirectoryFactory to use for indexes.
# Default for 32bit systems is solr.NRTCachingDirectoryFactory, for 64bit systems solr.MMapDirectoryFactory is recommended
solr.directoryFactory=solr.MMapDirectoryFactory

@ -0,0 +1,11 @@
## Solr solrconfig.xml System property substitution
##
## This is the property file for 32 bit systems
##
## depending on system architecture one default property file is copied to core/conf directory
## is system architecture is 64bit property file solrcore.properties is copied to core/conf/solrcore.properties
## otherwise if exists property file solrcore.x86.properties is copied to core/conf/solrcore.properties
#
# The DirectoryFactory to use for indexes.
# Default for 32bit systems is solr.NRTCachingDirectoryFactory, for 64bit systems solr.MMapDirectoryFactory is recommended
solr.directoryFactory=solr.NRTCachingDirectoryFactory

@ -39,7 +39,7 @@ import com.google.common.io.Files;
public class EmbeddedInstance implements SolrInstance { public class EmbeddedInstance implements SolrInstance {
private final static String[] confFiles = {"solrconfig.xml", "schema.xml", "stopwords.txt", "synonyms.txt", "protwords.txt", "currency.xml", "elevate.xml", "xslt/example.xsl", "xslt/json.xsl", "lang/"}; private final static String[] confFiles = {"solrconfig.xml", "schema.xml", "stopwords.txt", "synonyms.txt", "protwords.txt", "currency.xml", "elevate.xml", "xslt/example.xsl", "xslt/json.xsl", "lang/"};
// additional a optional solrcore.properties (or solrcore.x86.properties for 32bit systems is copied
private CoreContainer coreContainer; private CoreContainer coreContainer;
private String defaultCoreName; private String defaultCoreName;
private SolrCore defaultCore; private SolrCore defaultCore;
@ -92,7 +92,7 @@ public class EmbeddedInstance implements SolrInstance {
throw new IOException("cannot get the default core; available = " + MemoryControl.available() + ", free = " + MemoryControl.free()); throw new IOException("cannot get the default core; available = " + MemoryControl.available() + ", free = " + MemoryControl.free());
} }
this.defaultCoreServer = new EmbeddedSolrServer(this.coreContainer, this.defaultCoreName); this.defaultCoreServer = new EmbeddedSolrServer(this.coreContainer, this.defaultCoreName);
// initialize core cache // initialize core cache
this.cores = new ConcurrentHashMap<String, SolrCore>(); this.cores = new ConcurrentHashMap<String, SolrCore>();
this.cores.put(this.defaultCoreName, this.defaultCore); this.cores.put(this.defaultCoreName, this.defaultCore);
@ -129,13 +129,37 @@ public class EmbeddedInstance implements SolrInstance {
} else { } else {
target = new File(conf, cf); target = new File(conf, cf);
target.getParentFile().mkdirs(); target.getParentFile().mkdirs();
try { try {
Files.copy(source, target); Files.copy(source, target);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
// copy the solrcore.properties
// for 32bit systems (os.arch name not containing '64') take the solrcore.x86.properties as solrcore.properties if exists
String os = System.getProperty("os.arch");
if (os.contains("64")) {
source = new File(solr_config, "solrcore.properties");
} else {
source = new File(solr_config, "solrcore.x86.properties");
if (source.exists()) {
source = new File(solr_config, "solrcore.properties");
}
}
// solr alwasy reads the solrcore.properties file if exists in core/conf directory
target = new File(conf, "solrcore.properties");
if (source.exists()) {
try {
Files.copy(source, target);
Log.logFine("initializeCoreConf", "overwrite " + target.getAbsolutePath() + " with " + source.getAbsolutePath());
} catch (IOException ex) {
ex.printStackTrace();
}
}
} }
public File getContainerPath() { public File getContainerPath() {

@ -328,9 +328,9 @@ public final class Fulltext {
public URIMetadataNode getMetadata(WeakPriorityBlockingQueue.Element<WordReferenceVars> element) { public URIMetadataNode getMetadata(WeakPriorityBlockingQueue.Element<WordReferenceVars> element) {
if (element == null) return null; if (element == null) return null;
WordReferenceVars wre = element.getElement(); WordReferenceVars wre = element.getElement();
long weight = element.getWeight();
if (wre == null) return null; // all time was already wasted in takeRWI to get another element if (wre == null) return null; // all time was already wasted in takeRWI to get another element
long weight = element.getWeight();
URIMetadataNode node = getMetadata(wre.urlhash(), wre, weight); URIMetadataNode node = getMetadata(wre.urlhash(), wre, weight);
return node; return node;
} }
@ -612,7 +612,7 @@ public final class Fulltext {
if (urlHash == null) return null; if (urlHash == null) return null;
String reason = (String) this.getDefaultConnector().getFieldById(urlHash, CollectionSchema.failreason_s.getSolrFieldName()); String reason = (String) this.getDefaultConnector().getFieldById(urlHash, CollectionSchema.failreason_s.getSolrFieldName());
if (reason == null) return null; if (reason == null) return null;
return reason == null ? null : reason.length() == 0 ? null : reason; return reason.length() == 0 ? null : reason;
} }
public List<File> dumpFiles() { public List<File> dumpFiles() {

@ -622,9 +622,8 @@ public final class yacy {
if (OS.isWindows) headless = false; if (OS.isWindows) headless = false;
if (args.length >= 1 && args[0].toLowerCase().equals("-gui")) headless = false; if (args.length >= 1 && args[0].toLowerCase().equals("-gui")) headless = false;
System.setProperty("java.awt.headless", headless ? "true" : "false"); System.setProperty("java.awt.headless", headless ? "true" : "false");
System.setProperty("java.net.preferIPv4Stack", "true"); System.setProperty("java.net.preferIPv4Stack", "true");
System.setProperty("solr.directoryFactory","solr.MMapDirectoryFactory"); // should prevent ClosedChannelException
String s = ""; for (final String a: args) s += a + " "; String s = ""; for (final String a: args) s += a + " ";
yacyRelease.startParameter = s.trim(); yacyRelease.startParameter = s.trim();

Loading…
Cancel
Save