HBASE-13664 Use HBase 1.0 interfaces in ConnectionCache (Solomon Duskis)

This commit is contained in:
tedyu 2015-05-12 13:31:43 -07:00
parent 8e8e246248
commit e42e7ed110
1 changed files with 8 additions and 8 deletions

View File

@ -30,10 +30,10 @@ import org.apache.hadoop.hbase.Stoppable;
import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.HConnection; import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.HConnectionManager; import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.RegionLocator; import org.apache.hadoop.hbase.client.RegionLocator;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.security.User; import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.security.UserProvider; import org.apache.hadoop.hbase.security.UserProvider;
import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.UserGroupInformation;
@ -147,9 +147,9 @@ public class ConnectionCache {
/** /**
* Caller closes the table afterwards. * Caller closes the table afterwards.
*/ */
public HTableInterface getTable(String tableName) throws IOException { public Table getTable(String tableName) throws IOException {
ConnectionInfo connInfo = getCurrentConnection(); ConnectionInfo connInfo = getCurrentConnection();
return connInfo.connection.getTable(tableName); return connInfo.connection.getTable(TableName.valueOf(tableName));
} }
/** /**
@ -176,7 +176,7 @@ public class ConnectionCache {
ugi = UserGroupInformation.createProxyUser(userName, realUser); ugi = UserGroupInformation.createProxyUser(userName, realUser);
} }
User user = userProvider.create(ugi); User user = userProvider.create(ugi);
HConnection conn = HConnectionManager.createConnection(conf, user); Connection conn = ConnectionFactory.createConnection(conf, user);
connInfo = new ConnectionInfo(conn, userName); connInfo = new ConnectionInfo(conn, userName);
connections.put(userName, connInfo); connections.put(userName, connInfo);
} }
@ -188,14 +188,14 @@ public class ConnectionCache {
} }
class ConnectionInfo { class ConnectionInfo {
final HConnection connection; final Connection connection;
final String userName; final String userName;
volatile Admin admin; volatile Admin admin;
private long lastAccessTime; private long lastAccessTime;
private boolean closed; private boolean closed;
ConnectionInfo(HConnection conn, String user) { ConnectionInfo(Connection conn, String user) {
lastAccessTime = EnvironmentEdgeManager.currentTime(); lastAccessTime = EnvironmentEdgeManager.currentTime();
connection = conn; connection = conn;
closed = false; closed = false;