Package org.alfresco.solr.content
Class SolrContentStore
- java.lang.Object
-
- org.alfresco.solr.content.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
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 inAlfrescoCoreAdminHandlerand then passed to each registered core (seeSolrCoreLoadListener) The State pattern implemented by means of theAccessModeinterface allows for a givenSolrContentStoreinstance 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.
- 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.
- 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
-
-
Field Summary
Fields Modifier and Type Field Description static StringADDSstatic StringDELETESstatic StringFULL_REPLICATIONstatic StringINFOstatic longNO_CONTENT_STORE_REPLICATION_REQUIREDstatic longNO_VERSION_AVAILABLE
-
Constructor Summary
Constructors Constructor Description SolrContentStore(String solrHome)Builds a newSolrContentStoreinstance with the given SOLR HOME.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()booleanexists(String contentUrl)voidflushChangeSet()Map<String,List<Map<String,Object>>>getChanges(long version)Returns the content store changes since the given (requestor) version.longgetLastCommittedVersion()StringgetRootLocation()Returns the absolute path of the content store root folder.voidremoveDocFromContentStore(org.alfresco.solr.client.NodeMetaData nodeMetaData)RemovesSolrInputDocumentfrom Alfresco solr content store.org.apache.solr.common.SolrInputDocumentretrieveDocFromSolrContentStore(String tenant, long dbId)Retrieve document from SolrContentStore.voidsetLastCommittedVersion(long version)voidstoreDocOnSolrContentStore(String tenant, long dbId, org.apache.solr.common.SolrInputDocument doc)voidstoreDocOnSolrContentStore(org.alfresco.solr.client.NodeMetaData nodeMetaData, org.apache.solr.common.SolrInputDocument doc)StoreSolrInputDocumentin to Alfresco solr content store.voidswitchOnReadOnlyMode()voidswitchOnReadWriteMode()voidtoggleReadOnlyMode(boolean enableReadOnlyMode)Enables/disables the content store access mode.
-
-
-
Field Detail
-
NO_VERSION_AVAILABLE
public static final long NO_VERSION_AVAILABLE
- See Also:
- Constant Field Values
-
NO_CONTENT_STORE_REPLICATION_REQUIRED
public static final long NO_CONTENT_STORE_REPLICATION_REQUIRED
- See Also:
- Constant Field Values
-
INFO
public static final String INFO
- See Also:
- Constant Field Values
-
FULL_REPLICATION
public static final String FULL_REPLICATION
- See Also:
- Constant Field Values
-
DELETES
public static final String DELETES
- See Also:
- Constant Field Values
-
ADDS
public static final String ADDS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SolrContentStore
public SolrContentStore(String solrHome)
Builds a newSolrContentStoreinstance 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- identifierdbId- identifier- Returns:
SolrInputDocumentsearched 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)StoreSolrInputDocumentin 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)
RemovesSolrInputDocumentfrom Alfresco solr content store.- Parameters:
nodeMetaData- the incoming node metadata.
-
flushChangeSet
public void flushChangeSet() throws IOException- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
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.
-
-