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.CallQueueTooBigException;
23 import org.apache.hadoop.hbase.MultiActionResultTooLarge;
24 import org.apache.hadoop.hbase.RegionTooBusyException;
25 import org.apache.hadoop.hbase.RetryImmediatelyException;
26 import org.apache.hadoop.hbase.classification.InterfaceAudience;
27 import org.apache.hadoop.hbase.classification.InterfaceStability;
28 import org.apache.hadoop.hbase.quotas.ThrottlingException;
29 import org.apache.hadoop.ipc.RemoteException;
30
31 @InterfaceAudience.Private
32 @InterfaceStability.Evolving
33 public final class ClientExceptionsUtil {
34
35 private ClientExceptionsUtil() {}
36
37 public static boolean isMetaClearingException(Throwable cur) {
38 cur = findException(cur);
39
40 if (cur == null) {
41 return true;
42 }
43 return !isSpecialException(cur) || (cur instanceof RegionMovedException);
44 }
45
46 public static boolean isSpecialException(Throwable cur) {
47 return (cur instanceof RegionMovedException || cur instanceof RegionOpeningException
48 || cur instanceof RegionTooBusyException || cur instanceof ThrottlingException
49 || cur instanceof MultiActionResultTooLarge || cur instanceof RetryImmediatelyException
50 || cur instanceof CallQueueTooBigException);
51 }
52
53
54
55
56
57
58
59
60
61
62
63 public static Throwable findException(Object exception) {
64 if (exception == null || !(exception instanceof Throwable)) {
65 return null;
66 }
67 Throwable cur = (Throwable) exception;
68 while (cur != null) {
69 if (isSpecialException(cur)) {
70 return cur;
71 }
72 if (cur instanceof RemoteException) {
73 RemoteException re = (RemoteException) cur;
74 cur = re.unwrapRemoteException(
75 RegionOpeningException.class, RegionMovedException.class,
76 RegionTooBusyException.class);
77 if (cur == null) {
78 cur = re.unwrapRemoteException();
79 }
80
81
82
83 if (cur == re) {
84 return cur;
85 }
86 } else if (cur.getCause() != null) {
87 cur = cur.getCause();
88 } else {
89 return cur;
90 }
91 }
92
93 return null;
94 }
95 }