Package org.apache.stanbol.entityhub.servicesapi.yard

Examples of org.apache.stanbol.entityhub.servicesapi.yard.YardException


                }
            });
        } catch (PrivilegedActionException pae) {
            Exception e = pae.getException();
            if(e instanceof SolrServerException){
                throw new YardException("Error while deleting document " + id + " from the Solr server", e);
            } else if(e instanceof IOException){
                throw new YardException("Unable to access SolrServer",e);
            } else {
                throw RuntimeException.class.cast(e);
            }
        }
        // NOTE: We do not need to update all Documents that refer this ID, because
View Full Code Here


                }
            });
        } catch (PrivilegedActionException pae) {
            Exception e = pae.getException();
            if(e instanceof SolrServerException){
                throw new YardException("Error while deleting documents from the Solr server", e);
            } else if(e instanceof IOException){
                throw new YardException("Unable to access SolrServer",e);
            } else {
                throw RuntimeException.class.cast(e);
            }
        }
        // NOTE: We do not need to update all Documents that refer this ID, because
View Full Code Here

                }
            });
        } catch (PrivilegedActionException pae) {
            Exception e = pae.getException();
            if(e instanceof SolrServerException){
                throw new YardException("Error while deleting documents from the Solr server", e);
            } else if(e instanceof IOException){
                throw new YardException("Unable to access SolrServer",e);
            } else if(e instanceof YardException){
                throw (YardException)e;
            } else {
                throw RuntimeException.class.cast(e);
            }
View Full Code Here

            long stored = System.currentTimeMillis();
            log.debug("  ... done [create={}ms|store={}ms|sum={}ms]",
                new Object[] {(create - start),(stored - create),(stored - start)});
        } catch (PrivilegedActionException pae){
            if(pae.getException() instanceof SolrServerException){
                throw new YardException(String.format("Exception while adding Document to Solr",
                    representation.getId()), pae.getException());
            } else if( pae.getException() instanceof IOException){
                throw new YardException("Unable to access SolrServer", pae.getException());
            } else {
                throw RuntimeException.class.cast(pae.getException());
            }
        }
        return representation;
View Full Code Here

            update.process(server);
            if (immediateCommit) {
                server.commit();
            }
        } catch (SolrServerException e) {
            throw new YardException("Exception while adding Documents to the Solr Server!", e);
        } catch (IOException e) {
            throw new YardException("Unable to access Solr server", e);
        }
        long ready = System.currentTimeMillis();
        log.debug(String.format(
            "Processed store request for %d documents in %dms (created %dms| stored%dms)", inputDocs.size(),
            ready - start, created - start, ready - created));
View Full Code Here

        FieldMapper fieldMapper = getFieldMapper();
        int numDocs = ids.size(); // for debuging
        try {
            ids = checkRepresentations(server, fieldMapper,ids); // returns the ids found in the solrIndex
        } catch (SolrServerException e) {
            throw new YardException(
                    "Error while searching for alredy present documents before executing the actual update for the parsed Representations",
                    e);
        } catch (IOException e) {
            throw new YardException("Unable to access SolrServer", e);
        }
        long checked = System.currentTimeMillis();
        List<SolrInputDocument> inputDocs = new ArrayList<SolrInputDocument>(ids.size());
        List<Representation> updated = new ArrayList<Representation>();
        for (Representation representation : representations) {
            if (representation != null && ids.contains(representation.getId())) { // null parsed or not
                                                                                  // already present
                inputDocs.add(createSolrInputDocument(fieldMapper,representation));
                updated.add(representation);
            }
        }
        long created = System.currentTimeMillis();
        if (!inputDocs.isEmpty()) {
            try {
                final UpdateRequest update = new UpdateRequest();
                if (!immediateCommit) {
                    update.setCommitWithin(commitWithin);
                }
                update.add(inputDocs);
                AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                    public UpdateResponse run() throws IOException, SolrServerException {
                        update.process(server);
                        if (immediateCommit) {
                            server.commit();
                        }
                        return null;
                    }
                });
            } catch (PrivilegedActionException pae){
                if(pae.getException() instanceof SolrServerException){
                    throw new YardException("Error while adding updated Documents to the SolrServer",
                        pae.getException());
                } else if( pae.getException() instanceof IOException){
                    throw new YardException("Unable to access SolrServer", pae.getException());
                } else {
                    throw RuntimeException.class.cast(pae.getException());
                }
            }
        }
View Full Code Here

     * @throws YardException in case the yard is not active
     */
    private Yard lookupYard() throws YardException {
        Yard yard = getYard();
        if(yard == null){
            throw new YardException("The Entityhub Yard (ID="+config.getEntityhubYardId()+") is not active! Please check the configuration!!");
        }
        return yard;
    }
View Full Code Here

        // we need to change the exceptions, because this will be called outside
        // of an OSGI environment!
        try {
            activate(config);
        } catch (IOException e) {
            new YardException("Unable to access SolrServer" + config.getSolrServerLocation());
        } catch (SolrServerException e) {
            new YardException("Unable to initialize SolrServer" + config.getSolrServerLocation());
        } catch (ConfigurationException e) {
            new IllegalArgumentException("Unable to initialise SolrYard with the provided configuration", e);
        }
    }
View Full Code Here

        }
        //the server is not available -> throw an exception!
        if(server != null){
            return server;
        } else {
            throw new YardException(String.format("The SolrIndex '%s' for SolrYard '%s' is currently not active!",
                ((SolrYardConfig)getConfig()).getSolrServerLocation(),getName()));
        }
    }
View Full Code Here

            //init remote server
            try {
                _server = new CommonsHttpSolrServer(indexLocation);
                _server.ping(); //test if remove service is available
            } catch (RuntimeException e) {
                throw new YardException("Unable to connect to remote SolrServer '"+
                    config.getSolrServerLocation() +"' because of "+e.getMessage(),e);
            } catch (SolrServerException e) {
                throw new YardException("Unable to initialise to remote SolrServer '"+
                    config.getSolrServerLocation() +"' because of "+e.getMessage(),e);
            } catch (IOException e) {
                throw new YardException("Unable to connect to remote SolrServer '"+
                    config.getSolrServerLocation() +"' because of "+e.getMessage(),e);
            }
        } else { //locally managed Server
            //(1) check if available (also tries to create if not available and
            //    create is allowed based on the configuration)
            IndexReference indexReference = checkManagedSolrIndex(managedSolrServer,config);
            if(indexReference != null){
                if(context == null){ // outside OSGI
                    try {
                        _server = StandaloneEmbeddedSolrServerProvider.getInstance().getSolrServer(indexReference);
                    } catch (RuntimeException e) {
                        throw new YardException("Unable to initialise configured SolrServer'"+
                            config.getSolrServerLocation() +"'!",e);
                    }
                } else { //within OSGI dynamically track the service
                    try {
                        _registeredServerTracker = new RegisteredSolrServerTracker(
                            context.getBundleContext(), indexReference, null);
                        _registeredServerTracker.open(); //start tracking
                    } catch (InvalidSyntaxException e) {
                        throw new YardException("Unable to track configured SolrServer'"+
                            config.getSolrServerLocation() +"'!",e);
                    } catch (RuntimeException e) {
                        throw new YardException("Unable to initialise configured SolrServer'"+
                            config.getSolrServerLocation() +"'!",e);
                    }
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.stanbol.entityhub.servicesapi.yard.YardException

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.