caican00 commented on code in PR #4075:
URL: https://github.com/apache/gravitino/pull/4075#discussion_r1666206497
##########
catalogs/catalog-lakehouse-paimon/src/main/java/com/datastrato/gravitino/catalog/lakehouse/paimon/utils/CatalogUtils.java:
##########
@@ -46,17 +56,55 @@ public static Catalog loadCatalogBackend(PaimonConfig
paimonConfig) {
String metastore = paimonConfig.get(CATALOG_BACKEND);
Preconditions.checkArgument(
StringUtils.isNotBlank(metastore), "Paimon Catalog metastore can not
be null or empty.");
+
String warehouse = paimonConfig.get(CATALOG_WAREHOUSE);
Preconditions.checkArgument(
StringUtils.isNotBlank(warehouse), "Paimon Catalog warehouse can not
be null or empty.");
+
if (!PaimonCatalogBackend.FILESYSTEM.name().equalsIgnoreCase(metastore)) {
String uri = paimonConfig.get(CATALOG_URI);
Preconditions.checkArgument(
- StringUtils.isNotBlank(uri),
- String.format("Paimon Catalog uri can not be null or empty for %s.",
metastore));
+ StringUtils.isNotBlank(uri), "Paimon Catalog uri can not be null or
empty.");
}
+
+ Map<String, String> allConfig = paimonConfig.getAllConfig();
+ Configuration configuration = new Configuration();
+ allConfig.forEach(configuration::set);
+
CatalogContext catalogContext =
- CatalogContext.create(Options.fromMap(paimonConfig.getAllConfig()));
- return CatalogFactory.createCatalog(catalogContext);
+ CatalogContext.create(Options.fromMap(paimonConfig.getAllConfig()),
configuration);
+
+ AuthenticationConfig authenticationConfig = new
AuthenticationConfig(allConfig);
+ if (authenticationConfig.isSimpleAuth()) {
+ return CatalogFactory.createCatalog(catalogContext);
+ } else if (authenticationConfig.isKerberosAuth()) {
+ configuration.set(HADOOP_SECURITY_AUTHORIZATION, "true");
+ configuration.set(HADOOP_SECURITY_AUTHENTICATION, "kerberos");
+
+ switch
(PaimonCatalogBackend.valueOf(metastore.toUpperCase(Locale.ROOT))) {
+ case FILESYSTEM:
+ initKerberosAndReturnRealm(allConfig, configuration);
Review Comment:
`CatalogFactory.createCatalog(catalogContext)` will create Filesystem
client, and after `loginUserFromKeytab`,
the client can get the current ugi to initialize itselt.
##########
catalogs/catalog-lakehouse-paimon/src/main/java/com/datastrato/gravitino/catalog/lakehouse/paimon/authentication/kerberos/KerberosClient.java:
##########
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package
com.datastrato.gravitino.catalog.lakehouse.paimon.authentication.kerberos;
+
+import com.google.common.base.Preconditions;
+import com.google.common.base.Splitter;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.hadoop.security.authentication.util.KerberosName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class KerberosClient {
+ private static final Logger LOG =
LoggerFactory.getLogger(KerberosClient.class);
+
+ public static final String GRAVITINO_KEYTAB_FORMAT =
+ "keytabs/gravitino-lakehouse-paimon-%s-keytab";
+
+ private final ScheduledThreadPoolExecutor checkTgtExecutor;
+ private final Map<String, String> conf;
+ private final Configuration hadoopConf;
+
+ public KerberosClient(Map<String, String> conf, Configuration hadoopConf) {
+ this.conf = conf;
+ this.hadoopConf = hadoopConf;
+ this.checkTgtExecutor = new ScheduledThreadPoolExecutor(1,
getThreadFactory("check-tgt"));
+ }
+
+ public String login(String keytabFilePath) throws IOException {
Review Comment:
ok
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]