doc comments
This commit is contained in:
parent
4d058ecf51
commit
07c9529c14
1 changed files with 17 additions and 0 deletions
|
|
@ -23,6 +23,9 @@ import software.amazon.awssdk.services.kinesis.model.HashKeyRange;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Accessors(fluent = true)
|
@Accessors(fluent = true)
|
||||||
|
/**
|
||||||
|
* Lease POJO to hold the starting hashkey range and ending hashkey range of kinesis shards.
|
||||||
|
*/
|
||||||
public class HashKeyRangeForLease {
|
public class HashKeyRangeForLease {
|
||||||
|
|
||||||
private static final String DELIM = ":";
|
private static final String DELIM = ":";
|
||||||
|
|
@ -30,6 +33,10 @@ public class HashKeyRangeForLease {
|
||||||
private final String startingHashKey;
|
private final String startingHashKey;
|
||||||
private final String endingHashKey;
|
private final String endingHashKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serialize the HashKeyRangeForLease for persisting in external storage
|
||||||
|
* @return Serialized string
|
||||||
|
*/
|
||||||
public String serialize() {
|
public String serialize() {
|
||||||
return Joiner.on(DELIM).join(startingHashKey, endingHashKey);
|
return Joiner.on(DELIM).join(startingHashKey, endingHashKey);
|
||||||
}
|
}
|
||||||
|
|
@ -39,6 +46,11 @@ public class HashKeyRangeForLease {
|
||||||
return serialize();
|
return serialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deserialize from serialized hashKeyRange string from external storage.
|
||||||
|
* @param hashKeyRange
|
||||||
|
* @return HashKeyRangeForLease
|
||||||
|
*/
|
||||||
public static HashKeyRangeForLease deserialize(String hashKeyRange) {
|
public static HashKeyRangeForLease deserialize(String hashKeyRange) {
|
||||||
final String[] hashKeyTokens = hashKeyRange.split(DELIM);
|
final String[] hashKeyTokens = hashKeyRange.split(DELIM);
|
||||||
Validate.isTrue(hashKeyTokens.length == 2, "HashKeyRange should have exactly two tokens");
|
Validate.isTrue(hashKeyTokens.length == 2, "HashKeyRange should have exactly two tokens");
|
||||||
|
|
@ -48,6 +60,11 @@ public class HashKeyRangeForLease {
|
||||||
return new HashKeyRangeForLease(hashKeyTokens[0], hashKeyTokens[1]);
|
return new HashKeyRangeForLease(hashKeyTokens[0], hashKeyTokens[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct HashKeyRangeForLease from Kinesis HashKeyRange
|
||||||
|
* @param hashKeyRange
|
||||||
|
* @return HashKeyRangeForLease
|
||||||
|
*/
|
||||||
public static HashKeyRangeForLease fromHashKeyRange(HashKeyRange hashKeyRange) {
|
public static HashKeyRangeForLease fromHashKeyRange(HashKeyRange hashKeyRange) {
|
||||||
return new HashKeyRangeForLease(hashKeyRange.startingHashKey(), hashKeyRange.endingHashKey());
|
return new HashKeyRangeForLease(hashKeyRange.startingHashKey(), hashKeyRange.endingHashKey());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue