HBASE-14998 Unify synchronous and asynchronous methods in Admin and cleanup
This is based on patch sent me by Balazs Meszaros. The good stuff in here is from him. This patch does less than his ambition. It changes Admin class only. Can work on making AsyncAdmin cohere in a follow-on. * Deprecates getAlterStatus. Everywhere else we talk of 'modify' rather 'alter' and should use Future returned from async instead. * isTableAvailable(TableName, byte [][]) has been deprecated to be removed; use the overrie instead. This is a weird method. * Changed listTableDescriptor to getDescriptor. * Renamed other like methods to have same pattern (deprecating the old): balancer => balance setBalancerRunning => balancerSwitch setNormalizerRunning => normalizerSwitch enableCatalogJanitor => catalogJanitorSwitch setCleanerChoreRunning => cleanerChoreSwitch setSplitOrMergeEnabled => splitOrMergeEnabledSwitch * Renamed (with deprecation of old) runCatalogScan => runCatalogJanitor. * Reviewed generated javadoc and made some edits; purged reference to hbase issues from our API, fixed param names, etc. * Made all the enable services methods have same pattern. * Renamed takeSnapshotAsync as snapshotAsync (with deprecation of old) * Renamed execProcedureWithRet as execProcedureWithReturn (with deprecation) Signed-off-by: Michael Stack <stack@apache.org>
This commit is contained in:
parent
8bbfc836db
commit
780be085ed
|
@ -177,7 +177,7 @@ public class RestoreTool {
|
|||
LOG.debug("Found descriptor " + tableDescriptor + " through " + incrBackupId);
|
||||
|
||||
TableName newTableName = newTableNames[i];
|
||||
TableDescriptor newTableDescriptor = admin.listTableDescriptor(newTableName);
|
||||
TableDescriptor newTableDescriptor = admin.getDescriptor(newTableName);
|
||||
List<ColumnFamilyDescriptor> families = Arrays.asList(tableDescriptor.getColumnFamilies());
|
||||
List<ColumnFamilyDescriptor> existingFamilies =
|
||||
Arrays.asList(newTableDescriptor.getColumnFamilies());
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -342,7 +342,7 @@ public class HBaseAdmin implements Admin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public TableDescriptor listTableDescriptor(TableName tableName) throws TableNotFoundException, IOException {
|
||||
public TableDescriptor getDescriptor(TableName tableName) throws TableNotFoundException, IOException {
|
||||
return getTableDescriptor(tableName, getConnection(), rpcCallerFactory, rpcControllerFactory,
|
||||
operationTimeout, rpcTimeout);
|
||||
}
|
||||
|
@ -1410,7 +1410,7 @@ public class HBaseAdmin implements Admin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean setBalancerRunning(final boolean on, final boolean synchronous)
|
||||
public boolean balancerSwitch(final boolean on, final boolean synchronous)
|
||||
throws IOException {
|
||||
return executeCallable(new MasterCallable<Boolean>(getConnection(), getRpcControllerFactory()) {
|
||||
@Override
|
||||
|
@ -1423,7 +1423,7 @@ public class HBaseAdmin implements Admin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean balancer() throws IOException {
|
||||
public boolean balance() throws IOException {
|
||||
return executeCallable(new MasterCallable<Boolean>(getConnection(), getRpcControllerFactory()) {
|
||||
@Override
|
||||
protected Boolean rpcCall() throws Exception {
|
||||
|
@ -1434,7 +1434,7 @@ public class HBaseAdmin implements Admin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean balancer(final boolean force) throws IOException {
|
||||
public boolean balance(final boolean force) throws IOException {
|
||||
return executeCallable(new MasterCallable<Boolean>(getConnection(), getRpcControllerFactory()) {
|
||||
@Override
|
||||
protected Boolean rpcCall() throws Exception {
|
||||
|
@ -1478,7 +1478,7 @@ public class HBaseAdmin implements Admin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean setNormalizerRunning(final boolean on) throws IOException {
|
||||
public boolean normalizerSwitch(final boolean on) throws IOException {
|
||||
return executeCallable(new MasterCallable<Boolean>(getConnection(), getRpcControllerFactory()) {
|
||||
@Override
|
||||
protected Boolean rpcCall() throws Exception {
|
||||
|
@ -1490,7 +1490,7 @@ public class HBaseAdmin implements Admin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean enableCatalogJanitor(final boolean enable) throws IOException {
|
||||
public boolean catalogJanitorSwitch(final boolean enable) throws IOException {
|
||||
return executeCallable(new MasterCallable<Boolean>(getConnection(), getRpcControllerFactory()) {
|
||||
@Override
|
||||
protected Boolean rpcCall() throws Exception {
|
||||
|
@ -1501,7 +1501,7 @@ public class HBaseAdmin implements Admin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int runCatalogScan() throws IOException {
|
||||
public int runCatalogJanitor() throws IOException {
|
||||
return executeCallable(new MasterCallable<Integer>(getConnection(), getRpcControllerFactory()) {
|
||||
@Override
|
||||
protected Integer rpcCall() throws Exception {
|
||||
|
@ -1523,7 +1523,7 @@ public class HBaseAdmin implements Admin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean setCleanerChoreRunning(final boolean on) throws IOException {
|
||||
public boolean cleanerChoreSwitch(final boolean on) throws IOException {
|
||||
return executeCallable(new MasterCallable<Boolean>(getConnection(), getRpcControllerFactory()) {
|
||||
@Override public Boolean rpcCall() throws Exception {
|
||||
return master.setCleanerChoreRunning(getRpcController(), RequestConverter
|
||||
|
@ -2556,7 +2556,7 @@ public class HBaseAdmin implements Admin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void takeSnapshotAsync(SnapshotDescription snapshotDesc) throws IOException,
|
||||
public void snapshotAsync(SnapshotDescription snapshotDesc) throws IOException,
|
||||
SnapshotCreationException {
|
||||
asyncSnapshot(ProtobufUtil.createHBaseProtosSnapshotDesc(snapshotDesc));
|
||||
}
|
||||
|
@ -2763,7 +2763,7 @@ public class HBaseAdmin implements Admin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public byte[] execProcedureWithRet(String signature, String instance, Map<String, String> props)
|
||||
public byte[] execProcedureWithReturn(String signature, String instance, Map<String, String> props)
|
||||
throws IOException {
|
||||
ProcedureDescription desc = ProtobufUtil.buildProcedureDescription(signature, instance, props);
|
||||
final ExecProcedureRequest request =
|
||||
|
@ -3645,7 +3645,7 @@ public class HBaseAdmin implements Admin {
|
|||
* @return the table descriptor
|
||||
*/
|
||||
protected TableDescriptor getTableDescriptor() throws IOException {
|
||||
return getAdmin().listTableDescriptor(getTableName());
|
||||
return getAdmin().getDescriptor(getTableName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3843,7 +3843,7 @@ public class HBaseAdmin implements Admin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean[] setSplitOrMergeEnabled(final boolean enabled, final boolean synchronous,
|
||||
public boolean[] splitOrMergeEnabledSwitch(final boolean enabled, final boolean synchronous,
|
||||
final MasterSwitchType... switchTypes)
|
||||
throws IOException {
|
||||
return executeCallable(new MasterCallable<boolean[]>(getConnection(),
|
||||
|
@ -3865,7 +3865,7 @@ public class HBaseAdmin implements Admin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isSplitOrMergeEnabled(final MasterSwitchType switchType) throws IOException {
|
||||
public boolean splitOrMergeEnabledSwitch(final MasterSwitchType switchType) throws IOException {
|
||||
return executeCallable(new MasterCallable<Boolean>(getConnection(), getRpcControllerFactory()) {
|
||||
@Override
|
||||
protected Boolean rpcCall() throws Exception {
|
||||
|
|
|
@ -422,7 +422,7 @@ public class IntegrationTestDDLMasterFailover extends IntegrationTestBase {
|
|||
LOG.info("Creating table:" + td);
|
||||
admin.createTable(td, startKey, endKey, numRegions);
|
||||
Assert.assertTrue("Table: " + td + " was not created", admin.tableExists(tableName));
|
||||
TableDescriptor freshTableDesc = admin.listTableDescriptor(tableName);
|
||||
TableDescriptor freshTableDesc = admin.getDescriptor(tableName);
|
||||
Assert.assertTrue(
|
||||
"After create, Table: " + tableName + " in not enabled", admin.isTableEnabled(tableName));
|
||||
enabledTables.put(tableName, freshTableDesc);
|
||||
|
@ -461,7 +461,7 @@ public class IntegrationTestDDLMasterFailover extends IntegrationTestBase {
|
|||
admin.disableTable(tableName);
|
||||
Assert.assertTrue("Table: " + selected + " was not disabled",
|
||||
admin.isTableDisabled(tableName));
|
||||
TableDescriptor freshTableDesc = admin.listTableDescriptor(tableName);
|
||||
TableDescriptor freshTableDesc = admin.getDescriptor(tableName);
|
||||
Assert.assertTrue(
|
||||
"After disable, Table: " + tableName + " is not disabled",
|
||||
admin.isTableDisabled(tableName));
|
||||
|
@ -510,7 +510,7 @@ public class IntegrationTestDDLMasterFailover extends IntegrationTestBase {
|
|||
admin.enableTable(tableName);
|
||||
Assert.assertTrue("Table: " + selected + " was not enabled",
|
||||
admin.isTableEnabled(tableName));
|
||||
TableDescriptor freshTableDesc = admin.listTableDescriptor(tableName);
|
||||
TableDescriptor freshTableDesc = admin.getDescriptor(tableName);
|
||||
Assert.assertTrue(
|
||||
"After enable, Table: " + tableName + " in not enabled", admin.isTableEnabled(tableName));
|
||||
enabledTables.put(tableName, freshTableDesc);
|
||||
|
@ -607,7 +607,7 @@ public class IntegrationTestDDLMasterFailover extends IntegrationTestBase {
|
|||
LOG.info("Adding column family: " + cfd + " to table: " + tableName);
|
||||
admin.addColumnFamily(tableName, cfd);
|
||||
// assertion
|
||||
TableDescriptor freshTableDesc = admin.listTableDescriptor(tableName);
|
||||
TableDescriptor freshTableDesc = admin.getDescriptor(tableName);
|
||||
Assert.assertTrue("Column family: " + cfd + " was not added",
|
||||
freshTableDesc.hasColumnFamily(cfd.getName()));
|
||||
Assert.assertTrue(
|
||||
|
@ -659,7 +659,7 @@ public class IntegrationTestDDLMasterFailover extends IntegrationTestBase {
|
|||
admin.modifyTable(td);
|
||||
|
||||
// assertion
|
||||
TableDescriptor freshTableDesc = admin.listTableDescriptor(tableName);
|
||||
TableDescriptor freshTableDesc = admin.getDescriptor(tableName);
|
||||
ColumnFamilyDescriptor freshColumnDesc = freshTableDesc.getColumnFamily(columnDesc.getName());
|
||||
Assert.assertEquals("Column family: " + columnDesc + " was not altered",
|
||||
freshColumnDesc.getMaxVersions(), versions);
|
||||
|
@ -750,7 +750,7 @@ public class IntegrationTestDDLMasterFailover extends IntegrationTestBase {
|
|||
LOG.info("Deleting column family: " + cfd + " from table: " + tableName);
|
||||
admin.deleteColumnFamily(tableName, cfd.getName());
|
||||
// assertion
|
||||
TableDescriptor freshTableDesc = admin.listTableDescriptor(tableName);
|
||||
TableDescriptor freshTableDesc = admin.getDescriptor(tableName);
|
||||
Assert.assertFalse("Column family: " + cfd + " was not added",
|
||||
freshTableDesc.hasColumnFamily(cfd.getName()));
|
||||
Assert.assertTrue(
|
||||
|
@ -801,7 +801,7 @@ public class IntegrationTestDDLMasterFailover extends IntegrationTestBase {
|
|||
put.addColumn(family, qualifier, value);
|
||||
table.put(put);
|
||||
}
|
||||
TableDescriptor freshTableDesc = admin.listTableDescriptor(tableName);
|
||||
TableDescriptor freshTableDesc = admin.getDescriptor(tableName);
|
||||
Assert.assertTrue(
|
||||
"After insert, Table: " + tableName + " in not enabled", admin.isTableEnabled(tableName));
|
||||
enabledTables.put(tableName, freshTableDesc);
|
||||
|
|
|
@ -254,7 +254,7 @@ public class Action {
|
|||
HBaseTestingUtility util = this.context.getHBaseIntegrationTestingUtility();
|
||||
Admin admin = util.getAdmin();
|
||||
|
||||
TableDescriptor tableDescriptor = admin.listTableDescriptor(tableName);
|
||||
TableDescriptor tableDescriptor = admin.getDescriptor(tableName);
|
||||
ColumnFamilyDescriptor[] columnDescriptors = tableDescriptor.getColumnFamilies();
|
||||
|
||||
if (columnDescriptors == null || columnDescriptors.length == 0) {
|
||||
|
|
|
@ -52,7 +52,7 @@ public class RemoveColumnAction extends Action {
|
|||
|
||||
@Override
|
||||
public void perform() throws Exception {
|
||||
TableDescriptor tableDescriptor = admin.listTableDescriptor(tableName);
|
||||
TableDescriptor tableDescriptor = admin.getDescriptor(tableName);
|
||||
ColumnFamilyDescriptor[] columnDescriptors = tableDescriptor.getColumnFamilies();
|
||||
|
||||
if (columnDescriptors.length <= (protectedColumns == null ? 1 : protectedColumns.size())) {
|
||||
|
|
|
@ -161,7 +161,7 @@ public class CopyTable extends Configured implements Tool {
|
|||
try (Connection conn = ConnectionFactory.createConnection(getConf());
|
||||
Admin admin = conn.getAdmin()) {
|
||||
HFileOutputFormat2.configureIncrementalLoadMap(job,
|
||||
admin.listTableDescriptor((TableName.valueOf(dstTableName))));
|
||||
admin.getDescriptor((TableName.valueOf(dstTableName))));
|
||||
}
|
||||
} else {
|
||||
TableMapReduceUtil.initTableMapperJob(tableName, scan,
|
||||
|
|
|
@ -98,7 +98,7 @@ public class ExpiredMobFileCleaner extends Configured implements Tool {
|
|||
Connection connection = ConnectionFactory.createConnection(getConf());
|
||||
Admin admin = connection.getAdmin();
|
||||
try {
|
||||
TableDescriptor htd = admin.listTableDescriptor(tn);
|
||||
TableDescriptor htd = admin.getDescriptor(tn);
|
||||
ColumnFamilyDescriptor family = htd.getColumnFamily(Bytes.toBytes(familyName));
|
||||
if (family == null || !family.isMobEnabled()) {
|
||||
throw new IOException("Column family " + familyName + " is not a MOB column family");
|
||||
|
|
|
@ -154,7 +154,7 @@ public class TestHColumnDescriptorDefaultVersions {
|
|||
Admin admin = TEST_UTIL.getAdmin();
|
||||
|
||||
// Verify descriptor from master
|
||||
TableDescriptor htd = admin.listTableDescriptor(tableName);
|
||||
TableDescriptor htd = admin.getDescriptor(tableName);
|
||||
ColumnFamilyDescriptor[] hcds = htd.getColumnFamilies();
|
||||
verifyHColumnDescriptor(expected, hcds, tableName, families);
|
||||
|
||||
|
|
|
@ -319,14 +319,14 @@ public class TestReplicaWithCluster {
|
|||
Assert.assertFalse(r.isStale());
|
||||
|
||||
// Add a CF, it should work.
|
||||
TableDescriptor bHdt = HTU.getAdmin().listTableDescriptor(td.getTableName());
|
||||
TableDescriptor bHdt = HTU.getAdmin().getDescriptor(td.getTableName());
|
||||
td = TableDescriptorBuilder.newBuilder(td)
|
||||
.addColumnFamily(ColumnFamilyDescriptorBuilder.of(row))
|
||||
.build();
|
||||
HTU.getAdmin().disableTable(td.getTableName());
|
||||
HTU.getAdmin().modifyTable(td);
|
||||
HTU.getAdmin().enableTable(td.getTableName());
|
||||
TableDescriptor nHdt = HTU.getAdmin().listTableDescriptor(td.getTableName());
|
||||
TableDescriptor nHdt = HTU.getAdmin().getDescriptor(td.getTableName());
|
||||
Assert.assertEquals("fams=" + Arrays.toString(nHdt.getColumnFamilies()),
|
||||
bHdt.getColumnFamilyCount() + 1, nHdt.getColumnFamilyCount());
|
||||
|
||||
|
@ -350,7 +350,7 @@ public class TestReplicaWithCluster {
|
|||
}
|
||||
|
||||
Admin admin = HTU.getAdmin();
|
||||
nHdt =admin.listTableDescriptor(td.getTableName());
|
||||
nHdt =admin.getDescriptor(td.getTableName());
|
||||
Assert.assertEquals("fams=" + Arrays.toString(nHdt.getColumnFamilies()),
|
||||
bHdt.getColumnFamilyCount() + 1, nHdt.getColumnFamilyCount());
|
||||
|
||||
|
|
Loading…
Reference in New Issue