- Timestamp:
- Jul 10, 2010, 10:48:50 PM (14 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 11 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/conf/BootStrap.groovy
r571 r622 16 16 createDataService.createBaseData() 17 17 createDataService.createDemoData() 18 createDataService.start Lucene()18 createDataService.startSearchableIndex() 19 19 } 20 20 test { … … 22 22 createDataService.ensureSystemAndAdminAccess() 23 23 createDataService.createBaseData() 24 createDataService.start Lucene(false)24 createDataService.startSearchableIndex(false) 25 25 } 26 26 production { … … 28 28 createDataService.ensureSystemAndAdminAccess() 29 29 createDataService.createBaseData() 30 createDataService.start Lucene()30 createDataService.startSearchableIndex() 31 31 } 32 32 } -
trunk/grails-app/conf/Config.groovy
r608 r622 49 49 grails.spring.bean.packages = [] 50 50 51 /** 52 * Internal searchable index config. 53 */ 54 // Is set true by createDataService.startSearchableIndex() once bootstrap completes. 55 appSearchable.cascadeOnUpdate = false 56 57 /** 58 * Directory configuration. 59 * Pickup the Tomcat/Catalina directory else use the target or current dir. 60 */ 61 def fs = File.separator // Local variable. 62 globalDirs.targetDir = new File("target${fs}").isDirectory() ? "target${fs}" : '' 63 globalDirs.catalinaBase = System.properties.getProperty('catalina.base') 64 globalDirs.logDirectory = globalDirs.catalinaBase ? "${globalDirs.catalinaBase}${fs}logs${fs}" : globalDirs.targetDir 65 globalDirs.workDirectory = globalDirs.catalinaBase ? "${globalDirs.catalinaBase}${fs}work${fs}" : globalDirs.targetDir 66 globalDirs.searchableIndexDirectory = "${globalDirs.workDirectory}SearchableIndex${fs}${appName}${fs}" 51 67 52 68 /** … … 58 74 * Basic log levels are ALL < TRACE < DEBUG < INFO < WARN < ERROR < FATAL < OFF 59 75 */ 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.separator63 def logDirectory = catalinaBase ? "${catalinaBase}${fs}logs${fs}" : ''64 76 65 77 log4j = { … … 73 85 // Custom log file. 74 86 rollingFile name:"appLog", 75 file:"${ logDirectory}${appName}.log".toString(),87 file:"${globalDirs.logDirectory}${appName}.log".toString(), 76 88 maxFileSize:'300kB', 77 89 maxBackupIndex:1, … … 99 111 error 'grails.app.service.NavigationService' 100 112 error 'grails.app.service.com.zeddware.grails.plugins.filterpane.FilterService' 113 info 'org.codehaus.groovy.grails.plugins.searchable' 114 //info 'org.compass' 101 115 error 'grails.app.task' // Quartz jobs. 102 info 'grails.app.task.Inventory ReindexJob'116 info 'grails.app.task.InventoryIndexJob' 103 117 104 118 // Move anything that should behave differently into this section. -
trunk/grails-app/conf/Searchable.groovy
r598 r622 1 import org.codehaus.groovy.grails.commons.ConfigurationHolder 2 1 3 /** 2 4 * This {@link groovy.util.ConfigObject} script provides Grails Searchable Plugin configuration. … … 26 28 27 29 /** 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 40 37 41 38 /** -
trunk/grails-app/controllers/AppCoreController.groovy
r562 r622 253 253 254 254 /** 255 * Rebuild the lucenetext search index.255 * Rebuild the text search index. 256 256 */ 257 257 @Secured(['ROLE_AppAdmin', 'ROLE_Manager']) 258 258 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") 264 262 redirect(action: manager) 265 263 } -
trunk/grails-app/domain/Asset.groovy
r562 r622 1 import org.codehaus.groovy.grails.commons.ConfigurationHolder 2 1 3 class Asset { 2 4 … … 35 37 } 36 38 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 37 49 // This additional setter is used to convert the checkBoxList string or string array 38 50 // of ids selected to the corresponding domain objects. -
trunk/grails-app/domain/InventoryGroup.groovy
r566 r622 1 import org.codehaus.groovy.grails.commons.ConfigurationHolder 2 1 3 class InventoryGroup { 2 4 String name … … 18 20 } 19 21 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 20 32 } -
trunk/grails-app/domain/InventoryLocation.groovy
r562 r622 1 import org.codehaus.groovy.grails.commons.ConfigurationHolder 2 1 3 class InventoryLocation { 2 4 … … 22 24 } 23 25 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 24 36 } -
trunk/grails-app/i18n/messages.properties
r621 r622 423 423 report.error.no.inventory.items.found=Error: no inventory items found, please run report again. 424 424 report.error.too.many.inventory.items=Error: over {0} inventory items, please run report again. 425 426 # 427 # AppCore messages. 428 # 429 appCore.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. *1 import org.codehaus.groovy.grails.commons.ConfigurationHolder 2 2 3 3 /** 4 * Provides a quartz job that re index's the Lucene index for the Inventory domain class.5 * With concurrent=false the repeat interval starts afterthe 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. 6 6 * 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 7 9 */ 8 class Inventory ReindexJob {10 class InventoryIndexJob { 9 11 10 12 def concurrent = false … … 16 18 // See: http://www.quartz-scheduler.org/docs/tutorials/crontrigger.html 17 19 // Trigger every hour on the hour: 18 cron name: 'RebuildInventoryIndex', cronExpression: "0 0 * * * ?"20 //cron name: 'RebuildInventoryIndex', cronExpression: "0 0 * * * ?" 19 21 } 20 22 21 def execute( ) {23 def execute(context) { 22 24 23 25 // Some information can be accessed if we run with "def execute(context) ". … … 27 29 // log.debug context.getFireTime() 28 30 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() 33 38 } 34 39 } -
trunk/grails-app/services/CreateBulkDataService.groovy
r580 r622 12 12 def dateUtilService 13 13 def appConfigService 14 def createDataService 14 15 def searchableService 15 16 def assignedGroupService … … 43 44 return fail(code: 'default.not.development.environment.failure') 44 45 45 log.info "Stop mirroring lucene index." 46 searchableService.stopMirroring() 46 createDataService.stopSearchableIndex() 47 47 48 48 log.info "Creating BULK data..." … … 83 83 log.info "Creating BULK data...complete." 84 84 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() 90 86 91 87 return result … … 107 103 return fail(code: 'default.not.development.environment.failure') 108 104 109 log.info "Stop mirroring Lucene index." 110 searchableService.stopMirroring() 105 createDataService.stopSearchableIndex() 111 106 112 107 log.info "Creating BULK data..." … … 121 116 log.info "Creating BULK data...complete." 122 117 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() 128 119 129 120 return result -
trunk/grails-app/services/CreateDataService.groovy
r617 r622 1 import org.codehaus.groovy.grails.commons.ConfigurationHolder 2 1 3 /** 2 4 * Provides a data service to create base and demo data. … … 1525 1527 1526 1528 /** 1527 * Lucene index and mirroring is disabled at startup.1528 * Us this to start Luceneindexing after creating bootstrap data.1529 * SearchableIndex and mirroring is disabled at startup. 1530 * Use this to start indexing after creating bootstrap data. 1529 1531 * @param indexInNewThread Whether to run the index in a new thread, defaults to true. 1530 1532 */ 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 1533 1536 searchableService.startMirroring() 1534 1537 if(indexInNewThread) { 1535 1538 Thread.start { 1536 log.info "Rebuilding Lucene index, bulkIndex (new thread)."1539 log.info "Rebuilding searchable index, bulkIndex (new thread)." 1537 1540 searchableService.index() 1538 log.info "Rebuilding Lucene index, complete."1541 log.info "Rebuilding searchable index, complete." 1539 1542 } 1540 1543 } 1541 1544 else { 1542 log.info "Rebuilding Lucene index, bulkIndex."1545 log.info "Rebuilding searchable index, bulkIndex." 1543 1546 searchableService.index() 1544 log.info "Rebuilding Lucene index, complete."1547 log.info "Rebuilding searchable index, complete." 1545 1548 } 1546 1549 } 1547 1550 1548 1551 /** 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. 1551 1554 */ 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 1554 1558 searchableService.stopMirroring() 1555 1559 } -
trunk/grails-app/views/appCore/manager.gsp
r562 r622 80 80 <g:link action="rebuildTextSearchIndex"> 81 81 Rebuild 82 </g:link> - Re index the entire text search index.82 </g:link> - Rebuild the text search index. 83 83 <br /> 84 84 </td>
Note: See TracChangeset
for help on using the changeset viewer.