Commit Graph

174 Commits

Author SHA1 Message Date
Janne Valkealahti
e8debdc5a5 Add listener api for extended state variables
- New extendedStateChanged method in StateMachineListener and
  its wingman OnExtendedStateChanged in context events.
- DefaultExtendedState is now using ObservableMap to get notify
  when individual variables has been modified.
- Fixes #85
2015-08-09 14:56:54 +01:00
Janne Valkealahti
05f69070d8 Change TaskExecutor bean name
- Now using stateMachineTaskExecutor instead of taskExecutor
  so that it's easier to use custom executor and not to
  collide with bean created i.e. scheduling.
- Fixes #83
2015-08-09 09:53:46 +01:00
Janne Valkealahti
7fc7dd9cac Fix potential concurrency issue with join pseudostate
- Change notified flag to volatile which might explain
  some test failures.
- More testing tweaks for #76
2015-08-08 16:30:24 +01:00
Janne Valkealahti
5347ea4dd9 Fix internal transition for dist machine
- Change previous DistributedStateMachine fixes which didn't
  really work. Now explicitely getting state from machine to be set
  into ensemble for post internal transition.
- Now can send Message<E> via test plan instead of plain E.
- More testing for tweaked features.
2015-08-08 10:53:44 +01:00
Janne Valkealahti
435b306cf9 Fix DistributedStateMachine internal transition
- For some reason ZookeeperStateMachineEnsemble may return null
  for very early when postTransition() is handled. Adding check not
  to ping back ensemble if its getState() returns null. It really
  feels a bit wrong right now, so need to follow this.
2015-08-07 17:25:52 +01:00
Janne Valkealahti
bba3b231b3 Synchronize Join PseudoState state machine listener
- Synchronize JoinPseudoState's
  JoinTracker.stateChanged(State<S, E>, State<S, E>) method
  for playing nice with concurrent region execution.
  Should fix #93.
- Tuning test which relates to #76. What comes for the
  tests, there was this concurrency issue and also problem
  in tests itself.
- Polish JoinPseudoState.
2015-08-07 14:38:49 +01:00
Janne Valkealahti
e6c400e31c Fix jdk8 javadoc build 2015-08-04 09:08:22 +01:00
Janne Valkealahti
5ab1cb3fcb Add ref docs for error handling
- Base docs for error handling and some tests
  to verify added doc samples.
- Relates to #88
2015-07-31 16:58:47 +01:00
Janne Valkealahti
d5257c64e7 Add base feature for error handling
- Add related error handling methods to StateMachine.
- Enhance StateMachineListener and context events around
  error events.
- Modify StateMachineInterceptor and stuff around it order
  to handle errors.
- Fixes #6, fixes #77
2015-07-31 13:11:19 +01:00
Janne Valkealahti
6684b0deda Fixes for zk ensemble operations
- Fix some concurrent event issues which were
  born with new tests
- Enhance tests for dist machine and ensemble
- Add new features to testing system
- Polish and add more logging
2015-07-29 20:15:42 +01:00
Janne Valkealahti
706f1de232 Update ref docs
- First set of changes for doc updates for M3
- Relates #88
2015-07-26 16:52:15 +01:00
Janne Valkealahti
178ee816a4 Enhancements to tasks recipe
- Fix AbstractStateMachineFactory so that it does not try
  to create transitions with null source or target. Basically we
  just skip transition source or target which doesn't belong to
  region.
- Change DefaultExtendedState to use ConcurrentHashMap so that
  there's less change to get into trouble with concurrency.
- Add statechart for tasks recipe.
- Fix various concepts in TasksHandler and its tests.
- Prepare some examples for docs.
- Fixes #74
2015-07-25 17:09:54 +01:00
Janne Valkealahti
0fba91cbf2 Fix event overflow
- Fixes #89
- Added new method into EnsembleListeger which can
  be used to listen ensemble errors.
2015-07-25 08:31:03 +01:00
Janne Valkealahti
74f2f72ed6 Fix concepts around internal transitions
- Fixes #86
- Fix internal transition changes when extended
  state variables has been modified. Also internal
  transition is now correctly passed into other
  distributed state machines.
2015-07-24 09:07:03 +01:00
Janne Valkealahti
0cdd833648 Enhance concepts around interceptor
- Rename StateChangeInterceptor to StateMachineInterceptor and
  add methods for pre/post transitions.
- Adding getId concept into a state machine to help distributed
  machines to know from where a state change originates.
- Fix ZookeeperStateMachineEnsemble to work better with
  persisted state machine contexts.
2015-07-19 10:33:28 +01:00
Janne Valkealahti
15c6e507d8 Tweak concepts around state reset
- StateMachineAccess, replace state reset and variables
  with a StateMachineContext.
- Additional fixes to reset state properly even if
  target transition is a super state.
- Some polish
- Add tests
2015-07-15 11:17:43 +01:00
Janne Valkealahti
db5a1ab3f7 Update docs 2015-07-12 17:19:46 +01:00
Janne Valkealahti
c28ace7945 Enhance config model with StateMachineListener
- Fixes #84
2015-07-11 16:43:28 +01:00
Janne Valkealahti
48bb6631f9 Tweak factory lifecycle handling
- Setup autostart and afterPropertiesSet() for distributed machine.
2015-07-11 16:08:41 +01:00
Janne Valkealahti
087da55cbb Add autostart flag for top-level machine - take2
- Add actual start calls
- Rename autoStart to autoStartup in config methods.
- Tweak so that this works in factory and builder
2015-07-11 09:34:45 +01:00
Janne Valkealahti
2c0c79a537 Add autostart flag for top-level machine
- Fixes #82
- Now have configure method ConfigurationConfigurer.autoStart(boolean)
  which can be used to enable autostart feature for top-level state machine.
  We keep this feature disabled as default because most of the cases it is
  easier to enable it than disable it.
2015-07-10 18:37:16 +01:00
Janne Valkealahti
8292bbff00 Fixing initial state transitions
- Reported and fixex #81
- Change how internal state is entered and handled
  when transition doesn't terminate into initial state.
- Needed to change stuff in various places because
  some of the concepts were literally broken which were
  overlooked due to missing tests.
2015-07-10 17:24:56 +01:00
Janne Valkealahti
9b6caaf6b8 Docs updates 2015-07-05 17:36:45 +01:00
Janne Valkealahti
24ca522802 Fix typo 2015-07-05 15:52:40 +01:00
Janne Valkealahti
c4e5e999e0 Fix typo 2015-07-05 15:51:53 +01:00
Janne Valkealahti
9c67299a35 Add event if event is not accepted
- OnStateNotAcceptedEvent is fired via context
  if event is not accepted.
- eventNotAccepted called via StateMachineListener
  if event is not accepted.
- Test in StateMachineEventTests.testEventNotAccepted()
- Fixes #43
2015-07-05 15:43:04 +01:00
Janne Valkealahti
bba4bc1d28 Add headers and events to serialization
- Relates to #35
- Now event headers and extended state variables
  are serialized with kryo and zookeeper.
2015-07-05 09:52:36 +01:00
Janne Valkealahti
2ac515b04b Polish 2015-07-04 15:34:24 +01:00
Janne Valkealahti
6ae2f2fa43 Can now skip initial state
- Fixes #71
- If substate is entered directry, we don't
  go via initial state for particular state machine
  where transition ends.
- Fixing other tests which assumed initial state is entered.
- In terms of a history state, initial state is still entered.
2015-07-04 15:15:27 +01:00
Janne Valkealahti
4b858b1d9b Add skeleton for tasks recipe
- Relates to #74
- Tasks recipe not yet fully working, need to get
  this work in to be able to work with other tickets.
- Add childs to StateMachineContext
- A lot of fixes to regions concept throughout
  a code base. Some of the concepts were really broken
  if there were a complex recursive set of regions, etc.
- Add task executor/scheduler to StateMachineBuilder
2015-07-03 14:02:17 +01:00
Janne Valkealahti
44d09f257e Change StateMachinePersist interface
- Remove away from plain serialize/deserialize to write/read
  concept which works better in a generic abstraction.
- Tweak related class in zookeeper package.
- Relates to #35
2015-06-20 15:44:49 +01:00
Janne Valkealahti
e2fe4907d3 Add config builder for distributed machine
- New configurer which can be used to define an ensemble which
  if is set automatically wraps a machine with a distributed
  state machine and sets it to use an given ensemble.
- Relates to #35
2015-06-18 13:20:04 +01:00
Janne Valkealahti
742010f1a5 Change distributed machine to use interceptor
- Move away from using state machine listener if favor
  of interceptor which allows to skip state change.
- Remove previously added method in a
  StateMachineListener. (was a bad idea).
- More tweaks to zk example
- Relates to #35
2015-06-18 11:22:37 +01:00
Janne Valkealahti
1bcdbd5ae0 Add base work for recipes
- Better state sync handling #35
- Adding first recipe for synching and
  persisting a state # 73
2015-06-17 09:19:43 +01:00
Janne Valkealahti
608183f2a3 Add builder pattern for state machine instantiation
- Relates to #45
- Modify current annotation builder model to work via
  manual StateMachineBuilder class.
- Add ConfigurationConfigurer to configure bean factory,
  task executor and task scheduler via builder.
2015-06-13 22:17:06 +01:00
Janne Valkealahti
c68fa5d09d Add skeleton for distributed state machine
- NOTE: not yet fully working distributed sm, this
  commit is considered to be a stage 1 of further
  commits on this matter.
- Preliminary concept of DistributedStateMachine,
  StateMachineEnsemble and StateMachinePersist.
- New module spring-statemachine-zookeeper order to
  persist state in a distributed matter.
- Refactoring concept of a state machine access to get
  better internal access into a sm via functional interfaces.
- Change build to use jdk7 and change test to rely on jdk8
  order to test functional lambdas.
- new zookeeper sample demonstrating distributed concepts.
- Relates t0 #35 and #34.
- No docs until things are fully implemented.
2015-06-12 18:15:50 +01:00
Janne Valkealahti
1648b39de1 Lift requirement of enums for states and events
- Relasing the use of enums where applicable
- Fixes #69
2015-06-03 18:26:21 +01:00
Janne Valkealahti
75a4da811e Ref doc updates 2015-05-30 18:01:59 +01:00
Janne Valkealahti
aaa20e6b26 Add better spel support for actions and guards
- Add new StateContextExpressionMethods support class.
- Change SpelExpressionGuard to user methods class.
- Add new SpelExpressionAction which can take expression
  to execute action.
2015-05-30 17:02:45 +01:00
Janne Valkealahti
b73e22864f Add missing headers 2015-05-29 11:32:28 +01:00
Janne Valkealahti
2fb774e837 Polish 2015-05-29 11:24:39 +01:00
Janne Valkealahti
61ec8723df Updates to docs 2015-05-29 11:00:32 +01:00
Janne Valkealahti
2b3db24345 Better support for parallel regions
- Generally fixes #68
- First attempt to externalize event execution from state machine
  into its own class backed by an interface. This relates to #7
- Change of various places to have better support if execution
  is done in threads.
- Not yet a central place where concurrency can be defines, thus
  currently rely on global taskExecutor bean when can be overridded
  from a default which is SyncTaskExecutor. Futher work for
  that in separate tickets.
- Change tasks sample to use a thread pool.
- Change of concept how initial state/transition is handled, no
  longer handled manually in lifecycle method, thus giving a change
  for initial transition to execute its actions in a multiple threads.
2015-05-24 17:38:41 +01:00
Janne Valkealahti
517bf69364 Fix fragile tests
- Trying to fix test `StateMachineTests.testTimerTransition`
  by releasing latch after stateContexts list is updated. This
  is probably reason why assert failed for that list size.
- Again, fixes #36
2015-05-17 16:33:13 +01:00
Janne Valkealahti
2a31254b91 Add first concept of better internal machine comm
- Add concept of functional interface to work with
  recursive machines for function access.
- This also fixes a machine relay so that every used
  state context gets a correct top level machine
  for correctly dispatching events into a top level handling.
2015-05-17 15:28:42 +01:00
Janne Valkealahti
a4baf0135b Fix some issues for annotated methods for initial state
- Adding new tests for annotated methods.
- Fix a problem so that annotated method can
  be called when ititial state is set.
2015-05-16 17:25:06 +01:00
Janne Valkealahti
6394bae349 Fix join source with region state
- Change factory and join hanling so that if source
  is a region state, actual join states are end states
  from its regions.
2015-05-16 15:33:40 +01:00
Janne Valkealahti
844a70c588 Add way to remove listener
- Change Region interface and underlying listener
  classes so that we can unregister registered
  listeners.
2015-05-16 10:15:28 +01:00
Janne Valkealahti
d5811c3ac4 Fix choice state create
- Fix so that we don't need to define choice
  pseudostate as state.
2015-05-15 16:15:34 +01:00
Janne Valkealahti
d29c240ad0 Fix possible NPE in RegionState 2015-05-15 15:15:26 +01:00