blob: 441409fc57b472ea52f7086aa7aefa5f1a109593 [file] [log] [blame]
Yuta HIGUCHI66ca1bf2014-03-12 18:34:09 -07001package net.onrc.onos.datastore;
2
3import net.onrc.onos.datastore.utils.ByteArrayUtil;
4
5/**
6 * Exception thrown when conditional operation failed due to version mismatch.
7 */
8public class WrongVersionException extends RejectRulesException {
9 private static final long serialVersionUID = -1644202495890190823L;
10
11 public WrongVersionException(final String message) {
Yuta HIGUCHI826b4a42014-03-24 13:10:33 -070012 super(message);
Yuta HIGUCHI66ca1bf2014-03-12 18:34:09 -070013 }
14
15 public WrongVersionException(final IKVTableID tableID, final byte[] key,
Yuta HIGUCHI826b4a42014-03-24 13:10:33 -070016 final long expectedVersion, final Throwable cause) {
17 // It will be best if {@code cause} has actual version encountered, but
18 // doesn't currently.
19 super(ByteArrayUtil.toHexStringBuffer(key, ":") + " on table:"
20 + tableID + " was expected to be version:" + expectedVersion,
21 cause);
Yuta HIGUCHI66ca1bf2014-03-12 18:34:09 -070022 }
23
24 public WrongVersionException(final IKVTableID tableID, final byte[] key,
Yuta HIGUCHI826b4a42014-03-24 13:10:33 -070025 final long expectedVersion, final long encounteredVersion) {
26 super(ByteArrayUtil.toHexStringBuffer(key, ":") + " on table:"
27 + tableID + " was expected to be version:" + expectedVersion
28 + " but found:" + encounteredVersion);
Yuta HIGUCHI66ca1bf2014-03-12 18:34:09 -070029 }
30
31}