Class DefaultSemaphoreProvider
java.lang.Object
com.broadleafcommerce.search.index.core.DefaultSemaphoreProvider
- All Implemented Interfaces:
SemaphoreProvider
Default semaphore provider to allow shared access to a semaphore between the
SearchIndexMasterProcessLauncher
and the WorkerCompletedEventListener
.
- Author:
- Kelly Tisdell (ktisdell)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreate
(com.broadleafcommerce.search.api.type.IndexableType type) Creates a semaphore with zero permits.create
(com.broadleafcommerce.search.api.type.IndexableType type, int permits) Creates a semaphore with the given permits.void
destroy
(com.broadleafcommerce.search.api.type.IndexableType type) Removes the semaphore from the local registry.getCurrentSemaphore
(com.broadleafcommerce.search.api.type.IndexableType type) Looks for an existing semaphore and returns it if available.
-
Constructor Details
-
DefaultSemaphoreProvider
public DefaultSemaphoreProvider()
-
-
Method Details
-
create
Description copied from interface:SemaphoreProvider
Creates a semaphore with zero permits.- Specified by:
create
in interfaceSemaphoreProvider
- Parameters:
type
- the indexable type for which to create a new Semaphore- Returns:
- the newly created Semaphore
-
create
Description copied from interface:SemaphoreProvider
Creates a semaphore with the given permits.- Specified by:
create
in interfaceSemaphoreProvider
- Parameters:
type
- the indexable type for which to create a new Semaphorepermits
- the number of permits for the new Semaphore- Returns:
- the newly created Semaphore
-
getCurrentSemaphore
public Optional<Semaphore> getCurrentSemaphore(com.broadleafcommerce.search.api.type.IndexableType type) Description copied from interface:SemaphoreProvider
Looks for an existing semaphore and returns it if available.- Specified by:
getCurrentSemaphore
in interfaceSemaphoreProvider
- Parameters:
type
- the indexable type for which to get the semaphore- Returns:
- if present, the semaphore for the given indexable type
-
destroy
public void destroy(com.broadleafcommerce.search.api.type.IndexableType type) Description copied from interface:SemaphoreProvider
Removes the semaphore from the local registry.- Specified by:
destroy
in interfaceSemaphoreProvider
- Parameters:
type
- the indexable type for which to destroy the semaphore
-