Package io.mats3

Interface MatsConfig

All Known Subinterfaces:
MatsEndpoint.EndpointConfig<R,S>, MatsFactory.FactoryConfig, MatsStage.StageConfig<R,S,I>

public interface MatsConfig
All of MatsFactory, MatsEndpoint and MatsStage have some configurable elements, provided by a config instance, this is the top of that hierarchy.
  • Method Details

    • getConcurrency

      int getConcurrency()
      Returns the concurrency set up for this factory, or endpoint, or stage. Will provide the default unless overridden by setConcurrency(int) before start.

      It is the MatsStages that eventually will be affected by this number, specifically how many standard and interactive StageProcessors is fired up for each Stage. One StageProcessor is one thread consuming from the stage-specific queue, thus if the concurrency for a Stage is resolved to be 6, then by default 2 x 6 threads will be consuming from this stage's queue: 6 for normal priority, and 6 for interactive priority.

      If default logic is in effect (i.e. have not been set by setConcurrency(int), or that is set to 0), a MatsStage will default to its MatsEndpoint, while an endpoint will default to the MatsFactory. The default for the MatsFactory is 2 x the number returned by MatsFactory.FactoryConfig.getNumberOfCpus(), which by default is the number of processors on the server it is running on, as determined by Runtime.availableProcessors() (but this default can be changed by setting the System Property "mats.cpus").

      Returns:
      the concurrency set up for this factory, or endpoint, or process stage. Will provide the default unless overridden by setConcurrency(int) before start.
      See Also:
    • setConcurrency

      MatsConfig setConcurrency(int concurrency)
      Changes the default concurrency of the Factory, or of the endpoint (which defaults to the concurrency of the MatsFactory), or of the process stage (which defaults to the concurrency of the MatsEndpoint).

      Will only have effect before the MatsStage is started. Can be reset by stopping, setting, and restarting.

      Setting to 0 will invoke default logic.

      Parameters:
      concurrency - the concurrency for the Factory, or Endpoint, or Stage. If set to 0, default-logic is in effect.
      Returns:
      the config object, for method chaining.
      See Also:
    • isConcurrencyDefault

      boolean isConcurrencyDefault()
      Returns:
      whether the number provided by getConcurrency() is using default-logic (when the concurrency is set to 0) (true), or if it is set specifically (false).
      See Also:
    • getInteractiveConcurrency

      int getInteractiveConcurrency()
      Returns the interactive concurrency set up for this factory, or endpoint, or stage. Will provide the default unless overridden by setConcurrency(int) before start.

      If default logic is in effect (i.e. have not been set by setConcurrency(int), or that is set to 0), a MatsStage will see if the same Stage's normal concurrency is non-default, and if so, use that - otherwise, it will use the interactive concurrency of its parent Endpoint. The MatsEndpoint will see if the same Endpoint's normal concurrency is non-default, and if so, use that - otherwise it will use the interactive concurrency of its parent Factory. The MatsFactory will by default use the normal concurrency of the Factory.

      Effectively, a more specific setting for interactive concurrency overrides a less specific. Stage is more specific than Endpoint, which is more specific than Factory, and in addition interactive is more specific than normal.

      Returns:
      the interactive concurrency set up for this factory, or endpoint, or process stage. Will provide the default unless overridden by setInteractiveConcurrency(int) before start.
      See Also:
    • setInteractiveConcurrency

      MatsConfig setInteractiveConcurrency(int concurrency)
      Like setConcurrency(int), but changes the "interactive concurrency" specifically - this is relevant for the Mats Flows that are initiated with the interactive flag set.
      Parameters:
      concurrency - the interactive concurrency for the Factory, or Endpoint, or Stage. If set to 0, default-logic is in effect.
      Returns:
      the config object, for method chaining.
      See Also:
    • isInteractiveConcurrencyDefault

      boolean isInteractiveConcurrencyDefault()
      Returns:
      whether the number provided by getInteractiveConcurrency() is using default-logic (when the concurrency is set to 0) (true), or if it is set specifically (false).
      See Also:
    • isRunning

      boolean isRunning()
      Returns:
      whether the Mats entity has been started and not stopped. For the MatsFactory, it returns true if any of the endpoints return true (which also implies that if there are no Endpoints registered, it will return false). For MatsEndpoints, it returns true if any stage is running.
    • setAttribute

      MatsConfig setAttribute(String key, Object value)
      Sets an attribute for this entity (factory, endpoint, stage) - can e.g. be used by tooling or interceptors. If the value is null, the mapping for the specified key is cleared.
      Parameters:
      key - the key name for this attribute. Not null.
      value - the value for this attribute. If the value is null, the mapping for the specified key is cleared.
      Returns:
      the config object, for method chaining.
    • getAttribute

      <T> T getAttribute(String key)
      Type Parameters:
      T - the type of this attribute, to avoid explicit casting - but you should really know the type, otherwise request Object.
      Parameters:
      key - the key name for this attribute.
      Returns:
      the attribute value.