Yuta HIGUCHI | 66ca1bf | 2014-03-12 18:34:09 -0700 | [diff] [blame^] | 1 | package net.onrc.onos.datastore; |
| 2 | |
| 3 | import net.onrc.onos.datastore.utils.ByteArrayUtil; |
| 4 | |
| 5 | /** |
| 6 | * Exception thrown when conditional operation failed due to version mismatch. |
| 7 | */ |
| 8 | public 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 | } |