10018---solrserver Extension

来源:互联网 发布:mac cf 编辑:程序博客网 时间:2024/06/05 03:14

This document introduces the hybris solrserverextension.

Before Implementing

A hybris extension may provide functionality that is licensed through different hybris modules. 

Make sure to limit your implementation to the features defined in your contractlicense. 

In case of doubt, please contact your hybris Sales representative.

Overview

The solrserver extension includes a standalone Solr server which may be automatically configured, 

started and stopped together with the Platform. This extension is not required by default, 

but it is very convenient for you to enable it in CI or developer environments.

Multiple Solr instances can be created. A Solr instance is a combination of configuration, data and log files. 

Only one Solr server can be started/stopped per instance.

Configuration

Solr Instance Settings

The extension is able to control more than one instance. Each instance has a name and can be configured via properties in thelocal.properties file. The following properties are available:

Property name
Default value
Description
solrserver.instances.<instance name>.autostartfalseIf set to true, given Solr instance will be started/stopped automatically with the Platformsolrserver.instances.<instance name>.config.dir${HYBRIS_CONFIG_DIR}/solr/instances/<instance name>Directory that contains Solr instance configurationsolrserver.instances.<instance name>.data.dir${HYBRIS_DATA_DIR}/solr/instances/<instance name>Directory that contains Solr instance datasolrserver.instances.<instance name>.javaoptions Additional command line options to be used by the Solr server processsolrserver.instances.<instance name>.log.dir${HYBRIS_LOG_DIR}/solr/instances/<instance name>Directory that contains Solr instance logssolrserver.instances.<instance name>.memory512mThe amount of memory (heap) to be used by the Solr server processsolrserver.instances.<instance name>.port8983TCP port that is used by Solr server (each instance should use a different port)
Default configuration
solrserver.instances.default.autostart=truesolrserver.instances.default.port=8983solrserver.instances.default.memory=512m

Solr Server Configuration Files

In order to work properly the Solr server needs some configuration. Each instance will have its own set of configuration files that will be put under the instance configuration directory. Those files will be created automatically when the instance is created. By default it should have a structure similar to the following:



Note

Starting with version 5.7 the log4j.properties file will not be used on windows system. 

This is due to some limitations in the Solr startup scripts. To avoid issues no more than one Solr server should be started per hybris installation.

Controlling a Solr Instance / Server

Solr instances and servers may be controlled:

  • manually by using provided ant tasks;
  • automatically: Solr servers for instances with autostart=true are started when the Spring global context is 
            being initialized and are stopped when the context is being closed.

Algorithm for the Automatic Start of the Solr Server

For each Solr instance:

  1. Check if the corresponding Solr is running. If no, go to step 6.
  2. Check if the running Solr server is the proper one. If not, throw an error.
  3. If forceRestart property is set to false go to step 6.
  4. Stop the Solr server.
  5. Check if the Solr server is properly stopped. If not, throw an error.
  6. Start the Solr server.
  7. Check if the Solr server is properly started. If not, throw an error.


Some parts for the algorithm can be customized via properties in the local.properties file. The following properties are available:


Property name
Default value
Description
solrserver.failOnErrortrueIf an error occurs during the start of any Solr server, it will be treated as serious error and whole platform will not run.solrserver.forceRestarttrueIf a proper Solr server is already running when starting the platform, it will be restarted.solrserver.maxStatusRetries                            10The maximum number of status checks (e.g. checking if the Solr server is running or stopped). If the maximum is exceeded, an error will be thrown.solrserver.statusInterval5000The interval between status checks.

Available Ant Tasks

The solrserver extension provides some additional ant tasks that can be used to control the Solr instances and servers. By using a parameter it is possible to override some of the instance properties. The default instance name is default. The following ant tasks are available:

Task Name
Description
Parameters
createSolrInstance                                     Creates a Solr instance.allowed parameters: -Dinstance.name -Dinstance.conf.dir -Dinstance.data.dir -Dinstance.log.dirdeleteSolrInstanceDeletes a Solr instance. This means deleting all the configuration, data and log files.allowed parameters: -Dinstance.name -Dinstance.conf.dir -Dinstance.data.dir -Dinstance.log.dirstartSolrServerStarts a Solr server.allowed parameters: -Dinstance.name -Dinstance.port -Dinstance.conf.dir -Dinstance.data.dir -Dinstance.log.dir -Dinstance.memory -Dinstance.javaoptionsstopSolrServerStops a Solr server.allowed parameters: -Dinstance.name -Dinstance.port -Dinstance.data.dir

0 0