Skip to content

Commit a20fbc9

Browse files
HIVE-29073: Overlay modified session level metaconf to new hmsclient connection
1 parent df98c2e commit a20fbc9

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

ql/src/java/org/apache/hadoop/hive/ql/processors/SetProcessor.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,25 @@ public Map<String, String> getHiveVariable() {
272272
}
273273
if (register) {
274274
ss.getOverriddenConfigurations().put(key, value);
275+
276+
if (metaConfOverlayList.contains(key)) {
277+
try (Hive hive = Hive.get(ss.getConf())) {
278+
// Resources will be closed automatically
279+
hive.close(true);
280+
} catch (Exception e) {
281+
LOG.error("Error closing metastore connection", e);
282+
throw new RuntimeException(e);
283+
}
284+
}
285+
275286
}
276287
return result;
277288
}
278289

290+
// This is just temporary idea list. Will make this configurable later.
291+
private static final Set<String> metaConfOverlayList =
292+
Set.of("fs.s3a.endpoint", "fs.s3a.security.credential.provider.path");
293+
279294
private SortedMap<String,String> propertiesToSortedMap(Properties p){
280295
SortedMap<String,String> sortedPropMap = new TreeMap<String,String>();
281296
for (Map.Entry<Object, Object> entry : p.entrySet() ){

standalone-metastore/metastore-client/src/main/java/org/apache/hadoop/hive/metastore/client/ThriftHiveMetaStoreClient.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,7 @@ private void open() throws MetaException {
761761
LOG.error(errMsg, e);
762762
}
763763
if (isConnected) {
764+
overlayMetaConfig();
764765
break;
765766
}
766767
}
@@ -790,6 +791,21 @@ private void open() throws MetaException {
790791
snapshotActiveConf();
791792
}
792793

794+
private void overlayMetaConfig() {
795+
String overlayConfig = MetastoreConf.getVar(conf, MetastoreConf.ConfVars.HIVE_METACONF_OVERLAY);
796+
for (String entry : overlayConfig.split(",")) {
797+
String confVal = conf.get(entry.trim());
798+
if (!org.apache.commons.lang3.StringUtils.isBlank(confVal)) {
799+
try {
800+
setMetaConf(entry.trim(), confVal);
801+
} catch (TException e) {
802+
LOG.error(
803+
"Failed to set metastore config for {} with value {}", entry.trim(), confVal, e);
804+
}
805+
}
806+
}
807+
}
808+
793809
// wraps the underlyingTransport in the appropriate transport based on mode of authentication
794810
private TTransport createAuthBinaryTransport(URI store, TTransport underlyingTransport)
795811
throws MetaException {

standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,6 +1824,12 @@ public enum ConfVars {
18241824
HIVE_TXN_STATS_ENABLED("hive.txn.stats.enabled", "hive.txn.stats.enabled", true,
18251825
"Whether Hive supports transactional stats (accurate stats for transactional tables)"),
18261826

1827+
HIVE_METACONF_OVERLAY(
1828+
"hive.metastore.conf.overlay",
1829+
"hive.metastore.conf.overlay",
1830+
"fs.s3a.endpoint, fs.s3a.security.credential.provider.path",
1831+
"The list of configurations that needs to be overlayed to HiveMetasStore on client connection"),
1832+
18271833
// External RDBMS support
18281834
USE_CUSTOM_RDBMS("metastore.use.custom.database.product",
18291835
"hive.metastore.use.custom.database.product", false,

0 commit comments

Comments
 (0)