|
1 | 1 | /* |
2 | | - * Copyright (C) 2015 The Async HBase Authors. All rights reserved. |
| 2 | + * Copyright (C) 2015-2018 The Async HBase Authors. All rights reserved. |
3 | 3 | * This file is part of Async HBase. |
4 | 4 | * |
5 | 5 | * Redistribution and use in source and binary forms, with or without |
|
32 | 32 | */ |
33 | 33 | public class RpcTimedOutException extends HBaseException { |
34 | 34 |
|
| 35 | + /** The RPC that failed */ |
| 36 | + final HBaseRpc failed_rpc; |
| 37 | + |
35 | 38 | /** |
36 | 39 | * Constructor. |
37 | 40 | * @param msg The message of the exception, potentially including a stack |
38 | 41 | * trace. |
| 42 | + * @param rpc The RPC that timed out. |
39 | 43 | */ |
40 | | - RpcTimedOutException(final String msg) { |
| 44 | + RpcTimedOutException(final String msg, final HBaseRpc rpc) { |
41 | 45 | super(msg); |
| 46 | + failed_rpc = rpc; |
42 | 47 | } |
43 | 48 |
|
44 | 49 | /** |
45 | 50 | * Constructor. |
46 | 51 | * @param msg The message of the exception, potentially including a stack |
47 | 52 | * trace. |
48 | 53 | * @param cause The exception that caused this one to be thrown. |
| 54 | + * @param rpc The RPC that timed out. |
49 | 55 | */ |
50 | | - RpcTimedOutException(final String msg, final Throwable cause) { |
| 56 | + RpcTimedOutException(final String msg, |
| 57 | + final Throwable cause, |
| 58 | + final HBaseRpc rpc) { |
51 | 59 | super(msg, cause); |
| 60 | + failed_rpc = rpc; |
52 | 61 | } |
53 | 62 |
|
| 63 | + /** @return The RPC that timed out. */ |
| 64 | + public HBaseRpc getFailedRpc() { |
| 65 | + return failed_rpc; |
| 66 | + } |
| 67 | + |
| 68 | + @Override |
| 69 | + RpcTimedOutException make(final Object msg, final HBaseRpc rpc) { |
| 70 | + if (msg == this || msg instanceof RpcTimedOutException) { |
| 71 | + final RpcTimedOutException e = (RpcTimedOutException) msg; |
| 72 | + if (e.getCause() != null) { |
| 73 | + return new RpcTimedOutException(e.getMessage(), e.getCause(), rpc); |
| 74 | + } else { |
| 75 | + return new RpcTimedOutException(e.getMessage(), rpc); |
| 76 | + } |
| 77 | + } |
| 78 | + return new RpcTimedOutException(msg.toString(), rpc); |
| 79 | + } |
| 80 | + |
54 | 81 | private static final long serialVersionUID = -6245448564580938789L; |
55 | | - |
| 82 | + |
56 | 83 | } |
57 | 84 |
|
0 commit comments