@Override public void write(StateMachineContext<S,E> context, Stat stat) { byte[] data = serialize(context); CuratorTransaction tx = curatorClient.inTransaction(); try { CuratorTransactionFinal tt = tx.setData().withVersion(stat.getVersion()).forPath(path, data).and(); if (logPath != null) { tt = tt.setData().forPath(logPath + "/" + stat.getVersion() % logSize, data).and(); } Collection<CuratorTransactionResult> results = tt.commit(); int version = results.iterator().next().getResultStat().getVersion(); stat.setVersion(version); } catch (Exception e) { throw new StateMachineException("Error persisting data", e); } }