Changeset 622 for trunk


Ignore:
Timestamp:
Jul 10, 2010, 10:48:50 PM (14 years ago)
Author:
gav
Message:

Apply bug fix for ticket #76.
Rename all instances of Lucene to Searchable.
Improved global directory config.
Add log levels for searchable plugin and compass.

Location:
trunk/grails-app
Files:
11 edited
1 moved

Legend:

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

    r571 r622  
    1616                createDataService.createBaseData()
    1717                createDataService.createDemoData()
    18                 createDataService.startLucene()
     18                createDataService.startSearchableIndex()
    1919            }
    2020            test {
     
    2222                createDataService.ensureSystemAndAdminAccess()
    2323                createDataService.createBaseData()
    24                 createDataService.startLucene(false)
     24                createDataService.startSearchableIndex(false)
    2525            }
    2626            production {
     
    2828                createDataService.ensureSystemAndAdminAccess()
    2929                createDataService.createBaseData()
    30                 createDataService.startLucene()
     30                createDataService.startSearchableIndex()
    3131            }
    3232        }
  • trunk/grails-app/conf/Config.groovy

    r608 r622  
    4949grails.spring.bean.packages = []
    5050
     51/**
     52* Internal searchable index config.
     53*/
     54// Is set true by createDataService.startSearchableIndex() once bootstrap completes.
     55appSearchable.cascadeOnUpdate = false
     56
     57/**
     58* Directory configuration.
     59* Pickup the Tomcat/Catalina directory else use the target or current dir.
     60*/
     61def fs = File.separator // Local variable.
     62globalDirs.targetDir = new File("target${fs}").isDirectory() ? "target${fs}" : ''
     63globalDirs.catalinaBase = System.properties.getProperty('catalina.base')
     64globalDirs.logDirectory = globalDirs.catalinaBase ? "${globalDirs.catalinaBase}${fs}logs${fs}" : globalDirs.targetDir
     65globalDirs.workDirectory = globalDirs.catalinaBase ? "${globalDirs.catalinaBase}${fs}work${fs}" : globalDirs.targetDir
     66globalDirs.searchableIndexDirectory = "${globalDirs.workDirectory}SearchableIndex${fs}${appName}${fs}"
    5167
    5268/**
     
    5874 * Basic log levels are ALL < TRACE < DEBUG < INFO < WARN < ERROR < FATAL < OFF
    5975 */
    60 // Pickup the Tomcat/Catalina work directory else use the current or temp dir.
    61 def catalinaBase = System.properties.getProperty('catalina.base')
    62 def fs = File.separator
    63 def logDirectory = catalinaBase ? "${catalinaBase}${fs}logs${fs}" : ''
    6476
    6577log4j = {
     
    7385        // Custom log file.
    7486        rollingFile name:"appLog",
    75                         file:"${logDirectory}${appName}.log".toString(),
     87                        file:"${globalDirs.logDirectory}${appName}.log".toString(),
    7688                        maxFileSize:'300kB',
    7789                        maxBackupIndex:1,
     
    99111    error 'grails.app.service.NavigationService'
    100112    error 'grails.app.service.com.zeddware.grails.plugins.filterpane.FilterService'
     113    info 'org.codehaus.groovy.grails.plugins.searchable'
     114    //info 'org.compass'
    101115    error 'grails.app.task' // Quartz jobs.
    102     info 'grails.app.task.InventoryReindexJob'
     116    info 'grails.app.task.InventoryIndexJob'
    103117
    104118    // Move anything that should behave differently into this section.
  • trunk/grails-app/conf/Searchable.groovy

    r598 r622  
     1import org.codehaus.groovy.grails.commons.ConfigurationHolder
     2
    13/**
    24 * This {@link groovy.util.ConfigObject} script provides Grails Searchable Plugin configuration.
     
    2628
    2729    /**
    28      * The location of the Compass index
    29      *
    30      * Examples: "/home/app/compassindex", "ram://app-index" or null to use the default
    31      *
    32      * The default is "${user.home}/.grails/projects/${app.name}/searchable-index/${grails.env}"
    33      */
    34     // Pickup the Tomcat/Catalina work directory else use the current or temp dir.
    35     def catalinaBase = System.properties.getProperty('catalina.base')
    36     def fs = File.separator
    37     def indexDirectory = catalinaBase ? "${catalinaBase}${fs}work${fs}Lucene${fs}" : "Lucene${fs}"
    38 
    39     compassConnection = new File("${indexDirectory}${appName}").absolutePath
     30    * The location of the Compass index
     31    *
     32    * Examples: "/home/app/compassindex", "ram://app-index" or null to use the default
     33    *
     34    * The default is "${user.home}/.grails/projects/${app.name}/searchable-index/${grails.env}"
     35    */
     36    compassConnection = new File(ConfigurationHolder.config.globalDirs.searchableIndexDirectory).absolutePath
    4037
    4138    /**
  • trunk/grails-app/controllers/AppCoreController.groovy

    r562 r622  
    253253
    254254    /**
    255     * Rebuild the lucene text search index.
     255    * Rebuild the text search index.
    256256    */
    257257    @Secured(['ROLE_AppAdmin', 'ROLE_Manager'])
    258258    def rebuildTextSearchIndex = {
    259         log.info "Rebuilding lucene text search index."
    260         searchableService.reindex()
    261         log.info "Rebuilding lucene text search index, complete."
    262 
    263         flash.message = g.message(code:"default.update.success", args:["Index ", ''])
     259        InventoryIndexJob.triggerNow(['calledBy':'AppCoreController rebuildTextSearchIndex{}'])
     260
     261        flash.message = g.message(code:"appCore.rebuild.text.search.index")
    264262        redirect(action: manager)
    265263    }
  • trunk/grails-app/domain/Asset.groovy

    r562 r622  
     1import org.codehaus.groovy.grails.commons.ConfigurationHolder
     2
    13class Asset {
    24
     
    3537    }
    3638
     39    def afterUpdate = {
     40        // Update the Inventory searchable index, since cascading in searchable-0.5.5 is broken.
     41        if(ConfigurationHolder.config.appSearchable.cascadeOnUpdate) {
     42            try {
     43                InventoryIndexJob.triggerNow(['calledBy':'Asset afterUpdate{}'])
     44            }
     45            catch(e) {log.error e}
     46        } // if
     47    } // afterUpdate
     48
    3749    //  This additional setter is used to convert the checkBoxList string or string array
    3850    //  of ids selected to the corresponding domain objects.
  • trunk/grails-app/domain/InventoryGroup.groovy

    r566 r622  
     1import org.codehaus.groovy.grails.commons.ConfigurationHolder
     2
    13class InventoryGroup {
    24    String name
     
    1820    }
    1921
     22    def afterUpdate = {
     23        // Update the Inventory searchable index, since cascading in searchable-0.5.5 is broken.
     24        if(ConfigurationHolder.config.appSearchable.cascadeOnUpdate) {
     25            try {
     26                InventoryIndexJob.triggerNow(['calledBy':'InventoryGroup afterUpdate{}'])
     27            }
     28            catch(e) {log.error e}
     29        } // if
     30    } // afterUpdate
     31
    2032}
  • trunk/grails-app/domain/InventoryLocation.groovy

    r562 r622  
     1import org.codehaus.groovy.grails.commons.ConfigurationHolder
     2
    13class InventoryLocation {
    24
     
    2224    }
    2325
     26    def afterUpdate = {
     27        // Update the Inventory searchable index, since cascading in searchable-0.5.5 is broken.
     28        if(ConfigurationHolder.config.appSearchable.cascadeOnUpdate) {
     29            try {
     30                InventoryIndexJob.triggerNow(['calledBy':'InventoryLocation afterUpdate{}'])
     31            }
     32            catch(e) {log.error e}
     33        } // if
     34    } // afterUpdate
     35
    2436}
  • trunk/grails-app/i18n/messages.properties

    r621 r622  
    423423report.error.no.inventory.items.found=Error: no inventory items found, please run report again.
    424424report.error.too.many.inventory.items=Error: over {0} inventory items, please run report again.
     425
     426#
     427# AppCore messages.
     428#
     429appCore.rebuild.text.search.index=The text search index is being rebuilt in the background, see log file for details.
  • trunk/grails-app/jobs/InventoryIndexJob.groovy

    r620 r622  
    1 import org.codehaus.groovy.grails.commons.*
     1import org.codehaus.groovy.grails.commons.ConfigurationHolder
    22
    33/**
    4 * Provides a quartz job that reindex's the Lucene index for the Inventory domain class.
    5 * With concurrent=false the repeat interval starts after the previous job completes.
     4* Provides a quartz job that rebuilds the searchable index for the inventory search.
     5* With concurrent=false the next job is blocked until the previous job completes.
    66* We need a hibernate session otherwise we get a LazyInitializationException, default is true but we specify it to be sure.
     7* Rebuilding the index is required since searchable components are not updated when they change, that is
     8* until the parent is updated and reindexed. Cascade update is broken in searchable-0.5.5
    79*/
    8 class InventoryReindexJob {
     10class InventoryIndexJob {
    911
    1012    def concurrent = false
     
    1618        // See: http://www.quartz-scheduler.org/docs/tutorials/crontrigger.html
    1719        // Trigger every hour on the hour:
    18         cron name: 'RebuildInventoryIndex', cronExpression: "0 0 * * * ?"
     20        //cron name: 'RebuildInventoryIndex', cronExpression: "0 0 * * * ?"
    1921    }
    2022
    21     def execute() {
     23    def execute(context) {
    2224
    2325        // Some information can be accessed if we run with "def execute(context) ".
     
    2729        // log.debug context.getFireTime()
    2830
    29         // Reindex the Inventory domain class.
    30         log.info "Rebuilding Lucene index, Inventory.reindex()."
    31         InventoryItem.reindex()
    32         log.info "Rebuilding Lucene index, complete."
     31        // Called by.
     32        def calledBy =  context.mergedJobDataMap.get('calledBy')
     33        log.info "Called By: " + calledBy
     34
     35        // Rebuild the Inventory searchable index.
     36        log.info "Calling, Inventory.index()."
     37        InventoryItem.index()
    3338    }
    3439}
  • trunk/grails-app/services/CreateBulkDataService.groovy

    r580 r622  
    1212    def dateUtilService
    1313    def appConfigService
     14    def createDataService
    1415    def searchableService
    1516    def assignedGroupService
     
    4344            return fail(code: 'default.not.development.environment.failure')
    4445
    45         log.info "Stop mirroring lucene index."
    46         searchableService.stopMirroring()
     46        createDataService.stopSearchableIndex()
    4747
    4848        log.info "Creating BULK data..."
     
    8383        log.info "Creating BULK data...complete."
    8484
    85         log.info "Start mirroring Lucene index."
    86         searchableService.startMirroring()
    87         log.info "Rebuilding Lucene index, bulkIndex."
    88         searchableService.reindex()
    89         log.info "Rebuilding Lucene index, complete."
     85        createDataService.startSearchableIndex()
    9086
    9187        return result
     
    107103            return fail(code: 'default.not.development.environment.failure')
    108104
    109         log.info "Stop mirroring Lucene index."
    110         searchableService.stopMirroring()
     105        createDataService.stopSearchableIndex()
    111106
    112107        log.info "Creating BULK data..."
     
    121116        log.info "Creating BULK data...complete."
    122117
    123         log.info "Start mirroring Lucene index."
    124         searchableService.startMirroring()
    125         log.info "Rebuilding Lucene index, bulkIndex."
    126         searchableService.reindex()
    127         log.info "Rebuilding Lucene index, complete."
     118        createDataService.startSearchableIndex()
    128119
    129120        return result
  • trunk/grails-app/services/CreateDataService.groovy

    r617 r622  
     1import org.codehaus.groovy.grails.commons.ConfigurationHolder
     2
    13/**
    24* Provides a data service to create base and demo data.
     
    15251527
    15261528    /**
    1527     * Lucene index and mirroring is disabled at startup.
    1528     * Us this to start Lucene indexing after creating bootstrap data.
     1529    * SearchableIndex and mirroring is disabled at startup.
     1530    * Use this to start indexing after creating bootstrap data.
    15291531    * @param indexInNewThread Whether to run the index in a new thread, defaults to true.
    15301532    */
    1531     def startLucene(Boolean indexInNewThread = true) {
    1532         log.info "Start mirroring Lucene index."
     1533    def startSearchableIndex(Boolean indexInNewThread = true) {
     1534        log.info "Start mirroring searchable index."
     1535        ConfigurationHolder.config.appSearchable.cascadeOnUpdate = true
    15331536        searchableService.startMirroring()
    15341537        if(indexInNewThread) {
    15351538            Thread.start {
    1536                 log.info "Rebuilding Lucene index, bulkIndex (new thread)."
     1539                log.info "Rebuilding searchable index, bulkIndex (new thread)."
    15371540                searchableService.index()
    1538                 log.info "Rebuilding Lucene index, complete."
     1541                log.info "Rebuilding searchable index, complete."
    15391542            }
    15401543        }
    15411544        else {
    1542             log.info "Rebuilding Lucene index, bulkIndex."
     1545            log.info "Rebuilding searchable index, bulkIndex."
    15431546            searchableService.index()
    1544             log.info "Rebuilding Lucene index, complete."
     1547            log.info "Rebuilding searchable index, complete."
    15451548        }
    15461549    }
    15471550
    15481551    /**
    1549     * Lucene index and mirroring during bulk data creation may be slow.
    1550     * Us this to stop lucene indexing and restart with startLucene() after data creation.
     1552    * Searchable index and mirroring during bulk data creation may be slow.
     1553    * Use this to stop indexing and restart with startSearchableIndex() after data creation.
    15511554    */
    1552     def stopLucene() {
    1553         log.info "Stop mirroring lucene index."
     1555    def stopSearchableIndex() {
     1556        log.info "Stop mirroring searchable index."
     1557        ConfigurationHolder.config.appSearchable.cascadeOnUpdate = false
    15541558        searchableService.stopMirroring()
    15551559    }
  • trunk/grails-app/views/appCore/manager.gsp

    r562 r622  
    8080                                <g:link action="rebuildTextSearchIndex">
    8181                                    Rebuild
    82                                 </g:link> - Reindex the entire text search index.
     82                                </g:link> - Rebuild the text search index.
    8383                                <br />
    8484                            </td>
Note: See TracChangeset for help on using the changeset viewer.