Changeset 3175


Ignore:
Timestamp:
07/22/13 12:28:40 (11 years ago)
Author:
keeloo
Message:

Fixed some more errors

Location:
vlo/trunk/vlo_importer
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • vlo/trunk/vlo_importer/src/main/java/eu/clarin/cmdi/vlo/config/VloConfig.java

    r3136 r3175  
    165165   
    166166    @Element
    167     private static int maxDocsInSolrQueue = 0;
     167    private static int minDocsInSolrQueue = 0;
    168168   
    169169    @Element
     
    292292   
    293293    /**
    294      * Get the value of the maxDocsSolrQueue parameter<br><br>
     294     * Get the value of the minDocsInSolrQueue parameter<br><br>
    295295     *
    296296     * The value of the parameter indicates the number of documents in the
     
    300300     * @return the value
    301301     */
    302     public static int getDocsSolrQueue (){
    303         return maxDocsInSolrQueue;
    304     }
    305    
    306     /**
    307      * Set the value of the maxDocsSolrQueue parameter<br><br>
     302    public static int getMinDocsInSolrQueue (){
     303        return minDocsInSolrQueue;
     304    }
     305   
     306    /**
     307     * Set the value of the minDocsInSolrQueue parameter<br><br>
    308308     *
    309309     * The value of the parameter indicates the number of documents in the
     
    313313     * @param param the value
    314314     */
    315     public static void setDocsSolrQueue (int param){
    316         maxDocsInSolrQueue = param;
     315    public static void setMinDocsInSolrQueue (int param){
     316        minDocsInSolrQueue = param;
    317317    }
    318318   
  • vlo/trunk/vlo_importer/src/main/java/eu/clarin/cmdi/vlo/importer/MetadataImporter.java

    r3153 r3175  
    1515import java.util.Map;
    1616import java.util.Set;
    17 import java.util.logging.Level;
    1817import org.apache.commons.cli.CommandLine;
    1918import org.apache.commons.cli.CommandLineParser;
     
    207206
    208207    /**
    209      * Initialize SolrServer as specified in configuration file
     208     * Create an interface to the SOLR server.
     209     *
     210     * After the interface has been created the importer can send documents to
     211     * the server. Sending documents involves a queue. The importer adds
     212     * documents to a queue, and dedicated threads will empty it, and
     213     * effectively store store the documents.
    210214     *
    211215     * @throws MalformedURLException
     
    214218        String solrUrl = VloConfig.getSolrUrl();
    215219        LOG.info("Initializing Solr Server on " + solrUrl);
    216         solrServer = new StreamingUpdateSolrServer(solrUrl, VloConfig.getMaxDocsInList(), 2) {
     220       
     221        /* Specify the number of documents in the queue that will trigger the
     222         * threads, two of them, emptying it.
     223         */
     224        solrServer = new StreamingUpdateSolrServer(solrUrl,
     225                VloConfig.getMinDocsInSolrQueue(), 2) {
     226                    /*
     227                     * Let the super class method handle exceptions. Make the
     228                     * exception available to the importer in the form of the
     229                     * serverError variable.
     230                     */
    217231            @Override
    218             public void handleError(Throwable ex) {
    219                 super.handleError(ex);
    220                 serverError = ex;
     232            public void handleError(Throwable exception) {
     233                super.handleError(exception);
     234                serverError = exception;
    221235            }
    222236        };
     
    361375   
    362376    /**
    363      * Send the list of documents prepared to the solr server
     377     * Send the current list of documents to the SOLR server
    364378     *
    365379     * @throws SolrServerException
     
    371385       
    372386        LOG.info("Sending " + docs.size() +
    373                 " docs to solr server queue. Total number of docs updated till now: "
     387                " docs to solr server queue. Number of docs updated till now: "
    374388                + nrOFDocumentsUpdated);
    375389
    376390        nrOFDocumentsUpdated += docs.size();
    377391        // add the documents in the list to the solr queue
    378         while (! done){
     392        while (! done && wait <= VloConfig.getSolrTimeOut()){
    379393            solrServer.add(docs);
    380394            done = (serverError == null) && (wait <= VloConfig.getSolrTimeOut());
    381395            if (! done){
    382396                try {
    383                     Thread.sleep (1000* wait);
    384                 } catch (InterruptedException ex) {
    385                     java.util.logging.Logger.getLogger(
    386                             MetadataImporter.class.getName()).log(Level.SEVERE,
    387                             null, ex);
     397                    if (wait == 1) {
     398                        LOG.info("Waiting 1 second for the solr server to respond");
     399                    } else {
     400                        LOG.info("Waiting ", wait,
     401                                "seconds for the solr server to respond");
     402                    }
     403                    Thread.sleep(1000 * wait);
     404                } catch (InterruptedException e) {
     405                    LOG.info(e.toString());
    388406                }
    389407                wait = wait * 2;
    390408            }
    391409        }
    392        
    393         // turn wait into vlo parameter
    394410       
    395411        if (done) {
     
    397413            docs = new ArrayList<SolrInputDocument>();
    398414        } else {
     415            // the documents haven't reached the queue
    399416            if (wait > VloConfig.getSolrTimeOut()) {
    400                 // timeout
    401                 LOG.error("Timeout sending list of documents to solr queue");
     417                LOG.error("Timeout sending list of documents to solr server queue");
    402418            }
    403419            throw new SolrServerException(serverError);
  • vlo/trunk/vlo_importer/src/main/resources/VloConfig.xml

    r3136 r3175  
    55    <maxDocsInList>128</maxDocsInList>
    66   
    7     <maxDocsInSolrQueue>128</maxDocsInSolrQueue>
     7    <minDocsInSolrQueue>128</minDocsInSolrQueue>
    88   
    99    <solrTimeOut>300</solrTimeOut>
Note: See TracChangeset for help on using the changeset viewer.