Changeset 571 for trunk/grails-app


Ignore:
Timestamp:
Jun 6, 2010, 12:11:11 AM (15 years ago)
Author:
gav
Message:

Start lucene mirroring and index after creating bootstrap data.

Location:
trunk/grails-app
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/conf/BootStrap.groovy

    r508 r571  
    1616                createDataService.createBaseData()
    1717                createDataService.createDemoData()
     18                createDataService.startLucene()
    1819            }
    1920            test {
     
    2122                createDataService.ensureSystemAndAdminAccess()
    2223                createDataService.createBaseData()
     24                createDataService.startLucene(false)
    2325            }
    2426            production {
     
    2628                createDataService.ensureSystemAndAdminAccess()
    2729                createDataService.createBaseData()
     30                createDataService.startLucene()
    2831            }
    2932        }
  • trunk/grails-app/conf/Searchable.groovy

    r562 r571  
    124124     * If false, you must manage the index manually using index/unindex/reindex
    125125     */
    126     mirrorChanges = true
     126    mirrorChanges = false
    127127
    128128    /**
     
    137137     * which means do a non-forking, otherwise "fork" is recommended
    138138     */
    139     bulkIndexOnStartup = true
     139    bulkIndexOnStartup = false
    140140
    141141    /**
  • trunk/grails-app/services/CreateDataService.groovy

    r549 r571  
    1313    def dateUtilService
    1414    def appConfigService
     15    def searchableService
    1516    def inventoryItemService
    1617    def assignedGroupService
     
    15021503    }
    15031504
    1504 
    1505 /****************************************
    1506 Call this function instead of .save()
    1507 *****************************************/
     1505    /**
     1506    * Lucene index and mirroring is disabled at startup.
     1507    * Us this to start lucene indexing after creating bootstrap data.
     1508    * @param indexInNewThread Whether to run the index in a new thread, defaults to true.
     1509    */
     1510    def startLucene(Boolean indexInNewThread = true) {
     1511        log.info "Start mirroring lucene index."
     1512        searchableService.startMirroring()
     1513        if(indexInNewThread) {
     1514            Thread.start {
     1515                log.info "Rebuilding lucene text search index, bulkIndex in new thread."
     1516                searchableService.index()
     1517                log.info "Rebuilding lucene text search index, complete."
     1518            }
     1519        }
     1520        else {
     1521            log.info "Rebuilding lucene text search index, bulkIndex."
     1522            searchableService.index()
     1523            log.info "Rebuilding lucene text search index, complete."
     1524        }
     1525    }
     1526
     1527    /**
     1528    * Lucene index and mirroring during bulk data creation may be slow.
     1529    * Us this to stop lucene indexing and restart with startLucene() after data creation.
     1530    */
     1531    def stopLucene() {
     1532        log.info "Stop mirroring lucene index."
     1533        searchableService.stopMirroring()
     1534    }
     1535
     1536    /**
     1537    * Call this function instead of .save()
     1538    */
    15081539    private boolean saveAndTest(object) {
    15091540        if(!object.save()) {
     
    15151546        return true
    15161547    }
     1548
    15171549}
Note: See TracChangeset for help on using the changeset viewer.