1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.hadoop.hbase.client;
22
23 import org.apache.hadoop.hbase.HRegionLocation;
24 import org.apache.hadoop.hbase.ipc.HRegionInterface;
25
26 import java.io.IOException;
27 import java.util.concurrent.Callable;
28
29
30
31
32
33 public abstract class ServerCallable<T> implements Callable<T> {
34 protected final HConnection connection;
35 protected final byte [] tableName;
36 protected final byte [] row;
37 protected HRegionLocation location;
38 protected HRegionInterface server;
39
40
41
42
43
44
45 public ServerCallable(HConnection connection, byte [] tableName, byte [] row) {
46 this.connection = connection;
47 this.tableName = tableName;
48 this.row = row;
49 }
50
51
52
53
54
55
56 public void instantiateServer(boolean reload) throws IOException {
57 this.location = connection.getRegionLocation(tableName, row, reload);
58 this.server = connection.getHRegionConnection(location.getServerAddress());
59 }
60
61
62 public String getServerName() {
63 if (location == null) {
64 return null;
65 }
66 return location.getServerAddress().toString();
67 }
68
69
70 public byte[] getRegionName() {
71 if (location == null) {
72 return null;
73 }
74 return location.getRegionInfo().getRegionName();
75 }
76
77
78 public byte [] getRow() {
79 return row;
80 }
81 }