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

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


     */
    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


            return null;
        }
        Collection<IndexMetadata> clones = new HashSet<IndexMetadata>();
        synchronized (inMemoryModelLock) {
            for(IndexMetadata metadata : managed.get(state).values()){
                IndexMetadata clone = new IndexMetadata();
                clone.putAll(metadata);
                clones.add(clone);
            }
        }
        return clones;
       
View Full Code Here

        }
        return clones;
       
    }
    public IndexMetadata getIndexMetadata(String indexName){
        IndexMetadata metadata = null;
        synchronized (inMemoryModelLock) {
            Iterator<Map<String,IndexMetadata>> inStateIt = managed.values().iterator();
            while(metadata == null && inStateIt.hasNext()) {
                metadata = inStateIt.next().get(indexName);
            }
        }
        //we need to return a clone to prevent changes by external changes to
        //the internal state!
        if(metadata != null){
            IndexMetadata clone = new IndexMetadata();
            clone.putAll(metadata);
            return clone;
        } else {
            return null;
        }
    }
View Full Code Here

                        Collections.unmodifiableCollection(new ArrayList<String>(indexNames));
        }
    }
   
    public void addUninitialisedIndex(String indexName, String indexArchiveName, Boolean sync) throws IOException {
        IndexMetadata config  = new IndexMetadata();
        config = new IndexMetadata();
        config.setIndexName(indexName);
        config.setServerName(serverName);
        config.setState(ManagedIndexState.UNINITIALISED);
        if(sync != null){
            config.setSynchronized(sync);
        }
        //no need to clone, because we have created the instance
        updateIndexProperties(null, config, false);
    }
View Full Code Here

        } else {
            removeIndexConfig(name);
        }
        //clone is meaningless if properties are NULL
        if(clone && properties != null){
            IndexMetadata tmp = properties;
            properties = new IndexMetadata();
            properties.putAll(tmp);
        }
        Map<String,IndexMetadata> toAdd,toRemove;
        IndexMetadata oldMetadata = null;
        synchronized (inMemoryModelLock ) {
            ManagedIndexState currentState = getState(name);
            if(currentState != null){
                toRemove = managed.get(currentState);
            } else {
                toRemove = null;
            }
            if(properties == null){
                toAdd = null; //remove
            } else {
                ManagedIndexState newState = properties.getState();
                toAdd = managed.get(newState);
            }
            //now update in-memory state
            if(toRemove != null){
                oldMetadata = toRemove.remove(name);
            }
            if(toAdd != null){
                toAdd.put(name, properties);
            }
            //now update the archive name to core name mappings
            if(oldMetadata != null){
                for(String indexArchive : oldMetadata.getIndexArchives()){
                    Collection<String> indexes = archiveName2CoreName.get(indexArchive);
                    if(indexes.remove(name) && indexes.isEmpty()){
                        archiveName2CoreName.remove(indexArchive);
                    }
                }
View Full Code Here

            if (uninstalledConfigDir.exists()) {
                for (String file : uninstalledConfigDir.list(new SuffixFileFilter(
                        ConfigUtils.SOLR_INDEX_ARCHIVE_EXTENSION + ".ref"))) {
                    String indexName = file.substring(0, file.indexOf('.'));
                    File configFile = new File(uninstalledConfigDir, file);
                    IndexMetadata props = new IndexMetadata();
                    InputStream is = null;
                    try {
                        is = new FileInputStream(configFile);
                        props.load(is);
                        //validate Index-Name and Server-Name properties!
                        if(!indexName.equals(props.getIndexName())){
                            throw new IOException("The IndexName '"+props.getIndexName()+
                                "within the IndexConfig file does not correspond to the file name '"+
                                file+"'!");
                        }
                        if(!serverName.equals(props.getServerName())){
                            throw new IOException("The Name of the Referenced Solr server '"+
                                serverName+" does not correspond with the Server-Name value '"+
                                props.getServerName()+"' within the property file '"+
                                file+"'!");
                        }
                        configs.put(indexName, props);
                    } finally {
                        IOUtils.closeQuietly(is);
View Full Code Here

        }
    }

    @Override
    public IndexMetadata getIndexMetadata(String indexName) {
        IndexMetadata metadata;
        SolrCore core  = server.getCore(indexName);
        if(core != null){
             metadata = getMetadata(core,serverName);
            core.close();
        } else {
View Full Code Here

    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

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.