Package org.apache.stanbol.commons.solr

Examples of org.apache.stanbol.commons.solr.IndexReference


    private SolrServer getSolrServerFromTracker(String coreName) throws StoreException {
        SolrServer solrServer = null;
        for (int i = 0; solrServer == null && i <= SECONDS_TO_WAITFOR_CORE_TO_BEREADY; i++) {
            RegisteredSolrServerTracker tracker = null;
            try {
                tracker = new RegisteredSolrServerTracker(bundleContext, new IndexReference(
                        managedSolrServer.getServerName(), coreName));
            } catch (InvalidSyntaxException e) {
                String message = e.getMessage();
                if (message == null || message.isEmpty()) {
                    message = "Failed to create a RegisteredSolrServerTracker";
View Full Code Here


     * Getter for the {@link IndexReference} based on the {@link #getServerName()} and
     * {@link #getIndexName()} values
     * @return the {@link IndexReference} to the index described by this metadata
     */
    public IndexReference getIndexReference(){
        return new IndexReference(getServerName(), getIndexName());
    }
View Full Code Here

        //The constructors and the setConfiguration(..) only validate the parsed
        //parameters and initialise the member variables. This method performs
        //the the actual initialisation of the SolrYard!
        //copy a custom configuration (if present)
        EmbeddedSolrServer server;
        IndexReference solrServerRef = IndexReference.parse(solrYardConfig.getSolrServerLocation());
        if(solrIndexConfig != null){ //can only be != null if also solrIndexLocation
            //copy the configuration
            try {
                log.info(" ... copy Solr Configuration form {} to {}",solrIndexConfig,solrIndexLocation);
                FileUtils.copyDirectory(solrIndexConfig, solrIndexLocation);
            } catch (IOException e) {
                throw new IllegalStateException(String.format(
                    "Unable to copy the Solr index configuration from %s to %s!",
                    solrIndexConfig,solrIndexLocation),e);
            }
            solrYardConfig.setAllowInitialisation(Boolean.FALSE);
            server = StandaloneEmbeddedSolrServerProvider.getInstance().getSolrServer(
                solrServerRef,solrServerRef.getIndex());
        } else {
            //allow the default initialisation
            log.info("   ... use default Solr Configuration");
            solrYardConfig.setAllowInitialisation(Boolean.TRUE);
            server = StandaloneEmbeddedSolrServerProvider.getInstance().getSolrServer(
                solrServerRef,solrYardConfig.getIndexConfigurationName());
        }
        log.info("   ... create SolrYard");
        this.solrYard = new SolrYard(server,solrYardConfig,indexingConfig.getNamespacePrefixService());
        this.core = server.getCoreContainer().getCore(solrServerRef.getIndex());
    }
View Full Code Here

        //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;
View Full Code Here

        if(indexLocation.startsWith("http") && indexLocation.indexOf("://") > 0){
            solrServer = new HttpSolrServer(indexLocation);
            //directly register configs that use a remote server
            updateSolrYardRegistration(solrServer, config);
        } else { //locally managed Server
            IndexReference solrServerRef = IndexReference.parse(config.getSolrServerLocation());
            //We do not (yet) support creating SolrIndexes on ManagedSolrServers other than the
            //default
            if(config.isAllowInitialisation() && solrServerRef.getServer() != null){
                throw new ConfigurationException(SolrYardConfig.SOLR_SERVER_LOCATION,
                    "The SolrServerLocation ({server-name}:{index-name}) MUST NOT define a "
                            + "{server-name} if '"+SolrYardConfig.ALLOW_INITIALISATION_STATE
                            + "' is enabled. Change the cofiguration to use just a {index-name}");
            }
View Full Code Here

        if(managedServer == null || config == null){
            //this means that either no ManagedSolrServer is present or this
            //component was not yet activated ... will be called again
            return;
        }
        IndexReference solrIndexRef = IndexReference.parse(config.getSolrServerLocation());
        if(config.isAllowInitialisation()){ //are we allowed to create the SolrServer
            //get the name of the config to be used (default: default.solrindex.zip")
            String configName = config.getIndexConfigurationName();
            IndexMetadata metadata = managedServer.getIndexMetadata(solrIndexRef.getIndex());
            if(metadata == null){ //create a new index
                log.info(" ... creating Managed SolrIndex {} (configName: {}) on Server {}",
                    new Object[]{solrIndexRef.getIndex(),configName,managedServer.getServerName()});
                try {
                    metadata = managedServer.createSolrIndex(solrIndexRef.getIndex(), configName, null);
                } catch (IOException e) {
                    throw new IllegalStateException("Unable to create Managed SolrIndex "
                        + solrIndexRef.getIndex()+" (configName: "+configName+") on Server "
                        + managedServer.getServerName()+"!",e);
                }
            } else if(metadata.getState() != ManagedIndexState.ACTIVE){
                log.info(" ... activating Managed SolrIndex {} on Server {} (current state: {})",
                    new Object[]{solrIndexRef.getIndex(),managedServer.getServerName(),metadata.getState()});
                try {
                    managedServer.activateIndex(metadata.getIndexName());
                } catch (IOException e) {
                    throw new IllegalStateException("Unable to activate Managed SolrIndex "
                            + solrIndexRef.getIndex()+" (configName: "+configName+") on Server "
                            + managedServer.getServerName()+"!",e);
                } catch (SAXException e) {
                    throw new IllegalStateException("Unable to activate Managed SolrIndex "
                            + solrIndexRef.getIndex()+" (configName: "+configName+") on Server "
                            + managedServer.getServerName()+"!",e);
                }
            } //else already active nothing todo
            solrIndexRef = metadata.getIndexReference();
        } //else the SolrServer will be supplied (e.g. created by installing a full index)
        try {
            registeredServerTracker = new RegisteredSolrServerTracker(
                context, solrIndexRef,null){
                   
                    @Override
                    public void removedService(ServiceReference reference, Object service) {
                        updateSolrYardRegistration(registeredServerTracker.getService(),config);
                        super.removedService(reference, service);
                    }
                   

                    @Override
                    public void modifiedService(ServiceReference reference, Object service) {
                        updateSolrYardRegistration(registeredServerTracker.getService(),config);
                        super.modifiedService(reference, service);
                    }
                   
                    @Override
                    public SolrServer addingService(ServiceReference reference) {
                        SolrServer server = super.addingService(reference);
                        if(solrServer != null){
                            log.warn("Multiple SolrServer for IndexLocation {} available!",
                                config.getSolrServerLocation());
                        } else {
                            updateSolrYardRegistration(server,config);
                        }
                        return server;
                    }
                };
            log.info(" ... start tracking for SolrCore based on {}",solrIndexRef);
            registeredServerTracker.open(); //start tracking
        } catch (InvalidSyntaxException e) {
            throw new IllegalStateException("Unable to track Managed SolrIndex "
                    + solrIndexRef.getIndex() + "on Server "
                    + managedServer.getServerName()+"!",e);
        }
    }
View Full Code Here

        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 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",
View Full Code Here

   
    protected MockEntityhub(){
        SolrYardConfig config = new SolrYardConfig("dbpedia", "dbpedia");
        config.setIndexConfigurationName(TEST_SOLR_CORE_CONFIGURATION);
        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(server,config,null);
View Full Code Here

        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
        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);
View Full Code Here

                this.solrCoreId = defaultCoreId;
            }
            solrCoreConfig = getRequiredStringParam(config, solrCoreConfigProperty,
                this.solrCoreId + ".solrindex.zip");
            try {
                IndexReference indexReference = IndexReference.parse(solrCoreId);
                //String configName = getRequiredStringParam(config, SOLR_CONFIG, defaultValue)
                indexReference = checkInitSolrIndex(indexReference, solrCoreConfig);
                // track the solr core OSGi updates
                indexTracker = new RegisteredSolrServerTracker(context.getBundleContext(), indexReference);
                indexTracker.open();
View Full Code Here

TOP

Related Classes of org.apache.stanbol.commons.solr.IndexReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.