You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@griffin.apache.org by GitBox <gi...@apache.org> on 2020/06/17 15:06:00 UTC

[GitHub] [griffin] chitralverma opened a new pull request #575: [WIP] [GRIFFIN-305] Standardize sink hierarchy

chitralverma opened a new pull request #575:
URL: https://github.com/apache/griffin/pull/575


   **What changes were proposed in this pull request?**
   
   Currently, the implementation of `Sinks` in Griffin poses the below issues. This PR aims at fixing these issues.
   - `Sinks` are based on the recursive MultiSink class which is a sink itself but the underlying implementation is that of a `Seq` which causes ambiguity and isn't much useful. This has been removed.
   - Some unused code like `SinkContext` has been removed.
   - Data is converted from the performant DataFrame to RDD while persisting in both streaming and batch pipelines. A new method `sinkBatchRecords` has been added to allow operations directly on DataFrame for batch pipelines. Streaming will still use the old implementation which will be replaced with structured streaming.
   - Refactored the methods of `Sink` like changed `start`/ `finish` to `open`/ `close` and `jobName` was incorrectly passed as `metricName`.
   - Presently, only one instance of a sink with a given type can be defined in the env config. This will not allow the cases where you want to configure multiple sinks of same type like HDFS or JDBC. Added sink `name` to env config which is used to define the sink that should be used in the job config also.
   - Updated all sinks as per the changes above. With some additional changes to ConsoleSink
   
   **Does this PR introduce any user-facing change?**
   Yes. As mentioned above, the sink config has changed in env and job configs.
   
   How was this patch tested?
   Griffin test suite and additional unit test cases


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

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



[GitHub] [griffin] chitralverma commented on pull request #575: [GRIFFIN-305] Standardize sink hierarchy

Posted by GitBox <gi...@apache.org>.
chitralverma commented on pull request #575:
URL: https://github.com/apache/griffin/pull/575#issuecomment-659489358


   @wankunde I have provided the default implementation for the `open` and `close` methods.


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

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



[GitHub] [griffin] chitralverma commented on pull request #575: [GRIFFIN-305] Standardize sink hierarchy

Posted by GitBox <gi...@apache.org>.
chitralverma commented on pull request #575:
URL: https://github.com/apache/griffin/pull/575#issuecomment-669736481


   absolutely, I'm all in for Griffin. :)
   @wankunde can you please merge this. 
   
   Also, can you tell me how the requests are merged for this project so that I can help close some of the open PRs. Thanks.
   
   
   


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

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



[GitHub] [griffin] chitralverma commented on a change in pull request #575: [GRIFFIN-305] Standardize sink hierarchy

Posted by GitBox <gi...@apache.org>.
chitralverma commented on a change in pull request #575:
URL: https://github.com/apache/griffin/pull/575#discussion_r444881499



##########
File path: measure/src/main/scala/org/apache/griffin/measure/sink/Sink.scala
##########
@@ -18,30 +18,57 @@
 package org.apache.griffin.measure.sink
 
 import org.apache.spark.rdd.RDD
+import org.apache.spark.sql.DataFrame
 
 import org.apache.griffin.measure.Loggable
 
 /**
- * sink metric and record
+ * Base trait for batch and Streaming Sinks.
+ * To implement custom sinks, extend your classes with this trait.
  */
 trait Sink extends Loggable with Serializable {
-  val metricName: String
+
+  val jobName: String

Review comment:
       absolutely, I had the same in mind but I was planning to do it as part of a separate config refactoring in the near future.
   
   Do you suggest I do this right now or later? 




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

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



[GitHub] [griffin] guoyuepeng commented on pull request #575: [GRIFFIN-305] Standardize sink hierarchy

Posted by GitBox <gi...@apache.org>.
guoyuepeng commented on pull request #575:
URL: https://github.com/apache/griffin/pull/575#issuecomment-671141520


   @chitralverma 
   
   The merge process as following:
   use python 2.7
   
   - run ./merge_pr.py
   - Which pull request would you like to merge? (e.g. 34): 575 - select 575
   - Proceed with merging pull request #575? (y/n): y
   - Merge complete (local ref PR_TOOL_MERGE_PR_575_MASTER). Push to apache-git? (y/n): y
   - Would you like to pick 1aa8995a into another branch? (y/n): n
   - Would you like to update an associated JIRA? (y/n): y
   - Enter comma-separated fix version(s) [0.6.0]:
   
   You should have permission for this. tell me if you encounter any problem.
   
   Thanks,
   William


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

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



[GitHub] [griffin] chitralverma commented on a change in pull request #575: [GRIFFIN-305] Standardize sink hierarchy

Posted by GitBox <gi...@apache.org>.
chitralverma commented on a change in pull request #575:
URL: https://github.com/apache/griffin/pull/575#discussion_r444880634



##########
File path: measure/src/main/scala/org/apache/griffin/measure/sink/Sink.scala
##########
@@ -18,30 +18,57 @@
 package org.apache.griffin.measure.sink
 
 import org.apache.spark.rdd.RDD
+import org.apache.spark.sql.DataFrame
 
 import org.apache.griffin.measure.Loggable
 
 /**
- * sink metric and record
+ * Base trait for batch and Streaming Sinks.
+ * To implement custom sinks, extend your classes with this trait.
  */
 trait Sink extends Loggable with Serializable {
-  val metricName: String
+
+  val jobName: String
   val timeStamp: Long
 
   val config: Map[String, Any]
 
   val block: Boolean
 
-  def available(): Boolean
+  /**
+   * Ensures that the pre-requisites (if any) of the Sink are met before opening it.
+   */
+  def validate(): Boolean
 
-  def start(msg: String): Unit
-  def finish(): Unit
+  /**
+   * Allows initialization of the connection to the sink (if required).
+   *
+   * @param applicationId Spark Application ID
+   */
+  def open(applicationId: String): Unit

Review comment:
       @wankunde this is as per the existing implementation. I just changed the variable names to remove ambiguity and made no functional change. This has been done in many other places also.
   
   I'll refactor the applicationId in favor of more description soon.




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

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



[GitHub] [griffin] chitralverma commented on pull request #575: [GRIFFIN-305] Standardize sink hierarchy

Posted by GitBox <gi...@apache.org>.
chitralverma commented on pull request #575:
URL: https://github.com/apache/griffin/pull/575#issuecomment-646243010


   @guoyuepeng @wankunde Can you please review this. Thanks.


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

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



[GitHub] [griffin] chitralverma commented on pull request #575: [GRIFFIN-305] Standardize sink hierarchy

Posted by GitBox <gi...@apache.org>.
chitralverma commented on pull request #575:
URL: https://github.com/apache/griffin/pull/575#issuecomment-665761322


   @wankunde @guoyuepeng Can you please review this. Thanks.


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

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



[GitHub] [griffin] asfgit closed pull request #575: [GRIFFIN-305] Standardize sink hierarchy

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #575:
URL: https://github.com/apache/griffin/pull/575


   


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

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



[GitHub] [griffin] wankunde commented on pull request #575: [GRIFFIN-305] Standardize sink hierarchy

Posted by GitBox <gi...@apache.org>.
wankunde commented on pull request #575:
URL: https://github.com/apache/griffin/pull/575#issuecomment-669727067


   LGTM, @chitralverma Many thanks for your work.


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

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



[GitHub] [griffin] chitralverma commented on pull request #575: [GRIFFIN-305] Standardize sink hierarchy

Posted by GitBox <gi...@apache.org>.
chitralverma commented on pull request #575:
URL: https://github.com/apache/griffin/pull/575#issuecomment-648813731


   @wankunde the `open` and `close` methods are for future custom sinks implementations, for example, Redis, JDBC etc that do not rely on spark datasource v1/ v2. Such data sources require one-time initialization of connection/ connection pool which can then be serialized to all executor each time the write operation is called.
   
   This PR also acts as a basic cleanup for structured streaming sinks which I'm working on.
   I'm also planning to rewrite HDFSSink as FileBasedSink much like FileBasedDataConnector and include many other sinks.
   
   Griffin is going to get really exciting.


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

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



[GitHub] [griffin] wankunde commented on pull request #575: [GRIFFIN-305] Standardize sink hierarchy

Posted by GitBox <gi...@apache.org>.
wankunde commented on pull request #575:
URL: https://github.com/apache/griffin/pull/575#issuecomment-650745454


   Hi, @chitralverma , could you provide an implementation example of the `open` and `close` methods?
   
   


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

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



[GitHub] [griffin] wankunde commented on a change in pull request #575: [GRIFFIN-305] Standardize sink hierarchy

Posted by GitBox <gi...@apache.org>.
wankunde commented on a change in pull request #575:
URL: https://github.com/apache/griffin/pull/575#discussion_r444802163



##########
File path: measure/src/main/scala/org/apache/griffin/measure/sink/Sink.scala
##########
@@ -18,30 +18,57 @@
 package org.apache.griffin.measure.sink
 
 import org.apache.spark.rdd.RDD
+import org.apache.spark.sql.DataFrame
 
 import org.apache.griffin.measure.Loggable
 
 /**
- * sink metric and record
+ * Base trait for batch and Streaming Sinks.
+ * To implement custom sinks, extend your classes with this trait.
  */
 trait Sink extends Loggable with Serializable {
-  val metricName: String
+
+  val jobName: String
   val timeStamp: Long
 
   val config: Map[String, Any]
 
   val block: Boolean
 
-  def available(): Boolean
+  /**
+   * Ensures that the pre-requisites (if any) of the Sink are met before opening it.
+   */
+  def validate(): Boolean
 
-  def start(msg: String): Unit
-  def finish(): Unit
+  /**
+   * Allows initialization of the connection to the sink (if required).
+   *
+   * @param applicationId Spark Application ID
+   */
+  def open(applicationId: String): Unit

Review comment:
       What's the use of `applicationId `?  Can we use `jobName` instead?

##########
File path: measure/src/main/scala/org/apache/griffin/measure/sink/Sink.scala
##########
@@ -18,30 +18,57 @@
 package org.apache.griffin.measure.sink
 
 import org.apache.spark.rdd.RDD
+import org.apache.spark.sql.DataFrame
 
 import org.apache.griffin.measure.Loggable
 
 /**
- * sink metric and record
+ * Base trait for batch and Streaming Sinks.
+ * To implement custom sinks, extend your classes with this trait.
  */
 trait Sink extends Loggable with Serializable {
-  val metricName: String
+
+  val jobName: String

Review comment:
       It's better to unify the names of variable, and easier to understand.
   
   In `DQConfig` is `name`, in `BatchDQApp` is `metricName`, in `DQContext` is `name`, in `SinkFactory` is 
   `jobName`. 




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

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