-
Notifications
You must be signed in to change notification settings - Fork 332
Modularize federation (Option 2) #2332
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
Changes from 4 commits
0563e93
ba56f27
a579619
d38ef56
29bb8bf
f5dd5e4
d1537de
d27b4d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| plugins { | ||
| id("polaris-client") | ||
| alias(libs.plugins.jandex) | ||
| } | ||
|
|
||
| dependencies { | ||
| // Polaris dependencies | ||
| implementation(project(":polaris-core")) | ||
|
|
||
| implementation(platform(libs.iceberg.bom)) | ||
| implementation("org.apache.iceberg:iceberg-api") | ||
| implementation("org.apache.iceberg:iceberg-core") | ||
| implementation("org.apache.iceberg:iceberg-common") | ||
|
|
||
| // Hadoop dependencies (for Hadoop catalog support) | ||
| implementation(libs.hadoop.common) { | ||
| exclude("org.slf4j", "slf4j-reload4j") | ||
| exclude("org.slf4j", "slf4j-log4j12") | ||
| exclude("ch.qos.reload4j", "reload4j") | ||
| exclude("log4j", "log4j") | ||
| exclude("org.apache.zookeeper", "zookeeper") | ||
| exclude("org.apache.hadoop.thirdparty", "hadoop-shaded-protobuf_3_25") | ||
| exclude("com.github.pjfanning", "jersey-json") | ||
| exclude("com.sun.jersey", "jersey-core") | ||
| exclude("com.sun.jersey", "jersey-server") | ||
| exclude("com.sun.jersey", "jersey-servlet") | ||
| exclude("io.dropwizard.metrics", "metrics-core") | ||
| } | ||
| implementation(libs.hadoop.client.api) | ||
| implementation(libs.hadoop.client.runtime) | ||
|
|
||
| // CDI dependencies for runtime discovery | ||
| implementation(libs.jakarta.enterprise.cdi.api) | ||
| implementation(libs.smallrye.common.annotation) | ||
|
|
||
| // Logging | ||
| implementation(libs.slf4j.api) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /* | ||
| * 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.polaris.extensions.federation.hadoop; | ||
|
|
||
| import io.smallrye.common.annotation.Identifier; | ||
| import jakarta.enterprise.context.ApplicationScoped; | ||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.iceberg.catalog.Catalog; | ||
| import org.apache.iceberg.hadoop.HadoopCatalog; | ||
| import org.apache.polaris.core.catalog.ExternalCatalogFactory; | ||
| import org.apache.polaris.core.connection.AuthenticationParametersDpo; | ||
| import org.apache.polaris.core.connection.AuthenticationType; | ||
| import org.apache.polaris.core.connection.ConnectionConfigInfoDpo; | ||
| import org.apache.polaris.core.connection.ConnectionType; | ||
| import org.apache.polaris.core.connection.hadoop.HadoopConnectionConfigInfoDpo; | ||
| import org.apache.polaris.core.secrets.UserSecretsManager; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| /** Factory class for creating a Hadoop catalog handle based on connection configuration. */ | ||
| @ApplicationScoped | ||
| @Identifier(ConnectionType.HADOOP_FACTORY_IDENTIFIER) | ||
| public class HadoopFederatedCatalogFactory implements ExternalCatalogFactory { | ||
| private static final Logger LOGGER = LoggerFactory.getLogger(HadoopFederatedCatalogFactory.class); | ||
|
|
||
| @Override | ||
| public Catalog createCatalog( | ||
| ConnectionConfigInfoDpo connectionConfigInfoDpo, UserSecretsManager userSecretsManager) { | ||
| // Currently, Polaris supports Hadoop federation only via IMPLICIT authentication. | ||
| // Hence, prior to initializing the configuration, ensure that the catalog uses | ||
| // IMPLICIT authentication. | ||
| AuthenticationParametersDpo authenticationParametersDpo = | ||
| connectionConfigInfoDpo.getAuthenticationParameters(); | ||
| if (authenticationParametersDpo.getAuthenticationTypeCode() | ||
| != AuthenticationType.IMPLICIT.getCode()) { | ||
| throw new IllegalStateException("Hadoop federation only supports IMPLICIT authentication."); | ||
| } | ||
| Configuration conf = new Configuration(); | ||
| String warehouse = ((HadoopConnectionConfigInfoDpo) connectionConfigInfoDpo).getWarehouse(); | ||
| HadoopCatalog hadoopCatalog = new HadoopCatalog(conf, warehouse); | ||
| hadoopCatalog.initialize( | ||
| warehouse, connectionConfigInfoDpo.asIcebergCatalogProperties(userSecretsManager)); | ||
| return hadoopCatalog; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /* | ||
| * 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.polaris.core.catalog; | ||
|
|
||
| import org.apache.iceberg.catalog.Catalog; | ||
| import org.apache.polaris.core.connection.ConnectionConfigInfoDpo; | ||
| import org.apache.polaris.core.secrets.UserSecretsManager; | ||
|
|
||
| /** | ||
| * Factory interface for creating external catalog handles based on connection configuration. | ||
| * | ||
| * <p>Implementations should be annotated with CDI annotations and use the @Identifier annotation to | ||
| * specify which connection type they support. | ||
| */ | ||
| public interface ExternalCatalogFactory { | ||
|
|
||
| /** | ||
| * Creates a catalog handle for the given connection configuration. | ||
| * | ||
| * @param connectionConfig the connection configuration | ||
| * @param userSecretsManager the user secrets manager for handling credentials | ||
| * @return the initialized catalog | ||
| * @throws IllegalStateException if the connection configuration is invalid | ||
| */ | ||
| Catalog createCatalog( | ||
| ConnectionConfigInfoDpo connectionConfig, UserSecretsManager userSecretsManager); | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -35,6 +35,9 @@ public enum ConnectionType { | |||||||||||||||||||||||||||||
| HADOOP(2), | ||||||||||||||||||||||||||||||
| ; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| public static final String ICEBERG_REST_FACTORY_IDENTIFIER = "ICEBERG_REST"; | ||||||||||||||||||||||||||||||
| public static final String HADOOP_FACTORY_IDENTIFIER = "HADOOP"; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| private static final ConnectionType[] REVERSE_MAPPING_ARRAY; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| static { | ||||||||||||||||||||||||||||||
|
|
@@ -77,4 +80,22 @@ public enum ConnectionType { | |||||||||||||||||||||||||||||
| public int getCode() { | ||||||||||||||||||||||||||||||
| return this.code; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||
| * Get the factory identifier string used for CDI injection of the appropriate | ||||||||||||||||||||||||||||||
| * ExternalCatalogFactory. | ||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||
| * @return the factory identifier string | ||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||
| public String getFactoryIdentifier() { | ||||||||||||||||||||||||||||||
| switch (this) { | ||||||||||||||||||||||||||||||
| case ICEBERG_REST: | ||||||||||||||||||||||||||||||
| return ICEBERG_REST_FACTORY_IDENTIFIER; | ||||||||||||||||||||||||||||||
| case HADOOP: | ||||||||||||||||||||||||||||||
| return HADOOP_FACTORY_IDENTIFIER; | ||||||||||||||||||||||||||||||
| default: | ||||||||||||||||||||||||||||||
| throw new UnsupportedOperationException( | ||||||||||||||||||||||||||||||
| "No factory identifier for connection type: " + this); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
Comment on lines
+90
to
+100
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You may want to just return
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can't use the name().toLowerCase() directly because of two reasons:
To make things consistent, I've changed the declarations to use lower case. |
||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
THose are superfluous, as those are the enum names, and can therefore be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need these because we can't use ConnnectionType.ICEBERG_REST.name() or ConnectionType.HADOOP.name(). The annotations needs to be constant expressions. Here's the error for your reference.
The value for annotation attribute Identifier.value must be a constant expressionJava(536871525)