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 theSearchIndexMasterProcessLauncher
and theWorkerCompletedEventListener
.- Author:
- Kelly Tisdell (ktisdell)
-
-
Constructor Summary
Constructors Constructor Description DefaultSemaphoreProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Semaphore
create(com.broadleafcommerce.search.api.type.IndexableType type)
Creates a semaphore with zero permits.Semaphore
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.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: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
public Semaphore create(com.broadleafcommerce.search.api.type.IndexableType type, int permits)
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
-
-