Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client execution timeout configuration parameter #103

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ Refering $SPARK_HOME to the Spark installation directory.
| kinesis.client.numRetries | 3 | Maximum Number of retries for Kinesis API requests |
| kinesis.client.retryIntervalMs | 1000 | Cool-off period before retrying Kinesis API |
| kinesis.client.maxRetryIntervalMs | 10000 | Max Cool-off period between 2 retries |
| kinesis.client.clientExecutionTimeout | 0 | Amazon SDK client execution timeout |
| kinesis.client.avoidEmptyBatches| false | Avoid creating an empty microbatch job by checking upfront if there are any unread data in the stream before the batch is started

## Kinesis Sink Configuration
Expand Down
11 changes: 9 additions & 2 deletions src/main/scala/org/apache/spark/sql/kinesis/KinesisReader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import java.util
import java.util.{ArrayList, Locale}
import java.util.concurrent.{Executors, ThreadFactory}

import com.amazonaws.AbortedException
import com.amazonaws.{AbortedException, ClientConfiguration, ClientConfigurationFactory}
import com.amazonaws.services.kinesis.AmazonKinesisClient
import com.amazonaws.services.kinesis.clientlibrary.types.UserRecord
import com.amazonaws.services.kinesis.model.{GetRecordsRequest, ListShardsRequest, Shard, _}
Expand Down Expand Up @@ -72,13 +72,20 @@ private[kinesis] case class KinesisReader(
readerOptions.getOrElse("client.maxRetryIntervalMs".toLowerCase(Locale.ROOT), "10000").toLong
}

private val clientExecutionTimeout: Int = {
readerOptions.get("client.clientExecutionTimeout".toLowerCase(Locale.ROOT))
.fold(ClientConfiguration.DEFAULT_CLIENT_EXECUTION_TIMEOUT)(_.toInt)
}

private val maxSupportedShardsPerStream = 10000;

private var _amazonClient: AmazonKinesisClient = null

private def getAmazonClient(): AmazonKinesisClient = {
if (_amazonClient == null) {
_amazonClient = new AmazonKinesisClient(kinesisCredsProvider.provider)
val config = new ClientConfigurationFactory().getConfig
config.setClientExecutionTimeout(clientExecutionTimeout)
_amazonClient = new AmazonKinesisClient(kinesisCredsProvider.provider, config)
_amazonClient.setEndpoint(endpointUrl)
}
_amazonClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ class KinesisSourceOptionsSuite extends StreamTest with SharedSparkSession {
("kinesis.executor.maxFetchTimeInMs", "10000"),
("kinesis.client.numRetries", "2")
)
testKinesisOptions(
("kinesis.client.clientExecutionTimeout", "20000")
)
}

test("test for failOnDataLoss") {
Expand Down