Skip to content

Commit

Permalink
did you mean ...?
Browse files Browse the repository at this point in the history
  • Loading branch information
bpgergo committed Jan 30, 2012
1 parent d66c522 commit 1695ca5
Show file tree
Hide file tree
Showing 4 changed files with 277 additions and 193 deletions.
7 changes: 5 additions & 2 deletions src/main/java/hu/mokk/hunglish/job/MockJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ public void doSomeAction() {
logger.info("harness job finished, exit code:" + exitCode);
}
if (HARNESS_SUCCESS_CODE == exitCode) {
indexer.indexAll();
searcher.reInitSearcher();
logger.info("harness was successful, indexing comes...");
if (indexer.indexAll()){
logger.info("indexing changed indexes, sercher will be reinitialized...");
searcher.reInitSearcher();
}
}

} else {
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/hu/mokk/hunglish/lucene/Indexer.java
Original file line number Diff line number Diff line change
Expand Up @@ -370,19 +370,21 @@ public void optimizeIndex() {
* Create a jdbcConnection calls indexBatch until it returns false using the
* connection clear up connection
*/
synchronized public void indexAll() {
synchronized public boolean indexAll() {
boolean indexchanged = false;
Connection jdbcConnection = null;
try {

jdbcConnection = IndexerHelper.getJdbcConnection(dataSource);
logger.info("db connection initialized");

boolean indexchanged = deleteAllFromIndex(jdbcConnection);
indexchanged = deleteAllFromIndex(jdbcConnection);
indexchanged |= addAllToIndex(jdbcConnection);

if (indexchanged){
optimizeIndex();
}
logger.info("index will be optimized");
optimizeIndex();
}
} catch (SQLException sex) {

logger.error("Couldn't initialize database connection for indexing.", sex);
Expand All @@ -391,6 +393,7 @@ synchronized public void indexAll() {
IndexerHelper.closeConnection(jdbcConnection);
logger.info("db connection closed");
}
return indexchanged;
}


Expand Down
Loading

0 comments on commit 1695ca5

Please sign in to comment.