Search in sources :

Example 1 with SolrYardConfig

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());
    }
}
Also used : PlainLiteralImpl(org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl) ArrayList(java.util.ArrayList) EmbeddedSolrServer(org.apache.solr.client.solrj.embedded.EmbeddedSolrServer) SolrServer(org.apache.solr.client.solrj.SolrServer) ManagedSolrServer(org.apache.stanbol.commons.solr.managed.ManagedSolrServer) SolrYard(org.apache.stanbol.entityhub.yard.solr.impl.SolrYard) SolrYardConfig(org.apache.stanbol.entityhub.yard.solr.impl.SolrYardConfig) IndexConfiguration(org.apache.stanbol.enhancer.engines.lucenefstlinking.IndexConfiguration) CorpusInfo(org.apache.stanbol.enhancer.engines.lucenefstlinking.CorpusInfo) Future(java.util.concurrent.Future) CorpusCreationTask(org.apache.stanbol.enhancer.engines.lucenefstlinking.CorpusCreationTask) LanguageConfiguration(org.apache.stanbol.enhancer.nlp.utils.LanguageConfiguration) IndexReference(org.apache.stanbol.commons.solr.IndexReference) EmbeddedSolrServer(org.apache.solr.client.solrj.embedded.EmbeddedSolrServer) TimeoutException(java.util.concurrent.TimeoutException) BeforeClass(org.junit.BeforeClass)

Example 2 with SolrYardConfig

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);
}
Also used : YardBackend(org.apache.stanbol.entityhub.ldpath.backend.YardBackend) IndexReference(org.apache.stanbol.commons.solr.IndexReference) ManagedSolrServer(org.apache.stanbol.commons.solr.managed.ManagedSolrServer) SolrServer(org.apache.solr.client.solrj.SolrServer) SolrYard(org.apache.stanbol.entityhub.yard.solr.impl.SolrYard) SolrYardConfig(org.apache.stanbol.entityhub.yard.solr.impl.SolrYardConfig) BeforeClass(org.junit.BeforeClass)

Example 3 with SolrYardConfig

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;
}
Also used : SolrYardConfig(org.apache.stanbol.entityhub.yard.solr.impl.SolrYardConfig)

Example 4 with 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);
}
Also used : NamespacePrefixService(org.apache.stanbol.commons.namespaceprefix.NamespacePrefixService) IndexReference(org.apache.stanbol.commons.solr.IndexReference) StandaloneManagedSolrServer(org.apache.stanbol.commons.solr.managed.standalone.StandaloneManagedSolrServer) ManagedSolrServer(org.apache.stanbol.commons.solr.managed.ManagedSolrServer) SolrServer(org.apache.solr.client.solrj.SolrServer) SolrYard(org.apache.stanbol.entityhub.yard.solr.impl.SolrYard) SolrYardConfig(org.apache.stanbol.entityhub.yard.solr.impl.SolrYardConfig) BeforeClass(org.junit.BeforeClass)

Aggregations

SolrYardConfig (org.apache.stanbol.entityhub.yard.solr.impl.SolrYardConfig)4 SolrServer (org.apache.solr.client.solrj.SolrServer)3 IndexReference (org.apache.stanbol.commons.solr.IndexReference)3 ManagedSolrServer (org.apache.stanbol.commons.solr.managed.ManagedSolrServer)3 SolrYard (org.apache.stanbol.entityhub.yard.solr.impl.SolrYard)3 BeforeClass (org.junit.BeforeClass)3 ArrayList (java.util.ArrayList)1 Future (java.util.concurrent.Future)1 TimeoutException (java.util.concurrent.TimeoutException)1 PlainLiteralImpl (org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl)1 EmbeddedSolrServer (org.apache.solr.client.solrj.embedded.EmbeddedSolrServer)1 NamespacePrefixService (org.apache.stanbol.commons.namespaceprefix.NamespacePrefixService)1 StandaloneManagedSolrServer (org.apache.stanbol.commons.solr.managed.standalone.StandaloneManagedSolrServer)1 CorpusCreationTask (org.apache.stanbol.enhancer.engines.lucenefstlinking.CorpusCreationTask)1 CorpusInfo (org.apache.stanbol.enhancer.engines.lucenefstlinking.CorpusInfo)1 IndexConfiguration (org.apache.stanbol.enhancer.engines.lucenefstlinking.IndexConfiguration)1 LanguageConfiguration (org.apache.stanbol.enhancer.nlp.utils.LanguageConfiguration)1 YardBackend (org.apache.stanbol.entityhub.ldpath.backend.YardBackend)1