...
Code Block | ||||
---|---|---|---|---|
| ||||
/** * Return true the storage supports transactions. * * @return {@code true} if the storage supports transactions, {@code false} otherwise */ default boolean transactional() { return false; } /** * Flush any cached data * */ @Deprecated default void flush() {} /** * Flush and commit any cached data * <p> * For transactional state store commit applies all changes atomically. In other words, either the * entire commit will be successful or none of the changes will be applied. * <p> * For non-transactional state store this method flushes cached data. * * @param changelogOffset the offset of the changelog topic this commit corresponds to. The * offset can be null if the state store does not have a changelog * (e.g. a global store). * @code null} */ default void commit(final Long changelogOffset) { if (transactional()) { throw new UnsupportedOperationException("Transactional state store must implement StateStore#commit"); } else { flush(); } } /** * Recover a transactional state store * <p> * If a transactional state store shut down with a crash failure, this method can either * roll back or forward uncommitted changes. In any case, this method returns the changelog * offset it rolls to. * * @param changelogOffset the checkpointed changelog offset. * @return the changelog offset after recovery or {@code null} if recovery failed. */ default Long recover(final Long changelogOffset) { if (transactional()) { throw new UnsupportedOperationException("Transactional state store must implement StateStore#recover"); } return changelogOffset; } |
...