Package org.apache.stanbol.commons.solr.managed

Examples of org.apache.stanbol.commons.solr.managed.IndexMetadata


    public IndexMetadata updateIndex(String name, ArchiveInputStream ais, String archiveCoreName) throws IOException {

        if (name == null || name.isEmpty()) {
            throw new IllegalArgumentException("The parsed index name MUST NOT be NULL nor empty!");
        }
        IndexMetadata metadata = new IndexMetadata();
        metadata.setIndexName(name);
        metadata.setServerName(DEFAULT_SERVER_NAME);
        metadata.setSynchronized(false);
        metadata.setState(ManagedIndexState.ACTIVE);
        if (archiveCoreName != null) {
            metadata.setArchive(archiveCoreName);
        }
        return updateCore(metadata, ais);
    }
View Full Code Here


                ais = ManagementUtils.getArchiveInputStream(resourceName, is);
            } catch (ArchiveException e) {
                throw new IOException("Unable to open ArchiveInputStream for resource '"+
                    resourceName+"'!",e);
            }
            IndexMetadata metadata = new IndexMetadata();
            if(properties != null){
                metadata.putAll(properties);
            }
            metadata.setIndexName(name);
            metadata.setServerName(DEFAULT_SERVER_NAME);
            metadata.setSynchronized(false);
            metadata.setState(ManagedIndexState.ACTIVE);
            metadata.setArchive(resourceName);
            return updateCore(metadata, ais);
        } else {
            return null;
        }
    }
View Full Code Here

        return server.getDefaultCoreName();
    }
    @Override
    public IndexMetadata activateIndex(String indexName) throws IOException, SAXException {
        //if the index is already active -> return it
        IndexMetadata metadata = getIndexMetadata(indexName);
        if(metadata != null){
            return metadata;
        } else {
            //try to init an core for that directory located within the
            //managedDir
View Full Code Here

            return updateIndex(indexName, null);
        }
    }
    @Override
    public IndexMetadata deactivateIndex(String indexName) {
        IndexMetadata metadata;
        SolrCore core = server.remove(indexName);
        if(core != null){
            metadata = getMetadata(core,serverName);
            core.close();
            metadata.setState(ManagedIndexState.INACTIVE);
        } else {
            metadata = null;
        }
        return metadata;
    }
View Full Code Here

        //(1) Try to activate missing cores on the CoreContainer
        if(!activeByMetadata.isEmpty()){
            log.info("The following active managed Cores are not available on " +
                "the SolrServer: {}",activeByMetadata);
            for(String indexName : activeByMetadata){
                IndexMetadata metadata = managedCores.getIndexMetadata(indexName);
                try {
                    activateCore(metadata, server);
                    log.info("  ... index {} successfully started!",indexName);
                } catch (IOException e) {
                    metadata.setError(e);
                    log.error("Unable to activate previously active SolrIndex '"+
                        metadata.getIndexReference()+"'!",e);
                } catch (SAXException e) {
                    metadata.setError(e);
                    log.error("Unable to activate previously active SolrIndex '"+
                        metadata.getIndexReference()+"'!",e);
                } catch (RuntimeException e) {
                    metadata.setError(e);
                    log.error("Unable to activate previously active SolrIndex '"+
                        metadata.getIndexReference()+"'!",e);
                //} finally { The metadata are not modified anyway!
                //    managedCores.store(metadata);
                }
            }
        }
        //(2) Process active SolrCores on the CoreContainer that are not active
        //    based on the configuration
        if(!activeOnSolrServer.isEmpty()){
            log.info("The following Cores active on the SolrServer are not " +
                "marked as active in the Metadata: {}",activeOnSolrServer);
            log.info("Based on the Metadata (UNKNOWN ... no Index for that name):");
            for(String indexName : activeOnSolrServer){
                IndexMetadata metadata = managedCores.getIndexMetadata(indexName);
                ManagedIndexState state = metadata != null ? metadata.getState() : null;
                log.info("   - {} has state {}",indexName, state != null ? state : "UNKNOWN");
                if(metadata == null){
                    //unknown core ... deactivate
                    deactivateCore(indexName, server);
                    log.info("  ... deactiaved UNKOWN SolrCore {} on managed Solr Server {}",
                        indexName, serverName);
                } else if(state == ManagedIndexState.INACTIVE){
                    ////the metadata way this core should be deactivated!
                    deactivateCore(indexName, server);
                    log.info("  ... deactiaved INACTIVE SolrCore {} on managed Solr Server {}",
                        indexName, serverName);
                } else if(state == ManagedIndexState.ERROR){
                    //looks like that the error was resolved ...
                    // ... maybe someone has manually edited some files and
                    //     restarted this server
                    metadata.setState(ManagedIndexState.ACTIVE);
                    managedCores.store(metadata);
                    log.info("  ... successfully ACTIVATED SolrCore {} on managed Solr Server {}",
                        indexName, serverName);
                } else if(state == ManagedIndexState.UNINITIALISED){
                    //looks like someone has copied the required files manually
                    //to the solrServer ... update the metadata an activate
                    ManagementUtils.updateMetadata(metadata, server.getCore(indexName));
                    metadata.setState(ManagedIndexState.ACTIVE);
                    managedCores.store(metadata);
                    log.info("  ... successfully ACTIVATED SolrCore {} on managed Solr Server {}",
                        indexName, serverName);
                }
            }
View Full Code Here

        }
        if(isManagedIndex(indexName)){
            throw new IllegalArgumentException("An index with the parsed name '"+
                indexName+"' already exists on this managed Solr server '"+serverName+"'!");
        }
        IndexMetadata metadata = new IndexMetadata();
        if(properties != null){
            metadata.putAll(properties);
        }
        metadata.setServerName(serverName);
        metadata.setIndexName(indexName);
        metadata.setIndexArchives(Collections.singletonList(resourceName));
        metadata.setState(ManagedIndexState.UNINITIALISED);
        //TODO: we need to deal with the synchronised property!
        // now add the index to the list of uninitialised
        managedCores.store(metadata);
        //now start tracking this archive file
        indexArchiveTracker.addTracking(metadata);
View Full Code Here

    public void removeIndex(String indexName, boolean deleteFiles) {
        if(indexName == null || indexName.isEmpty()){
            throw new IllegalArgumentException("The parsed index name MUST NOT be NULL nor empty!");
        }
        //remove the index from the metadata
        IndexMetadata metadata = managedCores.remove(indexName);
        if(metadata != null){
            //and also tracked index archives from the DataFileTracker
            indexArchiveTracker.removeTracking(metadata);
            uninitialiseCore(metadata,deleteFiles);
        }
View Full Code Here

                "be NULL nor empty!");
        }
        if(ais == null){
            throw new IOException("The parsed ArchiveInputStream MUST NOT be NULL!");
        }
        IndexMetadata metadata = new IndexMetadata();
        metadata.setServerName(serverName);
        metadata.setIndexName(indexName);
        metadata.setSynchronized(false);
        if (archiveCoreName != null) {
            metadata.setArchive(archiveCoreName);
        }
        try {
            updateCore(metadata, ais);
        } finally {
            managedCores.store(metadata);
View Full Code Here

    @Override
    public IndexMetadata updateIndex(String indexName, String resourceName, Properties properties) throws IOException {
        //NOTE: this does not deactivate the current index version, but only updates
        //the metadata and re-registers the DataFileTracking
        IndexMetadata oldMetadata = managedCores.getIndexMetadata(indexName);
        IndexMetadata metadata = new IndexMetadata();
        if(properties != null){
            metadata.putAll(properties);
        }
        metadata.setServerName(serverName);
        metadata.setIndexName(indexName);
        metadata.setIndexArchives(Collections.singletonList(resourceName));
        if(oldMetadata != null){ //we need to
            metadata.setState(oldMetadata.getState()); //same as for the old version
            metadata.setDirectory(oldMetadata.getDirectory());
        } else {
            metadata.setState(ManagedIndexState.UNINITIALISED);
        }
        //TODO: we need to deal with the synchronised property!
        // now add the index to the list of uninitialised
        managedCores.store(metadata);
        indexArchiveTracker.updateTracking(oldMetadata,metadata);
View Full Code Here

        indexArchiveTracker.updateTracking(oldMetadata,metadata);
        return metadata;
    }
    @Override
    public IndexMetadata deactivateIndex(String indexName) {
        IndexMetadata metadata = managedCores.getIndexMetadata(indexName);
        if(metadata != null && metadata.getState() == ManagedIndexState.ACTIVE){
            try {
                deactivateCore(indexName, server);
                metadata.setState(ManagedIndexState.INACTIVE);
            } catch (RuntimeException e) {
                metadata.setError(e);
            } finally {
                managedCores.store(metadata);
            }
        }
        return metadata;
View Full Code Here

TOP

Related Classes of org.apache.stanbol.commons.solr.managed.IndexMetadata

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.