Skip to content

Commit

Permalink
Merge branch 'main' into issue-2705
Browse files Browse the repository at this point in the history
  • Loading branch information
lw-yang authored Apr 19, 2024
2 parents d17137b + 3c39fa9 commit 50ef009
Show file tree
Hide file tree
Showing 67 changed files with 3,383 additions and 327 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/backend-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
- name: Backend Integration Test
id: integrationTest
run: |
./gradlew test --rerun-tasks -PskipTests -PtestMode=${{ matrix.test-mode }} -PjdkVersion=${{ matrix.java-version }} -PskipWebITs -P${{ matrix.backend }}
./gradlew test --rerun-tasks -PskipTests -PtestMode=${{ matrix.test-mode }} -PjdkVersion=${{ matrix.java-version }} -PskipWebITs -P${{ matrix.backend }} -PskipPyClientITs
- name: Upload integrate tests reports
uses: actions/upload-artifact@v3
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/python-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@ jobs:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Free up disk space
run: |
dev/ci/util_free_space.sh
- name: Python Client Integration Test
id: integrationTest
run: |
#./gradlew compileDistribution -x test -PjdkVersion=${{ matrix.java-version }}
#for pythonVersion in "3.8" "3.9" "3.10" "3.11"
#do
# ./gradlew -PjdkVersion=${{ matrix.java-version }} -PpythonVersion=${pythonVersion} :client:client-python:integrationTest
#done
./gradlew compileDistribution -x test -PjdkVersion=${{ matrix.java-version }}
for pythonVersion in "3.8" "3.9" "3.10" "3.11"
do
echo "Use Python version ${pythonVersion} to test the Python client."
./gradlew -PjdkVersion=${{ matrix.java-version }} -PpythonVersion=${pythonVersion} :client:client-python:test
# Clean Gravitino database to clean test data
rm -rf ./distribution/package/data
done
- name: Upload integrate tests reports
uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ out/**
*.ipr

distribution
server/src/main/resources/project.properties
common/src/main/resources/project.properties

dev/docker/*/packages
docs/build
Expand Down
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,10 @@

Apache Arrow
./dev/ci/util_free_space.sh

This product bundles a third-party component under the
MIT License.

Kyligence/kylinpy
./clients/client-python/gravitino/utils/exceptions.py
./clients/client-python/gravitino/utils/http_client.py
1 change: 1 addition & 0 deletions LICENSE.bin
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@
Janino Common Compiler
Protocol Buffers
Treelayout
Kyligence/kylinpy

This product bundles various third-party components also under the
Common Development and Distribution License 1.0
Expand Down
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,9 @@ tasks.rat {
"**/NOTICE.*",
"ROADMAP.md",
"clients/client-python/.pytest_cache/*",
"clients/client-python/gravitino.egg-info/*"
"clients/client-python/gravitino.egg-info/*",
"clients/client-python/gravitino/utils/exceptions.py",
"clients/client-python/gravitino/utils/http_client.py"
)

// Add .gitignore excludes to the Apache Rat exclusion list.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,28 @@
import com.datastrato.gravitino.exceptions.BadRequestException;
import com.datastrato.gravitino.exceptions.CatalogAlreadyExistsException;
import com.datastrato.gravitino.exceptions.FilesetAlreadyExistsException;
import com.datastrato.gravitino.exceptions.GroupAlreadyExistsException;
import com.datastrato.gravitino.exceptions.MetalakeAlreadyExistsException;
import com.datastrato.gravitino.exceptions.NoSuchCatalogException;
import com.datastrato.gravitino.exceptions.NoSuchFilesetException;
import com.datastrato.gravitino.exceptions.NoSuchGroupException;
import com.datastrato.gravitino.exceptions.NoSuchMetalakeException;
import com.datastrato.gravitino.exceptions.NoSuchPartitionException;
import com.datastrato.gravitino.exceptions.NoSuchRoleException;
import com.datastrato.gravitino.exceptions.NoSuchSchemaException;
import com.datastrato.gravitino.exceptions.NoSuchTableException;
import com.datastrato.gravitino.exceptions.NoSuchTopicException;
import com.datastrato.gravitino.exceptions.NoSuchUserException;
import com.datastrato.gravitino.exceptions.NonEmptySchemaException;
import com.datastrato.gravitino.exceptions.NotFoundException;
import com.datastrato.gravitino.exceptions.PartitionAlreadyExistsException;
import com.datastrato.gravitino.exceptions.RESTException;
import com.datastrato.gravitino.exceptions.RoleAlreadyExistsException;
import com.datastrato.gravitino.exceptions.SchemaAlreadyExistsException;
import com.datastrato.gravitino.exceptions.TableAlreadyExistsException;
import com.datastrato.gravitino.exceptions.TopicAlreadyExistsException;
import com.datastrato.gravitino.exceptions.UnauthorizedException;
import com.datastrato.gravitino.exceptions.UserAlreadyExistsException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Joiner;
import java.util.List;
Expand Down Expand Up @@ -123,6 +129,33 @@ public static Consumer<ErrorResponse> topicErrorHandler() {
return TopicErrorHandler.INSTANCE;
}

/**
* Creates an error handler specific to User operations.
*
* @return A Consumer representing the User error handler.
*/
public static Consumer<ErrorResponse> userErrorHandler() {
return UserErrorHandler.INSTANCE;
}

/**
* Creates an error handler specific to Group operations.
*
* @return A Consumer representing the Group error handler.
*/
public static Consumer<ErrorResponse> groupErrorHandler() {
return GroupErrorHandler.INSTANCE;
}

/**
* Creates an error handler specific to Role operations.
*
* @return A Consumer representing the Role error handler.
*/
public static Consumer<ErrorResponse> roleErrorHandler() {
return RoleErrorHandler.INSTANCE;
}

private ErrorHandlers() {}

/**
Expand Down Expand Up @@ -459,6 +492,111 @@ public void accept(ErrorResponse errorResponse) {
}
}

/** Error handler specific to User operations. */
@SuppressWarnings("FormatStringAnnotation")
private static class UserErrorHandler extends RestErrorHandler {

private static final UserErrorHandler INSTANCE = new UserErrorHandler();

@Override
public void accept(ErrorResponse errorResponse) {
String errorMessage = formatErrorMessage(errorResponse);

switch (errorResponse.getCode()) {
case ErrorConstants.ILLEGAL_ARGUMENTS_CODE:
throw new IllegalArgumentException(errorMessage);

case ErrorConstants.NOT_FOUND_CODE:
if (errorResponse.getType().equals(NoSuchMetalakeException.class.getSimpleName())) {
throw new NoSuchMetalakeException(errorMessage);
} else if (errorResponse.getType().equals(NoSuchUserException.class.getSimpleName())) {
throw new NoSuchUserException(errorMessage);
} else {
throw new NotFoundException(errorMessage);
}

case ErrorConstants.ALREADY_EXISTS_CODE:
throw new UserAlreadyExistsException(errorMessage);

case ErrorConstants.INTERNAL_ERROR_CODE:
throw new RuntimeException(errorMessage);

default:
super.accept(errorResponse);
}
}
}

/** Error handler specific to Group operations. */
@SuppressWarnings("FormatStringAnnotation")
private static class GroupErrorHandler extends RestErrorHandler {

private static final GroupErrorHandler INSTANCE = new GroupErrorHandler();

@Override
public void accept(ErrorResponse errorResponse) {
String errorMessage = formatErrorMessage(errorResponse);

switch (errorResponse.getCode()) {
case ErrorConstants.ILLEGAL_ARGUMENTS_CODE:
throw new IllegalArgumentException(errorMessage);

case ErrorConstants.NOT_FOUND_CODE:
if (errorResponse.getType().equals(NoSuchMetalakeException.class.getSimpleName())) {
throw new NoSuchMetalakeException(errorMessage);
} else if (errorResponse.getType().equals(NoSuchGroupException.class.getSimpleName())) {
throw new NoSuchGroupException(errorMessage);
} else {
throw new NotFoundException(errorMessage);
}

case ErrorConstants.ALREADY_EXISTS_CODE:
throw new GroupAlreadyExistsException(errorMessage);

case ErrorConstants.INTERNAL_ERROR_CODE:
throw new RuntimeException(errorMessage);

default:
super.accept(errorResponse);
}
}
}

/** Error handler specific to Role operations. */
@SuppressWarnings("FormatStringAnnotation")
private static class RoleErrorHandler extends RestErrorHandler {

private static final RoleErrorHandler INSTANCE = new RoleErrorHandler();

@Override
public void accept(ErrorResponse errorResponse) {
String errorMessage = formatErrorMessage(errorResponse);

switch (errorResponse.getCode()) {
case ErrorConstants.ILLEGAL_ARGUMENTS_CODE:
throw new IllegalArgumentException(errorMessage);

case ErrorConstants.NOT_FOUND_CODE:
if (errorResponse.getType().equals(NoSuchMetalakeException.class.getSimpleName())) {
throw new NoSuchMetalakeException(errorMessage);
} else if (errorResponse.getType().equals(NoSuchRoleException.class.getSimpleName())) {
throw new NoSuchRoleException(errorMessage);
} else {
throw new NotFoundException(errorMessage);
}

case ErrorConstants.ALREADY_EXISTS_CODE:
throw new RoleAlreadyExistsException(errorMessage);

case ErrorConstants.INTERNAL_ERROR_CODE:
throw new RuntimeException(errorMessage);

default:
super.accept(errorResponse);
}
}
}

/** Generic error handler for REST requests. */
private static class RestErrorHandler extends ErrorHandler {
private static final ErrorHandler INSTANCE = new RestErrorHandler();
Expand Down
Loading

0 comments on commit 50ef009

Please sign in to comment.