diqiu50 commented on code in PR #12555:
URL: https://github.com/apache/gravitino/pull/12555#discussion_r3892070916
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/iceberg/IcebergConnectorAdapter.java:
##########
@@ -20,42 +20,131 @@
import static java.util.Collections.emptyList;
+import com.google.common.collect.ImmutableMap;
import io.trino.spi.session.PropertyMetadata;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.gravitino.catalog.property.PropertyConverter;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergConstants;
import org.apache.gravitino.credential.Credential;
+import org.apache.gravitino.trino.connector.GravitinoConfig;
import org.apache.gravitino.trino.connector.catalog.CatalogConnectorAdapter;
import
org.apache.gravitino.trino.connector.catalog.CatalogConnectorMetadataAdapter;
import org.apache.gravitino.trino.connector.metadata.GravitinoCatalog;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Transforming Apache Iceberg connector configuration and components into
Apache Gravitino
* connector.
*/
public class IcebergConnectorAdapter implements CatalogConnectorAdapter {
+ private static final Logger LOG =
LoggerFactory.getLogger(IcebergConnectorAdapter.class);
+
private static final String CONNECTOR_ICEBERG = "iceberg";
+ private static final String REST_CATALOG_BACKEND = "rest";
+ private static final String ICEBERG_PROVIDER = "lakehouse-iceberg";
+
+ /**
+ * Synthetic catalog property carrying the Iceberg REST server endpoint the
coordinator discovered
+ * for this catalog's metalake. {@link GravitinoConfig}'s own
discovered-endpoint map is populated
+ * only on the coordinator (the periodic discovery poll never runs on a
worker), so it cannot be
+ * read directly when building a catalog's internal connector config: every
node needs the same
+ * routing decision for the same catalog. Embedding the resolved endpoint
into the catalog itself,
+ * at registration time, means it travels to every node through the {@code
CREATE CATALOG}
+ * statement Trino replicates cluster-wide, the same way any other catalog
property does.
+ */
+ static final String DISCOVERED_ICEBERG_REST_URI_PROPERTY =
"__gravitino.iceberg.rest-uri";
+
private final IcebergPropertyMeta propertyMetadata;
- private final PropertyConverter catalogConverter;
+ private final IcebergCatalogPropertyConverter catalogConverter;
+ private final GravitinoConfig config;
/**
* Constructs a new IcebergConnectorAdapter. Initializes the property
metadata and catalog
* converter for handling Iceberg-specific configurations.
+ *
+ * @param config the Gravitino connector configuration
*/
- public IcebergConnectorAdapter() {
+ public IcebergConnectorAdapter(GravitinoConfig config) {
this.propertyMetadata = new IcebergPropertyMeta();
this.catalogConverter = new IcebergCatalogPropertyConverter();
+ this.config = config;
}
@Override
public Map<String, String> buildInternalConnectorConfig(
GravitinoCatalog catalog, Credential[] credentials) throws Exception {
- Map<String, String> config =
+ // The catalog backend describes how Gravitino stores the metadata; it
does not decide how
+ // Trino reaches the data. Whenever an Iceberg REST server endpoint is
available for this
+ // catalog's metalake, the catalog is loaded through it, the only path
that supports temporary
+ // credentials. A catalog that already has a REST backend keeps pointing
at its own configured
+ // endpoint. If no endpoint is available, this falls back to translating
catalog-backend as
+ // before — nothing to configure either way.
+ //
+ // The manual override is plain local config, so it is valid on every node
as-is. The
+ // discovered endpoint is coordinator-only knowledge, so it is read from
the catalog's own
+ // properties, where the coordinator embeds it at registration time (see
+ // embedDiscoveredIcebergRestUri), rather than from GravitinoConfig
directly.
+ String restUri = config.getManualIcebergRestUri();
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]