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