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
This commit is contained in:
Janne Valkealahti
2015-07-29 20:15:00 +01:00
parent 706f1de232
commit 6684b0deda
8 changed files with 936 additions and 35 deletions

View File

@@ -212,7 +212,7 @@ public abstract class AbstractStateMachineFactory<S, E> extends LifecycleObjectS
// we wrap previously build machine with a distributed
// state machine and set it to use given ensemble.
if (stateMachineConfigurationConfig.getStateMachineEnsemble() != null) {
DistributedStateMachine<S, E> distributedStateMachine = new DistributedStateMachine<>(
DistributedStateMachine<S, E> distributedStateMachine = new DistributedStateMachine<S, E>(
stateMachineConfigurationConfig.getStateMachineEnsemble(), machine);
distributedStateMachine.setAutoStartup(stateMachineConfigurationConfig.isAutoStart());
distributedStateMachine.afterPropertiesSet();

View File

@@ -75,13 +75,15 @@ public class DistributedStateMachine<S, E> extends LifecycleObjectSupport implem
@Override
protected void onInit() throws Exception {
delegate.getStateMachineAccessor().doWithAllRegions(new StateMachineFunction<StateMachineAccess<S, E>>() {
// TODO: should we register with all, not just top one?
delegate.getStateMachineAccessor().doWithRegion(new StateMachineFunction<StateMachineAccess<S, E>>() {
@Override
public void apply(StateMachineAccess<S, E> function) {
function.addStateMachineInterceptor(interceptor);
}
});
}
@Override
@@ -176,6 +178,9 @@ public class DistributedStateMachine<S, E> extends LifecycleObjectSupport implem
@Override
public void preStateChange(State<S, E> state, Message<E> message, Transition<S, E> transition,
StateMachine<S, E> stateMachine) {
if (log.isTraceEnabled()) {
log.trace("Received preStateChange from " + stateMachine + " for delegate " + delegate);
}
// only handle if state change originates from this dist machine
if (message != null
&& ObjectUtils.nullSafeEquals(delegate.getId(),

View File

@@ -417,6 +417,8 @@ public abstract class AbstractStateMachine<S, E> extends StateMachineObjectSuppo
if (currentState != null) {
buf.append(StringUtils.collectionToCommaDelimitedString(currentState.getIds()));
}
buf.append(" / id=");
buf.append(id);
return buf.toString();
}