Every Elastic Path administrator knows: if your search server goes down, your storefront is down and so is Commerce Manager. You can make your Elastic Path deployment more resilient by setting up search server failover.
In a nutshell, you set up two machines to run the search server web application. One is the main search server (master). The other is a backup (slave). Both machines are running behind a load balancer. The master search server uses rsync to synchronize multiple index files to the slave machine and then commits these new indexes into the slave's indexes. This essentially creates a duplicate of the master on the slave and, if the master server goes down, the slave server will be able to handle all requests.
The failover configuration consists of three components:
If the master becomes unavailable, due to a failure or planned downtime, the load balancer redirects search requests to the slave.
To make it all work, there are some scripts that need to get run by cron jobs on the master and slave. Note these scripts use rsync and Unix hard-links, so they only work on Linux/Unix environments.
You also need to set the searchHost setting in Elastic Path to point to the proxy server.
You can download the scripts and the setup documentation from the downloads page.
Many classes were refactored in Elastic Path 6.1 to improve testability of existing code and to accommodate new features (most notably the ability for a single Storefront WAR file to host multiple Stores). Here are the changes with the highest impact for developers (in no particular order).
ElasticPathImpl covers several distinct areas of responsibility: BeanFactory, Configuration, Filtered Navigation, asset lookup... In 6.1, new interfaces were created to move those areas of functionality out of ElasticPathImpl with the intention of rendering the object obsolete in future versions.
If any customizations were performed on some Elastic Path 6.0 code base that must be transferred to an Elastic Path 6.1 code base, most careful attention should be paid to any changes in the ElasticPath singleton, especially if any new settings were introduced that are designed to be read in from a commerce-config.xml configuration file. Since most settings were moved to the Settings framework, the code to parse the configuration file has mostly been removed.
New customizations should pay special attention to the Settings framework and use it where appropriate. Also, the BeanFactory should be injected into new classes where required instead of the ElasticPath object, as its use as a bean factory is being phased out.
New persistent classes should have a DAO that is separate from any new services, to allow for more flexible persistence implementations if functionality changes.
In testing, the big news is deprecation of ElasticPathTestCase.java and the introduction of JUnit4 and JMock2 testing frameworks.
Prior to 6.1, many test classes extended ElasticPathTestCase.java, which is a JUnit 3.8 extended test class that mocks out much of the application's domain using mock objects created with the JMock 1.x framework. This class is being phased out, and use of it is no longer recommended because it:
Instead, unit test classes should focus on unit-testing rather than integration-testing methods. Use of the JUnit4 and JMock2 framework features should help in that regard. There are many examples of their use in the new code; but for a start you may want to look at GiftCertificateThemeImplTest (for a relatively simple test class) and StoreResourceManagerImplTest (which takes advantage of some advanced features in the new JMock framework).
Store-specific Velocity template resolution has been introduced. Most static and storefront theme content (storefront velocity templates, email velocity templates, javascript files, css files, Power Reviews, etc) was moved outside the separate application WAR files into the pre-existing Assets folder on the file system.
In 6.0 only some assets (store images and digital goods) lived on the file system under the assets folder, while others (email templates, storefront UI files, and PowerReviews files) lived inside the WAR. All of these files were moved to appropriate locations under the file system's assets folder and the paths to such folders were made available through an AssetRepository object rather than through methods on the ElasticPath object. This allows the assets to be modified at runtime.
The Storefront application's Themes feature (see Themes documentation) required the introduction of a StoreResourceManager to handle Velocity's lookups and caching for Storefront velocity templates. It does not use the AssetRepository, but instead uses very similar code combined with hardcoding the velocity template directory within the assets folders (see StoreVelocityConfigHelper.java). A separate Velocity Engine is created for each and every Storefront operating within a WAR.
The Storefront's asset requests that are not for Velocity templates (e.g. css, javascript, images, Power Reviews) go through the AssetResourceController, which uses the AssetRepository indirectly through an AssetRetrievalStrategy. In order for controllers to know which store they are working with, a ThreadLocal reference to Store has been introduced, set by the StoreSelectionFilter. Any storefront controller requiring parameters specific to the store that is accessing the controller can inject the StoreConfig object, or they can retrieve it from the RequestHelper, which also has it injected. The current store is no longer retrieved from ElasticPath.java.
New DAO classes were introduced in some areas to separate service logic from persistence operations. In addition to some new features using separate Service and DAO classes, existing Services which have had DAO functionality factored out include:
DAO classes should generally not be accessed directly from outside of the Service layer. Such separation of business logic and persistence logic allows for far more flexibility and decoupling in the application. Future development should endeavor to follow this pattern (See the GiftCertificateThemeService / GiftCertificateThemeStoreAssignmentDao for an example of how such decoupling can be of benefit).
We are phasing out UID fields in the indexes, in favor of GUID fields, for greater decoupling. Secondary object UID fields have, for the most part, been replaced with GUID fields in object indexes so that searches can be performed based on GUIDs. For instance, the CategoryIndex contains the CategoryUid so that the UID can be retrieved from the index when a search match is found, but the index is built using the GUIDs from associated objects (e.g. you can search the CategoryIndex to return categories that are associated with a particular CatalogCode, but not with a particular CatalogUid). The corresponding SearchCriteria objects have been modified to reflect the index schema changes.
Index fields that have been modified as a result of this change are as follows:
In addition, several fields were added to the OrderReturn index schema.
The status of indexes, and the method of causing them to rebuild, has changed drastically:
In addition, if the server is brought down (either manually or catastrophically) while in the process of building an index, it will now remember its status upon restart and will start a new rebuild rather than assuming that the index is complete.
The Store Editor has been enhanced to better handle store themes. In addition, it has abstracted most of the business logic from where it may previously have been embedded in the UI code.
The search index rebuild process has undergone some substantial changes in Elastic Path 6.1, making it more robust and more usable.
In the past, to trigger a search index rebuild, you needed to manually modify the contents of some properties files on the search server. This is no longer supported. Now, Commerce Manager users with the proper permissions can initiate search index rebuilds.
In the Activity menu, choose Configuration. In the Configuration page on the left, under System Administration, click Search Indexes.
Select an index in the list, and click Rebuild Index. The rebuild should now be scheduled and the status column will show Rebuild is Scheduled.
When the index rebuild begins, the status column for the index being rebuilt will contain Rebuild in Progress. Note that you can rebuild multiple indexes at the same time. When the rebuild is done, the status is changed to Complete.
When the user runs an index rebuild from the Commerce Manager client, this is what happens behind the scenes:
You can monitor the status of rebuild process by checking the Status column in the search index list.
Finally, search index rebuilds are now more resilient to failures. If an index build is interrupted or fails to complete normally, the system will try to build it again on server startup or at the start of the next quartz job. If there is a rebuild in progress for an index and another rebuild for that index is requested by the user, the system will wait until the first rebuild is complete before processing the second request.