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

For minghuang #2

Closed
wants to merge 11 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.datastrato.gravitino.exceptions.NoSuchPartitionException;
import com.datastrato.gravitino.exceptions.PartitionAlreadyExistsException;
import com.datastrato.gravitino.rel.partitions.Partition;
import java.util.List;

/** Interface for tables that support partitions. */
@Evolving
Expand Down Expand Up @@ -79,22 +80,49 @@ default boolean partitionExists(String partitionName) {
/**
* Drop a partition with specified name.
*
* @param partitionName The identifier of the partition.
* @return true if a partition was deleted, false if the partition did not exist.
* @param partitionName the name of the partition
* @param ifExists If true, will not throw NoSuchPartitionException if the partition not exists
* @return true if a partition was deleted.
*/
boolean dropPartition(String partitionName, boolean ifExists) throws NoSuchPartitionException;

/**
* Drop partitions with specified names.
*
* @param partitionNames the names of the partition
* @param ifExists If true, will not throw NoSuchPartitionException if the partition not exists
* @return true if all partitions was deleted.
*/
boolean dropPartition(String partitionName);
boolean dropPartitions(List<String> partitionNames, boolean ifExists)
throws NoSuchPartitionException, UnsupportedOperationException;

/**
* If the table supports purging, drop a partition with specified name and completely remove
* partition data by skipping a trash.
*
* @param partitionName The name of the partition.
* @param ifExists If true, will not throw NoSuchPartitionException if the partition not exists
* @return true if a partition was deleted, false if the partition did not exist.
* @throws NoSuchPartitionException If the partition does not exist.
* @throws UnsupportedOperationException If partition purging is not supported.
*/
default boolean purgePartition(String partitionName)
default boolean purgePartition(String partitionName, boolean ifExists)
throws NoSuchPartitionException, UnsupportedOperationException {
throw new UnsupportedOperationException("Partition purging is not supported");
}

/**
* If the table supports purging, drop partitions with specified names and completely remove
* partition data by skipping a trash.
*
* @param partitionNames The name of the partition.
* @param ifExists If true, will not throw NoSuchPartitionException if the partition not exists
* @return true if a partition was deleted, false if the partition did not exist.
* @throws NoSuchPartitionException If the partition does not exist.
* @throws UnsupportedOperationException If partition purging is not supported.
*/
default boolean purgePartitions(List<String> partitionNames, boolean ifExists)
throws NoSuchPartitionException, UnsupportedOperationException {
throw new UnsupportedOperationException("Partitions purging is not supported");
}
}
15 changes: 15 additions & 0 deletions api/src/main/java/com/datastrato/gravitino/rel/TableCatalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,19 @@ Table alterTable(NameIdentifier ident, TableChange... changes)
default boolean purgeTable(NameIdentifier ident) throws UnsupportedOperationException {
throw new UnsupportedOperationException("purgeTable not supported.");
}

/**
* Drop a table from the catalog and completely remove its data. Removes both the metadata and the
* directory associated with the table completely and skipping trash.
*
* <p>If the catalog supports to purge a table, this method should be overridden. The default
* implementation throws an {@link UnsupportedOperationException}.
*
* @param ident A table identifier.
* @return True if the table was purged, false if the table did not exist.
* @throws UnsupportedOperationException If the catalog does not support to purge a table.
*/
default boolean purgeTableOneMeta(NameIdentifier ident) throws UnsupportedOperationException {
throw new UnsupportedOperationException("purgeTable not supported.");
}
}
59 changes: 59 additions & 0 deletions bili-onemeta/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright 2023 Datastrato Pvt Ltd.
* This software is licensed under the Apache License version 2.
*/
plugins {
`maven-publish`
id("java")
id("idea")
}

dependencies {
implementation(project(":api"))
implementation(project(":common"))
implementation(project(":server-common"))
implementation(project(":core"))
implementation(project(":server"))
implementation(libs.jackson.databind)
implementation(libs.jackson.annotations)
implementation(libs.jackson.datatype.jdk8)
implementation(libs.jackson.datatype.jsr310)
implementation(libs.guava)
implementation(libs.bundles.log4j)
implementation(libs.bundles.jetty)
implementation(libs.bundles.jersey)
implementation(libs.metrics.jersey2)

compileOnly(libs.lombok)
annotationProcessor(libs.lombok)
testCompileOnly(libs.lombok)
testAnnotationProcessor(libs.lombok)

testImplementation(libs.junit.jupiter.api)
testImplementation(libs.junit.jupiter.params)
testRuntimeOnly(libs.junit.jupiter.engine)
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.mockito.core)
testImplementation(libs.commons.io)
}

tasks.build {
dependsOn("javadoc")
}

tasks.javadoc {
dependsOn(":api:javadoc", ":common:javadoc")
source =
sourceSets["main"].allJava +
project(":api").sourceSets["main"].allJava +
project(":common").sourceSets["main"].allJava

classpath = configurations["compileClasspath"] +
project(":api").configurations["runtimeClasspath"] +
project(":common").configurations["runtimeClasspath"]
}
178 changes: 178 additions & 0 deletions bin/gravitino-debug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
#!/bin/bash
#
# Copyright 2023 Datastrato Pvt Ltd.
# This software is licensed under the Apache License version 2.
#
#set -ex
USAGE="-e Usage: bin/gravitino.sh [--config <conf-dir>]\n\t
{start|stop|restart|status}"

if [[ "$1" == "--config" ]]; then
shift
conf_dir="$1"
if [[ ! -d "${conf_dir}" ]]; then
echo "ERROR : ${conf_dir} is not a directory"
echo ${USAGE}
exit 1
else
export GRAVITINO_CONF_DIR="${conf_dir}"
fi
shift
fi

bin="$(dirname "${BASH_SOURCE-$0}")"
bin="$(cd "${bin}">/dev/null; pwd)"

. "${bin}/common.sh"

check_java_version

function check_process_status() {
local pid=$(found_gravitino_server_pid)

if [[ -z "${pid}" ]]; then
echo "Gravitino Server is not running"
else
echo "Gravitino Server is running[PID:$pid]"
fi
}

function found_gravitino_server_pid() {
process_name='GravitinoServer';
RUNNING_PIDS=$(ps x | grep ${process_name} | grep -v grep | awk '{print $1}');

if [[ -z "${RUNNING_PIDS}" ]]; then
return
fi

if ! kill -0 ${RUNNING_PIDS} > /dev/null 2>&1; then
echo "Gravitino Server running but process is dead"
fi

echo "${RUNNING_PIDS}"
}

function wait_for_gravitino_server_to_die() {
timeout=10
timeoutTime=$(date "+%s")
let "timeoutTime+=$timeout"
currentTime=$(date "+%s")
forceKill=1

while [[ $currentTime -lt $timeoutTime ]]; do
local pid=$(found_gravitino_server_pid)
if [[ -z "${pid}" ]]; then
forceKill=0
break
fi

$(kill ${pid} > /dev/null 2> /dev/null)
if kill -0 ${pid} > /dev/null 2>&1; then
sleep 3
else
forceKill=0
break
fi
currentTime=$(date "+%s")
done

if [[ forceKill -ne 0 ]]; then
$(kill -9 ${pid} > /dev/null 2> /dev/null)
fi
}

function start() {
local pid=$(found_gravitino_server_pid)

if [[ ! -z "${pid}" ]]; then
if kill -0 ${pid} >/dev/null 2>&1; then
echo "Gravitino Server is already running"
return 0;
fi
fi

if [[ ! -d "${GRAVITINO_LOG_DIR}" ]]; then
echo "Log dir doesn't exist, create ${GRAVITINO_LOG_DIR}"
mkdir -p "${GRAVITINO_LOG_DIR}"
fi

nohup ${JAVA_RUNNER} ${JAVA_OPTS} ${GRAVITINO_DEBUG_OPTS} -cp ${GRAVITINO_CLASSPATH} ${GRAVITINO_SERVER_NAME} >> "${GRAVITINO_OUTFILE}" 2>&1 &

pid=$!
if [[ -z "${pid}" ]]; then
echo "Gravitino Server start error!"
return 1;
else
echo "Gravitino Server start success!"
fi

sleep 2
check_process_status
}

function stop() {
local pid

pid=$(found_gravitino_server_pid)

if [[ -z "${pid}" ]]; then
echo "Gravitino Server is not running"
else
wait_for_gravitino_server_to_die
echo "Gravitino Server stop"
fi
}

HOSTNAME=$(hostname)
GRAVITINO_OUTFILE="${GRAVITINO_LOG_DIR}/gravitino-server.out"
GRAVITINO_SERVER_NAME=com.datastrato.gravitino.server.GravitinoServer

JAVA_OPTS+=" -Dfile.encoding=UTF-8"
JAVA_OPTS+=" -Dlog4j2.configurationFile=file://${GRAVITINO_CONF_DIR}/log4j2.properties"
JAVA_OPTS+=" -Dgravitino.log.path=${GRAVITINO_LOG_DIR} ${GRAVITINO_MEM}"
JAVA_OPTS+=" -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=7052"
if [ "$JVM_VERSION" -eq 17 ]; then
JAVA_OPTS+=" -XX:+IgnoreUnrecognizedVMOptions"
JAVA_OPTS+=" --add-opens java.base/java.io=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/java.lang.invoke=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/java.lang.reflect=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/java.lang=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/java.math=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/java.net=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/java.nio=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/java.text=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/java.time=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/java.util.concurrent=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/java.util.regex=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/java.util=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/jdk.internal.ref=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/jdk.internal.reflect=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.sql/java.sql=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/sun.util.calendar=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/sun.nio.ch=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/sun.nio.cs=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/sun.security.action=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/sun.util.calendar=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.security.jgss/sun.security.krb5=ALL-UNNAMED"
fi

addJarInDir "${GRAVITINO_HOME}/libs"

case "${1}" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
check_process_status
;;
*)
echo ${USAGE}
esac
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ tasks {
dependsOn(
":catalogs:catalog-hive:copyLibAndConfig",
":catalogs:catalog-lakehouse-iceberg:copyLibAndConfig",
":catalogs:catalog-bili-lakehouse-iceberg:copyLibAndConfig",
":catalogs:catalog-jdbc-doris:copyLibAndConfig",
":catalogs:catalog-jdbc-mysql:copyLibAndConfig",
":catalogs:catalog-jdbc-postgresql:copyLibAndConfig",
Expand Down
2 changes: 2 additions & 0 deletions catalogs/bundled-catalog/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies {
implementation(project(":catalogs:catalog-jdbc-mysql"))
implementation(project(":catalogs:catalog-jdbc-postgresql"))
implementation(project(":catalogs:catalog-lakehouse-iceberg"))
implementation(project(":catalogs:catalog-bili-lakehouse-iceberg"))
implementation(project(":core"))
implementation(libs.slf4j.api)
}
Expand Down Expand Up @@ -80,6 +81,7 @@ tasks.jar {
tasks.compileJava {
dependsOn(":catalogs:catalog-jdbc-postgresql:runtimeJars")
dependsOn(":catalogs:catalog-lakehouse-iceberg:runtimeJars")
dependsOn(":catalogs:catalog-bili-lakehouse-iceberg:runtimeJars")
dependsOn(":catalogs:catalog-jdbc-mysql:runtimeJars")
dependsOn(":catalogs:catalog-hive:runtimeJars")
dependsOn(":catalogs:catalog-hadoop:runtimeJars")
Expand Down
Loading