Class SolrContentStore

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public final class SolrContentStore
    extends Object
    implements Closeable
    A content store specific to SOLR's requirements: The URL is generated from a set of properties such as:
    • ACL ID
    • DB ID
    • Other metadata
    The URL, if not known, can be reliably regenerated using the SolrContentUrlBuilder.
    Since version 1.5 this class acts as a logical singleton: there will be only one instance per node. That reflects exactly what we physically have in the filesystem (i.e. there's only one content store per node). That unique instance is created at startup in AlfrescoCoreAdminHandler and then passed to each registered core (see SolrCoreLoadListener) The State pattern implemented by means of the AccessMode interface allows for a given SolrContentStore instance to act:
    • in READ/WRITE mode: when at least one core of the hosting node is a master or it is a standalone shard/instance.
    • in READ ONLY mode: when all cores of the hosting node are slaves.
    The Finite State Machine (FST) provides three possible states: Initial, Read Only, Read/Write. The allowed transitions are:
    • Initial -> ReadOnly: a slave core has been registered, the content store hasn't been yet initialised.
    • ReadOnly -> Read/Write: this scenario is unusual because we should have on the same instance a mixed set of cores (some master/standalone, some slaves). It happens when a first slave core registers and causes the transition described in the first point (initial -> read only). Then a master or standalone core registers so we need to move from a read only to a complete readable/writable managed content store.
    • Initial -> Read/Write: a master or standalone core has been registered, and the content store hasn't been yet initialised.
    Note the following transitions are not allowed:
    • Coming back to Initial state: once it has been initialised the Content Store cannot return back to the "Initial" state.
    • Read/Write -> ReadOnly: if at least one master or standalone core registers, the content store is permanently moved in Read/Write mode. So even a further slave node registers (not very usually as described above) the content store remains in RW mode.
    Since:
    1.5
    Author:
    Derek Hulley, Michael Suzuki, Andrea Gazzarini
    See Also:
    SolrCoreLoadListener, State Pattern
    • Constructor Detail

      • SolrContentStore

        public SolrContentStore​(String solrHome)
        Builds a new SolrContentStore instance with the given SOLR HOME.
        Parameters:
        solrHome - the Solr HOME.
    • Method Detail

      • getChanges

        public Map<String,​List<Map<String,​Object>>> getChanges​(long version)
        Returns the content store changes since the given (requestor) version.
        Parameters:
        version - the requestor version.
        Returns:
        the content store changes since the given (requestor) version.
      • retrieveDocFromSolrContentStore

        public org.apache.solr.common.SolrInputDocument retrieveDocFromSolrContentStore​(String tenant,
                                                                                        long dbId)
        Retrieve document from SolrContentStore.
        Parameters:
        tenant - identifier
        dbId - identifier
        Returns:
        SolrInputDocument searched document
      • getLastCommittedVersion

        public long getLastCommittedVersion()
      • setLastCommittedVersion

        public void setLastCommittedVersion​(long version)
      • getRootLocation

        public String getRootLocation()
        Returns the absolute path of the content store root folder.
        Returns:
        the absolute path of the content store root folder.
      • exists

        public boolean exists​(String contentUrl)
      • storeDocOnSolrContentStore

        public void storeDocOnSolrContentStore​(String tenant,
                                               long dbId,
                                               org.apache.solr.common.SolrInputDocument doc)
      • storeDocOnSolrContentStore

        public void storeDocOnSolrContentStore​(org.alfresco.solr.client.NodeMetaData nodeMetaData,
                                               org.apache.solr.common.SolrInputDocument doc)
        Store SolrInputDocument in to Alfresco solr content store.
        Parameters:
        nodeMetaData - the incoming node metadata.
        doc - the document itself.
      • removeDocFromContentStore

        public void removeDocFromContentStore​(org.alfresco.solr.client.NodeMetaData nodeMetaData)
        Removes SolrInputDocument from Alfresco solr content store.
        Parameters:
        nodeMetaData - the incoming node metadata.
      • switchOnReadWriteMode

        public void switchOnReadWriteMode()
      • switchOnReadOnlyMode

        public void switchOnReadOnlyMode()
      • toggleReadOnlyMode

        public void toggleReadOnlyMode​(boolean enableReadOnlyMode)
        Enables/disables the content store access mode. The term "toggles" is just for indicating that this method will be called several times (one for each registered core). The underlying FSM makes sure this call will be idempotent so in case of read/write content store the data structure used for maintaining the content store versioning will be initialised only once, even if this method is called repeatedly.
        Parameters:
        enableReadOnlyMode - a flag indicating if the requesting core requires a readOnly (true) or readWrite (false) content store.