Changeset 3175
- Timestamp:
- 07/22/13 12:28:40 (11 years ago)
- 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 165 165 166 166 @Element 167 private static int m axDocsInSolrQueue = 0;167 private static int minDocsInSolrQueue = 0; 168 168 169 169 @Element … … 292 292 293 293 /** 294 * Get the value of the m axDocsSolrQueue parameter<br><br>294 * Get the value of the minDocsInSolrQueue parameter<br><br> 295 295 * 296 296 * The value of the parameter indicates the number of documents in the … … 300 300 * @return the value 301 301 */ 302 public static int get DocsSolrQueue (){303 return m axDocsInSolrQueue;304 } 305 306 /** 307 * Set the value of the m axDocsSolrQueue parameter<br><br>302 public static int getMinDocsInSolrQueue (){ 303 return minDocsInSolrQueue; 304 } 305 306 /** 307 * Set the value of the minDocsInSolrQueue parameter<br><br> 308 308 * 309 309 * The value of the parameter indicates the number of documents in the … … 313 313 * @param param the value 314 314 */ 315 public static void set DocsSolrQueue (int param){316 m axDocsInSolrQueue = param;315 public static void setMinDocsInSolrQueue (int param){ 316 minDocsInSolrQueue = param; 317 317 } 318 318 -
vlo/trunk/vlo_importer/src/main/java/eu/clarin/cmdi/vlo/importer/MetadataImporter.java
r3153 r3175 15 15 import java.util.Map; 16 16 import java.util.Set; 17 import java.util.logging.Level;18 17 import org.apache.commons.cli.CommandLine; 19 18 import org.apache.commons.cli.CommandLineParser; … … 207 206 208 207 /** 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. 210 214 * 211 215 * @throws MalformedURLException … … 214 218 String solrUrl = VloConfig.getSolrUrl(); 215 219 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 */ 217 231 @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; 221 235 } 222 236 }; … … 361 375 362 376 /** 363 * Send the list of documents prepared to the solrserver377 * Send the current list of documents to the SOLR server 364 378 * 365 379 * @throws SolrServerException … … 371 385 372 386 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: " 374 388 + nrOFDocumentsUpdated); 375 389 376 390 nrOFDocumentsUpdated += docs.size(); 377 391 // add the documents in the list to the solr queue 378 while (! done ){392 while (! done && wait <= VloConfig.getSolrTimeOut()){ 379 393 solrServer.add(docs); 380 394 done = (serverError == null) && (wait <= VloConfig.getSolrTimeOut()); 381 395 if (! done){ 382 396 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()); 388 406 } 389 407 wait = wait * 2; 390 408 } 391 409 } 392 393 // turn wait into vlo parameter394 410 395 411 if (done) { … … 397 413 docs = new ArrayList<SolrInputDocument>(); 398 414 } else { 415 // the documents haven't reached the queue 399 416 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"); 402 418 } 403 419 throw new SolrServerException(serverError); -
vlo/trunk/vlo_importer/src/main/resources/VloConfig.xml
r3136 r3175 5 5 <maxDocsInList>128</maxDocsInList> 6 6 7 <m axDocsInSolrQueue>128</maxDocsInSolrQueue>7 <minDocsInSolrQueue>128</minDocsInSolrQueue> 8 8 9 9 <solrTimeOut>300</solrTimeOut>
Note: See TracChangeset
for help on using the changeset viewer.