Interface KinesisPartitioner<T>
-
- All Superinterfaces:
java.io.Serializable
- All Known Subinterfaces:
KinesisPartitioner.ExplicitPartitioner<T>
public interface KinesisPartitioner<T> extends java.io.SerializableKinesis interface for custom partitioner.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceKinesisPartitioner.ExplicitPartitioner<T>An explicit partitioner that always returns aNonnullexplicit hash key.
-
Field Summary
Fields Modifier and Type Field Description static java.math.BigIntegerMAX_HASH_KEYstatic java.math.BigIntegerMIN_HASH_KEY
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static <T> KinesisPartitioner<T>explicitRandomPartitioner(int shards)Explicit hash key partitioner that randomly returns one of x precalculated hash keys.default java.lang.StringgetExplicitHashKey(T record)Optional hash value (128-bit integer) to determine explicitly the shard a record is assigned to based on the hash key range of each shard.java.lang.StringgetPartitionKey(T record)Determines which shard in the stream the record is assigned to.
-
-
-
Method Detail
-
getPartitionKey
@Nonnull java.lang.String getPartitionKey(T record)
Determines which shard in the stream the record is assigned to. Partition keys are Unicode strings with a maximum length limit of 256 characters for each key. Amazon Kinesis Data Streams uses the partition key as input to a hash function that maps the partition key and associated data to a specific shard.
-
getExplicitHashKey
@Nullable default java.lang.String getExplicitHashKey(T record)
Optional hash value (128-bit integer) to determine explicitly the shard a record is assigned to based on the hash key range of each shard. The explicit hash key overrides the partition key hash.
-
explicitRandomPartitioner
static <T> KinesisPartitioner<T> explicitRandomPartitioner(int shards)
Explicit hash key partitioner that randomly returns one of x precalculated hash keys. Hash keys are derived by equally dividing the 128-bit hash universe, assuming that hash ranges of shards are also equally sized.Note: This simple approach is likely not applicable anymore after resharding a stream. In that case it is recommended to use the ListShards API to retrieve the actual hash key range of each shard and partition based on that.
- See Also:
- ListShards API
-
-