blob: 005905ec045327c160c71224c58db7cb8da7fcd6 [file] [log] [blame]
Jonathan Hart6df90172014-04-03 10:13:11 -07001package net.onrc.onos.core.datastore;
Yuta HIGUCHI66ca1bf2014-03-12 18:34:09 -07002
Jonathan Hart6df90172014-04-03 10:13:11 -07003import net.onrc.onos.core.datastore.utils.ByteArrayUtil;
Yuta HIGUCHI66ca1bf2014-03-12 18:34:09 -07004
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,
Ray Milkey269ffb92014-04-03 14:43:30 -070016 final long expectedVersion, final Throwable cause) {
Yuta HIGUCHI826b4a42014-03-24 13:10:33 -070017 // It will be best if {@code cause} has actual version encountered, but
18 // doesn't currently.
Yuta HIGUCHI805bc8f2014-04-16 11:51:43 -070019 super(ByteArrayUtil.toHexStringBuilder(key, ":") + " on table:"
Yuta HIGUCHI826b4a42014-03-24 13:10:33 -070020 + 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,
Ray Milkey269ffb92014-04-03 14:43:30 -070025 final long expectedVersion, final long encounteredVersion) {
Yuta HIGUCHI805bc8f2014-04-16 11:51:43 -070026 super(ByteArrayUtil.toHexStringBuilder(key, ":") + " on table:"
Yuta HIGUCHI826b4a42014-03-24 13:10:33 -070027 + tableID + " was expected to be version:" + expectedVersion
28 + " but found:" + encounteredVersion);
Yuta HIGUCHI66ca1bf2014-03-12 18:34:09 -070029 }
30
31}