in amoro-common/src/main/java/org/apache/amoro/utils/CatalogUtil.java [110:191]
public static TableMetaStore buildMetaStore(CatalogMeta catalogMeta) {
// load storage configs
TableMetaStore.Builder builder = TableMetaStore.builder();
if (catalogMeta.getStorageConfigs() != null) {
Map<String, String> storageConfigs = catalogMeta.getStorageConfigs();
if (CatalogMetaProperties.STORAGE_CONFIGS_VALUE_TYPE_HADOOP.equalsIgnoreCase(
CatalogUtil.getCompatibleStorageType(storageConfigs))) {
String coreSite = storageConfigs.get(CatalogMetaProperties.STORAGE_CONFIGS_KEY_CORE_SITE);
String hdfsSite = storageConfigs.get(CatalogMetaProperties.STORAGE_CONFIGS_KEY_HDFS_SITE);
String hiveSite = storageConfigs.get(CatalogMetaProperties.STORAGE_CONFIGS_KEY_HIVE_SITE);
builder
.withBase64CoreSite(coreSite)
.withBase64MetaStoreSite(hiveSite)
.withBase64HdfsSite(hdfsSite);
}
}
boolean loadAuthFromAMS =
propertyAsBoolean(
catalogMeta.getCatalogProperties(),
CatalogMetaProperties.LOAD_AUTH_FROM_AMS,
CatalogMetaProperties.LOAD_AUTH_FROM_AMS_DEFAULT);
// load auth configs from ams
if (loadAuthFromAMS) {
if (catalogMeta.getAuthConfigs() != null) {
Map<String, String> authConfigs = catalogMeta.getAuthConfigs();
String authType = authConfigs.get(CatalogMetaProperties.AUTH_CONFIGS_KEY_TYPE);
LOG.info("TableMetaStore use auth config in catalog meta, authType is {}", authType);
if (CatalogMetaProperties.AUTH_CONFIGS_VALUE_TYPE_SIMPLE.equalsIgnoreCase(authType)) {
String hadoopUsername =
authConfigs.get(CatalogMetaProperties.AUTH_CONFIGS_KEY_HADOOP_USERNAME);
builder.withSimpleAuth(hadoopUsername);
} else if (CatalogMetaProperties.AUTH_CONFIGS_VALUE_TYPE_KERBEROS.equalsIgnoreCase(
authType)) {
String krb5 = authConfigs.get(CatalogMetaProperties.AUTH_CONFIGS_KEY_KRB5);
String keytab = authConfigs.get(CatalogMetaProperties.AUTH_CONFIGS_KEY_KEYTAB);
String principal = authConfigs.get(CatalogMetaProperties.AUTH_CONFIGS_KEY_PRINCIPAL);
builder.withBase64KrbAuth(keytab, krb5, principal);
} else if (CatalogMetaProperties.AUTH_CONFIGS_VALUE_TYPE_AK_SK.equalsIgnoreCase(authType)) {
String accessKey = authConfigs.get(CatalogMetaProperties.AUTH_CONFIGS_KEY_ACCESS_KEY);
String secretKey = authConfigs.get(CatalogMetaProperties.AUTH_CONFIGS_KEY_SECRET_KEY);
builder.withAkSkAuth(accessKey, secretKey);
}
}
}
// cover auth configs from ams with auth configs in properties
String authType =
catalogMeta.getCatalogProperties().get(CatalogMetaProperties.AUTH_CONFIGS_KEY_TYPE);
if (StringUtils.isNotEmpty(authType)) {
LOG.info("TableMetaStore use auth config in properties, authType is {}", authType);
if (CatalogMetaProperties.AUTH_CONFIGS_VALUE_TYPE_SIMPLE.equalsIgnoreCase(authType)) {
String hadoopUsername =
catalogMeta
.getCatalogProperties()
.get(CatalogMetaProperties.AUTH_CONFIGS_KEY_HADOOP_USERNAME);
builder.withSimpleAuth(hadoopUsername);
} else if (CatalogMetaProperties.AUTH_CONFIGS_VALUE_TYPE_KERBEROS.equalsIgnoreCase(
authType)) {
String krb5 =
catalogMeta.getCatalogProperties().get(CatalogMetaProperties.AUTH_CONFIGS_KEY_KRB5);
String keytab =
catalogMeta.getCatalogProperties().get(CatalogMetaProperties.AUTH_CONFIGS_KEY_KEYTAB);
String principal =
catalogMeta
.getCatalogProperties()
.get(CatalogMetaProperties.AUTH_CONFIGS_KEY_PRINCIPAL);
builder.withBase64KrbAuth(keytab, krb5, principal);
} else if (CatalogMetaProperties.AUTH_CONFIGS_VALUE_TYPE_AK_SK.equalsIgnoreCase(authType)) {
String accessKey =
catalogMeta
.getCatalogProperties()
.get(CatalogMetaProperties.AUTH_CONFIGS_KEY_ACCESS_KEY);
String secretKey =
catalogMeta
.getCatalogProperties()
.get(CatalogMetaProperties.AUTH_CONFIGS_KEY_SECRET_KEY);
builder.withAkSkAuth(accessKey, secretKey);
}
}
return builder.build();
}