blob: 9b59ff127216753f832704bb0f280b2bc25de371 [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) {
12 super(message);
13 }
14
15 public WrongVersionException(final IKVTableID tableID, final byte[] key,
16 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);
22 }
23
24 public WrongVersionException(final IKVTableID tableID, final byte[] key,
25 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);
29 }
30
31}