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

Fix listShards to only specify nextToken #104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 8 additions & 7 deletions src/main/scala/org/apache/spark/sql/kinesis/KinesisReader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,9 @@ private[kinesis] case class KinesisReader(
}

private def listShards(): Seq[Shard] = {
var nextToken = ""
var returnedToken = ""
var nextToken: String = null
val shards = new ArrayList[Shard]()
val listShardsRequest = new ListShardsRequest
var listShardsRequest = new ListShardsRequest
listShardsRequest.setStreamName(streamName)
listShardsRequest.setMaxResults(maxSupportedShardsPerStream)

Expand All @@ -185,12 +184,14 @@ private[kinesis] case class KinesisReader(
}
}
shards.addAll(listShardsResult.getShards)
returnedToken = listShardsResult.getNextToken()
if (returnedToken != null) {
nextToken = returnedToken
nextToken = listShardsResult.getNextToken()
if (nextToken != null) {
// Requests cannot contain both a stream name and a token
listShardsRequest = new ListShardsRequest
listShardsRequest.setNextToken(nextToken)
listShardsRequest.setMaxResults(maxSupportedShardsPerStream)
}
} while (!nextToken.isEmpty)
} while (nextToken != null)

shards.asScala.toSeq
}
Expand Down