-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add other streaming trigger than only ProcessingTime.
- Loading branch information
Guillaume LECLERC
committed
Apr 12, 2024
1 parent
9362903
commit 1f6ad7b
Showing
17 changed files
with
475 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
core/src/main/scala/com/amadeus/dataio/config/fields/StreamingTriggerConfigurator.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.amadeus.dataio.config.fields | ||
|
||
import com.typesafe.config.Config | ||
import org.apache.spark.sql.streaming.Trigger | ||
|
||
import scala.concurrent.duration.Duration | ||
import scala.util.Try | ||
|
||
/** | ||
* Retrieve the trigger to be used from the configuration. | ||
* | ||
* See documentation: [[https://spark.apache.org/docs/latest/structured-streaming-programming-guide.html#continuous-processing]] | ||
* | ||
* Trigger = "" AvailableNow or Continuous. Optional in case of ProcessingTime trigger. | ||
* Duration = "1 minute". Optional in case of AvailableNow trigger. | ||
*/ | ||
trait StreamingTriggerConfigurator { | ||
|
||
/** | ||
* @param config The typesafe Config object holding the configuration. | ||
* @return the trigger of None is not defined. | ||
* @throws IllegalArgumentException in case the combination of Trigger and Duration is not supported. | ||
*/ | ||
def getStreamingTrigger(implicit config: Config): Option[Trigger] = { | ||
val streamingTrigger = Try(config.getString("Trigger")).toOption | ||
val duration = Try(config.getString("Duration")).toOption | ||
|
||
(streamingTrigger, duration) match { | ||
case (Some("AvailableNow"), _) => Some(Trigger.AvailableNow()) | ||
case (Some("Continuous"), Some(duration)) => Some(Trigger.Continuous(Duration(duration))) | ||
case (None, Some(duration)) => Some(Trigger.ProcessingTime(Duration(duration))) | ||
case (None, None) => None | ||
case _ => throw new IllegalArgumentException(s"The couple ($streamingTrigger, $duration) is not part of the allowed values") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.