-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Core: state machine entity base class #1511
Conversation
ee384a8
to
d0d41d1
Compare
spi/core-spi/src/main/java/org/eclipse/dataspaceconnector/spi/entity/StateMachine.java
Fixed
Show fixed
Hide fixed
spi/core-spi/src/main/java/org/eclipse/dataspaceconnector/spi/entity/StateMachine.java
Fixed
Show fixed
Hide fixed
spi/core-spi/src/main/java/org/eclipse/dataspaceconnector/spi/entity/StateMachine.java
Fixed
Show fixed
Hide fixed
spi/core-spi/src/main/java/org/eclipse/dataspaceconnector/spi/entity/StateMachine.java
Fixed
Show fixed
Hide fixed
Codecov Report
@@ Coverage Diff @@
## main #1511 +/- ##
==========================================
- Coverage 67.37% 67.16% -0.22%
==========================================
Files 735 736 +1
Lines 16198 16139 -59
Branches 1058 1048 -10
==========================================
- Hits 10913 10839 -74
- Misses 4803 4823 +20
+ Partials 482 477 -5
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the motivation behind modeling StatefulEntity
as an interface and StateMachine
as a superclass of TransferProcess
and ContractNegotiation
?
In my opinion they are not a StateMachine
, they are StatefulEntity
which state transitions are handled through a StateMachine
, so the latter shouldn't be a superclass but something that interacts with the entities into the manager.
I would keep the StatefulEntity
as an abstract class that would end up having an Entity
superclass in turn being superclass of TransferProcess
and ContractNegotiation
.
The Entity
class in the future would become the superclass of other non-stateful entities as Asset
and PolicyDefinition
Formally, "A state machine is an abstract machine that can be in exactly one of a finite number of states at any given time" (https://en.wikipedia.org/wiki/Finite-state_machine) so the state machine is the entity, not the manager. Nevertheless, I have renamed
As I understand this will be done by @diegogomez-zf as part of #1370. Is it ok to do things in two steps like this? |
1e478ff
to
549fd98
Compare
public B state(int value) { | ||
entity.state = value; | ||
return (B) this; | ||
return self(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really clever method to avoid casting and checks suppression 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks - the only clever thing I did was to find a blog by someone cleverer :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM apart from minor nits.
We could look into introducing another base class Entity
as superclass of StatefulEntity
. Analogously we could devise an InMemoryEntityStore
that in turn is a superclass of InMemoryEntityStore
and takes those Entity
objects.
There, we could store things like Policy
, ContractDefnition
, Asset
, etc. That need not be done in this PR though.
Yes indeed as I understand that is (at least in part) in scope for @diegogomez-zf in #1370. |
3ba8e56
to
955402f
Compare
* Core: state machine entity base class * Update CHANGELOG.md * Update EntitySendRetryManagerTest.java * Update StateMachine.java * Renamed StateMachine to StatefulEntity * Update ContractNegotiationIntegrationTest.java * grammar fix
What this PR changes/adds
StateMachine
utility class for state machine entitiesStateMachine
class toStateMachineManager
for clarity and uniformityWhy it does that
Further notes
Also fixed race condition in ContractNegotiation (
transition(DECLINED, DECLINING, PROVIDER_OFFERED, CONFIRMING, CONFIRMED, REQUESTED);
), that manifested itself during a test runLinked Issue(s)
Closes #1463
Checklist
no-changelog
)