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

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


        }
        return metadata;
    }
    @Override
    public IndexMetadata activateIndex(String indexName) throws IOException, SAXException {
        IndexMetadata metadata = managedCores.getIndexMetadata(indexName);
        if(metadata != null && metadata.getState() == ManagedIndexState.INACTIVE){
            try {
                activateCore(metadata, server);
                metadata.setState(ManagedIndexState.ACTIVE);
            } catch (IOException e) {
                metadata.setError(e);
                throw e;
            } catch (SAXException e) {
                metadata.setError(e);
                throw e;
            } catch (RuntimeException e) {
                metadata.setError(e);
                throw e;
            } finally {
                managedCores.store(metadata);
            }
        }
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

        }
       
        @Override
        public boolean unavailable(String resource) {
            for(String indexName : managedCores.getIndexNames(resource)){
                IndexMetadata metadata = managedCores.getIndexMetadata(indexName);
                if(metadata != null){ //may be removed in the meantime
                    String currentArchive = metadata.getArchive();
                    boolean inSync = metadata.isSynchronized();
                    if(resource.equals(currentArchive)){ //current archive may be null
                        currentArchive = null; //reset the current archive to null (none)
                        ArchiveInputStream ais = null;
                        for(String archive : metadata.getIndexArchives()){
                            if(!archive.equals(resource)) {
                                if(currentArchive == null){
                                    try {
                                        InputStream is = provider.getInputStream(null, archive, null);
                                        if(is != null){
                                            ais = ManagementUtils.getArchiveInputStream(archive, is);
                                        } else {
                                            ais = null;
                                        }
                                    } catch (IOException e) {
                                       //not available
                                        ais = null;
                                    } catch (ArchiveException e) {
                                        log.error("Unable to open ArchiveInputStream for Resource '"+
                                            archive+"'!",e);
                                        ais = null;
                                    }
                                    if(ais != null){ //ais != null also
                                        currentArchive = archive; //currentArchive != null
                                    }
                                }
                                //if resource become unavailable we might need to
                                //add resources for tracking
                                if(!tracker.isTracked(this, null, archive) && //if not already tracked
                                        (currentArchive == null || ( //and no archive found
                                                currentArchive != null && inSync))){ //or found but inSync
                                        tracker.add(this, archive,
                                            IndexMetadata.toStringMap(metadata));
                                } // else already tracked or no tracking needed
                            }
                        }
                        //If we have now a currentArchive and an ais we can
                        //switch to an alternate archive.
                        //If not we need to switch this in index in the UNAVAILABLE
                        // state
                        metadata.setArchive(currentArchive);//update the metadata
                        managedCores.store(metadata);
                        //if the parsed ais is NULL the index will be uninitialised
                        indexUpdateDaemon.update(
                            currentArchive == null ? ManagedIndexState.UNINITIALISED :
                                    ManagedIndexState.ACTIVE,
View Full Code Here

                ais = null;
            }
            if(ais != null){
                boolean keepTracking = false;
                for(String indexName : managedCores.getIndexNames(resourceName)){
                    IndexMetadata metadata = managedCores.getIndexMetadata(indexName);
                    List<String> archives = metadata.getIndexArchives();
                    String currentArchive = metadata.getArchive();
                    if(currentArchive == null ||
                            archives.indexOf(resourceName) < archives.indexOf(currentArchive)){
                        metadata.setArchive(resourceName);
                        managedCores.store(metadata);
                        indexUpdateDaemon.update(ManagedIndexState.ACTIVE,metadata, ais);
                        //if synchronised do not remove this listener
                        keepTracking = keepTracking || metadata.isSynchronized();
                    } else { //currently used Archive is of higher priority as
                        // this one.
                        //keep tracking if synchronised
                        keepTracking = keepTracking || metadata.isSynchronized();
                    }
                }
                return !keepTracking;
            } else { //unable to create an ArchiveInputStrem
                return false; //TODO: add support for ERROR state to the Tracker!
View Full Code Here

     */
    public static IndexMetadata getMetadata(SolrCore core, String serverName){
        if(core == null){
            return null;
        }
        IndexMetadata metadata = new IndexMetadata();
        if(serverName != null){
            metadata.setServerName(serverName);
        }
        metadata.setSynchronized(false);
        updateMetadata(metadata, core);
        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.