HBASE-1082 Administrative functions for table/region maintenance; Add byte array overloads for jgray

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@731987 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2009-01-06 16:22:59 +00:00
parent 8e047c5801
commit 7613afcf75
1 changed files with 43 additions and 7 deletions

View File

@ -547,15 +547,33 @@ public class HBaseAdmin {
* @throws IOException * @throws IOException
*/ */
public void flush(final String tableNameOrRegionName) throws IOException { public void flush(final String tableNameOrRegionName) throws IOException {
flush(Bytes.toBytes(tableNameOrRegionName));
}
/**
* Flush a table or an individual region
* @param tableNameOrRegionName
* @throws IOException
*/
public void flush(final byte [] tableNameOrRegionName) throws IOException {
modifyTable(tableNameOrRegionName, HConstants.MODIFY_TABLE_FLUSH); modifyTable(tableNameOrRegionName, HConstants.MODIFY_TABLE_FLUSH);
} }
/** /**
* Compact a table or an individual region * Compact a table or an individual region
* @param tableNameOrRegionName * @param tableNameOrRegionName
* @throws IOException * @throws IOException
*/ */
public void compact(final String tableNameOrRegionName) throws IOException { public void compact(final String tableNameOrRegionName) throws IOException {
compact(Bytes.toBytes(tableNameOrRegionName));
}
/**
* Compact a table or an individual region
* @param tableNameOrRegionName
* @throws IOException
*/
public void compact(final byte [] tableNameOrRegionName) throws IOException {
modifyTable(tableNameOrRegionName, HConstants.MODIFY_TABLE_COMPACT); modifyTable(tableNameOrRegionName, HConstants.MODIFY_TABLE_COMPACT);
} }
@ -565,6 +583,16 @@ public class HBaseAdmin {
* @throws IOException * @throws IOException
*/ */
public void majorCompact(final String tableNameOrRegionName) public void majorCompact(final String tableNameOrRegionName)
throws IOException {
majorCompact(Bytes.toBytes(tableNameOrRegionName));
}
/**
* Major compact a table or an individual region
* @param tableNameOrRegionName
* @throws IOException
*/
public void majorCompact(final byte [] tableNameOrRegionName)
throws IOException { throws IOException {
modifyTable(tableNameOrRegionName, HConstants.MODIFY_TABLE_MAJOR_COMPACT); modifyTable(tableNameOrRegionName, HConstants.MODIFY_TABLE_MAJOR_COMPACT);
} }
@ -575,10 +603,18 @@ public class HBaseAdmin {
* @throws IOException * @throws IOException
*/ */
public void split(final String tableNameOrRegionName) throws IOException { public void split(final String tableNameOrRegionName) throws IOException {
split(Bytes.toBytes(tableNameOrRegionName));
}
/**
* Split a table or an individual region
* @param tableNameOrRegionName
* @throws IOException
*/
public void split(final byte [] tableNameOrRegionName) throws IOException {
modifyTable(tableNameOrRegionName, HConstants.MODIFY_TABLE_SPLIT); modifyTable(tableNameOrRegionName, HConstants.MODIFY_TABLE_SPLIT);
} }
/* /*
* Call modifyTable using passed tableName or region name String. If no * Call modifyTable using passed tableName or region name String. If no
* such table, presume we have been passed a region name. * such table, presume we have been passed a region name.
@ -586,16 +622,16 @@ public class HBaseAdmin {
* @param op * @param op
* @throws IOException * @throws IOException
*/ */
private void modifyTable(final String tableNameOrRegionName, final int op) private void modifyTable(final byte [] tableNameOrRegionName, final int op)
throws IOException { throws IOException {
if (tableNameOrRegionName == null) { if (tableNameOrRegionName == null) {
throw new IllegalArgumentException("Pass a table name or region name"); throw new IllegalArgumentException("Pass a table name or region name");
} }
String tableName = tableExists(tableNameOrRegionName)? byte [] tableName = tableExists(tableNameOrRegionName)?
tableNameOrRegionName: null; tableNameOrRegionName: null;
String regionName = tableName == null? tableNameOrRegionName: null; byte [] regionName = tableName == null? tableNameOrRegionName: null;
Object [] args = regionName == null? null: new String [] {regionName}; Object [] args = regionName == null? null: new byte [][] {regionName};
modifyTable(tableName == null? null: Bytes.toBytes(tableName), op, args); modifyTable(tableName == null? null: tableName, op, args);
} }
/** /**