Interface ProcessStateService
- All Superinterfaces:
Distributable
,EventPublisher
- All Known Implementing Classes:
AbstractProcessStateService
,DefaultProcessStateService
Component to track the state of a given reindex process. More than one reindex can happen at the
same time, assuming that the indexes are unique. In other words, you can reindex products and
customers simultaneously as long as they are in separate indexes.
- Author:
- Kelly Tisdell (ktisdell)
-
Method Summary
Modifier and TypeMethodDescriptionvoid
endProcessState
(com.broadleafcommerce.search.api.type.IndexableType indexableType) End's a process for a given IndexableType.void
failFast
(com.broadleafcommerce.search.api.type.IndexableType indexableType) Notifies that the process has failed and does not require a Throwable to be provided.void
Provides an opportunity to fail without an exception, but rather with a message.void
Notifies that the process has failed and keeps track of the Throwables passed in.int
getClusterMemberCount
(com.broadleafcommerce.search.api.type.IndexableType indexableType) Returns the number of cluster members that may be working together to process data.getCorrelationId
(com.broadleafcommerce.search.api.type.IndexableType type) This returns the unique correlation.getCurrentProcessStateHolder
(com.broadleafcommerce.search.api.type.IndexableType indexableType) Method to retrieve the current ProcessStateHolder for the currently executing process of reindexing a particular IndexableType.boolean
isFailed
(com.broadleafcommerce.search.api.type.IndexableType indexableType) Indicates if the process has been notified as failing by one or more threads.boolean
isMaster
(com.broadleafcommerce.search.api.type.IndexableType indexableType) Indicates if this JVM kicked off the process for this IndexableType.boolean
isProcessStateEnabled
(com.broadleafcommerce.search.api.type.IndexableType indexableType) Indicates if any thread has started a process state associated with this IndexableType, and not stopped it.startProcessState
(com.broadleafcommerce.search.api.type.IndexableType indexableType, boolean master) Initiates an instance of ReindexStateHolder that will be used across multiple threads, typically for full reindexing.Methods inherited from interface com.broadleafcommerce.search.index.core.Distributable
isDistributed
Methods inherited from interface com.broadleafcommerce.search.index.core.EventPublisher
publishEvent
-
Method Details
-
startProcessState
ProcessStateHolder startProcessState(com.broadleafcommerce.search.api.type.IndexableType indexableType, boolean master) Initiates an instance of ReindexStateHolder that will be used across multiple threads, typically for full reindexing. The IndexableType allows for multiple reindexing to happen at the same time (e.g. catalog and customer).One approach is to use an enumeration value to start the process state for the reindexing of a particular entity. For example, you might use
org.broadleafcommerce.search.api.type.IndexableType.PRODUCT
to create a global ReindexStateHolder for reindexing a particular type of entity. For individual processes that may be reindexing individual documents, you might choose to use a unique ID, such as a UUID.You must use the same IndexableType to call endProcessState.
- Parameters:
indexableType
- the indexable type for which to start the process statemaster
- whether this process state is the master- Returns:
- the started process state holder
-
endProcessState
void endProcessState(com.broadleafcommerce.search.api.type.IndexableType indexableType) End's a process for a given IndexableType. This MUST be called, typically in a finally block of a control thread after a full re-index has been completed.- Parameters:
indexableType
- the indexable type for which to end the process state
-
isProcessStateEnabled
boolean isProcessStateEnabled(com.broadleafcommerce.search.api.type.IndexableType indexableType) Indicates if any thread has started a process state associated with this IndexableType, and not stopped it.- Parameters:
indexableType
- the indexable type for which to check the process state
-
failFast
void failFast(com.broadleafcommerce.search.api.type.IndexableType indexableType) Notifies that the process has failed and does not require a Throwable to be provided. This allows other threads to monitor this state and fail the entire process fast if another thread reported a failure.- Parameters:
indexableType
- the indexable type for which to report a failure
-
failFast
Provides an opportunity to fail without an exception, but rather with a message.- Parameters:
indexableType
-message
-
-
failFast
void failFast(com.broadleafcommerce.search.api.type.IndexableType indexableType, @Nullable Throwable th) Notifies that the process has failed and keeps track of the Throwables passed in. This allows other threads to monitor this state and fail the entire process fast if other thread reported a failure.- Parameters:
indexableType
- the indexable type for which to report a failureth
- the error which failed the process
-
isFailed
boolean isFailed(com.broadleafcommerce.search.api.type.IndexableType indexableType) Indicates if the process has been notified as failing by one or more threads.- Parameters:
indexableType
- the indexable type to check- Returns:
- whether the process is failed for the indexable type
-
isMaster
boolean isMaster(com.broadleafcommerce.search.api.type.IndexableType indexableType) Indicates if this JVM kicked off the process for this IndexableType.- Parameters:
indexableType
- the indexable type to check- Returns:
- whether the process is the master
-
getClusterMemberCount
int getClusterMemberCount(com.broadleafcommerce.search.api.type.IndexableType indexableType) Returns the number of cluster members that may be working together to process data. IfDistributable.isDistributed()
is false, then this should ALWAYS return 1.- Parameters:
indexableType
- the indexable type for which to get the cluster member count- Returns:
- the number of cluster members that may be working together to process data
-
getCurrentProcessStateHolder
Optional<ProcessStateHolder> getCurrentProcessStateHolder(com.broadleafcommerce.search.api.type.IndexableType indexableType) Method to retrieve the current ProcessStateHolder for the currently executing process of reindexing a particular IndexableType.- Parameters:
indexableType
- the indexable type for which to get the process state- Returns:
- if present, the process state for the indexable type
-
getCorrelationId
This returns the unique correlation. Correlation ID is unique to a node and an indexable type within a single reindex process. New processes should generate new correlationIds. But within a given process on a given node, the correlationId should be the same for a given IndexableType.- Parameters:
type
- the indexable type for which to get the process correlation ID- Returns:
- the process correlation ID for the indexable type, or null if there is none
-