You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "theoryxu (via GitHub)" <gi...@apache.org> on 2024/08/20 12:43:23 UTC
[PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
theoryxu opened a new pull request, #4598:
URL: https://github.com/apache/gravitino/pull/4598
…r Gravitino Iceberg REST server
<!--
1. Title: [#<issue>] <type>(<scope>): <subject>
Examples:
- "[#123] feat(operator): support xxx"
- "[#233] fix: check null before access result in xxx"
- "[MINOR] refactor: fix typo in variable name"
- "[MINOR] docs: fix typo in README"
- "[#255] test: fix flaky test NameOfTheTest"
Reference: https://www.conventionalcommits.org/en/v1.0.0/
2. If the PR is unfinished, please mark this PR as draft.
-->
### What changes were proposed in this pull request?
support Gravitino-based multi catalog support for Gravitino Iceberg REST server
### Why are the changes needed?
improvement: #4581
### Does this PR introduce _any_ user-facing change?
add a property key
### How was this patch tested?
1. add UT
2. manual test
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#discussion_r1729666353
##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergTableOpsManager.java:
##########
@@ -97,8 +126,19 @@ private String shelling(String rawPrefix) {
}
}
+ private void closeIcebergTableOps(IcebergTableOps ops) {
+ try {
+ ops.close();
+ } catch (Exception ex) {
+ LOG.warn("close iceberg table ops fail: {}, {}", ops, ex);
Review Comment:
iceberg -> Iceberg
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 merged PR #4598:
URL: https://github.com/apache/gravitino/pull/4598
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "theoryxu (via GitHub)" <gi...@apache.org>.
theoryxu commented on code in PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#discussion_r1728579287
##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/provider/GravitinoBasedIcebergTableOpsProvider.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * 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 org.apache.gravitino.iceberg.provider;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import java.util.Map;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.Catalog;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergConstants;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergPropertiesUtils;
+import org.apache.gravitino.client.GravitinoAdminClient;
+import org.apache.gravitino.iceberg.common.IcebergConfig;
+import org.apache.gravitino.iceberg.common.ops.IcebergTableOps;
+import org.apache.gravitino.iceberg.common.ops.IcebergTableOpsProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This provider proxy Gravitino lakehouse-iceberg catalogs.
+ *
+ * <p>For example, there are one catalog named iceberg_catalog in metalake
+ *
+ * <p>The catalogName is iceberg_catalog
+ */
+public class GravitinoBasedIcebergTableOpsProvider
+ implements IcebergTableOpsProvider, AutoCloseable {
+ public static final Logger LOG =
+ LoggerFactory.getLogger(GravitinoBasedIcebergTableOpsProvider.class);
+
+ public static final String GRAVITINO_BASE_ICEBERG_TABLE_OPS_PROVIDER_NAME =
+ "gravitino-based-provider";
+
+ private String gravitinoMetalake;
+
+ private GravitinoAdminClient client;
+
+ @Override
+ public void initialize(Map<String, String> properties) {
+ String uri = properties.get(IcebergConstants.GRAVITINO_URI);
+ String metalake = properties.get(IcebergConstants.GRAVITINO_METALAKE);
+
+ Preconditions.checkArgument(
+ StringUtils.isNotBlank(uri), IcebergConstants.GRAVITINO_URI + " is blank");
+ Preconditions.checkArgument(
+ StringUtils.isNotBlank(metalake), IcebergConstants.GRAVITINO_METALAKE + " is blank");
+
+ this.gravitinoMetalake = metalake;
+ this.client = GravitinoAdminClient.builder(uri).build();
+ }
+
+ @Override
+ public IcebergTableOps getIcebergTableOps(String catalogName) {
+ Preconditions.checkArgument(
+ StringUtils.isNotBlank(catalogName), "blank catalogName is illegal");
+ Preconditions.checkArgument(
+ !IcebergConstants.GRAVITINO_DEFAULT_CATALOG.equals(catalogName),
+ IcebergConstants.GRAVITINO_DEFAULT_CATALOG + " is illegal in gravitino-based-provider");
+
+ Catalog catalog = client.loadMetalake(gravitinoMetalake).loadCatalog(catalogName);
+
+ Preconditions.checkArgument(
+ "lakehouse-iceberg".equals(catalog.provider()),
+ String.format("%s.%s is not iceberg catalog", gravitinoMetalake, catalogName));
+
+ Map<String, String> properties =
+ IcebergPropertiesUtils.toIcebergCatalogProperties(catalog.properties());
+ return new IcebergTableOps(new IcebergConfig(properties));
+ }
+
+ @VisibleForTesting
+ void setClient(GravitinoAdminClient client) {
+ this.client = client;
+ }
+
+ @Override
+ public void close() throws Exception {
+ client.close();
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#discussion_r1728178113
##########
iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/IcebergConfig.java:
##########
@@ -166,6 +166,13 @@ public class IcebergConfig extends Config implements OverwriteDefaultConfig {
.stringConf()
.create();
+ public static final ConfigEntry<Long> ICEBERG_REST_CATALOG_CACHE_EVICTION_INTERVAL =
+ new ConfigBuilder(IcebergConstants.ICEBERG_REST_CATALOG_CACHE_EVICTION_INTERVAL)
+ .doc("Catalog cache eviction interval.")
+ .version(ConfigConstants.VERSION_0_7_0)
Review Comment:
default to 1 hour?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#discussion_r1728568092
##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergTableOpsManager.java:
##########
@@ -97,8 +126,20 @@ private String shelling(String rawPrefix) {
}
}
+ private void closeIcebergTableOps(IcebergTableOps ops) {
+ try {
+ ops.close();
+ } catch (Exception ex) {
+ LOG.warn("close iceberg table ops fail: {}", ops);
+ throw new RuntimeException(ex);
Review Comment:
what will happen if throwing exception here? I prefer to just print warning logs.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#discussion_r1728913692
##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/provider/GravitinoBasedIcebergTableOpsProvider.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * 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 org.apache.gravitino.iceberg.provider;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import java.util.Map;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.Catalog;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergConstants;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergPropertiesUtils;
+import org.apache.gravitino.client.GravitinoAdminClient;
+import org.apache.gravitino.iceberg.common.IcebergConfig;
+import org.apache.gravitino.iceberg.common.ops.IcebergTableOps;
+import org.apache.gravitino.iceberg.common.ops.IcebergTableOpsProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This provider proxy Gravitino lakehouse-iceberg catalogs.
+ *
+ * <p>For example, there are one catalog named iceberg_catalog in metalake
+ *
+ * <p>The catalogName is iceberg_catalog
+ */
+public class GravitinoBasedIcebergTableOpsProvider
+ implements IcebergTableOpsProvider, AutoCloseable {
+ public static final Logger LOG =
+ LoggerFactory.getLogger(GravitinoBasedIcebergTableOpsProvider.class);
+
+ public static final String GRAVITINO_BASE_ICEBERG_TABLE_OPS_PROVIDER_NAME =
+ "gravitino-based-provider";
+
+ private String gravitinoMetalake;
+
+ private GravitinoAdminClient client;
+
+ @Override
+ public void initialize(Map<String, String> properties) {
+ String uri = properties.get(IcebergConstants.GRAVITINO_URI);
+ String metalake = properties.get(IcebergConstants.GRAVITINO_METALAKE);
+
+ Preconditions.checkArgument(
+ StringUtils.isNotBlank(uri), IcebergConstants.GRAVITINO_URI + " is blank");
+ Preconditions.checkArgument(
+ StringUtils.isNotBlank(metalake), IcebergConstants.GRAVITINO_METALAKE + " is blank");
+
+ this.gravitinoMetalake = metalake;
+ this.client = GravitinoAdminClient.builder(uri).build();
+ }
+
+ @Override
+ public IcebergTableOps getIcebergTableOps(String catalogName) {
+ Preconditions.checkArgument(
+ StringUtils.isNotBlank(catalogName), "blank catalogName is illegal");
+ Preconditions.checkArgument(
+ !IcebergConstants.GRAVITINO_DEFAULT_CATALOG.equals(catalogName),
+ IcebergConstants.GRAVITINO_DEFAULT_CATALOG + " is illegal in gravitino-based-provider");
+
+ Catalog catalog = client.loadMetalake(gravitinoMetalake).loadCatalog(catalogName);
+
+ Preconditions.checkArgument(
+ "lakehouse-iceberg".equals(catalog.provider()),
+ String.format("%s.%s is not iceberg catalog", gravitinoMetalake, catalogName));
+
+ Map<String, String> properties =
+ IcebergPropertiesUtils.toIcebergCatalogProperties(catalog.properties());
+ return new IcebergTableOps(new IcebergConfig(properties));
+ }
+
+ @VisibleForTesting
+ void setClient(GravitinoAdminClient client) {
+ this.client = client;
Review Comment:
please remove this
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "theoryxu (via GitHub)" <gi...@apache.org>.
theoryxu commented on PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#issuecomment-2300413891
@jerryshao @FANNG1 please help to review, Thanks.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "theoryxu (via GitHub)" <gi...@apache.org>.
theoryxu commented on code in PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#discussion_r1728436981
##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergTableOpsManager.java:
##########
@@ -35,16 +43,41 @@ public class IcebergTableOpsManager implements AutoCloseable {
private static final ImmutableMap<String, String> ICEBERG_TABLE_OPS_PROVIDER_NAMES =
ImmutableMap.of(
ConfigBasedIcebergTableOpsProvider.CONFIG_BASE_ICEBERG_TABLE_OPS_PROVIDER_NAME,
- ConfigBasedIcebergTableOpsProvider.class.getCanonicalName());
+ ConfigBasedIcebergTableOpsProvider.class.getCanonicalName(),
+ GravitinoBasedIcebergTableOpsProvider.GRAVITINO_BASE_ICEBERG_TABLE_OPS_PROVIDER_NAME,
+ GravitinoBasedIcebergTableOpsProvider.class.getCanonicalName());
private final Cache<String, IcebergTableOps> icebergTableOpsCache;
private final IcebergTableOpsProvider provider;
public IcebergTableOpsManager(Map<String, String> properties) {
- this.icebergTableOpsCache = Caffeine.newBuilder().build();
this.provider = createProvider(properties);
this.provider.initialize(properties);
+ this.icebergTableOpsCache =
+ Caffeine.newBuilder()
+ .expireAfterWrite(
+ (new IcebergConfig(properties))
+ .get(IcebergConfig.ICEBERG_REST_CATALOG_CACHE_EVICTION_INTERVAL),
+ TimeUnit.MILLISECONDS)
+ .removalListener(
+ (k, v, c) -> {
+ LOG.info("Remove IcebergTableOps cache {}.", k);
+ try {
Review Comment:
I modified GravitinoCatalogProvider to maintain a GravitinoAdminClient and ensure it closes when IcebergTableOpsManager closes.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#discussion_r1728562544
##########
docs/iceberg-rest-service.md:
##########
@@ -215,6 +217,24 @@ You can access different catalogs by setting the `prefix` to the specific catalo
...
```
+##### gravitino-based catalog provider
Review Comment:
Gravitino based?
##########
docs/iceberg-rest-service.md:
##########
@@ -178,6 +178,8 @@ The Gravitino Iceberg REST server supports multiple catalogs and offers a config
|----------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|----------|---------------|
| `gravitino.iceberg-rest.catalog-provider` | Catalog provider class name, you can develop a class that implements `IcebergTableOpsProvider` and add the corresponding jar file to the Iceberg REST service classpath directory. | `config-based-provider` | No | 0.7.0 |
+##### config-based catalog provider
Review Comment:
Configuration based?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#discussion_r1728914097
##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergTableOpsManager.java:
##########
@@ -97,8 +126,19 @@ private String shelling(String rawPrefix) {
}
}
+ private void closeIcebergTableOps(IcebergTableOps ops) {
+ try {
+ ops.close();
+ } catch (Exception ex) {
+ LOG.warn("close iceberg table ops fail: {}, {}", ops, ex);
Review Comment:
close -> Close
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "theoryxu (via GitHub)" <gi...@apache.org>.
theoryxu commented on code in PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#discussion_r1728566750
##########
docs/iceberg-rest-service.md:
##########
@@ -178,6 +178,8 @@ The Gravitino Iceberg REST server supports multiple catalogs and offers a config
|----------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|----------|---------------|
| `gravitino.iceberg-rest.catalog-provider` | Catalog provider class name, you can develop a class that implements `IcebergTableOpsProvider` and add the corresponding jar file to the Iceberg REST service classpath directory. | `config-based-provider` | No | 0.7.0 |
+##### config-based catalog provider
Review Comment:
fixed
##########
docs/iceberg-rest-service.md:
##########
@@ -215,6 +217,24 @@ You can access different catalogs by setting the `prefix` to the specific catalo
...
```
+##### gravitino-based catalog provider
Review Comment:
fixed
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#discussion_r1728571604
##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/provider/GravitinoBasedIcebergTableOpsProvider.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * 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 org.apache.gravitino.iceberg.provider;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import java.util.Map;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.Catalog;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergConstants;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergPropertiesUtils;
+import org.apache.gravitino.client.GravitinoAdminClient;
+import org.apache.gravitino.iceberg.common.IcebergConfig;
+import org.apache.gravitino.iceberg.common.ops.IcebergTableOps;
+import org.apache.gravitino.iceberg.common.ops.IcebergTableOpsProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This provider proxy Gravitino lakehouse-iceberg catalogs.
+ *
+ * <p>For example, there are one catalog named iceberg_catalog in metalake
+ *
+ * <p>The catalogName is iceberg_catalog
+ */
+public class GravitinoBasedIcebergTableOpsProvider
+ implements IcebergTableOpsProvider, AutoCloseable {
+ public static final Logger LOG =
+ LoggerFactory.getLogger(GravitinoBasedIcebergTableOpsProvider.class);
+
+ public static final String GRAVITINO_BASE_ICEBERG_TABLE_OPS_PROVIDER_NAME =
+ "gravitino-based-provider";
+
+ private String gravitinoMetalake;
+
+ private GravitinoAdminClient client;
+
+ @Override
+ public void initialize(Map<String, String> properties) {
+ String uri = properties.get(IcebergConstants.GRAVITINO_URI);
+ String metalake = properties.get(IcebergConstants.GRAVITINO_METALAKE);
+
+ Preconditions.checkArgument(
+ StringUtils.isNotBlank(uri), IcebergConstants.GRAVITINO_URI + " is blank");
+ Preconditions.checkArgument(
+ StringUtils.isNotBlank(metalake), IcebergConstants.GRAVITINO_METALAKE + " is blank");
+
+ this.gravitinoMetalake = metalake;
+ this.client = GravitinoAdminClient.builder(uri).build();
+ }
+
+ @Override
+ public IcebergTableOps getIcebergTableOps(String catalogName) {
+ Preconditions.checkArgument(
+ StringUtils.isNotBlank(catalogName), "blank catalogName is illegal");
+ Preconditions.checkArgument(
+ !IcebergConstants.GRAVITINO_DEFAULT_CATALOG.equals(catalogName),
+ IcebergConstants.GRAVITINO_DEFAULT_CATALOG + " is illegal in gravitino-based-provider");
+
+ Catalog catalog = client.loadMetalake(gravitinoMetalake).loadCatalog(catalogName);
+
+ Preconditions.checkArgument(
+ "lakehouse-iceberg".equals(catalog.provider()),
+ String.format("%s.%s is not iceberg catalog", gravitinoMetalake, catalogName));
+
+ Map<String, String> properties =
+ IcebergPropertiesUtils.toIcebergCatalogProperties(catalog.properties());
+ return new IcebergTableOps(new IcebergConfig(properties));
+ }
+
+ @VisibleForTesting
+ void setClient(GravitinoAdminClient client) {
+ this.client = client;
+ }
+
+ @Override
+ public void close() throws Exception {
+ client.close();
Review Comment:
check whether the client is null?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#discussion_r1728913692
##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/provider/GravitinoBasedIcebergTableOpsProvider.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * 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 org.apache.gravitino.iceberg.provider;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import java.util.Map;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.Catalog;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergConstants;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergPropertiesUtils;
+import org.apache.gravitino.client.GravitinoAdminClient;
+import org.apache.gravitino.iceberg.common.IcebergConfig;
+import org.apache.gravitino.iceberg.common.ops.IcebergTableOps;
+import org.apache.gravitino.iceberg.common.ops.IcebergTableOpsProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This provider proxy Gravitino lakehouse-iceberg catalogs.
+ *
+ * <p>For example, there are one catalog named iceberg_catalog in metalake
+ *
+ * <p>The catalogName is iceberg_catalog
+ */
+public class GravitinoBasedIcebergTableOpsProvider
+ implements IcebergTableOpsProvider, AutoCloseable {
+ public static final Logger LOG =
+ LoggerFactory.getLogger(GravitinoBasedIcebergTableOpsProvider.class);
+
+ public static final String GRAVITINO_BASE_ICEBERG_TABLE_OPS_PROVIDER_NAME =
+ "gravitino-based-provider";
+
+ private String gravitinoMetalake;
+
+ private GravitinoAdminClient client;
+
+ @Override
+ public void initialize(Map<String, String> properties) {
+ String uri = properties.get(IcebergConstants.GRAVITINO_URI);
+ String metalake = properties.get(IcebergConstants.GRAVITINO_METALAKE);
+
+ Preconditions.checkArgument(
+ StringUtils.isNotBlank(uri), IcebergConstants.GRAVITINO_URI + " is blank");
+ Preconditions.checkArgument(
+ StringUtils.isNotBlank(metalake), IcebergConstants.GRAVITINO_METALAKE + " is blank");
+
+ this.gravitinoMetalake = metalake;
+ this.client = GravitinoAdminClient.builder(uri).build();
+ }
+
+ @Override
+ public IcebergTableOps getIcebergTableOps(String catalogName) {
+ Preconditions.checkArgument(
+ StringUtils.isNotBlank(catalogName), "blank catalogName is illegal");
+ Preconditions.checkArgument(
+ !IcebergConstants.GRAVITINO_DEFAULT_CATALOG.equals(catalogName),
+ IcebergConstants.GRAVITINO_DEFAULT_CATALOG + " is illegal in gravitino-based-provider");
+
+ Catalog catalog = client.loadMetalake(gravitinoMetalake).loadCatalog(catalogName);
+
+ Preconditions.checkArgument(
+ "lakehouse-iceberg".equals(catalog.provider()),
+ String.format("%s.%s is not iceberg catalog", gravitinoMetalake, catalogName));
+
+ Map<String, String> properties =
+ IcebergPropertiesUtils.toIcebergCatalogProperties(catalog.properties());
+ return new IcebergTableOps(new IcebergConfig(properties));
+ }
+
+ @VisibleForTesting
+ void setClient(GravitinoAdminClient client) {
+ this.client = client;
Review Comment:
please remove this
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#discussion_r1728177500
##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergTableOpsManager.java:
##########
@@ -35,16 +43,41 @@ public class IcebergTableOpsManager implements AutoCloseable {
private static final ImmutableMap<String, String> ICEBERG_TABLE_OPS_PROVIDER_NAMES =
ImmutableMap.of(
ConfigBasedIcebergTableOpsProvider.CONFIG_BASE_ICEBERG_TABLE_OPS_PROVIDER_NAME,
- ConfigBasedIcebergTableOpsProvider.class.getCanonicalName());
+ ConfigBasedIcebergTableOpsProvider.class.getCanonicalName(),
+ GravitinoBasedIcebergTableOpsProvider.GRAVITINO_BASE_ICEBERG_TABLE_OPS_PROVIDER_NAME,
+ GravitinoBasedIcebergTableOpsProvider.class.getCanonicalName());
private final Cache<String, IcebergTableOps> icebergTableOpsCache;
private final IcebergTableOpsProvider provider;
public IcebergTableOpsManager(Map<String, String> properties) {
- this.icebergTableOpsCache = Caffeine.newBuilder().build();
this.provider = createProvider(properties);
this.provider.initialize(properties);
+ this.icebergTableOpsCache =
+ Caffeine.newBuilder()
+ .expireAfterWrite(
+ (new IcebergConfig(properties))
+ .get(IcebergConfig.ICEBERG_REST_CATALOG_CACHE_EVICTION_INTERVAL),
+ TimeUnit.MILLISECONDS)
+ .removalListener(
+ (k, v, c) -> {
+ LOG.info("Remove IcebergTableOps cache {}.", k);
+ try {
Review Comment:
We could make GravitinoCatalogProvider implement `Closable`, and close it in remove listener
```java
if (v instanceOf Closeable) {
((Closable)v).close()
}
```
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "theoryxu (via GitHub)" <gi...@apache.org>.
theoryxu commented on code in PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#discussion_r1726398258
##########
iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/GravitinoBasedIcebergTableOpsProvider.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * 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 org.apache.gravitino.iceberg.common.ops;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.Catalog;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergConstants;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergPropertiesUtils;
+import org.apache.gravitino.client.GravitinoAdminClient;
+import org.apache.gravitino.client.GravitinoMetalake;
+import org.apache.gravitino.iceberg.common.IcebergConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This provider proxy Gravitino lakehouse-iceberg catalogs.
+ *
+ * <p>For example, there are one catalog named iceberg_catalog in metalake
+ *
+ * <p>The catalogName is iceberg_catalog
+ */
+public class GravitinoBasedIcebergTableOpsProvider implements IcebergTableOpsProvider {
Review Comment:
If we do that, IcebergTableOpsManager also needs be replaced togther.
##########
iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/GravitinoBasedIcebergTableOpsProvider.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * 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 org.apache.gravitino.iceberg.common.ops;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.Catalog;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergConstants;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergPropertiesUtils;
+import org.apache.gravitino.client.GravitinoAdminClient;
+import org.apache.gravitino.client.GravitinoMetalake;
+import org.apache.gravitino.iceberg.common.IcebergConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This provider proxy Gravitino lakehouse-iceberg catalogs.
+ *
+ * <p>For example, there are one catalog named iceberg_catalog in metalake
+ *
+ * <p>The catalogName is iceberg_catalog
+ */
+public class GravitinoBasedIcebergTableOpsProvider implements IcebergTableOpsProvider {
Review Comment:
If we do that, IcebergTableOpsManager also needs to be replaced together.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "theoryxu (via GitHub)" <gi...@apache.org>.
theoryxu commented on code in PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#discussion_r1726399176
##########
iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/GravitinoBasedIcebergTableOpsProvider.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * 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 org.apache.gravitino.iceberg.common.ops;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.Catalog;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergConstants;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergPropertiesUtils;
+import org.apache.gravitino.client.GravitinoAdminClient;
+import org.apache.gravitino.client.GravitinoMetalake;
+import org.apache.gravitino.iceberg.common.IcebergConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This provider proxy Gravitino lakehouse-iceberg catalogs.
+ *
+ * <p>For example, there are one catalog named iceberg_catalog in metalake
+ *
+ * <p>The catalogName is iceberg_catalog
+ */
+public class GravitinoBasedIcebergTableOpsProvider implements IcebergTableOpsProvider {
+ public static final Logger LOG =
+ LoggerFactory.getLogger(GravitinoBasedIcebergTableOpsProvider.class);
+
+ public static final String GRAVITINO_BASE_ICEBERG_TABLE_OPS_PROVIDER_NAME =
+ "gravitino-based-provider";
+ private final AtomicReference<GravitinoMetalake> metalakeWrapper = new AtomicReference<>();
+
+ private String gravitinoUri;
+
+ private String gravitinoMetalake;
+
+ @Override
+ public void initialize(Map<String, String> properties) {
+ this.gravitinoUri = properties.get(IcebergConstants.GRAVITINO_URI);
+ this.gravitinoMetalake = properties.get(IcebergConstants.GRAVITINO_METALAKE);
Review Comment:
done
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#issuecomment-2308797285
@theoryxu , thanks for your contribution!
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "theoryxu (via GitHub)" <gi...@apache.org>.
theoryxu commented on PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#issuecomment-2303865835
@FANNG1 All comments have been resolved. Could you review it again? Thanks
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#discussion_r1728562544
##########
docs/iceberg-rest-service.md:
##########
@@ -215,6 +217,24 @@ You can access different catalogs by setting the `prefix` to the specific catalo
...
```
+##### gravitino-based catalog provider
Review Comment:
Gravitino server based?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "theoryxu (via GitHub)" <gi...@apache.org>.
theoryxu commented on code in PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#discussion_r1728431895
##########
iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/IcebergConfig.java:
##########
@@ -166,6 +166,13 @@ public class IcebergConfig extends Config implements OverwriteDefaultConfig {
.stringConf()
.create();
+ public static final ConfigEntry<Long> ICEBERG_REST_CATALOG_CACHE_EVICTION_INTERVAL =
+ new ConfigBuilder(IcebergConstants.ICEBERG_REST_CATALOG_CACHE_EVICTION_INTERVAL)
+ .doc("Catalog cache eviction interval.")
+ .version(ConfigConstants.VERSION_0_7_0)
Review Comment:
done
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "theoryxu (via GitHub)" <gi...@apache.org>.
theoryxu commented on code in PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#discussion_r1728436981
##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergTableOpsManager.java:
##########
@@ -35,16 +43,41 @@ public class IcebergTableOpsManager implements AutoCloseable {
private static final ImmutableMap<String, String> ICEBERG_TABLE_OPS_PROVIDER_NAMES =
ImmutableMap.of(
ConfigBasedIcebergTableOpsProvider.CONFIG_BASE_ICEBERG_TABLE_OPS_PROVIDER_NAME,
- ConfigBasedIcebergTableOpsProvider.class.getCanonicalName());
+ ConfigBasedIcebergTableOpsProvider.class.getCanonicalName(),
+ GravitinoBasedIcebergTableOpsProvider.GRAVITINO_BASE_ICEBERG_TABLE_OPS_PROVIDER_NAME,
+ GravitinoBasedIcebergTableOpsProvider.class.getCanonicalName());
private final Cache<String, IcebergTableOps> icebergTableOpsCache;
private final IcebergTableOpsProvider provider;
public IcebergTableOpsManager(Map<String, String> properties) {
- this.icebergTableOpsCache = Caffeine.newBuilder().build();
this.provider = createProvider(properties);
this.provider.initialize(properties);
+ this.icebergTableOpsCache =
+ Caffeine.newBuilder()
+ .expireAfterWrite(
+ (new IcebergConfig(properties))
+ .get(IcebergConfig.ICEBERG_REST_CATALOG_CACHE_EVICTION_INTERVAL),
+ TimeUnit.MILLISECONDS)
+ .removalListener(
+ (k, v, c) -> {
+ LOG.info("Remove IcebergTableOps cache {}.", k);
+ try {
Review Comment:
I modified `GravitinoCatalogProvider` to maintain a `GravitinoAdminClient` and ensure it closes when `IcebergTableOpsManager` closes.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "theoryxu (via GitHub)" <gi...@apache.org>.
theoryxu commented on code in PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#discussion_r1728607986
##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergTableOpsManager.java:
##########
@@ -97,8 +126,20 @@ private String shelling(String rawPrefix) {
}
}
+ private void closeIcebergTableOps(IcebergTableOps ops) {
+ try {
+ ops.close();
+ } catch (Exception ex) {
+ LOG.warn("close iceberg table ops fail: {}", ops);
+ throw new RuntimeException(ex);
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#discussion_r1728914709
##########
docs/iceberg-rest-service.md:
##########
@@ -215,6 +217,24 @@ You can access different catalogs by setting the `prefix` to the specific catalo
...
```
+##### Gravitino server based catalog provider
+
+When using a Gravitino server based catalog provider, you can leverage Gravitino to support dynamic catalog management for the Iceberg REST server.
+
+| Configuration item | Description | Default value | Required | Since Version |
+|--------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|---------------|----------|---------------|
+| `gravitino.iceberg-rest.gravitino-uri` | The uri of Gravitino server address, only worked if `catalog-provider` is `gravitino-based-provider`. | (none) | No | 0.7.0 |
+| `gravitino.iceberg-rest.gravitino-metalake` | The metalake name that `gravitino-based-provider` used to request to Gravitino, only worked if `catalog-provider` is `gravitino-based-provider`. | (none) | No | 0.7.0 |
+| `gravitino.iceberg-rest.catalog-cache-eviction-interval-ms` | Catalog cache eviction interval. | 3600000 | No | 0.7.0 |
+
+```text
+gravitino.iceberg-rest.catalog-cache-eviction-interval-ms = 300000
+gravitino.iceberg-rest.catalog-provider = gravitino-based-provider
+gravitino.iceberg-rest.gravitino-uri = http://127.0.0.1:8090
+gravitino.iceberg-rest.gravitino-metalake = test
+...
Review Comment:
remove `...` ?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#discussion_r1728178727
##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/provider/GravitinoBasedIcebergTableOpsProvider.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * 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 org.apache.gravitino.iceberg.provider;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.Catalog;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergConstants;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergPropertiesUtils;
+import org.apache.gravitino.client.GravitinoAdminClient;
+import org.apache.gravitino.client.GravitinoMetalake;
+import org.apache.gravitino.iceberg.common.IcebergConfig;
+import org.apache.gravitino.iceberg.common.ops.IcebergTableOps;
+import org.apache.gravitino.iceberg.common.ops.IcebergTableOpsProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This provider proxy Gravitino lakehouse-iceberg catalogs.
+ *
+ * <p>For example, there are one catalog named iceberg_catalog in metalake
+ *
+ * <p>The catalogName is iceberg_catalog
+ */
+public class GravitinoBasedIcebergTableOpsProvider implements IcebergTableOpsProvider {
+ public static final Logger LOG =
+ LoggerFactory.getLogger(GravitinoBasedIcebergTableOpsProvider.class);
+
+ public static final String GRAVITINO_BASE_ICEBERG_TABLE_OPS_PROVIDER_NAME =
+ "gravitino-based-provider";
+ private final AtomicReference<GravitinoMetalake> metalakeWrapper = new AtomicReference<>();
+
+ private String gravitinoUri;
+
+ private String gravitinoMetalake;
+
+ @Override
+ public void initialize(Map<String, String> properties) {
+ String uri = IcebergConstants.GRAVITINO_URI;
+ String metalake = IcebergConstants.GRAVITINO_METALAKE;
+
+ Preconditions.checkArgument(
+ StringUtils.isNotBlank(uri), IcebergConstants.GRAVITINO_URI + " is blank");
+ Preconditions.checkArgument(
+ StringUtils.isNotBlank(metalake), IcebergConstants.GRAVITINO_METALAKE + " is blank");
+
+ this.gravitinoUri = uri;
+ this.gravitinoMetalake = metalake;
+ }
+
+ @Override
+ public IcebergTableOps getIcebergTableOps(String catalogName) {
+ Preconditions.checkArgument(
+ StringUtils.isNotBlank(catalogName), "blank catalogName is illegal");
+ Preconditions.checkArgument(
+ !IcebergConstants.GRAVITINO_DEFAULT_CATALOG.equals(catalogName),
+ IcebergConstants.GRAVITINO_DEFAULT_CATALOG + " is illegal in gravitino-based-provider");
+
+ Catalog catalog = getMetalake().loadCatalog(catalogName);
+
+ Preconditions.checkArgument(
+ "lakehouse-iceberg".equals(catalog.provider()),
+ String.format("%s.%s is not iceberg catalog", getMetalake(), catalogName));
+
+ Map<String, String> properties =
+ IcebergPropertiesUtils.toIcebergCatalogProperties(catalog.properties());
+ return new IcebergTableOps(new IcebergConfig(properties));
+ }
+
+ public GravitinoMetalake getMetalake() {
Review Comment:
close it in `close()` method?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#issuecomment-2306086765
LGTM except minor comments
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "theoryxu (via GitHub)" <gi...@apache.org>.
theoryxu commented on code in PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#discussion_r1728431647
##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/provider/GravitinoBasedIcebergTableOpsProvider.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * 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 org.apache.gravitino.iceberg.provider;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.Catalog;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergConstants;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergPropertiesUtils;
+import org.apache.gravitino.client.GravitinoAdminClient;
+import org.apache.gravitino.client.GravitinoMetalake;
+import org.apache.gravitino.iceberg.common.IcebergConfig;
+import org.apache.gravitino.iceberg.common.ops.IcebergTableOps;
+import org.apache.gravitino.iceberg.common.ops.IcebergTableOpsProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This provider proxy Gravitino lakehouse-iceberg catalogs.
+ *
+ * <p>For example, there are one catalog named iceberg_catalog in metalake
+ *
+ * <p>The catalogName is iceberg_catalog
+ */
+public class GravitinoBasedIcebergTableOpsProvider implements IcebergTableOpsProvider {
+ public static final Logger LOG =
+ LoggerFactory.getLogger(GravitinoBasedIcebergTableOpsProvider.class);
+
+ public static final String GRAVITINO_BASE_ICEBERG_TABLE_OPS_PROVIDER_NAME =
+ "gravitino-based-provider";
+ private final AtomicReference<GravitinoMetalake> metalakeWrapper = new AtomicReference<>();
+
+ private String gravitinoUri;
+
+ private String gravitinoMetalake;
+
+ @Override
+ public void initialize(Map<String, String> properties) {
+ String uri = IcebergConstants.GRAVITINO_URI;
+ String metalake = IcebergConstants.GRAVITINO_METALAKE;
+
+ Preconditions.checkArgument(
+ StringUtils.isNotBlank(uri), IcebergConstants.GRAVITINO_URI + " is blank");
+ Preconditions.checkArgument(
+ StringUtils.isNotBlank(metalake), IcebergConstants.GRAVITINO_METALAKE + " is blank");
+
+ this.gravitinoUri = uri;
+ this.gravitinoMetalake = metalake;
+ }
+
+ @Override
+ public IcebergTableOps getIcebergTableOps(String catalogName) {
+ Preconditions.checkArgument(
+ StringUtils.isNotBlank(catalogName), "blank catalogName is illegal");
+ Preconditions.checkArgument(
+ !IcebergConstants.GRAVITINO_DEFAULT_CATALOG.equals(catalogName),
+ IcebergConstants.GRAVITINO_DEFAULT_CATALOG + " is illegal in gravitino-based-provider");
+
+ Catalog catalog = getMetalake().loadCatalog(catalogName);
+
+ Preconditions.checkArgument(
+ "lakehouse-iceberg".equals(catalog.provider()),
+ String.format("%s.%s is not iceberg catalog", getMetalake(), catalogName));
+
+ Map<String, String> properties =
+ IcebergPropertiesUtils.toIcebergCatalogProperties(catalog.properties());
+ return new IcebergTableOps(new IcebergConfig(properties));
+ }
+
+ public GravitinoMetalake getMetalake() {
Review Comment:
`GravitinoMetalake` doesn't have `close()`, Only `GravitinoAdminClient` has it. I have rebuilt this part.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4581]feat(iceberg) support Gravitino-based multi catalog support for Gravitino Iceberg REST server [gravitino]
Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #4598:
URL: https://github.com/apache/gravitino/pull/4598#discussion_r1724857441
##########
iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/GravitinoBasedIcebergTableOpsProvider.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * 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 org.apache.gravitino.iceberg.common.ops;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.Catalog;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergConstants;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergPropertiesUtils;
+import org.apache.gravitino.client.GravitinoAdminClient;
+import org.apache.gravitino.client.GravitinoMetalake;
+import org.apache.gravitino.iceberg.common.IcebergConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This provider proxy Gravitino lakehouse-iceberg catalogs.
+ *
+ * <p>For example, there are one catalog named iceberg_catalog in metalake
+ *
+ * <p>The catalogName is iceberg_catalog
+ */
+public class GravitinoBasedIcebergTableOpsProvider implements IcebergTableOpsProvider {
+ public static final Logger LOG =
+ LoggerFactory.getLogger(GravitinoBasedIcebergTableOpsProvider.class);
+
+ public static final String GRAVITINO_BASE_ICEBERG_TABLE_OPS_PROVIDER_NAME =
+ "gravitino-based-provider";
+ private final AtomicReference<GravitinoMetalake> metalakeWrapper = new AtomicReference<>();
+
+ private String gravitinoUri;
+
+ private String gravitinoMetalake;
+
+ @Override
+ public void initialize(Map<String, String> properties) {
+ this.gravitinoUri = properties.get(IcebergConstants.GRAVITINO_URI);
+ this.gravitinoMetalake = properties.get(IcebergConstants.GRAVITINO_METALAKE);
Review Comment:
add validate check for here?
##########
iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/GravitinoBasedIcebergTableOpsProvider.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * 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 org.apache.gravitino.iceberg.common.ops;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.Catalog;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergConstants;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergPropertiesUtils;
+import org.apache.gravitino.client.GravitinoAdminClient;
+import org.apache.gravitino.client.GravitinoMetalake;
+import org.apache.gravitino.iceberg.common.IcebergConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This provider proxy Gravitino lakehouse-iceberg catalogs.
+ *
+ * <p>For example, there are one catalog named iceberg_catalog in metalake
+ *
+ * <p>The catalogName is iceberg_catalog
+ */
+public class GravitinoBasedIcebergTableOpsProvider implements IcebergTableOpsProvider {
Review Comment:
Seems more proper to place xxxTableOpsProvder in `iceberg-rest-server` module, WDYT?
##########
iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/GravitinoBasedIcebergTableOpsProvider.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * 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 org.apache.gravitino.iceberg.common.ops;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.Catalog;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergConstants;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergPropertiesUtils;
+import org.apache.gravitino.client.GravitinoAdminClient;
+import org.apache.gravitino.client.GravitinoMetalake;
+import org.apache.gravitino.iceberg.common.IcebergConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This provider proxy Gravitino lakehouse-iceberg catalogs.
+ *
+ * <p>For example, there are one catalog named iceberg_catalog in metalake
+ *
+ * <p>The catalogName is iceberg_catalog
+ */
+public class GravitinoBasedIcebergTableOpsProvider implements IcebergTableOpsProvider {
Review Comment:
after adding `GravitinoBasedIcebergTableOpsProvider`, How about add cache expire time in `IcebergTableOpsManager`? to refresh Iceberg catalogs after altering.
##########
iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/IcebergConfig.java:
##########
@@ -174,6 +174,21 @@ public class IcebergConfig extends Config implements OverwriteDefaultConfig {
.stringConf()
.createWithDefault("config-based-provider");
+ public static final ConfigEntry<String> GRAVITINO_URI =
+ new ConfigBuilder(IcebergConstants.GRAVITINO_URI)
+ .doc(
+ "The uri of Gravitino server address, only worked if `catalog-provider` is `gravitino-based-provider`.")
+ .version(ConfigConstants.VERSION_0_7_0)
+ .stringConf()
+ .create();
+
+ public static final ConfigEntry<String> GRAVITINO_METALAKE =
+ new ConfigBuilder(IcebergConstants.GRAVITINO_METALAKE)
+ .doc("The metalake name that `gravitino-based-provider` used to request to Gravitino.")
Review Comment:
add only worked if `catalog-provider` is `gravitino-based-provider`?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org