Examples of ManagedSolrServer


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

            log.error("Unable to remove Managed Index because the required Property '{}'" +
                    "used to define the name of the Index is missing",INDEX_NAME);
            setFinishedState(ResourceState.IGNORED);
        } else {
            String serverName = (String) getResource().getAttribute(ManagedIndexConstants.SERVER_NAME);
            ManagedSolrServer server = managedServers.get(serverName);
            if(server == null){
                log.warn("Unable to install Managed Solr Index {} because the {} " +
                        "Server {} is currently not active!",
                        new Object[]{indexName,serverName == null ? "default" : "",
                                serverName != null ? serverName : ""});
                setFinishedState(ResourceState.IGNORED); //needs still to be installed
            } else {
                //we have an index name and a server to in stall it ...
                //  ... let's do the work
                String archiveFormat = (String) getResource().getAttribute(PROPERTY_ARCHIVE_FORMAT);
                InputStream is = null;
                try {
                    is = getResource().getInputStream();
                    if ("properties".equals(archiveFormat)) {
                        InputStreamReader reader = new InputStreamReader(is, "UTF-8");
                        Properties props = new Properties();
                        try {
                            props.load(reader);
                        } finally {
                            IOUtils.closeQuietly(reader);
                        }
                        //TODO install to the right server!
                        String indexPath = props.getProperty(INDEX_ARCHIVES);
                        if (indexPath == null) {
                            indexPath = indexName + '.' + ConfigUtils.SOLR_INDEX_ARCHIVE_EXTENSION;
                            log.info("Property \""
                                     + INDEX_ARCHIVES
                                     + "\" not present within the SolrIndex references file. Will use the default name \""
                                     + indexPath + "\"");
                        }
                        server.updateIndex(indexName, indexPath, props);
                        setFinishedState(ResourceState.INSTALLED);
                    } else {
                        ArchiveInputStream ais = null;
                        try {
                            ais = ConfigUtils.getArchiveInputStream(archiveFormat, is);
                            server.updateIndex(indexName, ais);
                            // we are done ... set the state to installed!
                            setFinishedState(ResourceState.INSTALLED);
                        } finally {
                            IOUtils.closeQuietly(ais);
                        }
View Full Code Here

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

            log.error("Unable to remove Managed Index because the required Property '{}'" +
                "used to define the name of the Index is missing",INDEX_NAME);
            setFinishedState(ResourceState.IGNORED);
        } else {
            String serverName = (String) getResource().getAttribute(ManagedIndexConstants.SERVER_NAME);
            ManagedSolrServer server = managedServers.get(serverName);
            if(server == null){
                log.warn("Unable to remove Managed Solr Index {} because the {} " +
                    "Server {} is currently not active!",
                    new Object[]{indexName,serverName == null ? "default" : "",
                            serverName != null ? serverName : ""});
                setFinishedState(ResourceState.IGNORED);
            } else {
                server.removeIndex(indexName, true);
                setFinishedState(ResourceState.UNINSTALLED);
            }
        }
    }
View Full Code Here

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

                    }
                }
               
                @Override
                public Object addingService(ServiceReference reference) {
                    ManagedSolrServer server = (ManagedSolrServer)bc.getService(reference);
                    if(server != null){
                        lock.writeLock().lock();
                        try {
                            servers.put(reference, server);
                            updateRegistration(servers);
View Full Code Here

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

        }
        this.indexValueFactory = IndexValueFactory.getInstance();
        this.documentBoostFieldName = config.getDocumentBoostFieldName();
        this.fieldBoostMap = config.getFieldBoosts();
        //try to initialise the SolrServer
        ManagedSolrServer managedSolrServer = this.managedSolrServer;
        if(managedSolrServer != null){
            //check also if we need to create/init an SolrServer on startup
            try {
                checkManagedSolrIndex(managedSolrServer, config);
            } catch (Exception e) {
                log.error("Exception while checking SolrIndex '"+ config.getSolrServerLocation()
                    +"' on ManagedSolrServer '"+managedSolrServer.getServerName()+"'!",e);
            }
        }
        log.info("Activated SolrYard {}",config.getId());
    }
View Full Code Here

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

    private void deactivateSolrServer(){
        SolrYardConfig config = (SolrYardConfig) this.getConfig();
        String indexLocation = config.getSolrServerLocation();
        if(!(indexLocation.startsWith("http") && indexLocation.indexOf("://") > 0)){
            IndexReference indexReference = IndexReference.parse(indexLocation);
            ManagedSolrServer managedSolrServer = this.managedSolrServer;
            if(indexReference.isName() && managedSolrServer != null
                    && (indexReference.getServer() == null ||
                            indexReference.getServer().equals(managedSolrServer.getServerName()))){
                managedSolrServer.deactivateIndex(indexReference.getIndex());
            } //else no managed index or index not managed on #managedSolrServer
        }//an remote server
    }
View Full Code Here

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

        }
        this.indexValueFactory = IndexValueFactory.getInstance();
        this.documentBoostFieldName = config.getDocumentBoostFieldName();
        this.fieldBoostMap = config.getFieldBoosts();
        //try to initialise the SolrServer
        ManagedSolrServer managedSolrServer = this.managedSolrServer;
        if(managedSolrServer != null){
            //check also if we need to create/init an SolrServer on startup
            try {
                checkManagedSolrIndex(managedSolrServer, config);
            } catch (Exception e) {
                log.error("Exception while checking SolrIndex '"+ config.getSolrServerLocation()
                    +"' on ManagedSolrServer '"+managedSolrServer.getServerName()+"'!",e);
            }
        }
        log.info("Activated SolrYard {}",config.getId());
    }
View Full Code Here

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

    private void deactivateSolrServer(){
        SolrYardConfig config = (SolrYardConfig) this.getConfig();
        String indexLocation = config.getSolrServerLocation();
        if(!(indexLocation.startsWith("http") && indexLocation.indexOf("://") > 0)){
            IndexReference indexReference = IndexReference.parse(indexLocation);
            ManagedSolrServer managedSolrServer = this.managedSolrServer;
            if(indexReference.isName() && managedSolrServer != null
                    && (indexReference.getServer() == null ||
                            indexReference.getServer().equals(managedSolrServer.getServerName()))){
                managedSolrServer.deactivateIndex(indexReference.getIndex());
            } //else no managed index or index not managed on #managedSolrServer
        }//an remote server
    }
View Full Code Here

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

            log.error("Unable to remove Managed Index because the required Property '{}'" +
                    "used to define the name of the Index is missing",INDEX_NAME);
            setFinishedState(ResourceState.IGNORED);
        } else {
            String serverName = (String) getResource().getAttribute(ManagedIndexConstants.SERVER_NAME);
            ManagedSolrServer server = managedServers.get(serverName);
            if(server == null){
                log.warn("Unable to remove Managed Solr Index {} because the {} " +
                        "Server {} is currently not active!",
                        new Object[]{indexName,serverName == null ? "default" : "",
                                serverName != null ? serverName : ""});
                setFinishedState(ResourceState.IGNORED);
            } else {
                //we have an index name and a server to in stall it ...
                //  ... let's do the work
                String archiveFormat = (String) getResource().getAttribute(PROPERTY_ARCHIVE_FORMAT);
                InputStream is = null;
                try {
                    is = getResource().getInputStream();
                    if ("properties".equals(archiveFormat)) {
                        InputStreamReader reader = new InputStreamReader(is, "UTF-8");
                        Properties props = new Properties();
                        try {
                            props.load(reader);
                        } finally {
                            IOUtils.closeQuietly(reader);
                        }
                        //TODO install to the right server!
                        String indexPath = props.getProperty(INDEX_ARCHIVES);
                        if (indexPath == null) {
                            indexPath = indexName + '.' + ConfigUtils.SOLR_INDEX_ARCHIVE_EXTENSION;
                            log.info("Property \""
                                     + INDEX_ARCHIVES
                                     + "\" not present within the SolrIndex references file. Will use the default name \""
                                     + indexPath + "\"");
                        }
                        server.updateIndex(indexName, indexPath, props);
                        setFinishedState(ResourceState.INSTALLED);
                    } else {
                        ArchiveInputStream ais = null;
                        try {
                            ais = ConfigUtils.getArchiveInputStream(archiveFormat, is);
                            server.updateIndex(indexName, ais);
                            // we are done ... set the state to installed!
                            setFinishedState(ResourceState.INSTALLED);
                        } finally {
                            IOUtils.closeQuietly(ais);
                        }
View Full Code Here

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

        } else {
            map = new HashMap<String,ManagedSolrServer>();
            if(serverRefs.length > 1){
                Arrays.sort(serverRefs,ServiceReferenceRankingComparator.INSTANCE);
            }
            ManagedSolrServer defaultServer = null;
            for(ServiceReference ref : serverRefs){
                ManagedSolrServer server = (ManagedSolrServer)serverTracker.getService(ref);
                if(server != null){ //may become inactive in the meantime
                    map.put(server.getServerName(), server);
                    if(defaultServer == null){
                        defaultServer = server;
                    }
                }
            }
View Full Code Here

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

            log.error("Unable to remove Managed Index because the required Property '{}'" +
                    "used to define the name of the Index is missing",INDEX_NAME);
            setFinishedState(ResourceState.IGNORED);
        } else {
            String serverName = (String) getResource().getAttribute(ManagedIndexConstants.SERVER_NAME);
            ManagedSolrServer server = managedServers.get(serverName);
            if(server == null){
                log.warn("Unable to remove Managed Solr Index {} because the {} " +
                        "Server {} is currently not active!",
                        new Object[]{indexName,serverName == null ? "default" : "",
                                serverName != null ? serverName : ""});
                setFinishedState(ResourceState.IGNORED);
            } else {
                //we have an index name and a server to in stall it ...
                //  ... let's do the work
                String archiveFormat = (String) getResource().getAttribute(PROPERTY_ARCHIVE_FORMAT);
                InputStream is = null;
                try {
                    is = getResource().getInputStream();
                    if ("properties".equals(archiveFormat)) {
                        InputStreamReader reader = new InputStreamReader(is, "UTF-8");
                        Properties props = new Properties();
                        try {
                            props.load(reader);
                        } finally {
                            IOUtils.closeQuietly(reader);
                        }
                        //TODO install to the right server!
                        String indexPath = props.getProperty(INDEX_ARCHIVES);
                        if (indexPath == null) {
                            indexPath = indexName + '.' + ConfigUtils.SOLR_INDEX_ARCHIVE_EXTENSION;
                            log.info("Property \""
                                     + INDEX_ARCHIVES
                                     + "\" not present within the SolrIndex references file. Will use the default name \""
                                     + indexPath + "\"");
                        }
                        server.updateIndex(indexName, indexPath, props);
                        setFinishedState(ResourceState.INSTALLED);
                    } else {
                        ArchiveInputStream ais = null;
                        try {
                            ais = ConfigUtils.getArchiveInputStream(archiveFormat, is);
                            server.updateIndex(indexName, ais);
                            // we are done ... set the state to installed!
                            setFinishedState(ResourceState.INSTALLED);
                        } finally {
                            IOUtils.closeQuietly(ais);
                        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.