HBASE-13327 Addendum replaced the nested try with a cast of getAdmin() to HBaseAdmin and a call to the original compact/majorCompact method (Solomon)

This commit is contained in:
tedyu 2015-03-26 18:01:21 -07:00
parent 18256fc954
commit 306c44156a
1 changed files with 9 additions and 12 deletions

View File

@ -66,6 +66,7 @@ import org.apache.hadoop.hbase.client.Append;
import org.apache.hadoop.hbase.client.Delete; import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Durability; import org.apache.hadoop.hbase.client.Durability;
import org.apache.hadoop.hbase.client.Get; import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Increment; import org.apache.hadoop.hbase.client.Increment;
import org.apache.hadoop.hbase.client.OperationWithAttributes; import org.apache.hadoop.hbase.client.OperationWithAttributes;
@ -778,13 +779,11 @@ public class ThriftServerRunner implements Runnable {
@Override @Override
public void compact(ByteBuffer tableNameOrRegionName) throws IOError { public void compact(ByteBuffer tableNameOrRegionName) throws IOError {
byte[] tableNameOrRegionNameArray = getBytes(tableNameOrRegionName);
try { try {
try { // TODO: HBaseAdmin.compact(byte[]) deprecated and not trivial to replace here.
getAdmin().compactRegion(tableNameOrRegionNameArray); // ThriftServerRunner.compact should be deprecated and replaced with methods specific to
} catch (IllegalArgumentException e) { // table and region.
getAdmin().compact(TableName.valueOf(tableNameOrRegionNameArray)); ((HBaseAdmin) getAdmin()).compact(getBytes(tableNameOrRegionName));
}
} catch (IOException e) { } catch (IOException e) {
LOG.warn(e.getMessage(), e); LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage()); throw new IOError(e.getMessage());
@ -793,13 +792,11 @@ public class ThriftServerRunner implements Runnable {
@Override @Override
public void majorCompact(ByteBuffer tableNameOrRegionName) throws IOError { public void majorCompact(ByteBuffer tableNameOrRegionName) throws IOError {
byte[] tableNameOrRegionNameArray = getBytes(tableNameOrRegionName);
try { try {
try { // TODO: HBaseAdmin.majorCompact(byte[]) deprecated and not trivial to replace here.
getAdmin().majorCompactRegion(tableNameOrRegionNameArray); // ThriftServerRunner.majorCompact should be deprecated and replaced with methods specific
} catch (IllegalArgumentException e) { // to table and region.
getAdmin().majorCompact(TableName.valueOf(tableNameOrRegionNameArray)); ((HBaseAdmin) getAdmin()).majorCompact(getBytes(tableNameOrRegionName));
}
} catch (IOException e) { } catch (IOException e) {
LOG.warn(e.getMessage(), e); LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage()); throw new IOError(e.getMessage());