yuqi1129 commented on code in PR #6782:
URL: https://github.com/apache/gravitino/pull/6782#discussion_r2021072530


##########
core/src/main/java/org/apache/gravitino/lineage/LineageConfig.java:
##########
@@ -0,0 +1,130 @@
+/*
+ *  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.lineage;
+
+import com.google.common.base.Preconditions;
+import com.google.common.base.Splitter;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.Config;
+import org.apache.gravitino.config.ConfigBuilder;
+import org.apache.gravitino.config.ConfigConstants;
+import org.apache.gravitino.config.ConfigEntry;
+
+public class LineageConfig extends Config {
+
+  public static final String LINEAGE_CONFIG_PREFIX = "gravitino.lineage.";
+  public static final String LINEAGE_CONFIG_SINKS = "sinks";
+  public static final String LINEAGE_CONFIG_SOURCE = "source";
+  public static final String LINEAGE_SOURCE_CLASS_NAME = "sourceClass";
+  public static final String LINEAGE_PROCESSOR_CLASS_NAME = "processorClass";
+  public static final String LINEAGE_SINK_CLASS_NAME = "sinkClass";
+  public static final String LINEAGE_HTTP_SOURCE_CLASS_NAME =
+      "org.apache.gravitino.lineage.HTTPLineageSource";
+
+  public static final String LINEAGE_LOG_SINK_NAME = "log";
+  public static final String LINEAGE_HTTP_SOURCE_NAME = "http";
+
+  private static final Splitter splitter = Splitter.on(",");
+
+  public static final ConfigEntry<String> SOURCE_NAME =
+      new ConfigBuilder(LINEAGE_CONFIG_SOURCE)
+          .doc("The name of lineage event source")
+          .version(ConfigConstants.VERSION_0_9_0)
+          .stringConf()
+          .createWithDefault(LINEAGE_HTTP_SOURCE_NAME);
+
+  public static final ConfigEntry<String> PROCESSOR_CLASS =
+      new ConfigBuilder(LINEAGE_PROCESSOR_CLASS_NAME)
+          .doc("The class name of lineage event processor")
+          .version(ConfigConstants.VERSION_0_9_0)
+          .stringConf()
+          .createWithDefault(NoopProcessor.class.getName());
+
+  public static final ConfigEntry<String> SINKS =
+      new ConfigBuilder(LINEAGE_CONFIG_SINKS)
+          .doc("The sinks of lineage event")
+          .version(ConfigConstants.VERSION_0_9_0)
+          .stringConf()
+          .createWithDefault(LINEAGE_LOG_SINK_NAME);
+
+  public LineageConfig(Map<String, String> properties) {
+    super(false);
+    loadFromMap(properties, k -> true);
+  }
+
+  public String source() {
+    return get(SOURCE_NAME);
+  }
+
+  public String sourceClass() {
+    if (source().equals(LINEAGE_HTTP_SOURCE_NAME)) {
+      return LINEAGE_HTTP_SOURCE_CLASS_NAME;
+    }
+    String sourceConfig = source() + "." + LINEAGE_SOURCE_CLASS_NAME;
+    String sourceClass = getRawString(sourceConfig);
+    Preconditions.checkArgument(StringUtils.isNotBlank(sourceClass), 
sourceConfig + " is not set");
+    return sourceClass;
+  }
+
+  public String processorClass() {
+    return get(PROCESSOR_CLASS);
+  }
+
+  public Map<String, String> getSinkConfigs() {
+    List<String> sinks = sinks();
+
+    Map<String, String> config = getAllConfig();
+    Map m = new HashMap(config);

Review Comment:
   please add generic parameter here.



##########
core/src/main/java/org/apache/gravitino/GravitinoEnv.java:
##########
@@ -354,6 +359,26 @@ public FutureGrantManager futureGrantManager() {
     return futureGrantManager;
   }
 
+  /**
+   * Get the LineageService associated with the Gravitino environment.
+   *
+   * @return The LineageService instance.
+   */
+  public LineageService lineageService() {
+    return lineageService;
+  }
+
+  /**
+   * Get the REST packages associated with the Gravitino environment.
+   *
+   * @return The REST packages.
+   */
+  public Set<String> getRESTPackages() {
+    Set<String> packages = new java.util.HashSet<>();

Review Comment:
   Please optimize `java.util.HashSet` and use `import`



##########
server/build.gradle.kts:
##########
@@ -38,6 +38,9 @@ dependencies {
   implementation(libs.jackson.datatype.jsr310)
   implementation(libs.jackson.databind)
   implementation(libs.metrics.jersey2)
+  implementation(libs.openlineage.java) {
+    isTransitive = false

Review Comment:
   What is the configuration used for?



##########
core/src/main/java/org/apache/gravitino/utils/ClassUtils.java:
##########
@@ -0,0 +1,30 @@
+/*
+ *  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.utils;
+
+public class ClassUtils {
+  public static <T> T loadClass(String className) {
+    try {
+      return (T) 
Class.forName(className).getDeclaredConstructor().newInstance();

Review Comment:
   Does this method aim to load all classes, or is it just for loading 
`LineageSource` classes?



##########
core/src/main/java/org/apache/gravitino/lineage/LineageSinkManager.java:
##########
@@ -0,0 +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.lineage;
+
+import io.openlineage.server.OpenLineage.RunEvent;
+import java.io.Closeable;
+import java.util.List;
+import java.util.Map;
+
+@SuppressWarnings("unused")
+public class LineageSinkManager implements Closeable {
+
+  public void initialize(List<String> sinks, Map<String, String> 
LineageConfigs) {}
+
+  public boolean isHighWaterMark() {

Review Comment:
   What's the meaning of `highWatherMark` here? Could you please leave more 
comments here?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to