Fix possible event miss in zk dist machine

- Add condition to check if we're behind
  for notify events.
- Fixes #152
This commit is contained in:
Janne Valkealahti
2016-01-15 12:40:46 +00:00
parent c866bdcaa2
commit 6282ef7932

View File

@@ -408,7 +408,10 @@ public class ZookeeperStateMachineEnsemble<S, E> extends StateMachineEnsembleObj
traceLogWrappers(currentWrapper, notifyWrapper, newWrapper);
if (currentWrapper.version + 1 == newWrapper.version
&& notifyWrapper.version >= currentWrapper.version
&& stateRef.compareAndSet(currentWrapper, newWrapper)) {
// simply used to check if we don't need to replay, if so
// we can just try to notify
mayNotifyStateChanged(newWrapper);
} else {
final int start = (notifyWrapper != null ? (notifyWrapper.version) : 0) % logSize;