Class DefaultSemaphoreProvider
- java.lang.Object
-
- com.broadleafcommerce.search.index.core.DefaultSemaphoreProvider
-
- All Implemented Interfaces:
SemaphoreProvider
public class DefaultSemaphoreProvider extends Object implements SemaphoreProvider
Default semaphore provider to allow shared access to a semaphore between theSearchIndexMasterProcessLauncherand theWorkerCompletedEventListener.- Author:
- Kelly Tisdell (ktisdell)
-
-
Constructor Summary
Constructors Constructor Description DefaultSemaphoreProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Semaphorecreate(com.broadleafcommerce.search.api.type.IndexableType type)Creates a semaphore with zero permits.Semaphorecreate(com.broadleafcommerce.search.api.type.IndexableType type, int permits)Creates a semaphore with the given permits.voiddestroy(com.broadleafcommerce.search.api.type.IndexableType type)Removes the semaphore from the local registry.Optional<Semaphore>getCurrentSemaphore(com.broadleafcommerce.search.api.type.IndexableType type)Looks for an existing semaphore and returns it if available.
-
-
-
Method Detail
-
create
public Semaphore create(com.broadleafcommerce.search.api.type.IndexableType type)
Description copied from interface:SemaphoreProviderCreates a semaphore with zero permits.- Specified by:
createin interfaceSemaphoreProvider- Parameters:
type- the indexable type for which to create a new Semaphore- Returns:
- the newly created Semaphore
-
create
public Semaphore create(com.broadleafcommerce.search.api.type.IndexableType type, int permits)
Description copied from interface:SemaphoreProviderCreates a semaphore with the given permits.- Specified by:
createin 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:SemaphoreProviderLooks for an existing semaphore and returns it if available.- Specified by:
getCurrentSemaphorein 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:SemaphoreProviderRemoves the semaphore from the local registry.- Specified by:
destroyin interfaceSemaphoreProvider- Parameters:
type- the indexable type for which to destroy the semaphore
-
-