From 57f237be3d4015f058da0ec71607ed19517bf806 Mon Sep 17 00:00:00 2001 From: fanng Date: Tue, 1 Oct 2024 18:32:25 +0800 Subject: [PATCH] add pre event --- .../listener/api/event/PreEvent.java | 28 ++++++++++++++ .../api/event/IcebergCreateTablePreEvent.java | 38 +++++++++++++++++++ .../listener/api/event/IcebergPreEvent.java | 28 ++++++++++++++ .../api/event/IcebergUpdateTablePreEvent.java | 37 ++++++++++++++++++ 4 files changed, 131 insertions(+) create mode 100644 core/src/main/java/org/apache/gravitino/listener/api/event/PreEvent.java create mode 100644 iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateTablePreEvent.java create mode 100644 iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergPreEvent.java create mode 100644 iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateTablePreEvent.java diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/PreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/PreEvent.java new file mode 100644 index 00000000000..4af48a64818 --- /dev/null +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/PreEvent.java @@ -0,0 +1,28 @@ +/* + * 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.gravitino.listener.api.event; + +import org.apache.gravitino.NameIdentifier; + +public abstract class PreEvent extends Event { + protected PreEvent(String user, NameIdentifier identifier) { + super(user, identifier); + } +} diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateTablePreEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateTablePreEvent.java new file mode 100644 index 00000000000..2fdec8e0d66 --- /dev/null +++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateTablePreEvent.java @@ -0,0 +1,38 @@ +/* + * 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.gravitino.listener.api.event; + +import org.apache.gravitino.NameIdentifier; +import org.apache.iceberg.rest.requests.CreateTableRequest; + +public class IcebergCreateTablePreEvent extends IcebergPreEvent { + + private CreateTableRequest createTableRequest; + + public IcebergCreateTablePreEvent( + String user, NameIdentifier resourceIdentifier, CreateTableRequest createTableRequest) { + super(user, resourceIdentifier); + this.createTableRequest = createTableRequest; + } + + public CreateTableRequest createTableRequest() { + return createTableRequest; + } +} diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergPreEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergPreEvent.java new file mode 100644 index 00000000000..213afcc5a80 --- /dev/null +++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergPreEvent.java @@ -0,0 +1,28 @@ +/* + * 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.gravitino.listener.api.event; + +import org.apache.gravitino.NameIdentifier; + +public abstract class IcebergPreEvent extends PreEvent { + public IcebergPreEvent(String user, NameIdentifier resourceIdentifier) { + super(user, resourceIdentifier); + } +} diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateTablePreEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateTablePreEvent.java new file mode 100644 index 00000000000..d3a92d2d9e7 --- /dev/null +++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateTablePreEvent.java @@ -0,0 +1,37 @@ +/* + * 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.gravitino.listener.api.event; + +import org.apache.gravitino.NameIdentifier; +import org.apache.iceberg.rest.requests.UpdateTableRequest; + +public class IcebergUpdateTablePreEvent extends IcebergPreEvent { + private UpdateTableRequest updateTableRequest; + + public IcebergUpdateTablePreEvent( + String user, NameIdentifier resourceIdentifier, UpdateTableRequest updateTableRequest) { + super(user, resourceIdentifier); + this.updateTableRequest = updateTableRequest; + } + + public UpdateTableRequest updateTableRequest() { + return updateTableRequest; + } +}