getLeaseKey
This commit is contained in:
parent
1036006bb4
commit
760c52d7bc
3 changed files with 8 additions and 6 deletions
|
|
@ -149,9 +149,13 @@ public class ShardInfo {
|
|||
* @return lease key
|
||||
*/
|
||||
public static String getLeaseKey(ShardInfo shardInfo) {
|
||||
return getLeaseKey(shardInfo, shardInfo.shardId());
|
||||
}
|
||||
|
||||
public static String getLeaseKey(ShardInfo shardInfo, String shardId) {
|
||||
return shardInfo.streamIdentifierSerOpt().isPresent() ?
|
||||
MultiStreamLease.getLeaseKey(shardInfo.streamIdentifierSerOpt().get(), shardInfo.shardId()) :
|
||||
shardInfo.shardId();
|
||||
MultiStreamLease.getLeaseKey(shardInfo.streamIdentifierSerOpt().get(), shardId) :
|
||||
shardId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class BlockOnParentShardTask implements ConsumerTask {
|
|||
try {
|
||||
boolean blockedOnParentShard = false;
|
||||
for (String shardId : shardInfo.parentShardIds()) {
|
||||
final String leaseKey = shardInfo.streamIdentifierSerOpt().map(s -> s + ":" + shardId).orElse(shardId);
|
||||
final String leaseKey = ShardInfo.getLeaseKey(shardInfo, shardId);
|
||||
final Lease lease = leaseRefresher.getLease(leaseKey);
|
||||
if (lease != null) {
|
||||
ExtendedSequenceNumber checkpoint = lease.checkpoint();
|
||||
|
|
|
|||
|
|
@ -183,9 +183,7 @@ public class ShutdownTask implements ConsumerTask {
|
|||
private void createLeasesForChildShardsIfNotExist()
|
||||
throws DependencyException, InvalidStateException, ProvisionedThroughputException {
|
||||
for(ChildShard childShard : childShards) {
|
||||
final String leaseKey = shardInfo.streamIdentifierSerOpt()
|
||||
.map(s -> s + ":" + childShard.shardId())
|
||||
.orElse(childShard.shardId());
|
||||
final String leaseKey = ShardInfo.getLeaseKey(shardInfo, childShard.shardId());
|
||||
if(leaseCoordinator.getCurrentlyHeldLease(leaseKey) == null) {
|
||||
final Lease leaseToCreate = hierarchicalShardSyncer.createLeaseForChildShard(childShard, shardDetector.streamIdentifier());
|
||||
leaseCoordinator.leaseRefresher().createLeaseIfNotExists(leaseToCreate);
|
||||
|
|
|
|||
Loading…
Reference in a new issue