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:
@@ -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();
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user