use of org.apache.stanbol.entityhub.yard.solr.impl.SolrYardConfig in project stanbol by apache.
the class FstLinkingEngineTest method setup.
@BeforeClass
public static void setup() throws Exception {
// 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.setAllowInitialisation(false);
// the dbpedia default data
config.setIndexConfigurationName(TEST_SOLR_CORE_CONFIGURATION);
// init from datafile provider
config.setAllowInitialisation(true);
config.setName("DBpedia.org default data");
config.setDescription("Data used for FstLinkingEngie tests");
// create the Yard used for the tests
IndexReference solrIndexRef = IndexReference.parse(config.getSolrServerLocation());
SolrServer server = StandaloneEmbeddedSolrServerProvider.getInstance().getSolrServer(solrIndexRef, config.getIndexConfigurationName());
Assert.assertNotNull("Unable to initialise SolrServer for testing", server);
core = ((EmbeddedSolrServer) server).getCoreContainer().getCore(solrIndexRef.getIndex());
Assert.assertNotNull("Unable to get SolrCore '" + config.getIndexConfigurationName() + "' from SolrServer " + server, core);
yard = new SolrYard(server, config, null);
// setup the index configuration
LanguageConfiguration langConf = new LanguageConfiguration("not.used", new String[] { "en;field=dbpedia-ont:surfaceForm;generate=true" });
fstConfig = new IndexConfiguration(langConf, core, FieldEncodingEnum.SolrYard, "");
fstConfig.setExecutorService(Executors.newFixedThreadPool(1));
fstConfig.setTypeField("rdf:type");
fstConfig.setRankingField("entityhub:entityRank");
// fstConfig.setEntityCacheManager(new FastLRUCacheManager(2048));
fstConfig.setOrigin(new PlainLiteralImpl(TEST_ORIGIN));
// activate the FST config
// activate this configuration
fstConfig.activate();
// validate that the index contains the expected entities
validateTestIndex();
// now create the FST models
List<Future<?>> creationTasks = new ArrayList<Future<?>>();
for (CorpusInfo corpus : fstConfig.getCorpora()) {
Assert.assertTrue("Failure in UnitTest - all FST models need to be generate=true", corpus.allowCreation);
if (!corpus.isFstFile()) {
// create a task on the FST corpus creation service
creationTasks.add(fstConfig.getExecutorService().submit(new CorpusCreationTask(fstConfig, corpus)));
}
}
// typical hardware
for (Future<?> future : creationTasks) {
try {
future.get(FST_CREATION_WAIT_TIME, TimeUnit.SECONDS);
} catch (TimeoutException e) {
// we assert on future.isDone instead
}
Assert.assertTrue("FST Model creation not finished after " + FST_CREATION_WAIT_TIME + "seconds", future.isDone());
}
}
use of org.apache.stanbol.entityhub.yard.solr.impl.SolrYardConfig in project stanbol by apache.
the class LDPathTestBase method setup.
@BeforeClass
public static void setup() throws Exception {
// 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.setAllowInitialisation(false);
// the dbpedia default data
config.setIndexConfigurationName(TEST_SOLR_CORE_CONFIGURATION);
// init from datafile provider
config.setAllowInitialisation(true);
config.setName("DBpedia.org default data");
config.setDescription("Data used for the LDPath setup");
// create the Yard used for the tests
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);
}
use of org.apache.stanbol.entityhub.yard.solr.impl.SolrYardConfig in project stanbol by apache.
the class SolrYardIndexingDestination method createSolrYardConfig.
/**
* Creates a {@link SolrYardConfig} and initialised it to used single Yard
* Layout, lazy commits and a commitWithin duration of an minute
* @param yardName the name of the yard
* @param indexName the name of the index
*/
private SolrYardConfig createSolrYardConfig(String yardName, String indexName) {
SolrYardConfig solrYardConfig = new SolrYardConfig(yardName, indexName);
solrYardConfig.setMultiYardIndexLayout(Boolean.FALSE);
// use the lazy commit feature
solrYardConfig.setImmediateCommit(Boolean.FALSE);
// one minute
solrYardConfig.setCommitWithinDuration(1000 * 60);
return solrYardConfig;
}
use of org.apache.stanbol.entityhub.yard.solr.impl.SolrYardConfig in project stanbol by apache.
the class SolrYardTest method initYard.
@BeforeClass
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);
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");
config.setAllowInitialisation(true);
// for unit testing we want immidiate commits (required after STANBOL-1092
// as the default changed to false)
config.setImmediateCommit(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);
}
Aggregations