vishnu-chalil commented on code in PR #7397:
URL: https://github.com/apache/gravitino/pull/7397#discussion_r2157364998


##########
lineage/src/main/java/org/apache/gravitino/lineage/sink/LineageMarquezSink.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.sink;
+
+import io.openlineage.client.OpenLineageClient;
+import io.openlineage.client.OpenLineageClientException;
+import io.openlineage.client.transports.HttpConfig;
+import io.openlineage.client.transports.HttpTransport;
+import io.openlineage.server.OpenLineage;
+import java.util.Map;
+import javax.ws.rs.BadRequestException;
+import org.apache.gravitino.lineage.Utils;
+import org.apache.gravitino.lineage.auth.AuthenticationFactory;
+import org.apache.gravitino.lineage.auth.LineageServerAuthenticationStrategy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class LineageMarquezSink implements LineageSink {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(LineageMarquezSink.class);
+  private OpenLineageClient client;
+
+  @Override
+  public void initialize(Map<String, String> configs) {
+
+    String marquezUrl = configs.getOrDefault("url", "http://localhost:5000/";);
+    LOG.info("marquez url {}", marquezUrl);
+    String authType = configs.get("auth.type");
+    LOG.info("marquez authentication type {}", authType);
+    LineageServerAuthenticationStrategy authStrategy =
+        AuthenticationFactory.createStrategy(authType);
+
+    // Configure HttpConfig with authentication
+    HttpConfig httpConfig = authStrategy.configureHttpConfig(marquezUrl, 
configs);
+
+    HttpTransport transport = new HttpTransport(httpConfig);
+
+    client = OpenLineageClient.builder().transport(transport).build();
+  }
+
+  @Override
+  public void sink(OpenLineage.RunEvent runEvent) {
+
+    try {
+      client.emit(Utils.mapLineageServertoClientRunEvent(runEvent));
+      LOG.info("Sent lineage event to Marquez: {}", runEvent);
+    } catch (OpenLineageClientException e) {
+      LOG.error("Failed to send lineage event to Marquez", e);
+      throw new BadRequestException(String.format(e.getMessage()));

Review Comment:
   Updated to this



##########
lineage/src/main/java/org/apache/gravitino/lineage/auth/LineageServerAuthenticationStrategy.java:
##########
@@ -0,0 +1,26 @@
+/*
+ * 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.auth;
+
+import io.openlineage.client.transports.HttpConfig;
+import java.util.Map;
+
+public interface LineageServerAuthenticationStrategy {

Review Comment:
   Added java doc.



##########
lineage/src/main/java/org/apache/gravitino/lineage/Utils.java:
##########
@@ -35,4 +38,58 @@ public static String getJobName(RunEvent event) {
     Job job = event.getJob();
     return job == null ? "Unknown" : job.getName().toString();
   }
+
+  public static OpenLineage.RunEvent mapLineageServertoClientRunEvent(
+      io.openlineage.server.OpenLineage.RunEvent serverEvent) {
+    OpenLineage ol = new OpenLineage(serverEvent.getSchemaURL());
+
+    return ol.newRunEventBuilder()
+        
.eventType(OpenLineage.RunEvent.EventType.valueOf(serverEvent.getEventType().name()))
+        .eventTime(serverEvent.getEventTime())
+        .run(toClientRun(serverEvent.getRun(), ol))
+        .job(toClientJob(serverEvent.getJob(), ol))
+        .inputs(toClientInputs(serverEvent.getInputs(), ol))
+        .outputs(toClientOutputs(serverEvent.getOutputs(), ol))
+        .build();
+  }
+
+  private static OpenLineage.Run toClientRun(
+      io.openlineage.server.OpenLineage.Run serverRun, OpenLineage ol) {
+    return ol.newRun(serverRun.getRunId(), ol.newRunFacetsBuilder().build());
+  }
+
+  private static OpenLineage.Job toClientJob(
+      io.openlineage.server.OpenLineage.Job serverJob, OpenLineage ol) {
+    return ol.newJobBuilder()
+        .namespace(serverJob.getNamespace())
+        .name(serverJob.getName())
+        .facets(ol.newJobFacetsBuilder().build())

Review Comment:
   Removed this code since this is now done using mapper.



##########
lineage/src/main/java/org/apache/gravitino/lineage/sink/LineageMarquezSink.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.sink;
+
+import io.openlineage.client.OpenLineageClient;
+import io.openlineage.client.OpenLineageClientException;
+import io.openlineage.client.transports.HttpConfig;
+import io.openlineage.client.transports.HttpTransport;
+import io.openlineage.server.OpenLineage;
+import java.util.Map;
+import javax.ws.rs.BadRequestException;
+import org.apache.gravitino.lineage.Utils;
+import org.apache.gravitino.lineage.auth.AuthenticationFactory;
+import org.apache.gravitino.lineage.auth.LineageServerAuthenticationStrategy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class LineageMarquezSink implements LineageSink {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(LineageMarquezSink.class);
+  private OpenLineageClient client;
+
+  @Override
+  public void initialize(Map<String, String> configs) {
+
+    String marquezUrl = configs.getOrDefault("url", "http://localhost:5000/";);
+    LOG.info("marquez url {}", marquezUrl);
+    String authType = configs.get("auth.type");
+    LOG.info("marquez authentication type {}", authType);
+    LineageServerAuthenticationStrategy authStrategy =
+        AuthenticationFactory.createStrategy(authType);
+
+    // Configure HttpConfig with authentication
+    HttpConfig httpConfig = authStrategy.configureHttpConfig(marquezUrl, 
configs);
+
+    HttpTransport transport = new HttpTransport(httpConfig);
+
+    client = OpenLineageClient.builder().transport(transport).build();
+  }
+
+  @Override
+  public void sink(OpenLineage.RunEvent runEvent) {
+
+    try {
+      client.emit(Utils.mapLineageServertoClientRunEvent(runEvent));
+      LOG.info("Sent lineage event to Marquez: {}", runEvent);
+    } catch (OpenLineageClientException e) {
+      LOG.error("Failed to send lineage event to Marquez", e);

Review Comment:
   Updated too warn.



##########
lineage/src/main/java/org/apache/gravitino/lineage/Utils.java:
##########
@@ -35,4 +38,58 @@ public static String getJobName(RunEvent event) {
     Job job = event.getJob();
     return job == null ? "Unknown" : job.getName().toString();
   }
+
+  public static OpenLineage.RunEvent mapLineageServertoClientRunEvent(

Review Comment:
   Updated the mapping using mapper.



##########
lineage/src/main/java/org/apache/gravitino/lineage/sink/LineageMarquezSink.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.sink;
+
+import io.openlineage.client.OpenLineageClient;
+import io.openlineage.client.OpenLineageClientException;
+import io.openlineage.client.transports.HttpConfig;
+import io.openlineage.client.transports.HttpTransport;
+import io.openlineage.server.OpenLineage;
+import java.util.Map;
+import javax.ws.rs.BadRequestException;
+import org.apache.gravitino.lineage.Utils;
+import org.apache.gravitino.lineage.auth.AuthenticationFactory;
+import org.apache.gravitino.lineage.auth.LineageServerAuthenticationStrategy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class LineageMarquezSink implements LineageSink {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(LineageMarquezSink.class);
+  private OpenLineageClient client;
+
+  @Override
+  public void initialize(Map<String, String> configs) {
+
+    String marquezUrl = configs.getOrDefault("url", "http://localhost:5000/";);
+    LOG.info("marquez url {}", marquezUrl);
+    String authType = configs.get("auth.type");

Review Comment:
   Added the extra configurations in the gravitino.conf.template file. Can 
point me to the doc for updating lineage information?



-- 
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