Skip to content
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

Isolate Dropwizard and HK2 dependencies #523

Merged
merged 4 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
# under the License.
#

polaris-service/logs
polaris-service/build
polaris-core/build
logs
snazy marked this conversation as resolved.
Show resolved Hide resolved
build
.idea
2 changes: 1 addition & 1 deletion .github/workflows/check-md-link.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ jobs:
with:
use-quiet-mode: 'yes'
config-file: '.github/workflows/check-md-link-config.json'
folder-path: 'regtests, .github, build-logic, polaris-core, polaris-service, extension, spec, k8, getting-started, helm'
folder-path: 'regtests, .github, build-logic, polaris-core, service, dropwizard, extension, spec, k8, getting-started, helm'
file-path: 'CHAT_BYLAWS.md, CODE_OF_CONDUCT.md, CONTRIBUTING.md, README.md, SECURITY.md'
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
name: upload-test-artifacts
path: |
polaris-core/build/test-results/test
polaris-service/build/test-results/test
dropwizard/service/build/test-results/test

# NOTE: The Gradle Wrapper is the default and recommended way to run Gradle (https://docs.gradle.org/current/userguide/gradle_wrapper.html).
# If your project does not have the Gradle Wrapper configured, you can use the following configuration to run Gradle with a specified version.
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ RUN ./gradlew --no-daemon --info ${ECLIPSELINK_DEPS+"-PeclipseLinkDeps=$ECLIPSEL

FROM registry.access.redhat.com/ubi9/openjdk-21-runtime:1.20-2.1729089285
WORKDIR /app
COPY --from=build /app/polaris-service/build/docker-dist/bin /app/bin
COPY --from=build /app/polaris-service/build/docker-dist/lib /app/lib
COPY --from=build /app/dropwizard/service/build/docker-dist/bin /app/bin
COPY --from=build /app/dropwizard/service/build/docker-dist/lib /app/lib
COPY --from=build /app/polaris-server.yml /app

EXPOSE 8181
Expand Down
2 changes: 1 addition & 1 deletion aggregated-license-report/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import org.gradle.kotlin.dsl.support.unzipTo
val licenseReports by configurations.creating { description = "Used to generate license reports" }

dependencies {
licenseReports(project(":polaris-service", "licenseReports"))
licenseReports(project(":polaris-dropwizard-service", "licenseReports"))
}

val collectLicenseReportJars by
Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ tasks.named<RatTask>("rat").configure {
excludes.add("gradle/wrapper/gradle-wrapper*.jar*")

excludes.add("logs/**")
excludes.add("polaris-service/src/**/banner.txt")
excludes.add("polaris-service/logs")
excludes.add("service/common/src/**/banner.txt")
excludes.add("dropwizard/service/logs")

excludes.add("site/node_modules/**")
excludes.add("site/layouts/robots.txt")
Expand Down
187 changes: 187 additions & 0 deletions dropwizard/service/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
/*
* 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.
*/

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

plugins {
alias(libs.plugins.openapi.generator)
id("polaris-server")
id("polaris-license-report")
id("polaris-shadow-jar")
id("application")
}

dependencies {
implementation(project(":polaris-core"))
implementation(project(":polaris-service-common"))

implementation(platform(libs.dropwizard.bom))
implementation("io.dropwizard:dropwizard-core")
implementation("io.dropwizard:dropwizard-auth")
implementation("io.dropwizard:dropwizard-json-logging")

implementation(platform(libs.iceberg.bom))
implementation("org.apache.iceberg:iceberg-api")
implementation("org.apache.iceberg:iceberg-core")
implementation("org.apache.iceberg:iceberg-aws")

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")
}

compileOnly(libs.jakarta.annotation.api)
compileOnly(libs.jakarta.inject.api)
compileOnly(libs.jakarta.servlet.api)
compileOnly(libs.jakarta.validation.api)
compileOnly(libs.jakarta.ws.rs.api)

compileOnly(libs.smallrye.common.annotation)

implementation(platform(libs.google.cloud.storage.bom))
implementation("com.google.cloud:google-cloud-storage")

implementation(platform(libs.awssdk.bom))
implementation("software.amazon.awssdk:sts")
implementation("software.amazon.awssdk:iam-policy-builder")
implementation("software.amazon.awssdk:s3")

implementation(platform(libs.azuresdk.bom))
implementation("com.azure:azure-core")

implementation(platform(libs.micrometer.bom))
implementation("io.micrometer:micrometer-core")
implementation("io.micrometer:micrometer-registry-prometheus")
implementation(libs.prometheus.metrics.exporter.servlet.jakarta)

implementation(platform(libs.opentelemetry.bom))
implementation("io.opentelemetry:opentelemetry-api")
implementation("io.opentelemetry:opentelemetry-sdk-trace")
implementation("io.opentelemetry:opentelemetry-exporter-logging")
implementation(libs.opentelemetry.semconv)

implementation(libs.smallrye.common.annotation)

compileOnly(libs.swagger.annotations)
compileOnly(libs.spotbugs.annotations)
compileOnly(libs.jakarta.annotation.api)
compileOnly(libs.spotbugs.annotations)

testImplementation("org.apache.iceberg:iceberg-api:${libs.versions.iceberg.get()}:tests")
testImplementation("org.apache.iceberg:iceberg-core:${libs.versions.iceberg.get()}:tests")
testImplementation("io.dropwizard:dropwizard-testing")
testImplementation(platform(libs.testcontainers.bom))
testImplementation("org.testcontainers:testcontainers")
testImplementation(libs.s3mock.testcontainers)

testImplementation("org.apache.iceberg:iceberg-spark-3.5_2.12")
testImplementation("org.apache.iceberg:iceberg-spark-extensions-3.5_2.12")
testImplementation("org.apache.spark:spark-sql_2.12:3.5.1") {
// exclude log4j dependencies
exclude("org.apache.logging.log4j", "log4j-slf4j2-impl")
exclude("org.apache.logging.log4j", "log4j-api")
exclude("org.apache.logging.log4j", "log4j-1.2-api")
}

testImplementation(platform(libs.awssdk.bom))
testImplementation("software.amazon.awssdk:glue")
testImplementation("software.amazon.awssdk:kms")
testImplementation("software.amazon.awssdk:dynamodb")

testImplementation(libs.auth0.jwt)

testCompileOnly(libs.smallrye.common.annotation)

testImplementation(platform(libs.junit.bom))
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation(libs.assertj.core)
testImplementation(libs.mockito.core)
testRuntimeOnly("org.junit.platform:junit-platform-launcher")

testImplementation(project(":polaris-eclipselink"))
}

if (project.properties.get("eclipseLink") == "true") {
dependencies { implementation(project(":polaris-eclipselink")) }
}

tasks.named<Test>("test").configure {
if (System.getenv("AWS_REGION") == null) {
environment("AWS_REGION", "us-west-2")
}
jvmArgs("--add-exports", "java.base/sun.nio.ch=ALL-UNNAMED")
useJUnitPlatform()
maxParallelForks = 4
}

tasks.register<JavaExec>("runApp").configure {
if (System.getenv("AWS_REGION") == null) {
environment("AWS_REGION", "us-west-2")
}
classpath = sourceSets["main"].runtimeClasspath
mainClass = "org.apache.polaris.service.dropwizard.PolarisApplication"
args("server", "$rootDir/polaris-server.yml")
}

application { mainClass = "org.apache.polaris.service.dropwizard.PolarisApplication" }

tasks.named<Jar>("jar") {
manifest { attributes["Main-Class"] = "org.apache.polaris.service.dropwizard.PolarisApplication" }
}

tasks.register<Jar>("testJar") {
archiveClassifier.set("tests")
from(sourceSets.test.get().output)
}

val shadowJar =
tasks.named<ShadowJar>("shadowJar") {
manifest {
attributes["Main-Class"] = "org.apache.polaris.service.dropwizard.PolarisApplication"
}
mergeServiceFiles()
append("META-INF/hk2-locator/default")
isZip64 = true
finalizedBy("startScripts")
}

val startScripts =
tasks.named<CreateStartScripts>("startScripts") {
classpath = files(provider { shadowJar.get().archiveFileName })
applicationName = "polaris-service"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required to keep the script name to polaris-service and the environment variable to $POLARIS_SERVICE_OPTS

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to keep it as polaris-service or change it to polaris-dropwizard-service as well?
IMO the latter is likely better to not confuse people w/ Quarkus later.

}

tasks.register<Sync>("prepareDockerDist") {
into(project.layout.buildDirectory.dir("docker-dist"))
from(startScripts) { into("bin") }
from(shadowJar) { into("lib") }
doFirst { delete(project.layout.buildDirectory.dir("regtest-dist")) }
}

tasks.named("build").configure { dependsOn("prepareDockerDist") }

tasks.named("assemble").configure { dependsOn("testJar") }
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.polaris.service;
package org.apache.polaris.service.dropwizard;

import io.dropwizard.core.cli.ConfiguredCommand;
import io.dropwizard.core.setup.Bootstrap;
Expand All @@ -25,7 +25,7 @@
import org.apache.polaris.core.PolarisConfigurationStore;
import org.apache.polaris.core.auth.PolarisSecretsManager.PrincipalSecretsResult;
import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
import org.apache.polaris.service.config.PolarisApplicationConfig;
import org.apache.polaris.service.dropwizard.config.PolarisApplicationConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.polaris.service;
package org.apache.polaris.service.dropwizard;

import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Objects.requireNonNull;
import static org.apache.polaris.service.config.PolarisApplicationConfig.REQUEST_BODY_BYTES_NO_LIMIT;
import static org.apache.polaris.service.dropwizard.config.PolarisApplicationConfig.REQUEST_BODY_BYTES_NO_LIMIT;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
Expand All @@ -38,7 +38,6 @@
import com.fasterxml.jackson.databind.type.TypeFactory;
import io.dropwizard.auth.AuthDynamicFeature;
import io.dropwizard.auth.AuthFilter;
import io.dropwizard.auth.Authenticator;
import io.dropwizard.auth.oauth.OAuthCredentialAuthFilter;
import io.dropwizard.configuration.EnvironmentVariableSubstitutor;
import io.dropwizard.configuration.SubstitutingSourceProvider;
Expand Down Expand Up @@ -102,36 +101,37 @@
import org.apache.polaris.service.admin.api.PolarisPrincipalRolesApiService;
import org.apache.polaris.service.admin.api.PolarisPrincipalsApi;
import org.apache.polaris.service.admin.api.PolarisPrincipalsApiService;
import org.apache.polaris.service.auth.Authenticator;
import org.apache.polaris.service.catalog.IcebergCatalogAdapter;
import org.apache.polaris.service.catalog.api.IcebergRestCatalogApi;
import org.apache.polaris.service.catalog.api.IcebergRestCatalogApiService;
import org.apache.polaris.service.catalog.api.IcebergRestConfigurationApi;
import org.apache.polaris.service.catalog.api.IcebergRestConfigurationApiService;
import org.apache.polaris.service.catalog.api.IcebergRestOAuth2Api;
import org.apache.polaris.service.catalog.io.FileIOFactory;
import org.apache.polaris.service.config.PolarisApplicationConfig;
import org.apache.polaris.service.config.RealmEntityManagerFactory;
import org.apache.polaris.service.config.Serializers;
import org.apache.polaris.service.config.TaskHandlerConfiguration;
import org.apache.polaris.service.context.CallContextCatalogFactory;
import org.apache.polaris.service.context.CallContextResolver;
import org.apache.polaris.service.context.PolarisCallContextCatalogFactory;
import org.apache.polaris.service.context.RealmContextResolver;
import org.apache.polaris.service.context.RealmScopeContext;
import org.apache.polaris.service.dropwizard.config.PolarisApplicationConfig;
import org.apache.polaris.service.dropwizard.context.RealmScopeContext;
import org.apache.polaris.service.dropwizard.exception.JerseyViolationExceptionMapper;
import org.apache.polaris.service.dropwizard.persistence.cache.EntityCacheFactory;
import org.apache.polaris.service.dropwizard.throttling.StreamReadConstraintsExceptionMapper;
import org.apache.polaris.service.dropwizard.tracing.TracingFilter;
import org.apache.polaris.service.exception.IcebergExceptionMapper;
import org.apache.polaris.service.exception.IcebergJerseyViolationExceptionMapper;
import org.apache.polaris.service.exception.IcebergJsonProcessingExceptionMapper;
import org.apache.polaris.service.exception.PolarisExceptionMapper;
import org.apache.polaris.service.persistence.InMemoryPolarisMetaStoreManagerFactory;
import org.apache.polaris.service.persistence.cache.EntityCacheFactory;
import org.apache.polaris.service.ratelimiter.RateLimiterFilter;
import org.apache.polaris.service.task.ManifestFileCleanupTaskHandler;
import org.apache.polaris.service.task.TableCleanupTaskHandler;
import org.apache.polaris.service.task.TaskExecutor;
import org.apache.polaris.service.task.TaskExecutorImpl;
import org.apache.polaris.service.task.TaskFileIOSupplier;
import org.apache.polaris.service.throttling.StreamReadConstraintsExceptionMapper;
import org.apache.polaris.service.tracing.TracingFilter;
import org.eclipse.jetty.servlets.CrossOriginFilter;
import org.glassfish.hk2.api.Context;
import org.glassfish.hk2.api.Factory;
Expand Down Expand Up @@ -396,7 +396,7 @@ protected void configure() {
configuration.findService(new TypeLiteral<>() {});
AuthFilter<String, AuthenticatedPolarisPrincipal> oauthCredentialAuthFilter =
new OAuthCredentialAuthFilter.Builder<AuthenticatedPolarisPrincipal>()
.setAuthenticator(authenticator)
.setAuthenticator(authenticator::authenticate)
.setPrefix("Bearer")
.buildAuthFilter();
environment.jersey().register(new AuthDynamicFeature(oauthCredentialAuthFilter));
Expand Down Expand Up @@ -428,7 +428,7 @@ protected void configure() {
RESTSerializers.registerAll(objectMapper);
Serializers.registerSerializers(objectMapper);
environment.jersey().register(IcebergJsonProcessingExceptionMapper.class);
environment.jersey().register(IcebergJerseyViolationExceptionMapper.class);
environment.jersey().register(JerseyViolationExceptionMapper.class);

// for tests, we have to instantiate the TimedApplicationEventListener directly
environment.jersey().register(new TimedApplicationEventListener(polarisMetricRegistry));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.polaris.service;
package org.apache.polaris.service.dropwizard;

import com.codahale.metrics.health.HealthCheck;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.polaris.service;
package org.apache.polaris.service.dropwizard;

import io.dropwizard.core.cli.ConfiguredCommand;
import io.dropwizard.core.setup.Bootstrap;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
import org.apache.polaris.service.config.PolarisApplicationConfig;
import org.apache.polaris.service.dropwizard.config.PolarisApplicationConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.polaris.service;
package org.apache.polaris.service.dropwizard;

import static org.apache.polaris.core.monitor.PolarisMetricRegistry.TAG_RESP_CODE;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Stopwatch;
import io.micrometer.core.instrument.Tag;
import jakarta.inject.Inject;
import jakarta.ws.rs.ext.Provider;
import java.lang.reflect.Method;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.ws.rs.ext.Provider;
import org.apache.polaris.core.context.CallContext;
import org.apache.polaris.core.monitor.PolarisMetricRegistry;
import org.apache.polaris.core.resource.TimedApi;
Expand Down
Loading
Loading