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:46:30 UTC
svn commit: r1461477 - in /stanbol/trunk:
enhancement-engines/entitytagging/src/test/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/
entityhub/indexing/destination/solryard/src/main/java/org/apache/stanbol/entityhub/indexing/destination/so...
Author: rwesten
Date: Wed Mar 27 09:46:30 2013
New Revision: 1461477
URL: http://svn.apache.org/r1461477
Log:
STANBOL-997: adapted unit tests and the SolrYar indexing destionation (Entityhub Indexing Tool) to the changed API of the SolrYard
Modified:
stanbol/trunk/enhancement-engines/entitytagging/src/test/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/MockEntityhub.java
stanbol/trunk/entityhub/indexing/destination/solryard/src/main/java/org/apache/stanbol/entityhub/indexing/destination/solryard/SolrYardIndexingDestination.java
stanbol/trunk/entityhub/ldpath/src/test/java/org/apache/stanbol/entityhub/ldpath/impl/LDPathTestBase.java
Modified: stanbol/trunk/enhancement-engines/entitytagging/src/test/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/MockEntityhub.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitytagging/src/test/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/MockEntityhub.java?rev=1461477&r1=1461476&r2=1461477&view=diff
==============================================================================
--- stanbol/trunk/enhancement-engines/entitytagging/src/test/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/MockEntityhub.java (original)
+++ stanbol/trunk/enhancement-engines/entitytagging/src/test/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/MockEntityhub.java Wed Mar 27 09:46:30 2013
@@ -20,6 +20,9 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
+import org.apache.solr.client.solrj.SolrServer;
+import org.apache.stanbol.commons.solr.IndexReference;
+import org.apache.stanbol.commons.solr.managed.standalone.StandaloneEmbeddedSolrServerProvider;
import org.apache.stanbol.entityhub.core.model.EntityImpl;
import org.apache.stanbol.entityhub.core.query.DefaultQueryFactory;
import org.apache.stanbol.entityhub.core.query.QueryResultListImpl;
@@ -37,6 +40,7 @@ import org.apache.stanbol.entityhub.serv
import org.apache.stanbol.entityhub.servicesapi.yard.YardException;
import org.apache.stanbol.entityhub.yard.solr.impl.SolrYard;
import org.apache.stanbol.entityhub.yard.solr.impl.SolrYardConfig;
+import org.junit.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,9 +57,15 @@ class MockEntityhub implements Entityhub
protected SolrYard yard;
protected MockEntityhub(){
- SolrYardConfig config = new SolrYardConfig("dbpedia", "dbpedia_43k");
+ SolrYardConfig config = new SolrYardConfig("dbpedia", "dbpedia");
+ config.setIndexConfigurationName("dbpedia_43k");//use dbpedia default data for initialisation
+ config.setAllowInitialisation(true);
+ IndexReference solrIndexRef = IndexReference.parse(config.getSolrServerLocation());
+ SolrServer server = StandaloneEmbeddedSolrServerProvider.getInstance().getSolrServer(
+ solrIndexRef, config.getIndexConfigurationName());
+ Assert.assertNotNull("Unable to initialise SolrServer for testing",server);
try {
- yard = new SolrYard(config);
+ yard = new SolrYard(server,config,null);
Representation paris = yard.getRepresentation("http://dbpedia.org/resource/Paris");
if(paris == null){
throw new IllegalStateException("Initialised Yard does not contain the expected resource dbpedia:Paris!");
Modified: stanbol/trunk/entityhub/indexing/destination/solryard/src/main/java/org/apache/stanbol/entityhub/indexing/destination/solryard/SolrYardIndexingDestination.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/indexing/destination/solryard/src/main/java/org/apache/stanbol/entityhub/indexing/destination/solryard/SolrYardIndexingDestination.java?rev=1461477&r1=1461476&r2=1461477&view=diff
==============================================================================
--- stanbol/trunk/entityhub/indexing/destination/solryard/src/main/java/org/apache/stanbol/entityhub/indexing/destination/solryard/SolrYardIndexingDestination.java (original)
+++ stanbol/trunk/entityhub/indexing/destination/solryard/src/main/java/org/apache/stanbol/entityhub/indexing/destination/solryard/SolrYardIndexingDestination.java Wed Mar 27 09:46:30 2013
@@ -16,6 +16,11 @@
*/
package org.apache.stanbol.entityhub.indexing.destination.solryard;
+import static org.apache.stanbol.entityhub.yard.solr.impl.SolrYardConfig.ALLOW_INITIALISATION_STATE;
+import static org.apache.stanbol.entityhub.yard.solr.impl.SolrYardConfig.DOCUMENT_BOOST_FIELD;
+import static org.apache.stanbol.entityhub.yard.solr.impl.SolrYardConfig.MULTI_YARD_INDEX_LAYOUT;
+import static org.apache.stanbol.entityhub.yard.solr.impl.SolrYardConfig.SOLR_SERVER_LOCATION;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -32,6 +37,7 @@ import java.util.zip.ZipOutputStream;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
+import org.apache.solr.client.solrj.SolrServer;
import org.apache.stanbol.entityhub.core.mapping.FieldMappingUtils;
import org.apache.stanbol.entityhub.core.site.CacheUtils;
import org.apache.stanbol.entityhub.indexing.core.IndexingDestination;
@@ -42,9 +48,11 @@ import org.apache.stanbol.entityhub.serv
import org.apache.stanbol.entityhub.servicesapi.model.rdf.RdfResourceEnum;
import org.apache.stanbol.entityhub.servicesapi.yard.Yard;
import org.apache.stanbol.entityhub.servicesapi.yard.YardException;
+import org.apache.stanbol.commons.solr.IndexReference;
import org.apache.stanbol.commons.solr.SolrConstants;
import org.apache.stanbol.commons.solr.managed.ManagedIndexConstants;
import org.apache.stanbol.commons.solr.managed.ManagedSolrServer;
+import org.apache.stanbol.commons.solr.managed.standalone.StandaloneEmbeddedSolrServerProvider;
import org.apache.stanbol.entityhub.yard.solr.impl.SolrYard;
import org.apache.stanbol.entityhub.yard.solr.impl.SolrYardConfig;
import org.slf4j.Logger;
@@ -453,6 +461,8 @@ public class SolrYardIndexingDestination
//parameters and initialise the member variables. This method performs
//the the actual initialisation of the SolrYard!
//copy a custom configuration (if present)
+ SolrServer server;
+ IndexReference solrServerRef = IndexReference.parse(solrYardConfig.getSolrServerLocation());
if(solrIndexConfig != null){ //can only be != null if also solrIndexLocation
//copy the configuration
try {
@@ -463,20 +473,18 @@ public class SolrYardIndexingDestination
"Unable to copy the Solr index configuration from %s to %s!",
solrIndexConfig,solrIndexLocation),e);
}
- //disallow the default initialisation
- solrYardConfig.setDefaultInitialisation(Boolean.FALSE);
+ solrYardConfig.setAllowInitialisation(Boolean.FALSE);
+ server = StandaloneEmbeddedSolrServerProvider.getInstance().getSolrServer(
+ solrServerRef,solrServerRef.getIndex());
} else {
//allow the default initialisation
log.info(" ... use default Solr Configuration");
- solrYardConfig.setDefaultInitialisation(Boolean.TRUE);
- }
- try {
- log.info(" ... create SolrYard");
- this.solrYard = new SolrYard(solrYardConfig);
- } catch (YardException e) {
- throw new IllegalStateException("Unable to initialise SolrYard "+
- solrYardConfig.getId(),e);
+ solrYardConfig.setAllowInitialisation(Boolean.TRUE);
+ server = StandaloneEmbeddedSolrServerProvider.getInstance().getSolrServer(
+ solrServerRef,solrYardConfig.getIndexConfigurationName());
}
+ log.info(" ... create SolrYard");
+ this.solrYard = new SolrYard(server,solrYardConfig,indexingConfig.getNamespacePrefixService());
}
@Override
@@ -607,7 +615,7 @@ public class SolrYardIndexingDestination
//we need now add the solrYard specific parameters
String fieldBoostName = solrYardConfig.getDocumentBoostFieldName();
if(fieldBoostName != null){
- yardConfig.put(SolrYard.DOCUMENT_BOOST_FIELD, fieldBoostName);
+ yardConfig.put(DOCUMENT_BOOST_FIELD, fieldBoostName);
}
//TODO: fieldBoosts are currently not supported by the SolrYard Config
//solrYardConfig.getFieldBoosts();
@@ -615,20 +623,20 @@ public class SolrYardIndexingDestination
//The default values for the following parameters are OK
//solrYardConfig.getMaxBooleanClauses();
//solrYardConfig.getMaxQueryResultNumber();
- yardConfig.put(SolrYard.SOLR_SERVER_LOCATION, FilenameUtils.getName(solrYardConfig.getSolrServerLocation()));
+ yardConfig.put(SOLR_SERVER_LOCATION, FilenameUtils.getName(solrYardConfig.getSolrServerLocation()));
//the server type needs not to be set. It is automatically detected by
//the value of the server location
//solrYardConfig.getSolrServerType();
//deactivate default initialisation!
- yardConfig.put(SolrYard.SOLR_INDEX_DEFAULT_CONFIG, Boolean.FALSE);
+ yardConfig.put(ALLOW_INITIALISATION_STATE, Boolean.FALSE);
//for immediate commit use the default value (optionally one could also
//fore TRUE)
//yardConfig.put(SolrYard.IMMEDIATE_COMMIT, Boolean.TRUE);
//deactivate multi yard layout!
- yardConfig.put(SolrYard.MULTI_YARD_INDEX_LAYOUT, Boolean.FALSE);
+ yardConfig.put(MULTI_YARD_INDEX_LAYOUT, Boolean.FALSE);
String solrYardConfigFileName = SOLR_YARD_COMPONENT_ID+'-'+indexingConfig.getName()+".config";
OsgiConfigurationUtil.writeOsgiConfig(indexingConfig,solrYardConfigFileName, yardConfig);
Modified: stanbol/trunk/entityhub/ldpath/src/test/java/org/apache/stanbol/entityhub/ldpath/impl/LDPathTestBase.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/ldpath/src/test/java/org/apache/stanbol/entityhub/ldpath/impl/LDPathTestBase.java?rev=1461477&r1=1461476&r2=1461477&view=diff
==============================================================================
--- stanbol/trunk/entityhub/ldpath/src/test/java/org/apache/stanbol/entityhub/ldpath/impl/LDPathTestBase.java (original)
+++ stanbol/trunk/entityhub/ldpath/src/test/java/org/apache/stanbol/entityhub/ldpath/impl/LDPathTestBase.java Wed Mar 27 09:46:30 2013
@@ -27,7 +27,10 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
+import org.apache.solr.client.solrj.SolrServer;
+import org.apache.stanbol.commons.solr.IndexReference;
import org.apache.stanbol.commons.solr.managed.ManagedSolrServer;
+import org.apache.stanbol.commons.solr.managed.standalone.StandaloneEmbeddedSolrServerProvider;
import org.apache.stanbol.entityhub.ldpath.backend.YardBackend;
import org.apache.stanbol.entityhub.servicesapi.model.Representation;
import org.apache.stanbol.entityhub.servicesapi.util.ModelUtils;
@@ -35,6 +38,7 @@ import org.apache.stanbol.entityhub.serv
import org.apache.stanbol.entityhub.yard.solr.impl.SolrYard;
import org.apache.stanbol.entityhub.yard.solr.impl.SolrYardConfig;
import org.junit.AfterClass;
+import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
@@ -52,7 +56,8 @@ public abstract class LDPathTestBase {
* The SolrDirectoryManager also tested within this unit test
*/
public static final String TEST_YARD_ID = "dbpedia";
- public static final String TEST_SOLR_CORE_NAME = "dbpedia_43k";
+ public static final String TEST_SOLR_CORE_NAME = "dbpedia";
+ public static final String TEST_SOLR_CORE_CONFIGURATION = "dbpedia_43k";
protected static final String TEST_INDEX_REL_PATH = File.separatorChar + "target" + File.separatorChar
+ ManagedSolrServer.DEFAULT_SOLR_DATA_DIR;
@@ -67,11 +72,18 @@ public abstract class LDPathTestBase {
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.setDefaultInitialisation(false);
+ config.setAllowInitialisation(false);
+ config.setIndexConfigurationName(TEST_SOLR_CORE_CONFIGURATION); //the dbpedia default data
+ config.setAllowInitialisation(true); //init from datafile provider
config.setName("DBpedia.org default data");
config.setDescription("Data used for the LDPath setup");
// create the Yard used for the tests
- yard = new SolrYard(config);
+ IndexReference solrIndexRef = IndexReference.parse(config.getSolrServerLocation());
+
+ SolrServer server = StandaloneEmbeddedSolrServerProvider.getInstance().getSolrServer(
+ solrIndexRef, config.getIndexConfigurationName());
+ Assert.assertNotNull("Unable to initialise SolrServer for testing",server);
+ yard = new SolrYard(server,config,null);
backend = new YardBackend(yard);
}
@AfterClass