Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

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

reger8a7fcb391d0c
diff --git a/defaults/solr/solrcore.properties b/defaults/solr/solrcore.properties
new file mode 100644
index 000000000..7b689a10f
--- /dev/null
+++ b/defaults/solr/solrcore.properties
@@ -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
diff --git a/defaults/solr/solrcore.x86.properties b/defaults/solr/solrcore.x86.properties
new file mode 100644
index 000000000..9943418c6
--- /dev/null
+++ b/defaults/solr/solrcore.x86.properties
@@ -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
diff --git a/source/net/yacy/cora/federate/solr/instance/EmbeddedInstance.java b/source/net/yacy/cora/federate/solr/instance/EmbeddedInstance.java
index a21de9482..baef50a99 100644
--- a/source/net/yacy/cora/federate/solr/instance/EmbeddedInstance.java
+++ b/source/net/yacy/cora/federate/solr/instance/EmbeddedInstance.java
@@ -39,7 +39,7 @@ import com.google.common.io.Files;
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/"};
-
+ // additional a optional solrcore.properties (or solrcore.x86.properties for 32bit systems is copied
private CoreContainer coreContainer;
private String defaultCoreName;
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());
}
this.defaultCoreServer = new EmbeddedSolrServer(this.coreContainer, this.defaultCoreName);
-
+
// initialize core cache
this.cores = new ConcurrentHashMap<String, SolrCore>();
this.cores.put(this.defaultCoreName, this.defaultCore);
@@ -129,13 +129,37 @@ public class EmbeddedInstance implements SolrInstance {
} else {
target = new File(conf, cf);
target.getParentFile().mkdirs();
- try {
+ try {
Files.copy(source, target);
} catch (IOException e) {
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() {
diff --git a/source/net/yacy/search/index/Fulltext.java b/source/net/yacy/search/index/Fulltext.java
index 8d0f27ab5..bd37a2e28 100644
--- a/source/net/yacy/search/index/Fulltext.java
+++ b/source/net/yacy/search/index/Fulltext.java
@@ -328,9 +328,9 @@ public final class Fulltext {
public URIMetadataNode getMetadata(WeakPriorityBlockingQueue.Element<WordReferenceVars> element) {
if (element == null) return null;
- WordReferenceVars wre = element.getElement();
- long weight = element.getWeight();
+ WordReferenceVars wre = element.getElement();
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);
return node;
}
@@ -612,7 +612,7 @@ public final class Fulltext {
if (urlHash == null) return null;
String reason = (String) this.getDefaultConnector().getFieldById(urlHash, CollectionSchema.failreason_s.getSolrFieldName());
if (reason == null) return null;
- return reason == null ? null : reason.length() == 0 ? null : reason;
+ return reason.length() == 0 ? null : reason;
}
public List<File> dumpFiles() {
diff --git a/source/net/yacy/yacy.java b/source/net/yacy/yacy.java
index 356d65c65..b1f1a5e31 100644
--- a/source/net/yacy/yacy.java
+++ b/source/net/yacy/yacy.java
@@ -622,9 +622,8 @@ public final class yacy {
if (OS.isWindows) headless = false;
if (args.length >= 1 && args[0].toLowerCase().equals("-gui")) headless = false;
System.setProperty("java.awt.headless", headless ? "true" : "false");
- System.setProperty("java.net.preferIPv4Stack", "true");
- System.setProperty("solr.directoryFactory","solr.MMapDirectoryFactory"); // should prevent ClosedChannelException
-
+ System.setProperty("java.net.preferIPv4Stack", "true");
+
String s = ""; for (final String a: args) s += a + " ";
yacyRelease.startParameter = s.trim();