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.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
-
Method Summary
Modifier and TypeMethodDescription<T> T
getAttribute
(String key) int
Returns the concurrency set up for this factory, or endpoint, or stage.int
Returns the interactive concurrency set up for this factory, or endpoint, or stage.boolean
boolean
boolean
setAttribute
(String key, Object value) Sets an attribute for this entity (factory, endpoint, stage) - can e.g.setConcurrency
(int concurrency) Changes the default concurrency of the Factory, or of the endpoint (which defaults to the concurrency of theMatsFactory
), or of the process stage (which defaults to the concurrency of theMatsEndpoint
).setInteractiveConcurrency
(int concurrency) LikesetConcurrency(int)
, but changes the "interactive concurrency" specifically - this is relevant for the Mats Flows that are initiated with theinteractive
flag set.
-
Method Details
-
getConcurrency
int getConcurrency()Returns the concurrency set up for this factory, or endpoint, or stage. Will provide the default unless overridden bysetConcurrency(int)
before start. It is theMatsStage
s that eventually will be affected by this number, specifically how many standard andinteractive
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 bysetConcurrency(int)
, or that is set to 0), aMatsStage
will default to itsMatsEndpoint
, while an endpoint will default to theMatsFactory
. The default for theMatsFactory
is 2 x the number returned byMatsFactory.FactoryConfig.getNumberOfCpus()
, which by default is the number of processors on the server it is running on, as determined byRuntime.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
Changes the default concurrency of the Factory, or of the endpoint (which defaults to the concurrency of theMatsFactory
), or of the process stage (which defaults to the concurrency of theMatsEndpoint
). Will only have effect before theMatsStage
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 bysetConcurrency(int)
before start. If default logic is in effect (i.e. have not been set bysetConcurrency(int)
, or that is set to 0), aMatsStage
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. TheMatsEndpoint
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. TheMatsFactory
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
LikesetConcurrency(int)
, but changes the "interactive concurrency" specifically - this is relevant for the Mats Flows that are initiated with theinteractive
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 returnfalse
). ForMatsEndpoint
s, it returns true if any stage is running.
-
setAttribute
Sets an attribute for this entity (factory, endpoint, stage) - can e.g. be used by tooling or interceptors. If the value isnull
, the mapping for the specified key is cleared.- Parameters:
key
- the key name for this attribute. Notnull
.value
- the value for this attribute. If the value isnull
, the mapping for the specified key is cleared.- Returns:
- the config object, for method chaining.
-
getAttribute
- Type Parameters:
T
- the type of this attribute, to avoid explicit casting - but you should really know the type, otherwise requestObject
.- Parameters:
key
- the key name for this attribute.- Returns:
- the attribute value.
-