Skip to content

Commit

Permalink
support split iceberg rest service
Browse files Browse the repository at this point in the history
  • Loading branch information
FANNG1 committed Jul 2, 2024
1 parent d5d3fa2 commit 8df618a
Show file tree
Hide file tree
Showing 53 changed files with 1,232 additions and 99 deletions.
42 changes: 41 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,34 @@ tasks {
}
}

val compileIcebergRESTServer by registering {
dependsOn("iceberg-rest-server:copyLibs")

group = "Iceberg REST server distribution"
outputs.dir(projectDir.dir("distribution/${rootProject.name}-iceberg-rest-server"))
doLast {
copy {
from(projectDir.dir("conf")) { into("${rootProject.name}-iceberg-rest-server/conf") }
from(projectDir.dir("bin")) { into("${rootProject.name}-iceberg-rest-server/bin") }
into(outputDir)
rename { fileName ->
fileName.replace(".template", "")
}
fileMode = 0b111101101
}
copy {
from(projectDir.dir("licenses")) { into("${rootProject.name}-iceberg-rest-server/licenses") }
from(projectDir.file("LICENSE.bin")) { into("${rootProject.name}-iceberg-rest-server") }
from(projectDir.file("NOTICE.bin")) { into("${rootProject.name}-iceberg-rest-server") }
from(projectDir.file("README.md")) { into("${rootProject.name}-iceberg-rest-server") }
into(outputDir)
rename { fileName ->
fileName.replace(".bin", "")
}
}
}
}

val assembleDistribution by registering(Tar::class) {
dependsOn("assembleTrinoConnector")
group = "gravitino distribution"
Expand All @@ -566,6 +594,17 @@ tasks {
destinationDirectory.set(projectDir.dir("distribution"))
}

val assembleIcebergRESTServer by registering(Tar::class) {
dependsOn("iceberg-rest-server:copyLibs")
group = "gravitino distribution"
//finalizedBy("checksumTrinoConnector")
into("${rootProject.name}-iceberg-rest-server-$version")
from("iceberg-rest-server/build/libs")
compression = Compression.GZIP
archiveFileName.set("${rootProject.name}-iceberg-rest-server-$version.tar.gz")
destinationDirectory.set(projectDir.dir("distribution"))
}

register("checksumDistribution") {
group = "gravitino distribution"
dependsOn(assembleDistribution, "checksumTrinoConnector")
Expand Down Expand Up @@ -606,7 +645,7 @@ tasks {
register("copySubprojectDependencies", Copy::class) {
subprojects.forEach() {
if (!it.name.startsWith("catalog") &&
!it.name.startsWith("client") && !it.name.startsWith("filesystem") && !it.name.startsWith("spark") && it.name != "trino-connector" &&
!it.name.startsWith("client") && !it.name.startsWith("filesystem") && !it.name.startsWith("spark") && !it.name.startsWith("iceberg-") && it.name != "trino-connector" &&
it.name != "integration-test" && it.name != "bundled-catalog" && it.name != "flink-connector"
) {
from(it.configurations.runtimeClasspath)
Expand All @@ -621,6 +660,7 @@ tasks {
!it.name.startsWith("client") &&
!it.name.startsWith("filesystem") &&
!it.name.startsWith("spark") &&
!it.name.startsWith("iceberg-") &&
it.name != "trino-connector" &&
it.name != "integration-test" &&
it.name != "bundled-catalog" &&
Expand Down
1 change: 1 addition & 0 deletions catalogs/catalog-lakehouse-iceberg/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dependencies {
implementation(project(":api"))
implementation(project(":common"))
implementation(project(":core"))
implementation(project(":iceberg-common"))
implementation(project(":server-common"))
implementation(libs.bundles.iceberg)
implementation(libs.bundles.jetty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
package com.datastrato.gravitino.catalog.lakehouse.iceberg.integration.test;

import com.datastrato.gravitino.auxiliary.AuxiliaryServiceManager;
import com.datastrato.gravitino.catalog.lakehouse.iceberg.IcebergConfig;
import com.datastrato.gravitino.catalog.lakehouse.iceberg.IcebergRESTService;
import com.datastrato.gravitino.iceberg.common.IcebergConfig;
import com.datastrato.gravitino.iceberg.IcebergRESTService;
import com.datastrato.gravitino.iceberg.common.IcebergConstants;
import com.datastrato.gravitino.integration.test.container.HiveContainer;
import com.datastrato.gravitino.server.web.JettyServerConfig;
import com.datastrato.gravitino.utils.MapUtils;
Expand All @@ -22,7 +23,7 @@ public class CatalogIcebergRestIT extends CatalogIcebergBaseIT {
protected void initIcebergCatalogProperties() {
Map<String, String> map =
serverConfig.getConfigsWithPrefix(AuxiliaryServiceManager.GRAVITINO_AUX_SERVICE_PREFIX);
map = MapUtils.getPrefixMap(map, IcebergRESTService.SERVICE_NAME + ".");
map = MapUtils.getPrefixMap(map, IcebergConstants.GRAVITINO_ICEBERG_REST_SERVICE_NAME + ".");
IcebergConfig icebergConfig = new IcebergConfig(map);
String host = icebergConfig.get(JettyServerConfig.WEBSERVER_HOST);
int port = icebergConfig.get(JettyServerConfig.WEBSERVER_HTTP_PORT);
Expand Down
16 changes: 10 additions & 6 deletions core/src/main/java/com/datastrato/gravitino/GravitinoEnv.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,25 +106,29 @@ public static GravitinoEnv getInstance() {
*
* @param config The configuration object to initialize the environment.
*/
public void initialize(Config config) {
public void initialize(Config config, boolean initGravitinoServerComponet) {
LOG.info("Initializing Gravitino Environment...");

this.config = config;
this.metricsSystem = new MetricsSystem();
metricsSystem.register(new JVMMetricsSource());

this.eventListenerManager = new EventListenerManager();
eventListenerManager.init(
config.getConfigsWithPrefix(EventListenerManager.GRAVITINO_EVENT_LISTENER_PREFIX));
EventBus eventBus = eventListenerManager.createEventBus();

if (!initGravitinoServerComponet) {
return;
}

// Initialize EntityStore
this.entityStore = EntityStoreFactory.createEntityStore(config);
entityStore.initialize(config);

// create and initialize a random id generator
this.idGenerator = new RandomIdGenerator();

this.eventListenerManager = new EventListenerManager();
eventListenerManager.init(
config.getConfigsWithPrefix(EventListenerManager.GRAVITINO_EVENT_LISTENER_PREFIX));
EventBus eventBus = eventListenerManager.createEventBus();

// Create and initialize metalake related modules
MetalakeManager metalakeManager = new MetalakeManager(entityStore, idGenerator);
MetalakeNormalizeDispatcher metalakeNormalizeDispatcher =
Expand Down
124 changes: 124 additions & 0 deletions iceberg-common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
* Copyright 2023 Datastrato Pvt Ltd.
* This software is licensed under the Apache License version 2.
*/
description = "iceberg-common"

plugins {
`maven-publish`
id("java")
id("idea")
}

val scalaVersion: String = project.properties["scalaVersion"] as? String ?: extra["defaultScalaVersion"].toString()
val sparkVersion: String = libs.versions.spark34.get()
val sparkMajorVersion: String = sparkVersion.substringBeforeLast(".")
val icebergVersion: String = libs.versions.iceberg.get()
val scalaCollectionCompatVersion: String = libs.versions.scala.collection.compat.get()

dependencies {
implementation(project(":core"))
implementation(project(":server-common"))
implementation(libs.bundles.iceberg)
implementation(libs.bundles.log4j)
implementation(libs.commons.lang3)
implementation(libs.guava)
implementation(libs.iceberg.hive.metastore)
implementation(libs.hadoop2.common) {
exclude("com.github.spotbugs")
}
implementation(libs.hadoop2.hdfs)
implementation(libs.hadoop2.mapreduce.client.core)

annotationProcessor(libs.lombok)

compileOnly(libs.lombok)

testImplementation(project(":integration-test-common", "testArtifacts"))
testImplementation(project(":server"))

testImplementation(libs.jersey.test.framework.core) {
exclude(group = "org.junit.jupiter")
}
testImplementation(libs.jersey.test.framework.provider.jetty) {
exclude(group = "org.junit.jupiter")
}
testImplementation(libs.junit.jupiter.api)
testImplementation(libs.junit.jupiter.params)
testImplementation(libs.mockito.core)

testImplementation(libs.slf4j.api)
testImplementation(libs.testcontainers)

testRuntimeOnly(libs.junit.jupiter.engine)
}

tasks {
val runtimeJars by registering(Copy::class) {
from(configurations.runtimeClasspath)
into("build/libs")
}

val copyCatalogLibs by registering(Copy::class) {
dependsOn("jar", "runtimeJars")
from("build/libs")
into("$rootDir/distribution/package/catalogs/lakehouse-iceberg/libs")
}

val copyCatalogConfig by registering(Copy::class) {
from("src/main/resources")
into("$rootDir/distribution/package/catalogs/lakehouse-iceberg/conf")

include("lakehouse-iceberg.conf")
include("core-site.xml.template")
include("hdfs-site.xml.template")

rename { original ->
if (original.endsWith(".template")) {
original.replace(".template", "")
} else {
original
}
}

exclude { details ->
details.file.isDirectory()
}
}

register("copyLibAndConfig", Copy::class) {
dependsOn(copyCatalogLibs, copyCatalogConfig)
}
}

tasks.test {
val skipUTs = project.hasProperty("skipTests")
if (skipUTs) {
// Only run integration tests
include("**/integration/**")
}

val skipITs = project.hasProperty("skipITs")
if (skipITs) {
// Exclude integration tests
exclude("**/integration/**")
} else {
dependsOn(tasks.jar)

doFirst {
environment("GRAVITINO_CI_HIVE_DOCKER_IMAGE", "datastrato/gravitino-ci-hive:0.1.12")
environment("GRAVITINO_CI_KERBEROS_HIVE_DOCKER_IMAGE", "datastrato/gravitino-ci-kerberos-hive:0.1.2")
}

val init = project.extra.get("initIntegrationTest") as (Test) -> Unit
init(this)
}
}

tasks.clean {
delete("spark-warehouse")
}

tasks.getByName("generateMetadataFileForMavenJavaPublication") {
dependsOn("runtimeJars")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright 2023 Datastrato Pvt Ltd.
* This software is licensed under the Apache License version 2.
*/
package com.datastrato.gravitino.iceberg.common;

public enum IcebergCatalogBackend {
HIVE,
JDBC,
MEMORY,
REST
}
Loading

0 comments on commit 8df618a

Please sign in to comment.