FANNG1 commented on code in PR #5847:
URL: https://github.com/apache/gravitino/pull/5847#discussion_r1887975373


##########
core/src/main/java/org/apache/gravitino/GravitinoEnv.java:
##########
@@ -485,5 +489,6 @@ private void initGravitinoServerComponents() {
 
     // Tag manager
     this.tagManager = new TagManager(idGenerator, entityStore);
+    this.tagDispatcher = new TagEventDispatcher(eventBus, tagManager);

Review Comment:
   There is no need to keep `tagManager` as a member of `GravitinoEnv` class?



##########
core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java:
##########
@@ -0,0 +1,173 @@
+/*
+ * 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;
+
+import java.util.Map;
+import org.apache.gravitino.MetadataObject;
+import org.apache.gravitino.exceptions.NoSuchTagException;
+import org.apache.gravitino.tag.Tag;
+import org.apache.gravitino.tag.TagChange;
+import org.apache.gravitino.tag.TagDispatcher;
+
+public class TagEventDispatcher implements TagDispatcher {
+  @SuppressWarnings("unused")
+  private final EventBus eventBus;
+
+  @SuppressWarnings("unused")
+  private final TagDispatcher dispatcher;
+
+  public TagEventDispatcher(EventBus eventBus, TagDispatcher dispatcher) {
+    this.eventBus = eventBus;
+    this.dispatcher = dispatcher;
+  }
+
+  @Override
+  public String[] listTags(String metalake) {
+    // TODO: listTagsPreEvent
+    try {
+      // TODO: listTagsEvent
+    } catch (Exception e) {
+      // TODO: listTagFailureEvent
+      throw e;
+    }
+    return new String[0];
+  }
+
+  @Override
+  public Tag[] listTagsInfo(String metalake) {
+    // TODO: listTagsInfoPreEvent
+    try {
+      // TODO: listTagsInfoEvent
+    } catch (Exception e) {
+      // TODO: listTagsInfoFailureEvent
+      throw e;
+    }
+    return new Tag[0];
+  }
+
+  @Override
+  public Tag getTag(String metalake, String name) throws NoSuchTagException {
+    // TODO: getTagPreEvent
+    try {
+      // TODO: getTagEvent
+    } catch (NoSuchTagException e) {
+      // TODO: getTagFailureEvent
+      throw e;
+    }
+    return null;

Review Comment:
   +1, if not forwarding request, the tag request will takes no effect after 
this PR is merged.



##########
core/src/main/java/org/apache/gravitino/tag/TagDispatcher.java:
##########
@@ -0,0 +1,116 @@
+/*
+ * 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.tag;
+
+import java.util.Map;
+import org.apache.gravitino.MetadataObject;
+import org.apache.gravitino.exceptions.NoSuchTagException;
+
+public interface TagDispatcher {
+  /**
+   * List all the tag names for the specific object.
+   *
+   * @return The list of tag names.
+   */
+  String[] listTags(String metalake);
+
+  /**
+   * List all the tags with details for the specific object.
+   *
+   * @return The list of tags.
+   */
+  Tag[] listTagsInfo(String metalake);
+
+  /**
+   * Get a tag by its name for the specific object.
+   *
+   * @param name The name of the tag.
+   * @param metalake The name of the metalake
+   * @return The tag.
+   * @throws NoSuchTagException If the tag does not associate with the object.
+   */
+  Tag getTag(String metalake, String name) throws NoSuchTagException;
+
+  /**
+   * Create a new tag in the specified metalake.
+   *
+   * @param metalake The name of the metalake
+   * @param name The name of the tag
+   * @param comment A comment for the new tag.
+   * @param properties The properties of the tag.
+   * @return The created tag.
+   */
+  Tag createTag(String metalake, String name, String comment, Map<String, 
String> properties);
+
+  /**
+   * Alter an existing tag in the specified metalake
+   *
+   * @param metalake The name of the metalake.
+   * @param name The name of the tag.
+   * @param changes The changes to apply to the tag.
+   * @return The updated tag.
+   */
+  Tag alterTag(String metalake, String name, TagChange... changes);
+
+  /**
+   * @param metalake The name of the metalake.
+   * @param name The name of the tag.
+   * @return True if the tag was successfully deleted, false otherwise
+   */
+  boolean deleteTag(String metalake, String name);
+
+  /**
+   * @param metalake The name of the metalake.
+   * @param name The name of the tag.
+   * @return The array of metadata objects associated with the specified tag.
+   */
+  MetadataObject[] listMetadataObjectsForTag(String metalake, String name);
+
+  /**
+   * @param metalake The name of the metalake
+   * @param metadataObject The metadata object for which associated tags
+   * @return The list of tag names associated with the given metadata object.
+   */
+  String[] listTagsForMetadataObject(String metalake, MetadataObject 
metadataObject);
+
+  /**
+   * @param metalake

Review Comment:
   please complement the java doc



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to