Apache9 commented on a change in pull request #667: HBASE-23055 Alter hbase:meta
URL: https://github.com/apache/hbase/pull/667#discussion_r330096522
##########
File path:
hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/EnableTableProcedure.java
##########
@@ -175,40 +166,32 @@ protected Flow executeFromState(final MasterProcedureEnv
env, final EnableTableS
default:
throw new UnsupportedOperationException("unhandled state=" + state);
}
- } catch (IOException e) {
+ } catch (IOException | ExecutionException e) {
if (isRollbackSupported(state)) {
- setFailure("master-enable-table", e);
+ setFailure("master-enable-table", getCause(e));
} else {
- LOG.warn(
- "Retriable error trying to enable table=" + tableName + " (in
state=" + state + ")", e);
+ LOG.warn("Retryable error enabling {}, state={}", tableName, state,
getCause(e));
}
}
return Flow.HAS_MORE_STATE;
}
- private int getNumberOfReplicasFromMeta(Connection connection, int
regionReplicaCount,
- List<RegionInfo> regionsOfTable) throws IOException {
- Result r = getRegionFromMeta(connection, regionsOfTable);
- int replicasFound = 0;
- for (int i = 1; i < regionReplicaCount; i++) {
- // Since we have already added the entries to the META we will be
getting only that here
- List<Cell> columnCells =
- r.getColumnCells(HConstants.CATALOG_FAMILY,
MetaTableAccessor.getServerColumn(i));
- if (!columnCells.isEmpty()) {
- replicasFound++;
- }
- }
- return replicasFound;
+ /**
+ * @return If ExecutionException, pull out the cause.
+ */
+ private Throwable getCause(Exception e) {
+ return e instanceof ExecutionException?
((ExecutionException)e).getCause(): e;
}
- private Result getRegionFromMeta(Connection connection, List<RegionInfo>
regionsOfTable)
- throws IOException {
- byte[] metaKeyForRegion =
MetaTableAccessor.getMetaKeyForRegion(regionsOfTable.get(0));
- Get get = new Get(metaKeyForRegion);
- get.addFamily(HConstants.CATALOG_FAMILY);
- Table metaTable = MetaTableAccessor.getMetaHTable(connection);
- Result r = metaTable.get(get);
- return r;
+ /**
+ * @return If hbase;meta table, it goes to the registry implementation which
is what we want.
+ */
+ private int getReplicaCount(AsyncConnection connection, TableName tableName)
+ throws ExecutionException, InterruptedException {
+ AsyncTable t = connection.getTable(TableName.META_TABLE_NAME);
+ List<HRegionLocation> rls =
+ t.getRegionLocator().getRegionLocations(HConstants.EMPTY_START_ROW,
true).get();
Review comment:
Use FutureUtils.get? It will unwrap the ExecutionException.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services