You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2013/03/27 10:35:25 UTC
svn commit: r1461468 [2/2] - in /stanbol/trunk/entityhub/yard/solr: ./
src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/
src/main/resources/OSGI-INF/metatype/
src/test/java/org/apache/stanbol/entityhub/yard/solr/
Modified: stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrYardConfig.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrYardConfig.java?rev=1461468&r1=1461467&r2=1461468&view=diff
==============================================================================
--- stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrYardConfig.java (original)
+++ stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrYardConfig.java Wed Mar 27 09:35:25 2013
@@ -16,12 +16,16 @@
*/
package org.apache.stanbol.entityhub.yard.solr.impl;
+import java.util.Collections;
import java.util.Dictionary;
import java.util.Map;
+import java.util.Map.Entry;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.stanbol.entityhub.core.yard.AbstractYard.YardConfig;
import org.osgi.service.cm.ConfigurationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Used for the configuration of a SolrYard. Especially if the SolrYard is not running within an OSGI context,
@@ -34,6 +38,92 @@ import org.osgi.service.cm.Configuration
*
*/
public final class SolrYardConfig extends YardConfig {
+
+ private final Logger log = LoggerFactory.getLogger(SolrYardConfig.class);
+ /**
+ * The key used to configure the URL for the SolrServer
+ */
+ public static final String SOLR_SERVER_LOCATION = "org.apache.stanbol.entityhub.yard.solr.solrUri";
+ /**
+ * The key used to configure if data of multiple Yards are stored within the same index (
+ * <code>default=false</code>)
+ */
+ public static final String MULTI_YARD_INDEX_LAYOUT = "org.apache.stanbol.entityhub.yard.solr.multiYardIndexLayout";
+ /**
+ * The maximum boolean clauses as configured in the solrconfig.xml of the SolrServer. The default value
+ * for this config in Solr 1.4 is 1024.
+ * <p>
+ * This value is important for generating queries that search for multiple documents, because it
+ * determines the maximum number of OR combination for the searched document ids.
+ */
+ public static final String MAX_BOOLEAN_CLAUSES = "org.apache.stanbol.entityhub.yard.solr.maxBooleanClauses";
+ /**
+ * This property allows to define a field that is used to parse the boost for the parsed representation.
+ * Typically this will be the pageRank of that entity within the referenced site (e.g.
+ * {@link Math#log1p(double)} of the number of incoming links
+ */
+ public static final String DOCUMENT_BOOST_FIELD = "org.apache.stanbol.entityhub.yard.solr.documentBoost";
+ /**
+ * Key used to configure {@link Entry Entry<String,Float>} for fields with the boost. If no Map is
+ * configured or a field is not present in the Map, than 1.0f is used as Boost. If a Document boost is
+ * present than the boost of a Field is documentBoost*fieldBoost.
+ */
+ public static final String FIELD_BOOST_MAPPINGS = "org.apache.stanbol.entityhub.yard.solr.fieldBoosts";
+ /**
+ * Key used to to enable/disable the default configuration. If this is enabled,
+ * that the index will get initialised with the Default configuration.<p>
+ * Notes:<ul>
+ * <li> Configuration is only supported for EmbeddedSolrServers that use a
+ * relative path
+ * <li> If this property is enabled the value of the
+ * {@link #SOLR_INDEX_CONFIGURATION_NAME} will be ignored.
+ * </ul>
+ * Only applies in case a EmbeddedSolrServer is used.
+ * @see SolrYardConfig#isAllowInitialisation()
+ * @see SolrYardConfig#setAllowInitialisation(Boolean)
+ */
+ public static final String ALLOW_INITIALISATION_STATE = "org.apache.stanbol.entityhub.yard.solr.useDefaultConfig";
+ /**
+ * By default the use of an default configuration is disabled!
+ */
+ public static final boolean DEFAULT_ALLOW_INITIALISATION_STATE = false;
+ /**
+ * The name of the configuration use as default.
+ */
+ public static final String DEFAULT_SOLR_INDEX_CONFIGURATION_NAME = "default.solrindex.zip";
+ /**
+ * Allows to configure the name of the index used for the configuration of the Solr Core.
+ * Only applies in case of using an EmbeddedSolrServer and
+ * {@link #ALLOW_INITIALISATION_STATE} is disabled.
+ * As default the value of the {@link #SOLR_SERVER_LOCATION} is used.
+ * @see SolrYardConfig#getIndexConfigurationName()
+ * @see SolrYardConfig#setIndexConfigurationName(String)
+ */
+ public static final String SOLR_INDEX_CONFIGURATION_NAME = "org.apache.stanbol.entityhub.yard.solr.configName";
+ /**
+ * The default value for the maxBooleanClauses of SolrQueries. Set to {@value #DEFAULT_MAX_BOOLEAN_CLAUSES}
+ * the default of Slor 1.4
+ */
+ protected static final int DEFAULT_MAX_BOOLEAN_CLAUSES = 1024;
+ /**
+ * Key used to enable/disable committing of update(..) and store(..) operations. Enabling this ensures
+ * that indexed documents are immediately available for searches, but it will also decrease the
+ * performance for updates.
+ */
+ public static final String IMMEDIATE_COMMIT = "org.apache.stanbol.entityhub.yard.solr.immediateCommit";
+ /**
+ * By default {@link #IMMEDIATE_COMMIT} is enabled
+ */
+ public static final boolean DEFAULT_IMMEDIATE_COMMIT_STATE = true;
+ /**
+ * If {@link #IMMEDIATE_COMMIT} is deactivated, than this time is parsed to update(..) and store(..)
+ * operations as the maximum time (in ms) until a commit.
+ */
+ public static final String COMMIT_WITHIN_DURATION = "org.apache.stanbol.entityhub.yard.solr.commitWithinDuration";
+ /**
+ * The default value for the {@link #COMMIT_WITHIN_DURATION} parameter is 10 sec.
+ */
+ public static final int DEFAULT_COMMIT_WITHIN_DURATION = 1000 * 10;
/**
* Creates a new config with the minimal set of required properties
@@ -71,46 +161,6 @@ public final class SolrYardConfig extend
super(config);
}
-// /**
-// * Setter for the type of the SolrServer client to by used by the SolrYard. Setting the type to
-// * <code>null</code> will activate the default value. The default is determined based on the configured
-// * {@link #getSolrServerLocation()}
-// *
-// * @param type
-// * The type to use
-// */
-// public void setSolrServerType(SolrServerTypeEnum type) {
-// if (type == null) {
-// config.remove(SolrYard.SOLR_SERVER_TYPE);
-// } else {
-// config.put(SolrYard.SOLR_SERVER_TYPE, type);
-// }
-// }
-//
-// public SolrServerTypeEnum getSolrServerType() {
-// Object serverType = config.get(SolrYard.SOLR_SERVER_TYPE);
-// if (serverType != null) {
-// if (serverType instanceof SolrServerTypeEnum) {
-// return (SolrServerTypeEnum) serverType;
-// } else {
-// try {
-// return SolrServerTypeEnum.valueOf(serverType.toString());
-// } catch (IllegalArgumentException e) {
-// // invalid value set!
-// config.remove(SolrYard.SOLR_SERVER_TYPE);
-// }
-// }
-// }
-// // guess type based on Server Location
-// String serverLocation = getSolrServerLocation();
-// // TODO: maybe we need to improve this detection code.
-// if (serverLocation.startsWith("http")) {
-// return SolrServerTypeEnum.HTTP;
-// } else {
-// return SolrServerTypeEnum.EMBEDDED;
-// }
-// }
-
/**
* Setter for the location of the SolrServer. Might be a URL or a file.
*
@@ -119,9 +169,9 @@ public final class SolrYardConfig extend
*/
public void setSolrServerLocation(String url) {
if (url != null) {
- config.put(SolrYard.SOLR_SERVER_LOCATION, url);
+ config.put(SOLR_SERVER_LOCATION, url);
} else {
- config.remove(SolrYard.SOLR_SERVER_LOCATION);
+ config.remove(SOLR_SERVER_LOCATION);
}
}
@@ -133,7 +183,7 @@ public final class SolrYardConfig extend
* @return the URL or path to the SolrServer
*/
public String getSolrServerLocation() throws IllegalStateException {
- Object value = config.get(SolrYard.SOLR_SERVER_LOCATION);
+ Object value = config.get(SOLR_SERVER_LOCATION);
if (value != null) {
return value.toString();
} else {
@@ -150,9 +200,9 @@ public final class SolrYardConfig extend
*/
public void setMultiYardIndexLayout(Boolean multiYardIndexLayoutState) {
if (multiYardIndexLayoutState != null) {
- config.put(SolrYard.MULTI_YARD_INDEX_LAYOUT, multiYardIndexLayoutState);
+ config.put(MULTI_YARD_INDEX_LAYOUT, multiYardIndexLayoutState);
} else {
- config.remove(SolrYard.MULTI_YARD_INDEX_LAYOUT);
+ config.remove(MULTI_YARD_INDEX_LAYOUT);
}
}
@@ -168,7 +218,7 @@ public final class SolrYardConfig extend
* @return the multi yard index layout state
*/
public boolean isMultiYardIndexLayout() {
- Object value = config.get(SolrYard.MULTI_YARD_INDEX_LAYOUT);
+ Object value = config.get(MULTI_YARD_INDEX_LAYOUT);
if (value != null) {
if (value instanceof Boolean) {
return (Boolean) value;
@@ -189,8 +239,8 @@ public final class SolrYardConfig extend
*
* @return the state or <code>true</code> as default
*/
- public boolean isDefaultInitialisation() {
- Object value = config.get(SolrYard.SOLR_INDEX_DEFAULT_CONFIG);
+ public boolean isAllowInitialisation() {
+ Object value = config.get(ALLOW_INITIALISATION_STATE);
if (value != null) {
if (value instanceof Boolean) {
return (Boolean) value;
@@ -198,7 +248,7 @@ public final class SolrYardConfig extend
return Boolean.parseBoolean(value.toString());
}
} else {
- return SolrYard.DEFAULT_SOLR_INDEX_DEFAULT_CONFIG_STATE;
+ return DEFAULT_ALLOW_INITIALISATION_STATE;
}
}
@@ -213,11 +263,11 @@ public final class SolrYardConfig extend
* the state or <code>null</code> to remove the current configuration. The default state is
* <code>true</code>.
*/
- public void setDefaultInitialisation(Boolean defaultInitialisationState) {
+ public void setAllowInitialisation(Boolean defaultInitialisationState) {
if (defaultInitialisationState != null) {
- config.put(SolrYard.SOLR_INDEX_DEFAULT_CONFIG, defaultInitialisationState);
+ config.put(ALLOW_INITIALISATION_STATE, defaultInitialisationState);
} else {
- config.remove(SolrYard.SOLR_INDEX_DEFAULT_CONFIG);
+ config.remove(ALLOW_INITIALISATION_STATE);
}
}
@@ -225,20 +275,20 @@ public final class SolrYardConfig extend
* Getter for the name of the configuration used to initialise the SolrServer. <p>
* In case this property is not set the value of {@link #getSolrServerLocation()}
* is used as default.<p>
- * Please NOTE that in case <code>{@link #isDefaultInitialisation()} == true</code>
+ * Please NOTE that in case <code>{@link #isAllowInitialisation()} == true</code>
* the value of {@link SolrYard#DEFAULT_SOLR_INDEX_CONFIGURATION_NAME} MUST
* BE used to initialise the SolrIndex instead of the value returned by this
* Method!
* @return the name of the configuration of the SolrIndex
* @see SolrYard#SOLR_INDEX_CONFIGURATION_NAME
- * @see SolrYard#SOLR_INDEX_DEFAULT_CONFIG
+ * @see SolrYard#ALLOW_INITIALISATION_STATE
*/
public String getIndexConfigurationName() {
- Object value = config.get(SolrYard.SOLR_INDEX_CONFIGURATION_NAME);
+ Object value = config.get(SOLR_INDEX_CONFIGURATION_NAME);
if (value != null) {
return value.toString();
} else {
- return getSolrServerLocation();
+ return DEFAULT_SOLR_INDEX_CONFIGURATION_NAME;
}
}
@@ -252,9 +302,9 @@ public final class SolrYardConfig extend
*/
public void setIndexConfigurationName(String name) {
if (name == null || name.isEmpty()) {
- config.remove(SolrYard.SOLR_INDEX_CONFIGURATION_NAME);
+ config.remove(SOLR_INDEX_CONFIGURATION_NAME);
} else {
- config.put(SolrYard.SOLR_INDEX_CONFIGURATION_NAME, name);
+ config.put(SOLR_INDEX_CONFIGURATION_NAME, name);
}
}
@@ -264,109 +314,131 @@ public final class SolrYardConfig extend
* @return The configured number of <code>null</code> if not configured or the configured value is not an
* valid Integer.
*/
- public Integer getMaxBooleanClauses() {
- Object value = config.get(SolrYard.MAX_BOOLEAN_CLAUSES);
+ public int getMaxBooleanClauses() {
+ Object value = config.get(MAX_BOOLEAN_CLAUSES);
+ int clauses;
if (value != null) {
if (value instanceof Integer) {
- return (Integer) value;
+ clauses = ((Integer) value).intValue();
} else {
try {
- return Integer.parseInt(value.toString());
+ clauses = Integer.parseInt(value.toString());
} catch (NumberFormatException e) {
- return null;
+ log.warn("Unable to parse Integer property '" + MAX_BOOLEAN_CLAUSES
+ + "' from configured value '"+value+"'! Use default '"
+ + DEFAULT_MAX_BOOLEAN_CLAUSES + "' instead.",e);
+ clauses = DEFAULT_MAX_BOOLEAN_CLAUSES;
}
}
} else {
- return null;
+ clauses = DEFAULT_MAX_BOOLEAN_CLAUSES;
}
+ if(clauses < 1){
+ log.warn("Configured '{}={} is invalid (value MUST BE > 0). Use "
+ + "default {} instead.", new Object[]{ MAX_BOOLEAN_CLAUSES,
+ clauses, DEFAULT_MAX_BOOLEAN_CLAUSES});
+ clauses = DEFAULT_MAX_BOOLEAN_CLAUSES;
+ }
+ return clauses;
}
public void setMaxBooleanClauses(Integer integer) {
if (integer == null || integer.intValue() <= 0) {
- config.remove(SolrYard.MAX_BOOLEAN_CLAUSES);
+ config.remove(MAX_BOOLEAN_CLAUSES);
} else {
- config.put(SolrYard.MAX_BOOLEAN_CLAUSES, integer);
+ config.put(MAX_BOOLEAN_CLAUSES, integer);
}
}
public void setDocumentBoostFieldName(String fieldName) {
if (fieldName == null || fieldName.isEmpty()) {
- config.remove(SolrYard.DOCUMENT_BOOST_FIELD);
+ config.remove(DOCUMENT_BOOST_FIELD);
} else {
- config.put(SolrYard.DOCUMENT_BOOST_FIELD, fieldName);
+ config.put(DOCUMENT_BOOST_FIELD, fieldName);
}
}
public String getDocumentBoostFieldName() {
- Object name = config.get(SolrYard.DOCUMENT_BOOST_FIELD);
+ Object name = config.get(DOCUMENT_BOOST_FIELD);
return name == null ? null : name.toString();
}
public void setFieldBoosts(Map<String,Float> fieldBoosts) {
if (fieldBoosts != null) {
- config.put(SolrYard.FIELD_BOOST_MAPPINGS, fieldBoosts);
+ config.put(FIELD_BOOST_MAPPINGS, fieldBoosts);
} else {
- config.remove(SolrYard.FIELD_BOOST_MAPPINGS);
+ config.remove(FIELD_BOOST_MAPPINGS);
}
}
- public Boolean isImmediateCommit() {
- Object value = config.get(SolrYard.IMMEDIATE_COMMIT);
+ public boolean isImmediateCommit() {
+ Object value = config.get(IMMEDIATE_COMMIT);
if (value != null) {
if (value instanceof Boolean) {
- return (Boolean) value;
+ return ((Boolean) value).booleanValue();
} else {
return Boolean.parseBoolean(value.toString());
}
} else {
- return null;
+ return DEFAULT_IMMEDIATE_COMMIT_STATE;
}
}
public void setImmediateCommit(Boolean state) {
if (state != null) {
- config.put(SolrYard.IMMEDIATE_COMMIT, state);
+ config.put(IMMEDIATE_COMMIT, state);
} else {
- config.remove(SolrYard.IMMEDIATE_COMMIT);
+ config.remove(IMMEDIATE_COMMIT);
}
}
- public final Integer getCommitWithinDuration() {
- Object value = config.get(SolrYard.COMMIT_WITHIN_DURATION);
+ public final int getCommitWithinDuration() {
+ Object value = config.get(COMMIT_WITHIN_DURATION);
+ int duration;
if (value != null) {
if (value instanceof Integer) {
- return (Integer) value;
+ duration = ((Integer) value).intValue();
} else {
try {
- return Integer.parseInt(value.toString());
+ duration = Integer.parseInt(value.toString());
} catch (NumberFormatException e) {
- return null;
+ log.warn("Unable to parse Integer property '" + COMMIT_WITHIN_DURATION
+ + "' from configured value '"+value+"'! Use default "
+ + DEFAULT_COMMIT_WITHIN_DURATION + "ms instead.",e);
+ duration = DEFAULT_COMMIT_WITHIN_DURATION;
}
}
} else {
- return null;
+ duration = DEFAULT_COMMIT_WITHIN_DURATION;
}
+ if(duration <= 0){
+ log.warn("Configured '{}={}ms is invalid (value MUST BE >= 0). Use "
+ + "default {}ms instead.", new Object[]{ COMMIT_WITHIN_DURATION,
+ duration, DEFAULT_COMMIT_WITHIN_DURATION});
+ duration = DEFAULT_COMMIT_WITHIN_DURATION;
+ }
+ return duration;
}
public final void setCommitWithinDuration(Integer duration) {
if (duration == null || duration.intValue() <= 0) {
- config.remove(SolrYard.COMMIT_WITHIN_DURATION);
+ config.remove(COMMIT_WITHIN_DURATION);
} else {
- config.put(SolrYard.COMMIT_WITHIN_DURATION, duration);
+ config.put(COMMIT_WITHIN_DURATION, duration);
}
}
@SuppressWarnings("unchecked")
public Map<String,Float> getFieldBoosts() {
- Object fieldBoosts = config.get(SolrYard.FIELD_BOOST_MAPPINGS);
+ Object fieldBoosts = config.get(FIELD_BOOST_MAPPINGS);
if (fieldBoosts == null) {
return null;
} else if (fieldBoosts instanceof Map<?,?>) {
return (Map<String,Float>) fieldBoosts;
} else {
// TODO: add support for parsing from String[] and Collection<String>
- return null;
+ return Collections.emptyMap();
}
}
@@ -378,11 +450,11 @@ public final class SolrYardConfig extend
try {
String solrServer = getSolrServerLocation();
if (solrServer == null) {
- throw new ConfigurationException(SolrYard.SOLR_SERVER_LOCATION,
+ throw new ConfigurationException(SOLR_SERVER_LOCATION,
"The URL of the Solr server MUST NOT be NULL!");
}
} catch (IllegalStateException e) {
- throw new ConfigurationException(SolrYard.SOLR_SERVER_LOCATION, e.getMessage(), e.getCause());
+ throw new ConfigurationException(SOLR_SERVER_LOCATION, e.getMessage(), e.getCause());
}
}
Modified: stanbol/trunk/entityhub/yard/solr/src/main/resources/OSGI-INF/metatype/metatype.properties
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/yard/solr/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=1461468&r1=1461467&r2=1461468&view=diff
==============================================================================
--- stanbol/trunk/entityhub/yard/solr/src/main/resources/OSGI-INF/metatype/metatype.properties (original)
+++ stanbol/trunk/entityhub/yard/solr/src/main/resources/OSGI-INF/metatype/metatype.properties Wed Mar 27 09:35:25 2013
@@ -15,15 +15,20 @@
#Properties defined by the yard interface and used by the solr Yard implementation
org.apache.stanbol.entityhub.yard.solr.impl.SolrYard.name=Apache Stanbol Entityhub Yard: Solr Yard Configuration
-org.apache.stanbol.entityhub.yard.solr.impl.SolrYard.description=Used to configure a Yard (storage component of the Entityhub) based on a Solr instance
+org.apache.stanbol.entityhub.yard.solr.impl.SolrYard.description=Used to configure a \
+Yard (storage component of the Entityhub) based on a Solr instance
#org.apache.stanbol.entityhub.yard.solr.solrUri
org.apache.stanbol.entityhub.yard.solr.solrUri.name=Solr Index/Core
-org.apache.stanbol.entityhub.yard.solr.solrUri.description=This can be either the URL of a SolrServer, the absolute Path to an index/core an the local file system or just the core name to use the EmbeddedSolrServer internally managed by the SolrYard
+org.apache.stanbol.entityhub.yard.solr.solrUri.description=This can be either the URL of a \
+SolrServer, the absolute Path to an index/core an the local file system or just the core \
+name to use the EmbeddedSolrServer internally managed by the SolrYard
#org.apache.stanbol.entityhub.yard.solr.multiYardIndexLayout
org.apache.stanbol.entityhub.yard.solr.multiYardIndexLayout.name=Multiple Yard Layout
-org.apache.stanbol.entityhub.yard.solr.multiYardIndexLayout.description=If several Yards are using the same Solr index than set this property to TRUE. NOTE: That this is only an option if all Yards using the same Solr Index do not store Representations with the same URI!
+org.apache.stanbol.entityhub.yard.solr.multiYardIndexLayout.description=If several Yards \
+are using the same Solr index than set this property to TRUE. NOTE: That this is only an \
+option if all Yards using the same Solr Index do not store Representations with the same URI!
#org.apache.stanbol.entityhub.yard.id
org.apache.stanbol.entityhub.yard.id.name=ID
@@ -35,22 +40,35 @@ org.apache.stanbol.entityhub.yard.name.d
#org.apache.stanbol.entityhub.yard.Description
org.apache.stanbol.entityhub.yard.description.name=description
-org.apache.stanbol.entityhub.yard.description.description=Typically short description describing what kind of Data are stored in this Yard (e.g. local Cache for DBPedia)
+org.apache.stanbol.entityhub.yard.description.description=Typically short description \
+describing what kind of Data are stored in this Yard (e.g. local Cache for DBPedia)
#org.apache.stanbol.entityhub.yard.solr.maxQueryResultNumber
org.apache.stanbol.entityhub.yard.maxQueryResultNumber.name=Maximum Query Results
-org.apache.stanbol.entityhub.yard.maxQueryResultNumber.description=The maximum number of results per query (set to <= 0 for no restriction). If a parsed query asks for more results, than that value will be replaced by the value configured.
+org.apache.stanbol.entityhub.yard.maxQueryResultNumber.description=The maximum number \
+of results per query (set to <= 0 for no restriction). If a parsed query asks for more \
+results, than that value will be replaced by the value configured.
#org.apache.stanbol.entityhub.yard.solr.defaultQueryResultNumber
org.apache.stanbol.entityhub.yard.defaultQueryResultNumber.name=Default Query Results
-org.apache.stanbol.entityhub.yard.defaultQueryResultNumber.description=The default number of results set for queries that do not define such a value (set to <= 0 for no restriction, values > maximumQueryResult will be replaced by maximumQueryResult)
+org.apache.stanbol.entityhub.yard.defaultQueryResultNumber.description=The default \
+number of results set for queries that do not define such a value (set to <= 0 for no \
+restriction, values > maximumQueryResult will be replaced by maximumQueryResult)
#org.apache.stanbol.entityhub.yard.solr.useDefaultConfig
-org.apache.stanbol.entityhub.yard.solr.useDefaultConfig.name=Use default SolrCore configuration
-org.apache.stanbol.entityhub.yard.solr.useDefaultConfig.description=This enables the \
-use of the default SolrCore configuration for this SolrYard. Enabling this will create \
-an empty SolrCore.
+org.apache.stanbol.entityhub.yard.solr.useDefaultConfig.name=Allow Initialization
+org.apache.stanbol.entityhub.yard.solr.useDefaultConfig.description=If this option is enabled \
+the SolrYard will cerate a new SolrCore based on the SolrCore configuration defined by the \
+Solr Index Configuration field. If no configuration is defined than "default.solrindex.zip" is \
+used as default.
+
+org.apache.stanbol.entityhub.yard.solr.configName.name=Index Configuration
+org.apache.stanbol.entityhub.yard.solr.configName.description=The SolrCore configuration \
+used to create a new SolrCore on the managed SolrServer. This field takes only effect \
+if "Allow Initialization" is enabled.
#org.apache.stanbol.entityhub.yard.solr.maxBooleanClauses
org.apache.stanbol.entityhub.yard.solr.maxBooleanClauses.name=Max Boolean Clauses
-org.apache.stanbol.entityhub.yard.solr.maxBooleanClauses.description=This is the maximum number of boolean clauses allowed for Solr queries. This value is configured in the solrconf.xml by the maxBooleanClauses element.
+org.apache.stanbol.entityhub.yard.solr.maxBooleanClauses.description=This is the \
+maximum number of boolean clauses allowed for Solr queries. This value is configured \
+in the solrconf.xml by the maxBooleanClauses element.
Modified: stanbol/trunk/entityhub/yard/solr/src/test/java/org/apache/stanbol/entityhub/yard/solr/SolrYardTest.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/yard/solr/src/test/java/org/apache/stanbol/entityhub/yard/solr/SolrYardTest.java?rev=1461468&r1=1461467&r2=1461468&view=diff
==============================================================================
--- stanbol/trunk/entityhub/yard/solr/src/test/java/org/apache/stanbol/entityhub/yard/solr/SolrYardTest.java (original)
+++ stanbol/trunk/entityhub/yard/solr/src/test/java/org/apache/stanbol/entityhub/yard/solr/SolrYardTest.java Wed Mar 27 09:35:25 2013
@@ -20,10 +20,21 @@ import static junit.framework.Assert.ass
import static junit.framework.Assert.assertNotNull;
import java.io.File;
+import java.io.IOError;
+import java.io.IOException;
import java.util.Arrays;
import java.util.Iterator;
+import java.util.ServiceLoader;
+import org.apache.solr.client.solrj.SolrServer;
+import org.apache.stanbol.commons.namespaceprefix.NamespacePrefixService;
+import org.apache.stanbol.commons.solr.IndexReference;
+import org.apache.stanbol.commons.solr.SolrConstants;
+import org.apache.stanbol.commons.solr.SolrServerAdapter;
+import org.apache.stanbol.commons.solr.managed.IndexMetadata;
import org.apache.stanbol.commons.solr.managed.ManagedSolrServer;
+import org.apache.stanbol.commons.solr.managed.standalone.StandaloneEmbeddedSolrServerProvider;
+import org.apache.stanbol.commons.solr.managed.standalone.StandaloneManagedSolrServer;
import org.apache.stanbol.entityhub.servicesapi.defaults.NamespaceEnum;
import org.apache.stanbol.entityhub.servicesapi.model.Representation;
import org.apache.stanbol.entityhub.servicesapi.query.FieldQuery;
@@ -36,6 +47,7 @@ import org.apache.stanbol.entityhub.test
import org.apache.stanbol.entityhub.yard.solr.impl.SolrYard;
import org.apache.stanbol.entityhub.yard.solr.impl.SolrYardConfig;
import org.junit.After;
+import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
@@ -63,22 +75,36 @@ public class SolrYardTest extends YardTe
protected static final String TEST_INDEX_REL_PATH = File.separatorChar + "target" + File.separatorChar
+ ManagedSolrServer.DEFAULT_SOLR_DATA_DIR;
private static final Logger log = LoggerFactory.getLogger(SolrYardTest.class);
+
+ private static StandaloneEmbeddedSolrServerProvider solrServerProvider;
@BeforeClass
- public static final void initYard() throws YardException {
+ public static final void initYard() throws YardException, IOException {
// get the working directory
// use property substitution to test this feature!
String prefix = System.getProperty("basedir") == null ? "." : "${basedir}";
String solrServerDir = prefix + TEST_INDEX_REL_PATH;
log.info("Test Solr Server Directory: " + solrServerDir);
- System.setProperty(ManagedSolrServer.MANAGED_SOLR_DIR_PROPERTY, solrServerDir);
SolrYardConfig config = new SolrYardConfig(TEST_YARD_ID, TEST_SOLR_CORE_NAME);
config.setName("Solr Yard Test");
config.setDescription("The Solr Yard instance used to execute the Unit Tests defined for the Yard Interface");
- //use the default Solr Index configuration for this tests
- config.setDefaultInitialisation(true);
- // create the Yard used for the tests
- yard = new SolrYard(config);
+ config.setAllowInitialisation(true);
+ //init the ManagedSolrServer used for the UnitTest
+ System.setProperty(ManagedSolrServer.MANAGED_SOLR_DIR_PROPERTY, solrServerDir);
+ IndexReference solrServerRef = IndexReference.parse(config.getSolrServerLocation());
+ solrServerProvider = StandaloneEmbeddedSolrServerProvider.getInstance();
+ SolrServer server = solrServerProvider.getSolrServer(solrServerRef,
+ config.isAllowInitialisation() ? config.getIndexConfigurationName() : null);
+ //Optional support for the nsPrefix service
+ final NamespacePrefixService nsPrefixService;
+ ServiceLoader<NamespacePrefixService> spsl = ServiceLoader.load(NamespacePrefixService.class);
+ Iterator<NamespacePrefixService> it = spsl.iterator();
+ if(it.hasNext()){
+ nsPrefixService = it.next();
+ } else {
+ nsPrefixService = null;
+ }
+ yard = new SolrYard(server, config, nsPrefixService);
}
@Override