From f73787d8c68a15a6e591d6d4003aa9dd647d37d5 Mon Sep 17 00:00:00 2001 From: Harry Shih Date: Thu, 26 Dec 2024 10:42:35 +0800 Subject: [PATCH] Add docs and license --- .../api/event/ListTagFailureEvent.java | 42 ++++++++++++++++++- .../api/event/ListTagsInfoFailureEvent.java | 41 ++++++++++++++++++ .../listener/api/event/TagFailureEvent.java | 32 ++++++++++++++ .../gravitino/listener/api/info/TagInfo.java | 24 ++++++++++- .../listener/api/event/TestTagEvent.java | 28 +++++++++++-- 5 files changed, 161 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagFailureEvent.java index 829776d2ad2..a913c935eaf 100644 --- a/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagFailureEvent.java +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagFailureEvent.java @@ -1,19 +1,59 @@ +/* + * 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.gravitino.annotation.DeveloperApi; +/** + * Represents an event triggered when an attempt to list tags fails due to an exception. + */ +@DeveloperApi public class ListTagFailureEvent extends TagFailureEvent { private final String metalake; + /** + * Constructs a new {@code ListTagFailureEvent} instance. + * + * @param user The user who initiated the tag listing operation. + * @param metalake The metalake name where the tags are being listed. + * @param exception The exception encountered during the tag listing operation, providing insights into the reasons behind the failure. + */ public ListTagFailureEvent(String user, String metalake, Exception exception) { super(user, NameIdentifier.of(metalake), exception); this.metalake = metalake; } + /** + * Returns the metalake name where the tags are being listed. + * + * @return The metalake name. + */ public String metalake() { return metalake; } + /** + * Returns the type of operation. + * + * @return the operation type. + */ @Override public OperationType operationType() { return OperationType.LIST_TAG; diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoFailureEvent.java index 4709f353e03..a70d25d6df1 100644 --- a/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoFailureEvent.java +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoFailureEvent.java @@ -1,19 +1,60 @@ +/* + * 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.gravitino.annotation.DeveloperApi; +/** + * Represents an event triggered when an attempt to list tag information fails due to an exception. + */ +@DeveloperApi public class ListTagsInfoFailureEvent extends FailureEvent { private final String metalake; + /** + * Constructs a new {@code ListTagsInfoFailureEvent} instance. + * + * @param user The user who initiated the tag listing operation. + * @param metalake The metalake name where the tags are being listed. + * @param exception The exception encountered during the tag listing operation, providing insights into the reasons behind the failure. + */ public ListTagsInfoFailureEvent(String user, String metalake, Exception exception) { super(user, NameIdentifier.of(metalake), exception); this.metalake = metalake; } + /** + * Returns the metalake name where the tags are being listed. + * + * @return The metalake name. + */ public String metalake() { return metalake; } + /** + * Returns the type of operation. + * + * @return the operation type. + */ @Override public OperationType operationType() { return OperationType.LIST_TAGS_INFO; diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/TagFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/TagFailureEvent.java index 09e46cb0606..6c8287bb5b2 100644 --- a/core/src/main/java/org/apache/gravitino/listener/api/event/TagFailureEvent.java +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/TagFailureEvent.java @@ -1,8 +1,40 @@ +/* + * 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.gravitino.annotation.DeveloperApi; +/** + * Represents an event triggered when an attempt to perform a tag operation fails due to an exception. + */ +@DeveloperApi public class TagFailureEvent extends FailureEvent { + + /** + * Constructs a new {@code TagFailureEvent} instance. + * + * @param user The user who initiated the tag operation. + * @param identifier The identifier of the tag involved in the operation. + * @param exception The exception encountered during the tag operation, providing insights into the reasons behind the failure. + */ public TagFailureEvent(String user, NameIdentifier identifier, Exception exception) { super(user, identifier, exception); } diff --git a/core/src/main/java/org/apache/gravitino/listener/api/info/TagInfo.java b/core/src/main/java/org/apache/gravitino/listener/api/info/TagInfo.java index 7b1f84182c8..cb0def30c0b 100644 --- a/core/src/main/java/org/apache/gravitino/listener/api/info/TagInfo.java +++ b/core/src/main/java/org/apache/gravitino/listener/api/info/TagInfo.java @@ -1,10 +1,32 @@ +/* + * 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.info; -import com.google.common.collect.ImmutableMap; import java.util.Map; + import javax.annotation.Nullable; + import org.apache.gravitino.annotation.DeveloperApi; +import com.google.common.collect.ImmutableMap; + /** * Provides access to metadata about a Tag instance, designed for use by event listeners. This class * encapsulates the essential attributes of a Tag, including its name, optional description, diff --git a/core/src/test/java/org/apache/gravitino/listener/api/event/TestTagEvent.java b/core/src/test/java/org/apache/gravitino/listener/api/event/TestTagEvent.java index 6b03ea9fdef..5b2032629e3 100644 --- a/core/src/test/java/org/apache/gravitino/listener/api/event/TestTagEvent.java +++ b/core/src/test/java/org/apache/gravitino/listener/api/event/TestTagEvent.java @@ -1,10 +1,26 @@ -package org.apache.gravitino.listener.api.event; +/* + * 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 static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +package org.apache.gravitino.listener.api.event; -import com.google.common.collect.ImmutableMap; import java.util.Arrays; + import org.apache.gravitino.Entity; import org.apache.gravitino.MetadataObject; import org.apache.gravitino.exceptions.GravitinoRuntimeException; @@ -20,6 +36,10 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.TestInstance.Lifecycle; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import com.google.common.collect.ImmutableMap; @TestInstance(Lifecycle.PER_CLASS) public class TestTagEvent {