Question

I am deploying a Grails application to Cloud Foundry where the Searchable plugin 'compassConnection' is set to use a RAM index. Problem is Cloud Foundry applies some of it's magic auto-configuration to set the 'compassConnection' to use a file-based index instead.

This would be fine if I was using a disk-based index and Cloud Foundry needs to reconfigure to make it work in it's environment but I want the RAM index config left as it is.

Any ideas how I can make this work?

thanks, Olly

Was it helpful?

Solution

I found the cause of the issue after trawling through the Cloud Foundry plugin source code inside AbstractCloudBeanPostprocessor. The method for populating the compass connection doesn't check if it is a RAM index or not but blindly sets it to a location on disk.

    /**
 * Update the location of the Searchable Lucene index.
 * @param beanFactory the Spring bean factory
 * @param appConfig the application config
 */
protected void fixCompass(ConfigurableListableBeanFactory beanFactory, ConfigObject appConfig) {
    def compassBean = beanFactory.getBeanDefinition('compass')
    String indexLocation = getCompassIndexRootLocation(appConfig) + '/searchable-index'
    appConfig.searchable.compassConnection = indexLocation
    compassBean.propertyValues.addPropertyValue 'compassConnection', indexLocation
    log.debug "Updated Compass connection details: $indexLocation"
}

I think this should really check for presence of RAM index and only set it to disk location. One possible workaround would be to create my own BeanDefinitionRegistryPostProcessor and undo what the cloud foundry plugin does.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top