1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.hadoop.hbase.exceptions;
21
22 import org.apache.hadoop.hbase.CallDroppedException;
23 import org.apache.hadoop.hbase.CallQueueTooBigException;
24 import org.apache.hadoop.hbase.RegionTooBusyException;
25 import org.apache.hadoop.hbase.classification.InterfaceAudience;
26 import org.apache.hadoop.hbase.classification.InterfaceStability;
27 import org.apache.hadoop.hbase.quotas.ThrottlingException;
28 import org.apache.hadoop.ipc.RemoteException;
29
30 @InterfaceAudience.Private
31 @InterfaceStability.Evolving
32 public final class ClientExceptionsUtil {
33
34 private ClientExceptionsUtil() {}
35
36 public static boolean isMetaClearingException(Throwable cur) {
37 cur = findException(cur);
38
39 if (cur == null) {
40 return true;
41 }
42 return !isSpecialException(cur) || (cur instanceof RegionMovedException);
43 }
44
45 public static boolean isSpecialException(Throwable cur) {
46 return (cur instanceof RegionMovedException || cur instanceof RegionOpeningException
47 || cur instanceof RegionTooBusyException || cur instanceof ThrottlingException
48 || cur instanceof CallQueueTooBigException || cur instanceof CallDroppedException);
49 }
50
51
52
53
54
55
56
57 public static boolean isCallQueueTooBigException(Throwable t) {
58 t = findException(t);
59 return (t instanceof CallQueueTooBigException);
60 }
61
62
63
64
65
66
67
68 public static boolean isCallDroppedException(Throwable t) {
69 t = findException(t);
70 return (t instanceof CallDroppedException);
71 }
72
73
74
75
76
77
78
79
80
81
82 public static Throwable findException(Object exception) {
83 if (exception == null || !(exception instanceof Throwable)) {
84 return null;
85 }
86 Throwable cur = (Throwable) exception;
87 while (cur != null) {
88 if (isSpecialException(cur)) {
89 return cur;
90 }
91 if (cur instanceof RemoteException) {
92 RemoteException re = (RemoteException) cur;
93 cur = re.unwrapRemoteException(
94 RegionOpeningException.class, RegionMovedException.class,
95 RegionTooBusyException.class);
96 if (cur == null) {
97 cur = re.unwrapRemoteException();
98 }
99
100
101
102 if (cur == re) {
103 return cur;
104 }
105 } else if (cur.getCause() != null) {
106 cur = cur.getCause();
107 } else {
108 return cur;
109 }
110 }
111
112 return null;
113 }
114 }