1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.snapshot;
19
20 import java.util.concurrent.Callable;
21
22 import org.apache.hadoop.classification.InterfaceAudience;
23 import org.apache.hadoop.hbase.errorhandling.ForeignException;
24 import org.apache.hadoop.hbase.errorhandling.ForeignExceptionSnare;
25 import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher;
26 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
27
28
29
30
31 @InterfaceAudience.Private
32 public abstract class SnapshotTask implements ForeignExceptionSnare, Callable<Void>{
33
34 protected final SnapshotDescription snapshot;
35 protected final ForeignExceptionDispatcher errorMonitor;
36
37
38
39
40
41 public SnapshotTask(SnapshotDescription snapshot, ForeignExceptionDispatcher monitor) {
42 assert monitor != null : "ForeignExceptionDispatcher must not be null!";
43 assert snapshot != null : "SnapshotDescription must not be null!";
44 this.snapshot = snapshot;
45 this.errorMonitor = monitor;
46 }
47
48 public void snapshotFailure(String message, Exception e) {
49 ForeignException ee = new ForeignException(message, e);
50 errorMonitor.receive(ee);
51 }
52
53 @Override
54 public void rethrowException() throws ForeignException {
55 this.errorMonitor.rethrowException();
56 }
57
58 @Override
59 public boolean hasException() {
60 return this.errorMonitor.hasException();
61 }
62
63 @Override
64 public ForeignException getException() {
65 return this.errorMonitor.getException();
66 }
67 }