forked from scylladb/scylla-migrator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace our fork of spark-kinesis with our adapted copy of the releva…
…nt classes. We adapted the `KinesisReceiver` and its related classes to work with DynamoDB Streams, and we renamed it into `KinesisDynamoDBReceiver`. These classes are based on the code from the original `spark-kinesis-asl` module with some slight modifications based on the following resources: - https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Streams.KCLAdapter.Walkthrough.CompleteProgram.html - https://medium.com/@ravi72munde/using-spark-streaming-with-dynamodb-d325b9a73c79 - and our previous fork implementation As a result, instead of maintaining a complete fork of `spark-kinesis-asl`, we only maintain a copy of the relevant classes, which should result in much faster build times (especially in the CI). It is still not possible to test the streaming feature locally (thus not in the CI either), see scylladb#113. These changes were tested with my actual AWS account.
- Loading branch information
Showing
10 changed files
with
202 additions
and
80 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
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
Submodule spark-kinesis
deleted from
d7ba51
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
52 changes: 52 additions & 0 deletions
52
...amodb/src/main/scala/org/apache/spark/streaming/kinesis/KinesisDynamoDBInputDStream.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,52 @@ | ||
package org.apache.spark.streaming.kinesis | ||
|
||
import com.amazonaws.services.kinesis.model.Record | ||
import org.apache.spark.streaming.kinesis.KinesisInputDStream.{DEFAULT_KINESIS_ENDPOINT_URL, DEFAULT_STORAGE_LEVEL} | ||
import org.apache.spark.streaming.receiver.Receiver | ||
import org.apache.spark.streaming.StreamingContext | ||
|
||
import scala.reflect.ClassTag | ||
|
||
/** | ||
* Override the default behavior of [[KinesisInputDStream]] to create a [[KinesisDynamoDBReceiver]]. | ||
*/ | ||
class KinesisDynamoDBInputDStream[T: ClassTag]( | ||
ssc: StreamingContext, | ||
streamName: String, | ||
regionName: String, | ||
initialPosition: KinesisInitialPosition, | ||
checkpointAppName: String, | ||
messageHandler: Record => T, | ||
kinesisCreds: SparkAWSCredentials | ||
) extends KinesisInputDStream[T]( | ||
ssc, | ||
streamName, | ||
DEFAULT_KINESIS_ENDPOINT_URL, | ||
regionName, | ||
initialPosition, | ||
checkpointAppName, | ||
ssc.graph.batchDuration, | ||
DEFAULT_STORAGE_LEVEL, | ||
messageHandler, | ||
kinesisCreds, | ||
None, | ||
None | ||
) { | ||
|
||
override def getReceiver(): Receiver[T] = { | ||
new KinesisDynamoDBReceiver( | ||
streamName, | ||
endpointUrl, | ||
regionName, | ||
initialPosition, | ||
checkpointAppName, | ||
checkpointInterval, | ||
DEFAULT_STORAGE_LEVEL, | ||
messageHandler, | ||
kinesisCreds, | ||
dynamoDBCreds, | ||
cloudWatchCreds | ||
) | ||
} | ||
|
||
} |
Oops, something went wrong.