[midPoint-git] [Evolveum/midpoint] 5afcbf: Implement script pooling for Polyglot script evalu...
Andrej
noreply at github.com
Mon Sep 1 10:07:47 CEST 2025
Branch: refs/heads/improvement/10061
Home: https://github.com/Evolveum/midpoint
Commit: 5afcbf89428d72dd23a3fce89f083da4320df1af
https://github.com/Evolveum/midpoint/commit/5afcbf89428d72dd23a3fce89f083da4320df1af
Author: Andrej Zan <andrej.zan at evolveum.com>
Date: 2025-09-01 (Mon, 01 Sep 2025)
Changed paths:
M model/model-common/pom.xml
M model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/script/polyglot/ContextPerScriptPool.java
M model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/script/polyglot/PolyglotScriptEvaluator.java
M model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/script/polyglot/PolyglotScriptPool.java
A model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/polyglot/ContextPerScriptPoolTest.java
A model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/polyglot/FakePolyglotScript.java
M model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/polyglot/PolyglotScriptEvaluatorTest.java
Log Message:
-----------
Implement script pooling for Polyglot script evaluator
**What**
Implement pooling of scripts, which is used by the Polyglot scripts
evaluator.
**Why**
The Graal Polyglot APIs, especially the `Context` class can not be used
by more than one thread at a same time. To prevent such a scenario, the
parsed scripts are stored in a pool.
If some thread wants to evaluate a script, it has to be firstly acquired
from the pool (blocking operation with a timeout). The pool makes sure,
that the script is acquired at most once. After that the script needs to
be released to the pool before it can be acquired again.
The capacity of the pool is limited. By default the limit is 50 scripts.
I assume, that there will not be more than 50 threads trying to access
the script at a same time.
The creation of new script in the pool is done by explicitly calling the
`createIfHasCapacity` method. The intention is to let a thread firstly
try to acquire existing script. If that is not done in time, then the
thread may try to create new script in the pool. You can see the
intended usage in the `PolyglotScriptEvaluator` class.
To unsubscribe from these emails, change your notification settings at https://github.com/Evolveum/midpoint/settings/notifications
More information about the midPoint-svn
mailing list