Skip to content

Commit

Permalink
HBASE-13327 Addendum replaced the nested try with a cast of getAdmin(…
Browse files Browse the repository at this point in the history
…) to HBaseAdmin and a call to the original compact/majorCompact method (Solomon)
  • Loading branch information
tedyu committed Mar 27, 2015
1 parent 18256fc commit 306c441
Showing 1 changed file with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Durability;
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.Increment;
import org.apache.hadoop.hbase.client.OperationWithAttributes;
Expand Down Expand Up @@ -778,13 +779,11 @@ public boolean isTableEnabled(ByteBuffer tableName) throws IOError {

@Override
public void compact(ByteBuffer tableNameOrRegionName) throws IOError {
byte[] tableNameOrRegionNameArray = getBytes(tableNameOrRegionName);
try {
try {
getAdmin().compactRegion(tableNameOrRegionNameArray);
} catch (IllegalArgumentException e) {
getAdmin().compact(TableName.valueOf(tableNameOrRegionNameArray));
}
// TODO: HBaseAdmin.compact(byte[]) deprecated and not trivial to replace here.
// ThriftServerRunner.compact should be deprecated and replaced with methods specific to
// table and region.
((HBaseAdmin) getAdmin()).compact(getBytes(tableNameOrRegionName));
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
Expand All @@ -793,13 +792,11 @@ public void compact(ByteBuffer tableNameOrRegionName) throws IOError {

@Override
public void majorCompact(ByteBuffer tableNameOrRegionName) throws IOError {
byte[] tableNameOrRegionNameArray = getBytes(tableNameOrRegionName);
try {
try {
getAdmin().majorCompactRegion(tableNameOrRegionNameArray);
} catch (IllegalArgumentException e) {
getAdmin().majorCompact(TableName.valueOf(tableNameOrRegionNameArray));
}
// TODO: HBaseAdmin.majorCompact(byte[]) deprecated and not trivial to replace here.
// ThriftServerRunner.majorCompact should be deprecated and replaced with methods specific
// to table and region.
((HBaseAdmin) getAdmin()).majorCompact(getBytes(tableNameOrRegionName));
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw new IOError(e.getMessage());
Expand Down

0 comments on commit 306c441

Please sign in to comment.