From 6b37a8843681789d9d49db1d5e7dbeceb82d7e79 Mon Sep 17 00:00:00 2001 From: fanng Date: Thu, 17 Oct 2024 11:49:28 +0800 Subject: [PATCH] fix comment --- .../iceberg/IcebergCatalogOperations.java | 4 +-- .../iceberg/ops/TestIcebergTableUpdate.java | 3 +- .../credential/CredentialProviderManager.java | 14 ++------- .../gravitino/credential/CredentialUtils.java | 4 --- .../ops/IcebergCatalogConfigProvider.java | 4 +-- .../common/ops/IcebergCatalogWrapper.java | 3 -- ...nfigBasedIcebergCatalogConfigProvider.java | 3 +- ...tinoBasedIcebergCatalogConfigProvider.java | 1 - .../service/IcebergCatalogWrapperManager.java | 10 ++++--- .../service/rest/IcebergTableOperations.java | 30 ++++++++++++------- ...dIcebergCatalogWrapperProviderForTest.java | 1 - 11 files changed, 34 insertions(+), 43 deletions(-) diff --git a/catalogs/catalog-lakehouse-iceberg/src/main/java/org/apache/gravitino/catalog/lakehouse/iceberg/IcebergCatalogOperations.java b/catalogs/catalog-lakehouse-iceberg/src/main/java/org/apache/gravitino/catalog/lakehouse/iceberg/IcebergCatalogOperations.java index d5884b8601a..bf787df0b91 100644 --- a/catalogs/catalog-lakehouse-iceberg/src/main/java/org/apache/gravitino/catalog/lakehouse/iceberg/IcebergCatalogOperations.java +++ b/catalogs/catalog-lakehouse-iceberg/src/main/java/org/apache/gravitino/catalog/lakehouse/iceberg/IcebergCatalogOperations.java @@ -110,9 +110,7 @@ public void initialize( resultConf.put("catalog_uuid", info.id().toString()); IcebergConfig icebergConfig = new IcebergConfig(resultConf); - this.icebergCatalogWrapper = - new IcebergCatalogWrapper( - icebergConfig); + this.icebergCatalogWrapper = new IcebergCatalogWrapper(icebergConfig); this.icebergCatalogWrapperHelper = new IcebergCatalogWrapperHelper(icebergCatalogWrapper.getCatalog()); } diff --git a/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/ops/TestIcebergTableUpdate.java b/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/ops/TestIcebergTableUpdate.java index 54852a166b3..37124dc5f33 100644 --- a/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/ops/TestIcebergTableUpdate.java +++ b/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/ops/TestIcebergTableUpdate.java @@ -81,8 +81,7 @@ public class TestIcebergTableUpdate { @BeforeEach public void init() { - icebergCatalogWrapper = - new IcebergCatalogWrapper(new IcebergConfig(Collections.emptyMap())); + icebergCatalogWrapper = new IcebergCatalogWrapper(new IcebergConfig(Collections.emptyMap())); icebergCatalogWrapperHelper = new IcebergCatalogWrapperHelper(icebergCatalogWrapper.getCatalog()); createNamespace(TEST_NAMESPACE_NAME); diff --git a/core/src/main/java/org/apache/gravitino/credential/CredentialProviderManager.java b/core/src/main/java/org/apache/gravitino/credential/CredentialProviderManager.java index 98ccfe89e3b..9c00c50b658 100644 --- a/core/src/main/java/org/apache/gravitino/credential/CredentialProviderManager.java +++ b/core/src/main/java/org/apache/gravitino/credential/CredentialProviderManager.java @@ -19,20 +19,12 @@ package org.apache.gravitino.credential; -import com.google.common.collect.ImmutableSet; -import java.util.HashMap; -import java.util.Map; -import org.apache.gravitino.utils.PrincipalUtils; - public class CredentialProviderManager { - public void registerCredentialProvider(String catalogName, CredentialProvider credentialProvider) { - - } + public void registerCredentialProvider( + String catalogName, CredentialProvider credentialProvider) {} - public void unregisterCredentialProvider(String catalogName) { - - } + public void unregisterCredentialProvider(String catalogName) {} public CredentialProvider getCredentialProvider(String catalogName) { return null; diff --git a/core/src/main/java/org/apache/gravitino/credential/CredentialUtils.java b/core/src/main/java/org/apache/gravitino/credential/CredentialUtils.java index 07d1cccabd4..ad81953ac61 100644 --- a/core/src/main/java/org/apache/gravitino/credential/CredentialUtils.java +++ b/core/src/main/java/org/apache/gravitino/credential/CredentialUtils.java @@ -20,10 +20,6 @@ package org.apache.gravitino.credential; import com.google.common.collect.ImmutableSet; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import org.apache.commons.lang3.StringUtils; import org.apache.gravitino.utils.PrincipalUtils; public class CredentialUtils { diff --git a/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogConfigProvider.java b/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogConfigProvider.java index 4548770b962..fc0d488a11d 100644 --- a/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogConfigProvider.java +++ b/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogConfigProvider.java @@ -23,8 +23,8 @@ import org.apache.gravitino.iceberg.common.IcebergConfig; /** - * {@code IcebergCatalogConfigProvider} is an interface defining how Iceberg REST catalog server gets - * Iceberg catalog configurations. + * {@code IcebergCatalogConfigProvider} is an interface defining how Iceberg REST catalog server + * gets Iceberg catalog configurations. */ public interface IcebergCatalogConfigProvider { diff --git a/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogWrapper.java b/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogWrapper.java index 2bf10ac846c..11b42eefb69 100644 --- a/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogWrapper.java +++ b/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogWrapper.java @@ -31,7 +31,6 @@ import lombok.Getter; import lombok.Setter; import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergConstants; -import org.apache.gravitino.credential.CredentialProvider; import org.apache.gravitino.iceberg.common.IcebergCatalogBackend; import org.apache.gravitino.iceberg.common.IcebergConfig; import org.apache.gravitino.iceberg.common.utils.IcebergCatalogUtil; @@ -103,8 +102,6 @@ public IcebergCatalogWrapper(IcebergConfig icebergConfig) { key -> catalogPropertiesToClientKeys.contains(key)); this.catalogPropertiesMap = icebergConfig.getIcebergCatalogProperties(); - - } private void validateNamespace(Optional namespace) { diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/provider/ConfigBasedIcebergCatalogConfigProvider.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/provider/ConfigBasedIcebergCatalogConfigProvider.java index 250d5ff69f9..734b04eb02f 100644 --- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/provider/ConfigBasedIcebergCatalogConfigProvider.java +++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/provider/ConfigBasedIcebergCatalogConfigProvider.java @@ -43,7 +43,8 @@ public class ConfigBasedIcebergCatalogConfigProvider implements IcebergCatalogCo public static final Logger LOG = LoggerFactory.getLogger(ConfigBasedIcebergCatalogConfigProvider.class); - public static final String CONFIG_BASE_ICEBERG_CATALOG_CONFIG_PROVIDER_NAME = "config-based-provider"; + public static final String CONFIG_BASE_ICEBERG_CATALOG_CONFIG_PROVIDER_NAME = + "config-based-provider"; @VisibleForTesting Map catalogConfigs; diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/provider/GravitinoBasedIcebergCatalogConfigProvider.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/provider/GravitinoBasedIcebergCatalogConfigProvider.java index 3100e4bd466..7e2aef1f032 100644 --- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/provider/GravitinoBasedIcebergCatalogConfigProvider.java +++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/provider/GravitinoBasedIcebergCatalogConfigProvider.java @@ -29,7 +29,6 @@ import org.apache.gravitino.client.GravitinoAdminClient; import org.apache.gravitino.exceptions.NoSuchCatalogException; import org.apache.gravitino.iceberg.common.IcebergConfig; -import org.apache.gravitino.iceberg.common.ops.IcebergCatalogWrapper; import org.apache.gravitino.iceberg.common.ops.IcebergCatalogConfigProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergCatalogWrapperManager.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergCatalogWrapperManager.java index 4bed0840e2e..9616b72a4f9 100644 --- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergCatalogWrapperManager.java +++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergCatalogWrapperManager.java @@ -34,8 +34,8 @@ import org.apache.gravitino.credential.CredentialProviderFactory; import org.apache.gravitino.credential.CredentialProviderManager; import org.apache.gravitino.iceberg.common.IcebergConfig; -import org.apache.gravitino.iceberg.common.ops.IcebergCatalogWrapper; import org.apache.gravitino.iceberg.common.ops.IcebergCatalogConfigProvider; +import org.apache.gravitino.iceberg.common.ops.IcebergCatalogWrapper; import org.apache.gravitino.iceberg.provider.ConfigBasedIcebergCatalogConfigProvider; import org.apache.gravitino.iceberg.provider.GravitinoBasedIcebergCatalogConfigProvider; import org.slf4j.Logger; @@ -70,7 +70,7 @@ public IcebergCatalogWrapperManager(Map properties) { TimeUnit.MILLISECONDS) .removalListener( (k, v, c) -> { - String catalogName = (String)k; + String catalogName = (String) k; LOG.info("Remove IcebergCatalogWrapper cache {}.", catalogName); closeIcebergCatalogWrapper((IcebergCatalogWrapper) v); credentialProviderManager.unregisterCredentialProvider(catalogName); @@ -115,7 +115,8 @@ private IcebergCatalogWrapper createCatalogWrapper(String catalogName) { IcebergConfig config = icebergConfig.get(); String credentialProviderType = config.get(IcebergConfig.CREDENTIAL_PROVIDER_TYPE); if (StringUtils.isNotBlank(credentialProviderType)) { - CredentialProvider credentialProvider = CredentialProviderFactory.create(credentialProviderType, config.getAllConfig()); + CredentialProvider credentialProvider = + CredentialProviderFactory.create(credentialProviderType, config.getAllConfig()); credentialProviderManager.registerCredentialProvider(catalogName, credentialProvider); } @@ -137,7 +138,8 @@ private String getCatalogName(String rawPrefix) { private IcebergCatalogConfigProvider createProvider(Map properties) { String providerName = (new IcebergConfig(properties)).get(IcebergConfig.ICEBERG_REST_CATALOG_PROVIDER); - String className = ICEBERG_CATALOG_CONFIG_PROVIDER_NAMES.getOrDefault(providerName, providerName); + String className = + ICEBERG_CATALOG_CONFIG_PROVIDER_NAMES.getOrDefault(providerName, providerName); LOG.info("Load Iceberg catalog provider: {}.", className); try { Class providerClz = Class.forName(className); diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableOperations.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableOperations.java index 042f251859c..655aac6e6e0 100644 --- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableOperations.java +++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableOperations.java @@ -41,9 +41,8 @@ import javax.ws.rs.core.Response; import org.apache.commons.lang3.StringUtils; import org.apache.gravitino.credential.Credential; -import org.apache.gravitino.credential.CredentialProvider; -import org.apache.gravitino.credential.CredentialProviderManager; import org.apache.gravitino.credential.CredentialPropertyUtils; +import org.apache.gravitino.credential.CredentialProvider; import org.apache.gravitino.credential.CredentialUtils; import org.apache.gravitino.iceberg.service.IcebergCatalogWrapperManager; import org.apache.gravitino.iceberg.service.IcebergObjectMapper; @@ -112,7 +111,10 @@ public Response createTable( accessDelegation, isCredentialVending); if (isCredentialVending) { - LoadTableResponse loadTableResponse = icebergCatalogWrapperManager.getOps(prefix).createTable(RESTUtil.decodeNamespace(namespace), createTableRequest); + LoadTableResponse loadTableResponse = + icebergCatalogWrapperManager + .getOps(prefix) + .createTable(RESTUtil.decodeNamespace(namespace), createTableRequest); return IcebergRestUtils.ok(injectCredentialConfig(prefix, loadTableResponse)); } else { return IcebergRestUtils.ok( @@ -245,20 +247,26 @@ private String SerializeUpdateTableRequest(UpdateTableRequest updateTableRequest } } - private LoadTableResponse injectCredentialConfig(String prefix, - LoadTableResponse loadTableResponse) { - CredentialProvider credentialProvider = icebergCatalogWrapperManager.getCredentialProvider(prefix); + private LoadTableResponse injectCredentialConfig( + String prefix, LoadTableResponse loadTableResponse) { + CredentialProvider credentialProvider = + icebergCatalogWrapperManager.getCredentialProvider(prefix); if (credentialProvider == null) { throw new RuntimeException("Doesn't support credential vending"); } - Credential credential = CredentialUtils.vendCredential(credentialProvider, - loadTableResponse.tableMetadata().location()); + Credential credential = + CredentialUtils.vendCredential( + credentialProvider, loadTableResponse.tableMetadata().location()); if (credential == null) { - throw new RuntimeException("Couldn't generate credential for " + credentialProvider.credentialType()); + throw new RuntimeException( + "Couldn't generate credential for " + credentialProvider.credentialType()); } Map credentialConfig = CredentialPropertyUtils.toIcebergProperties(credential); - return LoadTableResponse.builder().withTableMetadata(loadTableResponse.tableMetadata()) - .addAllConfig(loadTableResponse.config()).addAllConfig(credentialConfig).build(); + return LoadTableResponse.builder() + .withTableMetadata(loadTableResponse.tableMetadata()) + .addAllConfig(loadTableResponse.config()) + .addAllConfig(credentialConfig) + .build(); } private boolean isCredentialVending(String accessDelegation) { diff --git a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/ConfigBasedIcebergCatalogWrapperProviderForTest.java b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/ConfigBasedIcebergCatalogWrapperProviderForTest.java index af0486ca53f..f3cfd72cbf7 100644 --- a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/ConfigBasedIcebergCatalogWrapperProviderForTest.java +++ b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/ConfigBasedIcebergCatalogWrapperProviderForTest.java @@ -19,7 +19,6 @@ package org.apache.gravitino.iceberg.service.rest; import org.apache.gravitino.iceberg.common.IcebergConfig; -import org.apache.gravitino.iceberg.common.ops.IcebergCatalogWrapper; import org.apache.gravitino.iceberg.provider.ConfigBasedIcebergCatalogConfigProvider; public class ConfigBasedIcebergCatalogWrapperProviderForTest