HBASE-18911 Unify Admin and AsyncAdmin's methods name

This commit is contained in:
Guanghao Zhang 2017-10-14 17:41:15 +08:00
parent f7ce3fd48a
commit 8b30adb834
14 changed files with 520 additions and 204 deletions

View File

@ -26,6 +26,7 @@ import java.util.EnumSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -58,6 +59,7 @@ import org.apache.hadoop.hbase.snapshot.HBaseSnapshotException;
import org.apache.hadoop.hbase.snapshot.RestoreSnapshotException; import org.apache.hadoop.hbase.snapshot.RestoreSnapshotException;
import org.apache.hadoop.hbase.snapshot.SnapshotCreationException; import org.apache.hadoop.hbase.snapshot.SnapshotCreationException;
import org.apache.hadoop.hbase.snapshot.UnknownSnapshotException; import org.apache.hadoop.hbase.snapshot.UnknownSnapshotException;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.Pair; import org.apache.hadoop.hbase.util.Pair;
/** /**
@ -916,15 +918,43 @@ public interface Admin extends Abortable, Closeable {
/** /**
* Compact all regions on the region server. Asynchronous operation in that this method requests * Compact all regions on the region server. Asynchronous operation in that this method requests
* that a Compaction run and then it returns. It does not wait on the completion of Compaction * that a Compaction run and then it returns. It does not wait on the completion of Compaction (it
* (it can take a while). * can take a while).
* @param sn the region server name * @param sn the region server name
* @param major if it's major compaction * @param major if it's major compaction
* @throws IOException * @throws IOException if a remote or network exception occurs
* @throws InterruptedException * @throws InterruptedException
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. Use
* {@link #compactRegionServer(ServerName)} or
* {@link #majorCompactRegionServer(ServerName)}.
*/ */
void compactRegionServer(ServerName sn, boolean major) @Deprecated
throws IOException, InterruptedException; default void compactRegionServer(ServerName sn, boolean major) throws IOException,
InterruptedException {
if (major) {
majorCompactRegionServer(sn);
} else {
compactRegionServer(sn);
}
}
/**
* Compact all regions on the region server. Asynchronous operation in that this method requests
* that a Compaction run and then it returns. It does not wait on the completion of Compaction (it
* can take a while).
* @param serverName the region server name
* @throws IOException if a remote or network exception occurs
*/
void compactRegionServer(ServerName serverName) throws IOException;
/**
* Major compact all regions on the region server. Asynchronous operation in that this method
* requests that a Compaction run and then it returns. It does not wait on the completion of
* Compaction (it can take a while).
* @param serverName the region server name
* @throws IOException if a remote or network exception occurs
*/
void majorCompactRegionServer(ServerName serverName) throws IOException;
/** /**
* Move the region <code>r</code> to <code>dest</code>. * Move the region <code>r</code> to <code>dest</code>.
@ -1380,14 +1410,75 @@ public interface Admin extends Abortable, Closeable {
*/ */
ClusterStatus getClusterStatus(EnumSet<Option> options) throws IOException; ClusterStatus getClusterStatus(EnumSet<Option> options) throws IOException;
/**
* @return current master server name
* @throws IOException if a remote or network exception occurs
*/
default ServerName getMaster() throws IOException {
return getClusterStatus(EnumSet.of(Option.MASTER)).getMaster();
}
/**
* @return current backup master list
* @throws IOException if a remote or network exception occurs
*/
default Collection<ServerName> getBackupMasters() throws IOException {
return getClusterStatus(EnumSet.of(Option.BACKUP_MASTERS)).getBackupMasters();
}
/**
* @return current live region servers list
* @throws IOException if a remote or network exception occurs
*/
default Collection<ServerName> getRegionServers() throws IOException {
return getClusterStatus(EnumSet.of(Option.LIVE_SERVERS)).getServers();
}
/** /**
* Get {@link RegionLoad} of all regions hosted on a regionserver. * Get {@link RegionLoad} of all regions hosted on a regionserver.
* *
* @param serverName region server from which regionload is required. * @param serverName region server from which regionload is required.
* @return region load map of all regions hosted on a region server * @return region load map of all regions hosted on a region server
* @throws IOException if a remote or network exception occurs * @throws IOException if a remote or network exception occurs
* @deprecated since 2.0 version and will be removed in 3.0 version.
* use {@link #getRegionLoads(ServerName)}
*/ */
Map<byte[], RegionLoad> getRegionLoad(ServerName serverName) throws IOException; @Deprecated
default Map<byte[], RegionLoad> getRegionLoad(ServerName serverName) throws IOException {
return getRegionLoad(serverName, null);
}
/**
* Get {@link RegionLoad} of all regions hosted on a regionserver.
*
* @param serverName region server from which regionload is required.
* @return a region load list of all regions hosted on a region server
* @throws IOException if a remote or network exception occurs
*/
default List<RegionLoad> getRegionLoads(ServerName serverName) throws IOException {
return getRegionLoads(serverName, null);
}
/**
* Get {@link RegionLoad} of all regions hosted on a regionserver for a table.
*
* @param serverName region server from which regionload is required.
* @param tableName get region load of regions belonging to the table
* @return region load map of all regions of a table hosted on a region server
* @throws IOException if a remote or network exception occurs
* @deprecated since 2.0 version and will be removed in 3.0 version.
* use {@link #getRegionLoads(ServerName, TableName)}
*/
@Deprecated
default Map<byte[], RegionLoad> getRegionLoad(ServerName serverName, TableName tableName)
throws IOException {
List<RegionLoad> regionLoads = getRegionLoads(serverName, tableName);
Map<byte[], RegionLoad> resultMap = new TreeMap<>(Bytes.BYTES_COMPARATOR);
for (RegionLoad regionLoad : regionLoads) {
resultMap.put(regionLoad.getName(), regionLoad);
}
return resultMap;
}
/** /**
* Get {@link RegionLoad} of all regions hosted on a regionserver for a table. * Get {@link RegionLoad} of all regions hosted on a regionserver for a table.
@ -1397,7 +1488,7 @@ public interface Admin extends Abortable, Closeable {
* @return region load map of all regions of a table hosted on a region server * @return region load map of all regions of a table hosted on a region server
* @throws IOException if a remote or network exception occurs * @throws IOException if a remote or network exception occurs
*/ */
Map<byte[], RegionLoad> getRegionLoad(ServerName serverName, TableName tableName) throws IOException; List<RegionLoad> getRegionLoads(ServerName serverName, TableName tableName) throws IOException;
/** /**
* @return Configuration used by the instance. * @return Configuration used by the instance.
@ -2135,13 +2226,22 @@ public interface Admin extends Abortable, Closeable {
/** /**
* Return a QuotaRetriever to list the quotas based on the filter. * Return a QuotaRetriever to list the quotas based on the filter.
*
* @param filter the quota settings filter * @param filter the quota settings filter
* @return the quota retriever * @return the quota retriever
* @throws IOException if a remote or network exception occurs * @throws IOException if a remote or network exception occurs
* @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #getQuota(QuotaFilter)}.
*/ */
@Deprecated
QuotaRetriever getQuotaRetriever(QuotaFilter filter) throws IOException; QuotaRetriever getQuotaRetriever(QuotaFilter filter) throws IOException;
/**
* List the quotas based on the filter.
* @param filter the quota settings filter
* @return the QuotaSetting list
* @throws IOException if a remote or network exception occurs
*/
List<QuotaSettings> getQuota(QuotaFilter filter) throws IOException;
/** /**
* Creates and returns a {@link com.google.protobuf.RpcChannel} instance connected to the active * Creates and returns a {@link com.google.protobuf.RpcChannel} instance connected to the active
* master. <p> The obtained {@link com.google.protobuf.RpcChannel} instance can be used to access * master. <p> The obtained {@link com.google.protobuf.RpcChannel} instance can be used to access
@ -2285,49 +2385,82 @@ public interface Admin extends Abortable, Closeable {
/** /**
* Turn the Split or Merge switches on or off. * Turn the Split or Merge switches on or off.
*
* @param enabled enabled or not * @param enabled enabled or not
* @param synchronous If <code>true</code>, it waits until current split() call, if outstanding, to return. * @param synchronous If <code>true</code>, it waits until current split() call, if outstanding,
* to return.
* @param switchTypes switchType list {@link MasterSwitchType} * @param switchTypes switchType list {@link MasterSwitchType}
* @return Previous switch value array * @return Previous switch value array
* @deprecated Since 2.0.0. Will be removed in 3.0.0. Use * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #splitSwitch(boolean, boolean)}
* {@link #splitOrMergeEnabledSwitch(boolean, boolean, MasterSwitchType...)}. * or {@link #mergeSwitch(boolean, boolean)} instead.
*/ */
@Deprecated @Deprecated
default boolean[] setSplitOrMergeEnabled(boolean enabled, boolean synchronous, default boolean[] setSplitOrMergeEnabled(boolean enabled, boolean synchronous,
MasterSwitchType... switchTypes) throws IOException { MasterSwitchType... switchTypes) throws IOException {
return splitOrMergeEnabledSwitch(enabled, synchronous, switchTypes); boolean[] preValues = new boolean[switchTypes.length];
for (int i = 0; i < switchTypes.length; i++) {
switch (switchTypes[i]) {
case SPLIT:
preValues[i] = splitSwitch(enabled, synchronous);
break;
case MERGE:
preValues[i] = mergeSwitch(enabled, synchronous);
break;
default:
throw new UnsupportedOperationException("Unsupported switch type:" + switchTypes[i]);
}
}
return preValues;
} }
/** /**
* Turn the Split or Merge switches on or off. * Turn the split switch on or off.
*
* @param enabled enabled or not * @param enabled enabled or not
* @param synchronous If <code>true</code>, it waits until current split() call, if outstanding, to return. * @param synchronous If <code>true</code>, it waits until current split() call, if outstanding,
* @param switchTypes switchType list {@link MasterSwitchType} * to return.
* @return Previous switch value array * @return Previous switch value
*/ */
boolean[] splitOrMergeEnabledSwitch(boolean enabled, boolean synchronous, boolean splitSwitch(boolean enabled, boolean synchronous) throws IOException;
MasterSwitchType... switchTypes) throws IOException;
/**
* Turn the merge switch on or off.
* @param enabled enabled or not
* @param synchronous If <code>true</code>, it waits until current merge() call, if outstanding,
* to return.
* @return Previous switch value
*/
boolean mergeSwitch(boolean enabled, boolean synchronous) throws IOException;
/** /**
* Query the current state of the switch. * Query the current state of the switch.
* *
* @return <code>true</code> if the switch is enabled, <code>false</code> otherwise. * @return <code>true</code> if the switch is enabled, <code>false</code> otherwise.
* @deprecated Since 2.0.0. Will be removed in 3.0.0. Use * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use
* {@link #splitOrMergeEnabledSwitch(MasterSwitchType)}} instead. * {@link #isSplitEnabled()} or {@link #isMergeEnabled()} instead.
*/ */
@Deprecated @Deprecated
default boolean isSplitOrMergeEnabled(MasterSwitchType switchType) throws IOException { default boolean isSplitOrMergeEnabled(MasterSwitchType switchType) throws IOException {
return splitOrMergeEnabledSwitch(switchType); switch (switchType) {
case SPLIT:
return isSplitEnabled();
case MERGE:
return isMergeEnabled();
default:
break;
}
throw new UnsupportedOperationException("Unsupported switch type:" + switchType);
} }
/** /**
* Query the current state of the switch. * Query the current state of the split switch.
*
* @return <code>true</code> if the switch is enabled, <code>false</code> otherwise. * @return <code>true</code> if the switch is enabled, <code>false</code> otherwise.
*/ */
boolean splitOrMergeEnabledSwitch(MasterSwitchType switchType) throws IOException; boolean isSplitEnabled() throws IOException;
/**
* Query the current state of the merge switch.
* @return <code>true</code> if the switch is enabled, <code>false</code> otherwise.
*/
boolean isMergeEnabled() throws IOException;
/** /**
* Add a new replication peer for replicating data to slave cluster. * Add a new replication peer for replicating data to slave cluster.

View File

@ -19,6 +19,7 @@ package org.apache.hadoop.hbase.client;
import com.google.protobuf.RpcChannel; import com.google.protobuf.RpcChannel;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
@ -61,8 +62,8 @@ public interface AsyncAdmin {
* List all the userspace tables. * List all the userspace tables.
* @return - returns a list of TableDescriptors wrapped by a {@link CompletableFuture}. * @return - returns a list of TableDescriptors wrapped by a {@link CompletableFuture}.
*/ */
default CompletableFuture<List<TableDescriptor>> listTables() { default CompletableFuture<List<TableDescriptor>> listTableDescriptors() {
return listTables(false); return listTableDescriptors(false);
} }
/** /**
@ -70,7 +71,7 @@ public interface AsyncAdmin {
* @param includeSysTables False to match only against userspace tables * @param includeSysTables False to match only against userspace tables
* @return - returns a list of TableDescriptors wrapped by a {@link CompletableFuture}. * @return - returns a list of TableDescriptors wrapped by a {@link CompletableFuture}.
*/ */
CompletableFuture<List<TableDescriptor>> listTables(boolean includeSysTables); CompletableFuture<List<TableDescriptor>> listTableDescriptors(boolean includeSysTables);
/** /**
* List all the tables matching the given pattern. * List all the tables matching the given pattern.
@ -78,7 +79,15 @@ public interface AsyncAdmin {
* @param includeSysTables False to match only against userspace tables * @param includeSysTables False to match only against userspace tables
* @return - returns a list of TableDescriptors wrapped by a {@link CompletableFuture}. * @return - returns a list of TableDescriptors wrapped by a {@link CompletableFuture}.
*/ */
CompletableFuture<List<TableDescriptor>> listTables(Pattern pattern, boolean includeSysTables); CompletableFuture<List<TableDescriptor>> listTableDescriptors(Pattern pattern,
boolean includeSysTables);
/**
* Get list of table descriptors by namespace.
* @param name namespace name
* @return returns a list of TableDescriptors wrapped by a {@link CompletableFuture}.
*/
CompletableFuture<List<TableDescriptor>> listTableDescriptorsByNamespace(String name);
/** /**
* List all of the names of userspace tables. * List all of the names of userspace tables.
@ -104,12 +113,19 @@ public interface AsyncAdmin {
*/ */
CompletableFuture<List<TableName>> listTableNames(Pattern pattern, boolean includeSysTables); CompletableFuture<List<TableName>> listTableNames(Pattern pattern, boolean includeSysTables);
/**
* Get list of table names by namespace.
* @param name namespace name
* @return The list of table names in the namespace wrapped by a {@link CompletableFuture}.
*/
CompletableFuture<List<TableName>> listTableNamesByNamespace(String name);
/** /**
* Method for getting the tableDescriptor * Method for getting the tableDescriptor
* @param tableName as a {@link TableName} * @param tableName as a {@link TableName}
* @return the read-only tableDescriptor wrapped by a {@link CompletableFuture}. * @return the read-only tableDescriptor wrapped by a {@link CompletableFuture}.
*/ */
CompletableFuture<TableDescriptor> getTableDescriptor(TableName tableName); CompletableFuture<TableDescriptor> getDescriptor(TableName tableName);
/** /**
* Creates a new table. * Creates a new table.
@ -140,7 +156,7 @@ public interface AsyncAdmin {
*/ */
CompletableFuture<Void> createTable(TableDescriptor desc, byte[][] splitKeys); CompletableFuture<Void> createTable(TableDescriptor desc, byte[][] splitKeys);
/* /**
* Modify an existing table, more IRB friendly version. * Modify an existing table, more IRB friendly version.
* @param desc modified description of the table * @param desc modified description of the table
*/ */
@ -259,12 +275,12 @@ public interface AsyncAdmin {
/** /**
* Get all the online regions on a region server. * Get all the online regions on a region server.
*/ */
CompletableFuture<List<RegionInfo>> getOnlineRegions(ServerName serverName); CompletableFuture<List<RegionInfo>> getRegions(ServerName serverName);
/** /**
* Get the regions of a given table. * Get the regions of a given table.
*/ */
CompletableFuture<List<RegionInfo>> getTableRegions(TableName tableName); CompletableFuture<List<RegionInfo>> getRegions(TableName tableName);
/** /**
* Flush a table. * Flush a table.
@ -363,28 +379,28 @@ public interface AsyncAdmin {
* @param on * @param on
* @return Previous switch value wrapped by a {@link CompletableFuture} * @return Previous switch value wrapped by a {@link CompletableFuture}
*/ */
CompletableFuture<Boolean> setMergeOn(boolean on); CompletableFuture<Boolean> mergeSwitch(boolean on);
/** /**
* Query the current state of the Merge switch. * Query the current state of the Merge switch.
* @return true if the switch is on, false otherwise. The return value will be wrapped by a * @return true if the switch is on, false otherwise. The return value will be wrapped by a
* {@link CompletableFuture} * {@link CompletableFuture}
*/ */
CompletableFuture<Boolean> isMergeOn(); CompletableFuture<Boolean> isMergeEnabled();
/** /**
* Turn the Split switch on or off. * Turn the Split switch on or off.
* @param on * @param on
* @return Previous switch value wrapped by a {@link CompletableFuture} * @return Previous switch value wrapped by a {@link CompletableFuture}
*/ */
CompletableFuture<Boolean> setSplitOn(boolean on); CompletableFuture<Boolean> splitSwitch(boolean on);
/** /**
* Query the current state of the Split switch. * Query the current state of the Split switch.
* @return true if the switch is on, false otherwise. The return value will be wrapped by a * @return true if the switch is on, false otherwise. The return value will be wrapped by a
* {@link CompletableFuture} * {@link CompletableFuture}
*/ */
CompletableFuture<Boolean> isSplitOn(); CompletableFuture<Boolean> isSplitEnabled();
/** /**
* Merge two regions. * Merge two regions.
@ -746,7 +762,7 @@ public interface AsyncAdmin {
* @param props Property/Value pairs of properties passing to the procedure * @param props Property/Value pairs of properties passing to the procedure
* @return data returned after procedure execution. null if no return data. * @return data returned after procedure execution. null if no return data.
*/ */
CompletableFuture<byte[]> execProcedureWithRet(String signature, String instance, CompletableFuture<byte[]> execProcedureWithReturn(String signature, String instance,
Map<String, String> props); Map<String, String> props);
/** /**
@ -842,6 +858,14 @@ public interface AsyncAdmin {
return getClusterStatus(EnumSet.of(Option.LIVE_SERVERS)).thenApply(ClusterStatus::getServers); return getClusterStatus(EnumSet.of(Option.LIVE_SERVERS)).thenApply(ClusterStatus::getServers);
} }
/**
* @return a list of master coprocessors wrapped by {@link CompletableFuture}
*/
default CompletableFuture<List<String>> getMasterCoprocessors() {
return getClusterStatus(EnumSet.of(Option.MASTER_COPROCESSORS))
.thenApply(ClusterStatus::getMasterCoprocessors).thenApply(Arrays::asList);
}
/** /**
* Get the info port of the current master if one is available. * Get the info port of the current master if one is available.
* @return master info port * @return master info port
@ -966,7 +990,7 @@ public interface AsyncAdmin {
* @param on * @param on
* @return Previous balancer value wrapped by a {@link CompletableFuture}. * @return Previous balancer value wrapped by a {@link CompletableFuture}.
*/ */
CompletableFuture<Boolean> setBalancerOn(boolean on); CompletableFuture<Boolean> balancerSwitch(boolean on);
/** /**
* Invoke the balancer. Will run the balancer and if regions to move, it will go ahead and do the * Invoke the balancer. Will run the balancer and if regions to move, it will go ahead and do the
@ -993,21 +1017,21 @@ public interface AsyncAdmin {
* @return true if the balance switch is on, false otherwise. The return value will be wrapped by a * @return true if the balance switch is on, false otherwise. The return value will be wrapped by a
* {@link CompletableFuture}. * {@link CompletableFuture}.
*/ */
CompletableFuture<Boolean> isBalancerOn(); CompletableFuture<Boolean> isBalancerEnabled();
/** /**
* Set region normalizer on/off. * Set region normalizer on/off.
* @param on whether normalizer should be on or off * @param on whether normalizer should be on or off
* @return Previous normalizer value wrapped by a {@link CompletableFuture} * @return Previous normalizer value wrapped by a {@link CompletableFuture}
*/ */
CompletableFuture<Boolean> setNormalizerOn(boolean on); CompletableFuture<Boolean> normalizerSwitch(boolean on);
/** /**
* Query the current state of the region normalizer * Query the current state of the region normalizer
* @return true if region normalizer is on, false otherwise. The return value will be wrapped by a * @return true if region normalizer is on, false otherwise. The return value will be wrapped by a
* {@link CompletableFuture} * {@link CompletableFuture}
*/ */
CompletableFuture<Boolean> isNormalizerOn(); CompletableFuture<Boolean> isNormalizerEnabled();
/** /**
* Invoke region normalizer. Can NOT run for various reasons. Check logs. * Invoke region normalizer. Can NOT run for various reasons. Check logs.
@ -1021,14 +1045,14 @@ public interface AsyncAdmin {
* @param on * @param on
* @return Previous cleaner state wrapped by a {@link CompletableFuture} * @return Previous cleaner state wrapped by a {@link CompletableFuture}
*/ */
CompletableFuture<Boolean> setCleanerChoreOn(boolean on); CompletableFuture<Boolean> cleanerChoreSwitch(boolean on);
/** /**
* Query the current state of the cleaner chore. * Query the current state of the cleaner chore.
* @return true if cleaner chore is on, false otherwise. The return value will be wrapped by * @return true if cleaner chore is on, false otherwise. The return value will be wrapped by
* a {@link CompletableFuture} * a {@link CompletableFuture}
*/ */
CompletableFuture<Boolean> isCleanerChoreOn(); CompletableFuture<Boolean> isCleanerChoreEnabled();
/** /**
* Ask for cleaner chore to run. * Ask for cleaner chore to run.
@ -1042,14 +1066,14 @@ public interface AsyncAdmin {
* @param on * @param on
* @return the previous state wrapped by a {@link CompletableFuture} * @return the previous state wrapped by a {@link CompletableFuture}
*/ */
CompletableFuture<Boolean> setCatalogJanitorOn(boolean on); CompletableFuture<Boolean> catalogJanitorSwitch(boolean on);
/** /**
* Query on the catalog janitor state. * Query on the catalog janitor state.
* @return true if the catalog janitor is on, false otherwise. The return value will be * @return true if the catalog janitor is on, false otherwise. The return value will be
* wrapped by a {@link CompletableFuture} * wrapped by a {@link CompletableFuture}
*/ */
CompletableFuture<Boolean> isCatalogJanitorOn(); CompletableFuture<Boolean> isCatalogJanitorEnabled();
/** /**
* Ask for a scan of the catalog table. * Ask for a scan of the catalog table.

View File

@ -84,14 +84,19 @@ class AsyncHBaseAdmin implements AsyncAdmin {
} }
@Override @Override
public CompletableFuture<List<TableDescriptor>> listTables(boolean includeSysTables) { public CompletableFuture<List<TableDescriptor>> listTableDescriptors(boolean includeSysTables) {
return wrap(rawAdmin.listTables(includeSysTables)); return wrap(rawAdmin.listTableDescriptors(includeSysTables));
} }
@Override @Override
public CompletableFuture<List<TableDescriptor>> listTables(Pattern pattern, public CompletableFuture<List<TableDescriptor>> listTableDescriptors(Pattern pattern,
boolean includeSysTables) { boolean includeSysTables) {
return wrap(rawAdmin.listTables(pattern, includeSysTables)); return wrap(rawAdmin.listTableDescriptors(pattern, includeSysTables));
}
@Override
public CompletableFuture<List<TableDescriptor>> listTableDescriptorsByNamespace(String name) {
return wrap(rawAdmin.listTableDescriptorsByNamespace(name));
} }
@Override @Override
@ -106,8 +111,13 @@ class AsyncHBaseAdmin implements AsyncAdmin {
} }
@Override @Override
public CompletableFuture<TableDescriptor> getTableDescriptor(TableName tableName) { public CompletableFuture<List<TableName>> listTableNamesByNamespace(String name) {
return wrap(rawAdmin.getTableDescriptor(tableName)); return wrap(rawAdmin.listTableNamesByNamespace(name));
}
@Override
public CompletableFuture<TableDescriptor> getDescriptor(TableName tableName) {
return wrap(rawAdmin.getDescriptor(tableName));
} }
@Override @Override
@ -214,13 +224,13 @@ class AsyncHBaseAdmin implements AsyncAdmin {
} }
@Override @Override
public CompletableFuture<List<RegionInfo>> getOnlineRegions(ServerName serverName) { public CompletableFuture<List<RegionInfo>> getRegions(ServerName serverName) {
return wrap(rawAdmin.getOnlineRegions(serverName)); return wrap(rawAdmin.getRegions(serverName));
} }
@Override @Override
public CompletableFuture<List<RegionInfo>> getTableRegions(TableName tableName) { public CompletableFuture<List<RegionInfo>> getRegions(TableName tableName) {
return wrap(rawAdmin.getTableRegions(tableName)); return wrap(rawAdmin.getRegions(tableName));
} }
@Override @Override
@ -284,23 +294,23 @@ class AsyncHBaseAdmin implements AsyncAdmin {
} }
@Override @Override
public CompletableFuture<Boolean> setMergeOn(boolean on) { public CompletableFuture<Boolean> mergeSwitch(boolean on) {
return wrap(rawAdmin.setMergeOn(on)); return wrap(rawAdmin.mergeSwitch(on));
} }
@Override @Override
public CompletableFuture<Boolean> isMergeOn() { public CompletableFuture<Boolean> isMergeEnabled() {
return wrap(rawAdmin.isMergeOn()); return wrap(rawAdmin.isMergeEnabled());
} }
@Override @Override
public CompletableFuture<Boolean> setSplitOn(boolean on) { public CompletableFuture<Boolean> splitSwitch(boolean on) {
return wrap(rawAdmin.setSplitOn(on)); return wrap(rawAdmin.splitSwitch(on));
} }
@Override @Override
public CompletableFuture<Boolean> isSplitOn() { public CompletableFuture<Boolean> isSplitEnabled() {
return wrap(rawAdmin.isSplitOn()); return wrap(rawAdmin.isSplitEnabled());
} }
@Override @Override
@ -512,9 +522,9 @@ class AsyncHBaseAdmin implements AsyncAdmin {
} }
@Override @Override
public CompletableFuture<byte[]> execProcedureWithRet(String signature, String instance, public CompletableFuture<byte[]> execProcedureWithReturn(String signature, String instance,
Map<String, String> props) { Map<String, String> props) {
return wrap(rawAdmin.execProcedureWithRet(signature, instance, props)); return wrap(rawAdmin.execProcedureWithReturn(signature, instance, props));
} }
@Override @Override
@ -643,8 +653,8 @@ class AsyncHBaseAdmin implements AsyncAdmin {
} }
@Override @Override
public CompletableFuture<Boolean> setBalancerOn(boolean on) { public CompletableFuture<Boolean> balancerSwitch(boolean on) {
return wrap(rawAdmin.setBalancerOn(on)); return wrap(rawAdmin.balancerSwitch(on));
} }
@Override @Override
@ -653,18 +663,18 @@ class AsyncHBaseAdmin implements AsyncAdmin {
} }
@Override @Override
public CompletableFuture<Boolean> isBalancerOn() { public CompletableFuture<Boolean> isBalancerEnabled() {
return wrap(rawAdmin.isBalancerOn()); return wrap(rawAdmin.isBalancerEnabled());
} }
@Override @Override
public CompletableFuture<Boolean> setNormalizerOn(boolean on) { public CompletableFuture<Boolean> normalizerSwitch(boolean on) {
return wrap(rawAdmin.setNormalizerOn(on)); return wrap(rawAdmin.normalizerSwitch(on));
} }
@Override @Override
public CompletableFuture<Boolean> isNormalizerOn() { public CompletableFuture<Boolean> isNormalizerEnabled() {
return wrap(rawAdmin.isNormalizerOn()); return wrap(rawAdmin.isNormalizerEnabled());
} }
@Override @Override
@ -673,13 +683,13 @@ class AsyncHBaseAdmin implements AsyncAdmin {
} }
@Override @Override
public CompletableFuture<Boolean> setCleanerChoreOn(boolean enabled) { public CompletableFuture<Boolean> cleanerChoreSwitch(boolean enabled) {
return wrap(rawAdmin.setCleanerChoreOn(enabled)); return wrap(rawAdmin.cleanerChoreSwitch(enabled));
} }
@Override @Override
public CompletableFuture<Boolean> isCleanerChoreOn() { public CompletableFuture<Boolean> isCleanerChoreEnabled() {
return wrap(rawAdmin.isCleanerChoreOn()); return wrap(rawAdmin.isCleanerChoreEnabled());
} }
@Override @Override
@ -688,13 +698,13 @@ class AsyncHBaseAdmin implements AsyncAdmin {
} }
@Override @Override
public CompletableFuture<Boolean> setCatalogJanitorOn(boolean enabled) { public CompletableFuture<Boolean> catalogJanitorSwitch(boolean enabled) {
return wrap(rawAdmin.setCatalogJanitorOn(enabled)); return wrap(rawAdmin.catalogJanitorSwitch(enabled));
} }
@Override @Override
public CompletableFuture<Boolean> isCatalogJanitorOn() { public CompletableFuture<Boolean> isCatalogJanitorEnabled() {
return wrap(rawAdmin.isCatalogJanitorOn()); return wrap(rawAdmin.isCatalogJanitorEnabled());
} }
@Override @Override

View File

@ -30,11 +30,11 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future; import java.util.concurrent.Future;
@ -225,8 +225,6 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos;
public class HBaseAdmin implements Admin { public class HBaseAdmin implements Admin {
private static final Log LOG = LogFactory.getLog(HBaseAdmin.class); private static final Log LOG = LogFactory.getLog(HBaseAdmin.class);
private static final String ZK_IDENTIFIER_PREFIX = "hbase-admin-on-";
private ClusterConnection connection; private ClusterConnection connection;
private volatile Configuration conf; private volatile Configuration conf;
@ -1230,14 +1228,17 @@ public class HBaseAdmin implements Admin {
compactRegion(regionName, columnFamily, false); compactRegion(regionName, columnFamily, false);
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void compactRegionServer(final ServerName sn, boolean major) public void compactRegionServer(final ServerName serverName) throws IOException {
throws IOException, InterruptedException { for (RegionInfo region : getRegions(serverName)) {
for (RegionInfo region : getRegions(sn)) { compact(this.connection.getAdmin(serverName), region, false, null);
compact(this.connection.getAdmin(sn), region, major, null); }
}
@Override
public void majorCompactRegionServer(final ServerName serverName) throws IOException {
for (RegionInfo region : getRegions(serverName)) {
compact(this.connection.getAdmin(serverName), region, true, null);
} }
} }
@ -2085,21 +2086,11 @@ public class HBaseAdmin implements Admin {
} }
@Override @Override
public Map<byte[], RegionLoad> getRegionLoad(final ServerName sn) throws IOException { public List<RegionLoad> getRegionLoads(ServerName serverName, TableName tableName)
return getRegionLoad(sn, null);
}
@Override
public Map<byte[], RegionLoad> getRegionLoad(final ServerName sn, final TableName tableName)
throws IOException { throws IOException {
AdminService.BlockingInterface admin = this.connection.getAdmin(sn); AdminService.BlockingInterface admin = this.connection.getAdmin(serverName);
HBaseRpcController controller = rpcControllerFactory.newController(); HBaseRpcController controller = rpcControllerFactory.newController();
List<RegionLoad> regionLoads = ProtobufUtil.getRegionLoad(controller, admin, tableName); return ProtobufUtil.getRegionLoad(controller, admin, tableName);
Map<byte[], RegionLoad> resultMap = new TreeMap<>(Bytes.BYTES_COMPARATOR);
for (RegionLoad regionLoad : regionLoads) {
resultMap.put(regionLoad.getName(), regionLoad);
}
return resultMap;
} }
@Override @Override
@ -3035,6 +3026,18 @@ public class HBaseAdmin implements Admin {
return QuotaRetriever.open(conf, filter); return QuotaRetriever.open(conf, filter);
} }
@Override
public List<QuotaSettings> getQuota(QuotaFilter filter) throws IOException {
List<QuotaSettings> quotas = new LinkedList<>();
try (QuotaRetriever retriever = QuotaRetriever.open(conf, filter)) {
Iterator<QuotaSettings> iterator = retriever.iterator();
while (iterator.hasNext()) {
quotas.add(iterator.next());
}
}
return quotas;
}
private <C extends RetryingCallable<V> & Closeable, V> V executeCallable(C callable) private <C extends RetryingCallable<V> & Closeable, V> V executeCallable(C callable)
throws IOException { throws IOException {
return executeCallable(callable, rpcCallerFactory, operationTimeout, rpcTimeout); return executeCallable(callable, rpcCallerFactory, operationTimeout, rpcTimeout);
@ -3793,34 +3796,46 @@ public class HBaseAdmin implements Admin {
} }
@Override @Override
public boolean[] splitOrMergeEnabledSwitch(final boolean enabled, final boolean synchronous, public boolean splitSwitch(boolean enabled, boolean synchronous) throws IOException {
final MasterSwitchType... switchTypes) return splitOrMergeSwitch(enabled, synchronous, MasterSwitchType.SPLIT);
throws IOException { }
return executeCallable(new MasterCallable<boolean[]>(getConnection(),
getRpcControllerFactory()) { @Override
public boolean mergeSwitch(boolean enabled, boolean synchronous) throws IOException {
return splitOrMergeSwitch(enabled, synchronous, MasterSwitchType.MERGE);
}
private boolean splitOrMergeSwitch(boolean enabled, boolean synchronous,
MasterSwitchType switchType) throws IOException {
return executeCallable(new MasterCallable<Boolean>(getConnection(), getRpcControllerFactory()) {
@Override @Override
protected boolean[] rpcCall() throws Exception { protected Boolean rpcCall() throws Exception {
MasterProtos.SetSplitOrMergeEnabledResponse response = MasterProtos.SetSplitOrMergeEnabledResponse response = master.setSplitOrMergeEnabled(
master.setSplitOrMergeEnabled(getRpcController(), getRpcController(),
RequestConverter.buildSetSplitOrMergeEnabledRequest(enabled, synchronous, RequestConverter.buildSetSplitOrMergeEnabledRequest(enabled, synchronous, switchType));
switchTypes)); return response.getPrevValueList().get(0);
boolean[] result = new boolean[switchTypes.length];
int i = 0;
for (Boolean prevValue : response.getPrevValueList()) {
result[i++] = prevValue;
}
return result;
} }
}); });
} }
@Override @Override
public boolean splitOrMergeEnabledSwitch(final MasterSwitchType switchType) throws IOException { public boolean isSplitEnabled() throws IOException {
return executeCallable(new MasterCallable<Boolean>(getConnection(), getRpcControllerFactory()) { return executeCallable(new MasterCallable<Boolean>(getConnection(), getRpcControllerFactory()) {
@Override @Override
protected Boolean rpcCall() throws Exception { protected Boolean rpcCall() throws Exception {
return master.isSplitOrMergeEnabled(getRpcController(), return master.isSplitOrMergeEnabled(getRpcController(),
RequestConverter.buildIsSplitOrMergeEnabledRequest(switchType)).getEnabled(); RequestConverter.buildIsSplitOrMergeEnabledRequest(MasterSwitchType.SPLIT)).getEnabled();
}
});
}
@Override
public boolean isMergeEnabled() throws IOException {
return executeCallable(new MasterCallable<Boolean>(getConnection(), getRpcControllerFactory()) {
@Override
protected Boolean rpcCall() throws Exception {
return master.isSplitOrMergeEnabled(getRpcController(),
RequestConverter.buildIsSplitOrMergeEnabledRequest(MasterSwitchType.MERGE)).getEnabled();
} }
}); });
} }

View File

@ -184,6 +184,10 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListDecomm
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListDecommissionedRegionServersResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListDecommissionedRegionServersResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListNamespaceDescriptorsRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListNamespaceDescriptorsRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListNamespaceDescriptorsResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListNamespaceDescriptorsResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListTableDescriptorsByNamespaceRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListTableDescriptorsByNamespaceResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListTableNamesByNamespaceRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListTableNamesByNamespaceResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MajorCompactionTimestampForRegionRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MajorCompactionTimestampForRegionRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MajorCompactionTimestampRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MajorCompactionTimestampRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MajorCompactionTimestampResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MajorCompactionTimestampResponse;
@ -399,7 +403,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
} }
@Override @Override
public CompletableFuture<List<TableDescriptor>> listTables(boolean includeSysTables) { public CompletableFuture<List<TableDescriptor>> listTableDescriptors(boolean includeSysTables) {
return getTableDescriptors(RequestConverter.buildGetTableDescriptorsRequest(null, return getTableDescriptors(RequestConverter.buildGetTableDescriptorsRequest(null,
includeSysTables)); includeSysTables));
} }
@ -408,7 +412,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
* {@link #listTables(boolean)} * {@link #listTables(boolean)}
*/ */
@Override @Override
public CompletableFuture<List<TableDescriptor>> listTables(Pattern pattern, public CompletableFuture<List<TableDescriptor>> listTableDescriptors(Pattern pattern,
boolean includeSysTables) { boolean includeSysTables) {
Preconditions.checkNotNull(pattern, Preconditions.checkNotNull(pattern,
"pattern is null. If you don't specify a pattern, use listTables(boolean) instead"); "pattern is null. If you don't specify a pattern, use listTables(boolean) instead");
@ -450,7 +454,31 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
} }
@Override @Override
public CompletableFuture<TableDescriptor> getTableDescriptor(TableName tableName) { public CompletableFuture<List<TableDescriptor>> listTableDescriptorsByNamespace(String name) {
return this.<List<TableDescriptor>> newMasterCaller().action((controller, stub) -> this
.<ListTableDescriptorsByNamespaceRequest, ListTableDescriptorsByNamespaceResponse,
List<TableDescriptor>> call(
controller, stub,
ListTableDescriptorsByNamespaceRequest.newBuilder().setNamespaceName(name).build(),
(s, c, req, done) -> s.listTableDescriptorsByNamespace(c, req, done),
(resp) -> ProtobufUtil.toTableDescriptorList(resp)))
.call();
}
@Override
public CompletableFuture<List<TableName>> listTableNamesByNamespace(String name) {
return this.<List<TableName>> newMasterCaller().action((controller, stub) -> this
.<ListTableNamesByNamespaceRequest, ListTableNamesByNamespaceResponse,
List<TableName>> call(
controller, stub,
ListTableNamesByNamespaceRequest.newBuilder().setNamespaceName(name).build(),
(s, c, req, done) -> s.listTableNamesByNamespace(c, req, done),
(resp) -> ProtobufUtil.toTableNameList(resp.getTableNameList())))
.call();
}
@Override
public CompletableFuture<TableDescriptor> getDescriptor(TableName tableName) {
CompletableFuture<TableDescriptor> future = new CompletableFuture<>(); CompletableFuture<TableDescriptor> future = new CompletableFuture<>();
this.<List<TableSchema>> newMasterCaller() this.<List<TableSchema>> newMasterCaller()
.action( .action(
@ -727,7 +755,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
} }
@Override @Override
public CompletableFuture<List<RegionInfo>> getOnlineRegions(ServerName serverName) { public CompletableFuture<List<RegionInfo>> getRegions(ServerName serverName) {
return this.<List<RegionInfo>> newAdminCaller() return this.<List<RegionInfo>> newAdminCaller()
.action((controller, stub) -> this .action((controller, stub) -> this
.<GetOnlineRegionRequest, GetOnlineRegionResponse, List<RegionInfo>> adminCall( .<GetOnlineRegionRequest, GetOnlineRegionResponse, List<RegionInfo>> adminCall(
@ -738,7 +766,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
} }
@Override @Override
public CompletableFuture<List<RegionInfo>> getTableRegions(TableName tableName) { public CompletableFuture<List<RegionInfo>> getRegions(TableName tableName) {
if (tableName.equals(META_TABLE_NAME)) { if (tableName.equals(META_TABLE_NAME)) {
return connection.getLocator().getRegionLocation(tableName, null, null, operationTimeoutNs) return connection.getLocator().getRegionLocation(tableName, null, null, operationTimeoutNs)
.thenApply(loc -> Collections.singletonList(loc.getRegion())); .thenApply(loc -> Collections.singletonList(loc.getRegion()));
@ -873,7 +901,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
private CompletableFuture<Void> compactRegionServer(ServerName sn, boolean major) { private CompletableFuture<Void> compactRegionServer(ServerName sn, boolean major) {
CompletableFuture<Void> future = new CompletableFuture<>(); CompletableFuture<Void> future = new CompletableFuture<>();
getOnlineRegions(sn).whenComplete((hRegionInfos, err) -> { getRegions(sn).whenComplete((hRegionInfos, err) -> {
if (err != null) { if (err != null) {
future.completeExceptionally(err); future.completeExceptionally(err);
return; return;
@ -1043,22 +1071,22 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
} }
@Override @Override
public CompletableFuture<Boolean> setMergeOn(boolean on) { public CompletableFuture<Boolean> mergeSwitch(boolean on) {
return setSplitOrMergeOn(on, MasterSwitchType.MERGE); return setSplitOrMergeOn(on, MasterSwitchType.MERGE);
} }
@Override @Override
public CompletableFuture<Boolean> isMergeOn() { public CompletableFuture<Boolean> isMergeEnabled() {
return isSplitOrMergeOn(MasterSwitchType.MERGE); return isSplitOrMergeOn(MasterSwitchType.MERGE);
} }
@Override @Override
public CompletableFuture<Boolean> setSplitOn(boolean on) { public CompletableFuture<Boolean> splitSwitch(boolean on) {
return setSplitOrMergeOn(on, MasterSwitchType.SPLIT); return setSplitOrMergeOn(on, MasterSwitchType.SPLIT);
} }
@Override @Override
public CompletableFuture<Boolean> isSplitOn() { public CompletableFuture<Boolean> isSplitEnabled() {
return isSplitOrMergeOn(MasterSwitchType.SPLIT); return isSplitOrMergeOn(MasterSwitchType.SPLIT);
} }
@ -1622,7 +1650,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
@Override @Override
public CompletableFuture<List<TableCFs>> listReplicatedTableCFs() { public CompletableFuture<List<TableCFs>> listReplicatedTableCFs() {
CompletableFuture<List<TableCFs>> future = new CompletableFuture<List<TableCFs>>(); CompletableFuture<List<TableCFs>> future = new CompletableFuture<List<TableCFs>>();
listTables().whenComplete( listTableDescriptors().whenComplete(
(tables, error) -> { (tables, error) -> {
if (!completeExceptionally(future, error)) { if (!completeExceptionally(future, error)) {
List<TableCFs> replicatedTableCFs = new ArrayList<>(); List<TableCFs> replicatedTableCFs = new ArrayList<>();
@ -2062,7 +2090,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
} }
@Override @Override
public CompletableFuture<byte[]> execProcedureWithRet(String signature, String instance, public CompletableFuture<byte[]> execProcedureWithReturn(String signature, String instance,
Map<String, String> props) { Map<String, String> props) {
ProcedureDescription proDesc = ProcedureDescription proDesc =
ProtobufUtil.buildProcedureDescription(signature, instance, props); ProtobufUtil.buildProcedureDescription(signature, instance, props);
@ -2861,7 +2889,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
} }
@Override @Override
public CompletableFuture<Boolean> setBalancerOn(final boolean on) { public CompletableFuture<Boolean> balancerSwitch(final boolean on) {
return this return this
.<Boolean> newMasterCaller() .<Boolean> newMasterCaller()
.action( .action(
@ -2883,7 +2911,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
} }
@Override @Override
public CompletableFuture<Boolean> isBalancerOn() { public CompletableFuture<Boolean> isBalancerEnabled() {
return this return this
.<Boolean> newMasterCaller() .<Boolean> newMasterCaller()
.action( .action(
@ -2894,7 +2922,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
} }
@Override @Override
public CompletableFuture<Boolean> setNormalizerOn(boolean on) { public CompletableFuture<Boolean> normalizerSwitch(boolean on) {
return this return this
.<Boolean> newMasterCaller() .<Boolean> newMasterCaller()
.action( .action(
@ -2906,7 +2934,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
} }
@Override @Override
public CompletableFuture<Boolean> isNormalizerOn() { public CompletableFuture<Boolean> isNormalizerEnabled() {
return this return this
.<Boolean> newMasterCaller() .<Boolean> newMasterCaller()
.action( .action(
@ -2929,7 +2957,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
} }
@Override @Override
public CompletableFuture<Boolean> setCleanerChoreOn(boolean enabled) { public CompletableFuture<Boolean> cleanerChoreSwitch(boolean enabled) {
return this return this
.<Boolean> newMasterCaller() .<Boolean> newMasterCaller()
.action( .action(
@ -2941,7 +2969,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
} }
@Override @Override
public CompletableFuture<Boolean> isCleanerChoreOn() { public CompletableFuture<Boolean> isCleanerChoreEnabled() {
return this return this
.<Boolean> newMasterCaller() .<Boolean> newMasterCaller()
.action( .action(
@ -2965,7 +2993,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
} }
@Override @Override
public CompletableFuture<Boolean> setCatalogJanitorOn(boolean enabled) { public CompletableFuture<Boolean> catalogJanitorSwitch(boolean enabled) {
return this return this
.<Boolean> newMasterCaller() .<Boolean> newMasterCaller()
.action( .action(
@ -2977,7 +3005,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
} }
@Override @Override
public CompletableFuture<Boolean> isCatalogJanitorOn() { public CompletableFuture<Boolean> isCatalogJanitorEnabled() {
return this return this
.<Boolean> newMasterCaller() .<Boolean> newMasterCaller()
.action( .action(
@ -3125,7 +3153,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
private CompletableFuture<byte[][]> getTableSplits(TableName tableName) { private CompletableFuture<byte[][]> getTableSplits(TableName tableName) {
CompletableFuture<byte[][]> future = new CompletableFuture<>(); CompletableFuture<byte[][]> future = new CompletableFuture<>();
getTableRegions(tableName).whenComplete((regions, err2) -> { getRegions(tableName).whenComplete((regions, err2) -> {
if (err2 != null) { if (err2 != null) {
future.completeExceptionally(err2); future.completeExceptionally(err2);
return; return;
@ -3202,7 +3230,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
future.completeExceptionally(err); future.completeExceptionally(err);
return; return;
} }
getTableDescriptor(tableName).whenComplete( getDescriptor(tableName).whenComplete(
(tableDesc, err1) -> { (tableDesc, err1) -> {
if (err1 != null) { if (err1 != null) {
future.completeExceptionally(err1); future.completeExceptionally(err1);
@ -3249,7 +3277,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
private CompletableFuture<Void> compareTableWithPeerCluster(TableName tableName, private CompletableFuture<Void> compareTableWithPeerCluster(TableName tableName,
TableDescriptor tableDesc, ReplicationPeerDescription peer, AsyncAdmin peerAdmin) { TableDescriptor tableDesc, ReplicationPeerDescription peer, AsyncAdmin peerAdmin) {
CompletableFuture<Void> future = new CompletableFuture<>(); CompletableFuture<Void> future = new CompletableFuture<>();
peerAdmin.getTableDescriptor(tableName).whenComplete( peerAdmin.getDescriptor(tableName).whenComplete(
(peerTableDesc, err) -> { (peerTableDesc, err) -> {
if (err != null) { if (err != null) {
future.completeExceptionally(err); future.completeExceptionally(err);
@ -3280,7 +3308,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
*/ */
private CompletableFuture<Void> setTableReplication(TableName tableName, boolean enableRep) { private CompletableFuture<Void> setTableReplication(TableName tableName, boolean enableRep) {
CompletableFuture<Void> future = new CompletableFuture<>(); CompletableFuture<Void> future = new CompletableFuture<>();
getTableDescriptor(tableName).whenComplete( getDescriptor(tableName).whenComplete(
(tableDesc, err) -> { (tableDesc, err) -> {
if (err != null) { if (err != null) {
future.completeExceptionally(err); future.completeExceptionally(err);

View File

@ -163,6 +163,7 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.CreateTabl
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetCompletedSnapshotsResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetCompletedSnapshotsResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetTableDescriptorsResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetTableDescriptorsResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListNamespaceDescriptorsResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListNamespaceDescriptorsResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListTableDescriptorsByNamespaceResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MajorCompactionTimestampResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MajorCompactionTimestampResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos; import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos;
import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos; import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos;
@ -437,6 +438,20 @@ public final class ProtobufUtil {
* @return a list of TableDescriptor * @return a list of TableDescriptor
*/ */
public static List<TableDescriptor> toTableDescriptorList(GetTableDescriptorsResponse proto) { public static List<TableDescriptor> toTableDescriptorList(GetTableDescriptorsResponse proto) {
if (proto == null) {
return new ArrayList<>();
}
return proto.getTableSchemaList().stream().map(ProtobufUtil::toTableDescriptor)
.collect(Collectors.toList());
}
/**
* Get a list of TableDescriptor from ListTableDescriptorsByNamespaceResponse protobuf
* @param proto the ListTableDescriptorsByNamespaceResponse
* @return a list of TableDescriptor
*/
public static List<TableDescriptor>
toTableDescriptorList(ListTableDescriptorsByNamespaceResponse proto) {
if (proto == null) return new ArrayList<>(); if (proto == null) return new ArrayList<>();
return proto.getTableSchemaList().stream().map(ProtobufUtil::toTableDescriptor) return proto.getTableSchemaList().stream().map(ProtobufUtil::toTableDescriptor)
.collect(Collectors.toList()); .collect(Collectors.toList());

View File

@ -0,0 +1,91 @@
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.hbase.client;
import static org.junit.Assert.assertTrue;
import java.io.Closeable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.Abortable;
import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@Category({ ClientTests.class, SmallTests.class })
public class TestInterfaceAlign {
private static final Log LOG = LogFactory.getLog(TestInterfaceAlign.class);
/**
* Test methods name match up
*/
@Test
public void testAdminWithAsyncAdmin() {
List<String> adminMethodNames = getMethodNames(Admin.class);
List<String> asyncAdminMethodNames = getMethodNames(AsyncAdmin.class);
// Remove some special methods
adminMethodNames.remove("getOperationTimeout");
adminMethodNames.remove("getConnection");
adminMethodNames.remove("getConfiguration");
adminMethodNames.removeAll(getMethodNames(Abortable.class));
adminMethodNames.removeAll(getMethodNames(Closeable.class));
// TODO: Remove this after HBASE-19139
adminMethodNames.remove("clearBlockCache");
adminMethodNames.forEach(method -> {
boolean contains = asyncAdminMethodNames.contains(method);
if (method.endsWith("Async")) {
contains = asyncAdminMethodNames.contains(method.replace("Async", ""));
}
assertTrue("Admin method " + method + " should in AsyncAdmin too", contains);
});
asyncAdminMethodNames.forEach(method -> {
boolean contains = adminMethodNames.contains(method);
if (!contains) {
contains = adminMethodNames.contains(method + "Async");
}
assertTrue("AsyncAdmin method " + method + " should in Admin too", contains);
});
}
private <T> List<String> getMethodNames(Class<T> c) {
return Arrays.asList(c.getDeclaredMethods()).stream().filter(m -> !isDeprecated(m))
.map(Method::getName).distinct().collect(Collectors.toList());
}
private boolean isDeprecated(Method method) {
Annotation[] annotations = method.getDeclaredAnnotations();
for (Annotation annotation : annotations) {
if (annotation instanceof Deprecated) {
return true;
}
}
return false;
}
}

View File

@ -233,7 +233,7 @@ public class TestAsyncClusterAdminApi extends TestAsyncAdminBase {
@Test @Test
public void testGetRegionLoads() throws Exception { public void testGetRegionLoads() throws Exception {
// Turn off the balancer // Turn off the balancer
admin.setBalancerOn(false).join(); admin.balancerSwitch(false).join();
TableName[] tables = TableName[] tables =
new TableName[] { TableName.valueOf(tableName.getNameAsString() + "1"), new TableName[] { TableName.valueOf(tableName.getNameAsString() + "1"),
TableName.valueOf(tableName.getNameAsString() + "2"), TableName.valueOf(tableName.getNameAsString() + "2"),
@ -244,13 +244,13 @@ public class TestAsyncClusterAdminApi extends TestAsyncAdminBase {
// Check if regions match with the regionLoad from the server // Check if regions match with the regionLoad from the server
Collection<ServerName> servers = admin.getRegionServers().get(); Collection<ServerName> servers = admin.getRegionServers().get();
for (ServerName serverName : servers) { for (ServerName serverName : servers) {
List<RegionInfo> regions = admin.getOnlineRegions(serverName).get(); List<RegionInfo> regions = admin.getRegions(serverName).get();
checkRegionsAndRegionLoads(regions, admin.getRegionLoads(serverName).get()); checkRegionsAndRegionLoads(regions, admin.getRegionLoads(serverName).get());
} }
// Check if regionLoad matches the table's regions and nothing is missed // Check if regionLoad matches the table's regions and nothing is missed
for (TableName table : tables) { for (TableName table : tables) {
List<RegionInfo> tableRegions = admin.getTableRegions(table).get(); List<RegionInfo> tableRegions = admin.getRegions(table).get();
List<RegionLoad> regionLoads = Lists.newArrayList(); List<RegionLoad> regionLoads = Lists.newArrayList();
for (ServerName serverName : servers) { for (ServerName serverName : servers) {
regionLoads.addAll(admin.getRegionLoads(serverName, table).get()); regionLoads.addAll(admin.getRegionLoads(serverName, table).get());

View File

@ -56,7 +56,7 @@ public class TestAsyncDecommissionAdminApi extends TestAsyncAdminBase {
// leaving one online. // leaving one online.
int i; int i;
for (i = 0; i < clusterRegionServers.size(); i++) { for (i = 0; i < clusterRegionServers.size(); i++) {
List<RegionInfo> regionsOnServer = admin.getOnlineRegions(clusterRegionServers.get(i)).get(); List<RegionInfo> regionsOnServer = admin.getRegions(clusterRegionServers.get(i)).get();
if (regionsOnServer.size() > 0) { if (regionsOnServer.size() > 0) {
serversToDecommssion.put(clusterRegionServers.get(i), regionsOnServer); serversToDecommssion.put(clusterRegionServers.get(i), regionsOnServer);
break; break;

View File

@ -87,7 +87,7 @@ public class TestAsyncProcedureAdminApi extends TestAsyncAdminBase {
@Test @Test
public void testExecProcedureWithRet() throws Exception { public void testExecProcedureWithRet() throws Exception {
byte[] result = admin.execProcedureWithRet(SimpleMasterProcedureManager.SIMPLE_SIGNATURE, byte[] result = admin.execProcedureWithReturn(SimpleMasterProcedureManager.SIMPLE_SIGNATURE,
"myTest2", new HashMap<>()).get(); "myTest2", new HashMap<>()).get();
assertArrayEquals("Incorrect return data from execProcedure", assertArrayEquals("Incorrect return data from execProcedure",
SimpleMasterProcedureManager.SIMPLE_DATA.getBytes(), result); SimpleMasterProcedureManager.SIMPLE_DATA.getBytes(), result);

View File

@ -152,7 +152,7 @@ public class TestAsyncRegionAdminApi extends TestAsyncAdminBase {
@Test @Test
public void testMoveRegion() throws Exception { public void testMoveRegion() throws Exception {
admin.setBalancerOn(false).join(); admin.balancerSwitch(false).join();
RegionInfo hri = createTableAndGetOneRegion(tableName); RegionInfo hri = createTableAndGetOneRegion(tableName);
RawAsyncHBaseAdmin rawAdmin = (RawAsyncHBaseAdmin) ASYNC_CONN.getAdmin(); RawAsyncHBaseAdmin rawAdmin = (RawAsyncHBaseAdmin) ASYNC_CONN.getAdmin();
@ -186,7 +186,7 @@ public class TestAsyncRegionAdminApi extends TestAsyncAdminBase {
} }
Thread.sleep(100); Thread.sleep(100);
} }
admin.setBalancerOn(true).join(); admin.balancerSwitch(true).join();
} }
@Test @Test
@ -202,7 +202,7 @@ public class TestAsyncRegionAdminApi extends TestAsyncAdminBase {
rs -> { rs -> {
ServerName serverName = rs.getServerName(); ServerName serverName = rs.getServerName();
try { try {
Assert.assertEquals(admin.getOnlineRegions(serverName).get().size(), rs Assert.assertEquals(admin.getRegions(serverName).get().size(), rs
.getRegions().size()); .getRegions().size());
} catch (Exception e) { } catch (Exception e) {
fail("admin.getOnlineRegions() method throws a exception: " + e.getMessage()); fail("admin.getOnlineRegions() method throws a exception: " + e.getMessage());
@ -266,18 +266,18 @@ public class TestAsyncRegionAdminApi extends TestAsyncAdminBase {
int originalCount = regionLocations.size(); int originalCount = regionLocations.size();
initSplitMergeSwitch(); initSplitMergeSwitch();
assertTrue(admin.setSplitOn(false).get()); assertTrue(admin.splitSwitch(false).get());
try { try {
admin.split(tableName, Bytes.toBytes(rows / 2)).join(); admin.split(tableName, Bytes.toBytes(rows / 2)).join();
} catch (Exception e){ } catch (Exception e){
//Expected //Expected
} }
int count = admin.getTableRegions(tableName).get().size(); int count = admin.getRegions(tableName).get().size();
assertTrue(originalCount == count); assertTrue(originalCount == count);
assertFalse(admin.setSplitOn(true).get()); assertFalse(admin.splitSwitch(true).get());
admin.split(tableName).join(); admin.split(tableName).join();
while ((count = admin.getTableRegions(tableName).get().size()) == originalCount) { while ((count = admin.getRegions(tableName).get().size()) == originalCount) {
Threads.sleep(100); Threads.sleep(100);
} }
assertTrue(originalCount < count); assertTrue(originalCount < count);
@ -299,36 +299,36 @@ public class TestAsyncRegionAdminApi extends TestAsyncAdminBase {
initSplitMergeSwitch(); initSplitMergeSwitch();
admin.split(tableName).join(); admin.split(tableName).join();
int postSplitCount = originalCount; int postSplitCount = originalCount;
while ((postSplitCount = admin.getTableRegions(tableName).get().size()) == originalCount) { while ((postSplitCount = admin.getRegions(tableName).get().size()) == originalCount) {
Threads.sleep(100); Threads.sleep(100);
} }
assertTrue("originalCount=" + originalCount + ", postSplitCount=" + postSplitCount, assertTrue("originalCount=" + originalCount + ", postSplitCount=" + postSplitCount,
originalCount != postSplitCount); originalCount != postSplitCount);
// Merge switch is off so merge should NOT succeed. // Merge switch is off so merge should NOT succeed.
assertTrue(admin.setMergeOn(false).get()); assertTrue(admin.mergeSwitch(false).get());
List<RegionInfo> regions = admin.getTableRegions(tableName).get(); List<RegionInfo> regions = admin.getRegions(tableName).get();
assertTrue(regions.size() > 1); assertTrue(regions.size() > 1);
admin.mergeRegions(regions.get(0).getRegionName(), regions.get(1).getRegionName(), true).join(); admin.mergeRegions(regions.get(0).getRegionName(), regions.get(1).getRegionName(), true).join();
int count = admin.getTableRegions(tableName).get().size(); int count = admin.getRegions(tableName).get().size();
assertTrue("postSplitCount=" + postSplitCount + ", count=" + count, postSplitCount == count); assertTrue("postSplitCount=" + postSplitCount + ", count=" + count, postSplitCount == count);
// Merge switch is on so merge should succeed. // Merge switch is on so merge should succeed.
assertFalse(admin.setMergeOn(true).get()); assertFalse(admin.mergeSwitch(true).get());
admin.mergeRegions(regions.get(0).getRegionName(), regions.get(1).getRegionName(), true).join(); admin.mergeRegions(regions.get(0).getRegionName(), regions.get(1).getRegionName(), true).join();
count = admin.getTableRegions(tableName).get().size(); count = admin.getRegions(tableName).get().size();
assertTrue((postSplitCount / 2) == count); assertTrue((postSplitCount / 2) == count);
} }
private void initSplitMergeSwitch() throws Exception { private void initSplitMergeSwitch() throws Exception {
if (!admin.isSplitOn().get()) { if (!admin.isSplitEnabled().get()) {
admin.setSplitOn(true).get(); admin.splitSwitch(true).get();
} }
if (!admin.isMergeOn().get()) { if (!admin.isMergeEnabled().get()) {
admin.setMergeOn(true).get(); admin.mergeSwitch(true).get();
} }
assertTrue(admin.isSplitOn().get()); assertTrue(admin.isSplitEnabled().get());
assertTrue(admin.isMergeOn().get()); assertTrue(admin.isMergeEnabled().get());
} }
@Test @Test

View File

@ -114,13 +114,13 @@ public class TestAsyncReplicationAdminApiWithClusters extends TestAsyncAdminBase
// default replication scope is local // default replication scope is local
createTableWithDefaultConf(tableName); createTableWithDefaultConf(tableName);
admin.enableTableReplication(tableName).join(); admin.enableTableReplication(tableName).join();
TableDescriptor tableDesc = admin.getTableDescriptor(tableName).get(); TableDescriptor tableDesc = admin.getDescriptor(tableName).get();
for (ColumnFamilyDescriptor fam : tableDesc.getColumnFamilies()) { for (ColumnFamilyDescriptor fam : tableDesc.getColumnFamilies()) {
assertEquals(HConstants.REPLICATION_SCOPE_GLOBAL, fam.getScope()); assertEquals(HConstants.REPLICATION_SCOPE_GLOBAL, fam.getScope());
} }
admin.disableTableReplication(tableName).join(); admin.disableTableReplication(tableName).join();
tableDesc = admin.getTableDescriptor(tableName).get(); tableDesc = admin.getDescriptor(tableName).get();
for (ColumnFamilyDescriptor fam : tableDesc.getColumnFamilies()) { for (ColumnFamilyDescriptor fam : tableDesc.getColumnFamilies()) {
assertEquals(HConstants.REPLICATION_SCOPE_LOCAL, fam.getScope()); assertEquals(HConstants.REPLICATION_SCOPE_LOCAL, fam.getScope());
} }
@ -140,7 +140,7 @@ public class TestAsyncReplicationAdminApiWithClusters extends TestAsyncAdminBase
createTableWithDefaultConf(admin, tableName); createTableWithDefaultConf(admin, tableName);
createTableWithDefaultConf(admin2, tableName); createTableWithDefaultConf(admin2, tableName);
TableDescriptorBuilder builder = TableDescriptorBuilder builder =
TableDescriptorBuilder.newBuilder(admin.getTableDescriptor(tableName).get()); TableDescriptorBuilder.newBuilder(admin.getDescriptor(tableName).get());
builder.addColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("newFamily")) builder.addColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("newFamily"))
.build()); .build());
admin2.disableTable(tableName).join(); admin2.disableTable(tableName).join();
@ -158,7 +158,7 @@ public class TestAsyncReplicationAdminApiWithClusters extends TestAsyncAdminBase
admin.modifyTable(builder.build()).join(); admin.modifyTable(builder.build()).join();
admin.enableTable(tableName).join(); admin.enableTable(tableName).join();
admin.enableTableReplication(tableName).join(); admin.enableTableReplication(tableName).join();
TableDescriptor tableDesc = admin.getTableDescriptor(tableName).get(); TableDescriptor tableDesc = admin.getDescriptor(tableName).get();
for (ColumnFamilyDescriptor fam : tableDesc.getColumnFamilies()) { for (ColumnFamilyDescriptor fam : tableDesc.getColumnFamilies()) {
assertEquals(HConstants.REPLICATION_SCOPE_GLOBAL, fam.getScope()); assertEquals(HConstants.REPLICATION_SCOPE_GLOBAL, fam.getScope());
} }

View File

@ -76,7 +76,7 @@ public class TestAsyncTableAdminApi extends TestAsyncAdminBase {
@Test @Test
public void testListTables() throws Exception { public void testListTables() throws Exception {
int numTables = admin.listTables().get().size(); int numTables = admin.listTableDescriptors().get().size();
final TableName tableName1 = TableName.valueOf(tableName.getNameAsString() + "1"); final TableName tableName1 = TableName.valueOf(tableName.getNameAsString() + "1");
final TableName tableName2 = TableName.valueOf(tableName.getNameAsString() + "2"); final TableName tableName2 = TableName.valueOf(tableName.getNameAsString() + "2");
final TableName tableName3 = TableName.valueOf(tableName.getNameAsString() + "3"); final TableName tableName3 = TableName.valueOf(tableName.getNameAsString() + "3");
@ -85,7 +85,7 @@ public class TestAsyncTableAdminApi extends TestAsyncAdminBase {
createTableWithDefaultConf(tables[i]); createTableWithDefaultConf(tables[i]);
} }
List<TableDescriptor> tableDescs = admin.listTables().get(); List<TableDescriptor> tableDescs = admin.listTableDescriptors().get();
int size = tableDescs.size(); int size = tableDescs.size();
assertTrue(size >= tables.length); assertTrue(size >= tables.length);
for (int i = 0; i < tables.length && i < size; i++) { for (int i = 0; i < tables.length && i < size; i++) {
@ -118,7 +118,7 @@ public class TestAsyncTableAdminApi extends TestAsyncAdminBase {
admin.deleteTable(tables[i]).join(); admin.deleteTable(tables[i]).join();
} }
tableDescs = admin.listTables(true).get(); tableDescs = admin.listTableDescriptors(true).get();
assertTrue("Not found system tables", tableDescs.size() > 0); assertTrue("Not found system tables", tableDescs.size() > 0);
tableNames = admin.listTableNames(true).get(); tableNames = admin.listTableNames(true).get();
assertTrue("Not found system tables", tableNames.size() > 0); assertTrue("Not found system tables", tableNames.size() > 0);
@ -134,16 +134,16 @@ public class TestAsyncTableAdminApi extends TestAsyncAdminBase {
TableDescriptor desc = builder.build(); TableDescriptor desc = builder.build();
admin.createTable(desc).join(); admin.createTable(desc).join();
ModifyableTableDescriptor modifyableDesc = ((ModifyableTableDescriptor) desc); ModifyableTableDescriptor modifyableDesc = ((ModifyableTableDescriptor) desc);
TableDescriptor confirmedHtd = admin.getTableDescriptor(tableName).get(); TableDescriptor confirmedHtd = admin.getDescriptor(tableName).get();
assertEquals(modifyableDesc.compareTo((ModifyableTableDescriptor) confirmedHtd), 0); assertEquals(modifyableDesc.compareTo((ModifyableTableDescriptor) confirmedHtd), 0);
} }
@Test @Test
public void testCreateTable() throws Exception { public void testCreateTable() throws Exception {
List<TableDescriptor> tables = admin.listTables().get(); List<TableDescriptor> tables = admin.listTableDescriptors().get();
int numTables = tables.size(); int numTables = tables.size();
createTableWithDefaultConf(tableName); createTableWithDefaultConf(tableName);
tables = admin.listTables().get(); tables = admin.listTableDescriptors().get();
assertEquals(numTables + 1, tables.size()); assertEquals(numTables + 1, tables.size());
assertTrue("Table must be enabled.", TEST_UTIL.getHBaseCluster().getMaster() assertTrue("Table must be enabled.", TEST_UTIL.getHBaseCluster().getMaster()
.getTableStateManager().isTableState(tableName, TableState.State.ENABLED)); .getTableStateManager().isTableState(tableName, TableState.State.ENABLED));
@ -650,7 +650,7 @@ public class TestAsyncTableAdminApi extends TestAsyncAdminBase {
// Modify colymn family // Modify colymn family
admin.modifyColumnFamily(tableName, cfd).join(); admin.modifyColumnFamily(tableName, cfd).join();
TableDescriptor htd = admin.getTableDescriptor(tableName).get(); TableDescriptor htd = admin.getDescriptor(tableName).get();
ColumnFamilyDescriptor hcfd = htd.getColumnFamily(FAMILY_0); ColumnFamilyDescriptor hcfd = htd.getColumnFamily(FAMILY_0);
assertTrue(hcfd.getBlocksize() == newBlockSize); assertTrue(hcfd.getBlocksize() == newBlockSize);
} }
@ -720,7 +720,7 @@ public class TestAsyncTableAdminApi extends TestAsyncAdminBase {
private void verifyTableDescriptor(final TableName tableName, final byte[]... families) private void verifyTableDescriptor(final TableName tableName, final byte[]... families)
throws Exception { throws Exception {
// Verify descriptor from master // Verify descriptor from master
TableDescriptor htd = admin.getTableDescriptor(tableName).get(); TableDescriptor htd = admin.getDescriptor(tableName).get();
verifyTableDescriptor(htd, tableName, families); verifyTableDescriptor(htd, tableName, families);
// Verify descriptor from HDFS // Verify descriptor from HDFS

View File

@ -35,93 +35,93 @@ public class TestAsyncToolAdminApi extends TestAsyncAdminBase {
@Test @Test
public void testBalancer() throws Exception { public void testBalancer() throws Exception {
boolean initialState = admin.isBalancerOn().get(); boolean initialState = admin.isBalancerEnabled().get();
// Start the balancer, wait for it. // Start the balancer, wait for it.
boolean prevState = admin.setBalancerOn(!initialState).get(); boolean prevState = admin.balancerSwitch(!initialState).get();
// The previous state should be the original state we observed // The previous state should be the original state we observed
assertEquals(initialState, prevState); assertEquals(initialState, prevState);
// Current state should be opposite of the original // Current state should be opposite of the original
assertEquals(!initialState, admin.isBalancerOn().get()); assertEquals(!initialState, admin.isBalancerEnabled().get());
// Reset it back to what it was // Reset it back to what it was
prevState = admin.setBalancerOn(initialState).get(); prevState = admin.balancerSwitch(initialState).get();
// The previous state should be the opposite of the initial state // The previous state should be the opposite of the initial state
assertEquals(!initialState, prevState); assertEquals(!initialState, prevState);
// Current state should be the original state again // Current state should be the original state again
assertEquals(initialState, admin.isBalancerOn().get()); assertEquals(initialState, admin.isBalancerEnabled().get());
} }
@Test @Test
public void testNormalizer() throws Exception { public void testNormalizer() throws Exception {
boolean initialState = admin.isNormalizerOn().get(); boolean initialState = admin.isNormalizerEnabled().get();
// flip state // flip state
boolean prevState = admin.setNormalizerOn(!initialState).get(); boolean prevState = admin.normalizerSwitch(!initialState).get();
// The previous state should be the original state we observed // The previous state should be the original state we observed
assertEquals(initialState, prevState); assertEquals(initialState, prevState);
// Current state should be opposite of the original // Current state should be opposite of the original
assertEquals(!initialState, admin.isNormalizerOn().get()); assertEquals(!initialState, admin.isNormalizerEnabled().get());
// Reset it back to what it was // Reset it back to what it was
prevState = admin.setNormalizerOn(initialState).get(); prevState = admin.normalizerSwitch(initialState).get();
// The previous state should be the opposite of the initial state // The previous state should be the opposite of the initial state
assertEquals(!initialState, prevState); assertEquals(!initialState, prevState);
// Current state should be the original state again // Current state should be the original state again
assertEquals(initialState, admin.isNormalizerOn().get()); assertEquals(initialState, admin.isNormalizerEnabled().get());
} }
@Test @Test
public void testCleanerChore() throws Exception { public void testCleanerChore() throws Exception {
boolean initialState = admin.isCleanerChoreOn().get(); boolean initialState = admin.isCleanerChoreEnabled().get();
// flip state // flip state
boolean prevState = admin.setCleanerChoreOn(!initialState).get(); boolean prevState = admin.cleanerChoreSwitch(!initialState).get();
// The previous state should be the original state we observed // The previous state should be the original state we observed
assertEquals(initialState, prevState); assertEquals(initialState, prevState);
// Current state should be opposite of the original // Current state should be opposite of the original
assertEquals(!initialState, admin.isCleanerChoreOn().get()); assertEquals(!initialState, admin.isCleanerChoreEnabled().get());
// Reset it back to what it was // Reset it back to what it was
prevState = admin.setCleanerChoreOn(initialState).get(); prevState = admin.cleanerChoreSwitch(initialState).get();
// The previous state should be the opposite of the initial state // The previous state should be the opposite of the initial state
assertEquals(!initialState, prevState); assertEquals(!initialState, prevState);
// Current state should be the original state again // Current state should be the original state again
assertEquals(initialState, admin.isCleanerChoreOn().get()); assertEquals(initialState, admin.isCleanerChoreEnabled().get());
} }
@Test @Test
public void testCatalogJanitor() throws Exception { public void testCatalogJanitor() throws Exception {
boolean initialState = admin.isCatalogJanitorOn().get(); boolean initialState = admin.isCatalogJanitorEnabled().get();
// flip state // flip state
boolean prevState = admin.setCatalogJanitorOn(!initialState).get(); boolean prevState = admin.catalogJanitorSwitch(!initialState).get();
// The previous state should be the original state we observed // The previous state should be the original state we observed
assertEquals(initialState, prevState); assertEquals(initialState, prevState);
// Current state should be opposite of the original // Current state should be opposite of the original
assertEquals(!initialState, admin.isCatalogJanitorOn().get()); assertEquals(!initialState, admin.isCatalogJanitorEnabled().get());
// Reset it back to what it was // Reset it back to what it was
prevState = admin.setCatalogJanitorOn(initialState).get(); prevState = admin.catalogJanitorSwitch(initialState).get();
// The previous state should be the opposite of the initial state // The previous state should be the opposite of the initial state
assertEquals(!initialState, prevState); assertEquals(!initialState, prevState);
// Current state should be the original state again // Current state should be the original state again
assertEquals(initialState, admin.isCatalogJanitorOn().get()); assertEquals(initialState, admin.isCatalogJanitorEnabled().get());
} }
} }