Class SplitMergeStage<T>

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
net.shibboleth.metadata.pipeline.AbstractStage<T>
net.shibboleth.metadata.pipeline.SplitMergeStage<T>
Type Parameters:
T - type of items upon which this stage operates
All Implemented Interfaces:
Stage<T>, net.shibboleth.shared.component.Component, net.shibboleth.shared.component.DestructableComponent, net.shibboleth.shared.component.IdentifiableComponent, net.shibboleth.shared.component.IdentifiedComponent, net.shibboleth.shared.component.InitializableComponent

@ThreadSafe public class SplitMergeStage<T> extends AbstractStage<T>
A stage which splits a given collection according to a provided selection strategy and passes selected items to one pipeline and non-selected items to another.

The selected and non-selected item pipelines are executed via the set executor.

The results of the two pipelines are merged to produce the result.

This stage requires the following properties be set prior to initialization:

  • selectionStrategy
  • selectedItemPipeline or nonselectedItemPipeline

If an executor is provided, it will be used to execute the pipelines, potentially concurrently. By default, the pipelines will be executed sequentially on the calling thread.

The caller is responsible for the lifecycle of any provided Executor, including the lifecycle of any threads or thread pools associated with it.

If no collectionFactory is given, then SimpleItemCollectionFactory is used.

If one or the other pipeline is null then no objects will be passed to it (obviously).

  • Field Details

    • LOG

      @Nonnull private static final org.slf4j.Logger LOG
      Class logger.
    • executor

      @Nonnull private Executor executor
      Executor used to execute the pipelines.
    • collectionFactory

      @Nonnull private Supplier<List<Item<T>>> collectionFactory
      Factory used to create the Item collection that is then given to the pipelines.
    • selectionStrategy

      @Nonnull private Predicate<Item<T>> selectionStrategy
      Strategy used to split the given item collection.
    • selectedItemPipeline

      @Nullable private Pipeline<T> selectedItemPipeline
      Pipeline that receives the selected items.
    • nonselectedItemPipeline

      @Nullable private Pipeline<T> nonselectedItemPipeline
      Pipeline that receives the non-selected items.
    • mergeStrategy

      @Nonnull private CollectionMergeStrategy mergeStrategy
      Strategy used to merge all the joined pipeline results in to the final Item collection.
  • Constructor Details

    • SplitMergeStage

      public SplitMergeStage()
  • Method Details

    • getExecutor

      @Nonnull public final Executor getExecutor()
      Gets the executor used to run the selected and non-selected item pipelines.
      Returns:
      executor used to run the selected and non-selected item pipelines
      Since:
      0.10.0
    • getExecutorService

      @Deprecated(since="0.10.0", forRemoval=true) @Nonnull public final Executor getExecutorService()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the executor service used to run the selected and non-selected item pipelines.
      Returns:
      executor service used to run the selected and non-selected item pipelines
    • setExecutor

      public void setExecutor(@Nonnull Executor exec)
      Sets the executor used to run the selected and non-selected item pipelines.
      Parameters:
      exec - executor used to run the selected and non-selected item pipelines
      Since:
      0.10.0
    • setExecutorService

      @Deprecated(since="0.10.0", forRemoval=true) public void setExecutorService(@Nonnull ExecutorService service)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the executor service used to run the selected and non-selected item pipelines.
      Parameters:
      service - executor service used to run the selected and non-selected item pipelines
    • getCollectionFactory

      @Nonnull public final Supplier<List<Item<T>>> getCollectionFactory()
      Gets the factory used to create the Item collection that is then given to the pipelines.
      Returns:
      factory used to create the Item collection that is then given to the pipelines
    • setCollectionFactory

      public void setCollectionFactory(@Nonnull Supplier<List<Item<T>>> factory)
      Sets the factory used to create the Item collection that is then given to the pipelines.
      Parameters:
      factory - factory used to create the Item collection that is then given to the pipelines
    • getSelectionStrategy

      @Nonnull public final Predicate<Item<T>> getSelectionStrategy()
      Gets the strategy used to split the given item collection.
      Returns:
      strategy used to split the given item collection
    • setSelectionStrategy

      public void setSelectionStrategy(@Nonnull Predicate<Item<T>> strategy)
      Sets the strategy used to split the given item collection.
      Parameters:
      strategy - strategy used to split the given item collection, never null
    • getSelectedItemPipeline

      @Nullable public final Pipeline<T> getSelectedItemPipeline()
      Gets the pipeline that receives the selected items.
      Returns:
      pipeline that receives the selected items
    • setSelectedItemPipeline

      public void setSelectedItemPipeline(@Nullable Pipeline<T> pipeline)
      Sets the pipeline that receives the selected items.
      Parameters:
      pipeline - pipeline that receives the selected items
    • getNonselectedItemPipeline

      @Nullable public final Pipeline<T> getNonselectedItemPipeline()
      Gets the pipeline that receives the non-selected items.
      Returns:
      pipeline that receives the non-selected items
    • setNonselectedItemPipeline

      public void setNonselectedItemPipeline(@Nullable Pipeline<T> pipeline)
      Sets the pipeline that receives the non-selected items.
      Parameters:
      pipeline - pipeline that receives the non-selected items
    • getCollectionMergeStrategy

      @Nonnull public final CollectionMergeStrategy getCollectionMergeStrategy()
      Gets the strategy used to merge all the joined pipeline results in to the final Item collection.
      Returns:
      strategy used to merge all the joined pipeline results in to the final Item collection, never null
    • setCollectionMergeStrategy

      public void setCollectionMergeStrategy(@Nonnull CollectionMergeStrategy strategy)
      Sets the strategy used to merge all the joined pipeline results in to the final Item collection.
      Parameters:
      strategy - strategy used to merge all the joined pipeline results in to the final Item collection, never null
    • doExecute

      protected void doExecute(@Nonnull @NonnullElements List<Item<T>> items) throws StageProcessingException
      Description copied from class: AbstractStage
      Performs the stage processing on the given Item collection.

      The stage is guaranteed to be have been initialized and not destroyed when this is invoked.

      Specified by:
      doExecute in class AbstractStage<T>
      Parameters:
      items - collection to be processed
      Throws:
      StageProcessingException - thrown if there is an unrecoverable problem when processing the stage
    • executePipeline

      @Nonnull private Future<List<Item<T>>> executePipeline(@Nullable Pipeline<T> pipeline, @Nonnull List<Item<T>> items)
      Executes a pipeline.
      Parameters:
      pipeline - the pipeline, may be null
      items - the collections of items
      Returns:
      the token representing the background execution of the pipeline
    • doInitialize

      protected void doInitialize() throws net.shibboleth.shared.component.ComponentInitializationException
      Overrides:
      doInitialize in class net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
      Throws:
      net.shibboleth.shared.component.ComponentInitializationException