Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add personalized configuration parameters for each metastore. #315

Merged
merged 14 commits into from
May 27, 2024

Conversation

yangyuxia
Copy link

📝 Description

Different hive Metastores may have different parameter values for the same parameter. If multiple federated Metastores are configured in waggle dance, you can configure their own parameter values for each metastore.
For example, when hivemetastore enabled the kerberos authentication, the value of the "hive.metastore.kerberos.principal", some metastore is configured to "hive/_HOST@Realm", but some metastore is configured as "hive/{clusterName}@realm", so you need to configure personalized configuration parameters for each metastore.

🔗 Related Issues

@yangyuxia
Copy link
Author

cat waggle-dance-server.yml

verbose: true
port: 48869
database-resolution: PREFIXED
yaml-storage:
 overwrite-config-on-shutdown: false
logging:
 config: file:${WAGGLE_DANCE_HOME}/conf/log4j2.xml
configuration-properties:
 hadoop.security.authentication: KERBEROS
 hadoop.kerberos.keytab.login.autorenewal.enabled: true
 hadoop.proxyuser.hive.users: ''
 hadoop.proxyuser.hive.groups: '
'
 hadoop.proxyuser.hive.hosts: '*'
 hive.metastore.sasl.enabled: true
 hive.metastore.kerberos.principal: hive/_HOST@HADOOP.COM
 hive.metastore.kerberos.keytab.file: ${WAGGLE_DANCE_HOME}/conf/wd.keytab
 hive.cluster.delegation.token.store.class: org.apache.hadoop.hive.thrift.ZooKeeperTokenStore
 hive.cluster.delegation.token.store.zookeeper.connectString: host-zk1:2181,host-zk2:2181,host-zk3:2181
 hive.cluster.delegation.token.store.zookeeper.znode: /hive/cluster/delegationwg
 hive.cluster.delegation.token.store.zookeeper.acl: "world:anyone:rwcda"
 hive.server2.authentication: KERBEROS
 hive.server2.authentication.kerberos.keytab: ${WAGGLE_DANCE_HOME}/conf/wd.keytab
 hive.server2.authentication.kerberos.principal: hive/_HOST@HADOOP.COM
 hive.server2.authentication.client.kerberos.principal: hive/_HOST@HADOOP.COM
 wd-metastore:
  hms1:
    hive.metastore.kerberos.principal: hive/_HOST@HADOOP.COM
  hms2:
    hive.metastore.kerberos.principal: hive/test2@HADOOP.COM

@@ -45,7 +43,21 @@ public class CloseableThriftHiveMetastoreIfaceClientFactory {
public CloseableThriftHiveMetastoreIface newInstance(AbstractMetaStore metaStore) {
Map<String, String> properties = new HashMap<>();
if (waggleDanceConfiguration.getConfigurationProperties() != null) {
properties.putAll(waggleDanceConfiguration.getConfigurationProperties());
// properties.putAll(waggleDanceConfiguration.getConfigurationProperties());
Map<String, String> serverConfigMap=waggleDanceConfiguration.getConfigurationProperties();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we move these properties to the AbstractMetastore class and make it part of the waggle-dance-federation.yml and this code can become much simpler like:

properties.putAll(waggleDanceConfiguration.getConfigurationProperties());
//override per metastore
properties.putAll(metastore.getConfigurationProperties());

Copy link
Contributor

@patduin patduin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you please have a look and my comment.

@yangyuxia
Copy link
Author

yangyuxia commented Apr 22, 2024

primary-meta-store:
  database-prefix: ''
  name: hms1
  remote-meta-store-uris: thrift://host-hms1:9083
  access-control-type: READ_AND_WRITE_AND_CREATE
  impersonation-enabled: false
  configuration-properties:
    hive.metastore.kerberos.principal: hive/hms@HADOOP.COM
    hive.server2.enable.doAs: true

@@ -47,6 +47,8 @@ public CloseableThriftHiveMetastoreIface newInstance(AbstractMetaStore metaStore
if (waggleDanceConfiguration.getConfigurationProperties() != null) {
properties.putAll(waggleDanceConfiguration.getConfigurationProperties());
}
//override per metastore
properties.putAll(metaStore.getConfigurationProperties());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a junit test please?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

private @NotBlank String name;
private @NotBlank String remoteMetaStoreUris;
private @Valid MetastoreTunnel metastoreTunnel;
private @NotNull AccessControlType accessControlType = AccessControlType.READ_ONLY;
private transient @JsonProperty @NotNull MetaStoreStatus status = MetaStoreStatus.UNKNOWN;
private long latency = 0;
private transient @JsonIgnore HashBiMap<String, String> databaseNameBiMapping = HashBiMap.create();
private Map<String, String> configurationProperties = Collections.emptyMap();
private Map<String, String> configurationProperties;// = Collections.emptyMap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't it nicer to instantiate as emptyMap so you don't need the null check?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yangyuxia if you could revert or explain why this change was made I'm happy to approver once that's done,thanks!

@@ -51,15 +51,15 @@ public abstract class AbstractMetaStore {
private List<String> writableDatabaseWhitelist;
private List<String> mappedDatabases;
private @Valid List<MappedTables> mappedTables;
private Map<String, String> databaseNameMapping = Collections.emptyMap();
private transient Map<String, String> databaseNameMapping = Collections.emptyMap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this had to change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yangyuxia if you could revert or explain why this change was made I'm happy to approver once that's done,thanks!

@@ -243,4 +244,12 @@ public String toString() {
.toString();
}

public Map<String, String> getConfigurationProperties() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move these two methods below the setDatabaseNameMapping method to keep them in sync with the property definitions. Normally, toString (if defined) is the last method in a class.

@@ -47,6 +47,10 @@ public CloseableThriftHiveMetastoreIface newInstance(AbstractMetaStore metaStore
if (waggleDanceConfiguration.getConfigurationProperties() != null) {
properties.putAll(waggleDanceConfiguration.getConfigurationProperties());
}
//override per metastore

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment isn't needed.
nit: there's a space missing between if and (. You might also want to leave an empty line before the return statement to improve readability.


factory.newInstance(newFederatedInstance("fed1", THRIFT_URI));
FederatedMetaStore fed1 = newFederatedInstance("fed1", THRIFT_URI);
fed1.setConfigurationProperties(Collections.singletonMap(ConfVars.METASTORE_KERBEROS_PRINCIPAL.varname,"hive/_HOST@HADOOP.COM"));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: there's a space missing between the key and the value.

@jmnunezizu
Copy link

Thanks for the contribution. Please update the readme explaining how this works and how it can be utilised. Thanks.

Copy link

@jmnunezizu jmnunezizu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Contributor

@patduin patduin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@patduin patduin merged commit 842aa2e into ExpediaGroup:hive-3.x May 27, 2024
0 of 2 checks passed
flaming-archer pushed a commit to flaming-archer/waggle-dance that referenced this pull request May 28, 2024
…aGroup#315)

* Add personalized configuration parameters for each metastore.

* Add personalized configuration parameters for each metastore

* Recover

* Update junit test

* Update Junit Test

* Update Junit Test

* Update Junit Test

* Format the code and update the readme

* Revert

* Update FederatedMetaStoreTest.java

* Update PrimaryMetaStoreTest.java

* Update AbstractMetaStore.java

using new HashMap so the generated Yaml doesn't generate an anchor (reference &id001)

* Update YamlFederatedMetaStoreStorageTest.java

fixing test

---------

Co-authored-by: yangyx <360508847@qq.com>
Co-authored-by: Patrick Duin <patduin@gmail.com>
patduin pushed a commit that referenced this pull request May 29, 2024
…e delegatetoken in the kerberos environment (#313)

* Use different tokens instead of forcing WD and all HMS to use the same delegatetoken in the kerberos environment

* Add personalized configuration parameters for each metastore. (#315)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants