use of org.apache.hadoop.hbase.master.ClusterSchema in project hbase by apache.
the class RSGroupUtil method getRSGroupInfo.
/**
* Will try to get the rsgroup from {@link TableDescriptor} first, and then try to get the rsgroup
* from the {@link NamespaceDescriptor}. If still not present, return empty.
*/
public static Optional<RSGroupInfo> getRSGroupInfo(MasterServices master, RSGroupInfoManager manager, TableName tableName) throws IOException {
TableDescriptor td = master.getTableDescriptors().get(tableName);
if (td == null) {
return Optional.empty();
}
// RSGroup information determined by client.
Optional<String> optGroupNameOfTable = td.getRegionServerGroup();
if (optGroupNameOfTable.isPresent()) {
RSGroupInfo group = manager.getRSGroup(optGroupNameOfTable.get());
if (group != null) {
return Optional.of(group);
}
}
// for backward compatible, where we may still have table configs in the RSGroupInfo after
// upgrading when migrating is still on-going.
RSGroupInfo groupFromOldRSGroupInfo = manager.getRSGroupForTable(tableName);
if (groupFromOldRSGroupInfo != null) {
return Optional.of(groupFromOldRSGroupInfo);
}
// RSGroup information determined by administrator.
String groupDeterminedByAdmin = manager.determineRSGroupInfoForTable(tableName);
RSGroupInfo groupInfo = null;
if (groupDeterminedByAdmin != null) {
groupInfo = manager.getRSGroup(groupDeterminedByAdmin);
}
if (groupInfo != null) {
return Optional.of(groupInfo);
}
// Finally, we will try to fall back to namespace as rsgroup if exists
ClusterSchema clusterSchema = master.getClusterSchema();
if (clusterSchema == null) {
if (TableName.isMetaTableName(tableName)) {
LOG.info("Can not get the namespace rs group config for meta table, since the" + " meta table is not online yet, will use default group to assign meta first");
} else {
LOG.warn("ClusterSchema is null, can only use default rsgroup, should not happen?");
}
return Optional.empty();
}
NamespaceDescriptor nd = clusterSchema.getNamespace(tableName.getNamespaceAsString());
String groupNameOfNs = nd.getConfigurationValue(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP);
if (groupNameOfNs == null) {
return Optional.empty();
}
return Optional.ofNullable(manager.getRSGroup(groupNameOfNs));
}
Aggregations