Class GenericSearchIndexWorkerProcessLauncher<T>

    • Constructor Detail

      • GenericSearchIndexWorkerProcessLauncher

        protected GenericSearchIndexWorkerProcessLauncher​(com.broadleafcommerce.search.api.type.IndexableType indexableType,
                                                          ProcessStateService processStateService,
                                                          QueueProvider queueProvider,
                                                          int threads,
                                                          long waitTime,
                                                          int maxTries)
    • Method Detail

      • executeInternally

        protected void executeInternally()
      • run

        public final void run()
        Specified by:
        run in interface Runnable
      • createExecutor

        protected Executor createExecutor​(int threads,
                                          com.broadleafcommerce.search.api.type.IndexableType type)
        This creates a ThreadPoolTaskExecutor by default. If you override this method, consider overriding the destroyExecutor method as well.
        Parameters:
        threads - the number of threads for the executor pool
        type - the indexable type for the workers
        Returns:
        new ThreadPoolTaskExecutor for reindex workers
      • destroyExecutor

        protected void destroyExecutor​(Executor executor)
        This is always called to close the Executor when it's finished. By default, this expects a ThreadPoolTaskExecutor.
        Parameters:
        executor - the executor to shut down.
      • createNewTask

        protected abstract AbstractWorker<T> createNewTask​(ProcessStateService processStateService,
                                                           Semaphore semaphore,
                                                           com.broadleafcommerce.search.api.type.IndexableType type,
                                                           ReindexQueue<T> queue)
        Launch a worker process.
        Parameters:
        processStateService - the service managing process state
        semaphore - the semaphore tracking worker completion
        type - the indexableType the worker will process for
        queue - the queue the worker will read from
        Returns:
        the new worker
      • instance

        public static SearchIndexWorkerProcessLauncher instance​(com.broadleafcommerce.search.api.type.IndexableType type)
        Convenient way to access the SearchIndexWorkerProcessLauncher associated with a particular IndexableType. Returns null if no SearchIndexWorkerProcessLauncher was registered for the specified type.
        Parameters:
        type - the type to get the worker launcher for
        Returns:
        the worker launcher for the type
      • getIndexableType

        public com.broadleafcommerce.search.api.type.IndexableType getIndexableType()
        Description copied from interface: IndexableTypeAware
        Components that implement this method should return the same, non-null value on each invocation. This should basically return a constant value.
        Specified by:
        getIndexableType in interface IndexableTypeAware
        Returns:
        the associated indexable type
      • getWorkerThreads

        protected int getWorkerThreads()
        The number of worker threads which should be started on a reindex process.
        Returns:
        number of worker threads on a reindex process
      • getWaitTime

        protected long getWaitTime()
        Time in milliseconds to wait for something to arrive in the Queue. Keep this rather small.
        Returns:
        time to wait for something to arrive in the queue
      • getMaxTries

        protected int getMaxTries()
        Defines the number of times that we'll try to retrieve something from a queue with the given wait time before giving up. Either nothing is putting data on the queue, or the cluster size is too big and we're just not receiving data because other threads are consuming the data fast enough that we never receive any.
        Returns:
        number of times to try to retrieve something from the queue
      • isExecuting

        protected boolean isExecuting()
        Whether or not this is currently executing.
        Returns:
        whether or not this is currently executing