updateLeaseWithMetaInfo with expectation
This commit is contained in:
parent
f713017528
commit
6738087a8f
4 changed files with 23 additions and 1 deletions
|
|
@ -120,6 +120,11 @@ public class KinesisClientLeaseSerializer implements ILeaseSerializer<KinesisCli
|
||||||
return baseSerializer.getDynamoNonexistantExpectation();
|
return baseSerializer.getDynamoNonexistantExpectation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, ExpectedAttributeValue> getDynamoExistantExpectation(final String leaseKey) {
|
||||||
|
return baseSerializer.getDynamoExistantExpectation(leaseKey);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, AttributeValueUpdate> getDynamoLeaseCounterUpdate(KinesisClientLease lease) {
|
public Map<String, AttributeValueUpdate> getDynamoLeaseCounterUpdate(KinesisClientLease lease) {
|
||||||
return baseSerializer.getDynamoLeaseCounterUpdate(lease);
|
return baseSerializer.getDynamoLeaseCounterUpdate(lease);
|
||||||
|
|
|
||||||
|
|
@ -620,7 +620,7 @@ public class LeaseManager<T extends Lease> implements ILeaseManager<T> {
|
||||||
UpdateItemRequest request = new UpdateItemRequest();
|
UpdateItemRequest request = new UpdateItemRequest();
|
||||||
request.setTableName(table);
|
request.setTableName(table);
|
||||||
request.setKey(serializer.getDynamoHashKey(lease));
|
request.setKey(serializer.getDynamoHashKey(lease));
|
||||||
request.setExpected(serializer.getDynamoLeaseCounterExpectation(lease));
|
request.setExpected(serializer.getDynamoExistantExpectation(lease.getLeaseKey()));
|
||||||
|
|
||||||
Map<String, AttributeValueUpdate> updates = serializer.getDynamoUpdateLeaseUpdate(lease, updateField);
|
Map<String, AttributeValueUpdate> updates = serializer.getDynamoUpdateLeaseUpdate(lease, updateField);
|
||||||
updates.putAll(serializer.getDynamoUpdateLeaseUpdate(lease));
|
updates.putAll(serializer.getDynamoUpdateLeaseUpdate(lease));
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,16 @@ public class LeaseSerializer implements ILeaseSerializer<Lease> {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, ExpectedAttributeValue> getDynamoExistantExpectation(final String leaseKey) {
|
||||||
|
Map<String, ExpectedAttributeValue> result = new HashMap<>();
|
||||||
|
|
||||||
|
ExpectedAttributeValue expectedAV = new ExpectedAttributeValue(DynamoUtils.createAttributeValue(leaseKey));
|
||||||
|
result.put(LEASE_KEY_KEY, expectedAV);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, AttributeValueUpdate> getDynamoLeaseCounterUpdate(Lease lease) {
|
public Map<String, AttributeValueUpdate> getDynamoLeaseCounterUpdate(Lease lease) {
|
||||||
return getDynamoLeaseCounterUpdate(lease.getLeaseCounter());
|
return getDynamoLeaseCounterUpdate(lease.getLeaseCounter());
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,13 @@ public interface ILeaseSerializer<T extends Lease> {
|
||||||
*/
|
*/
|
||||||
public Map<String, ExpectedAttributeValue> getDynamoNonexistantExpectation();
|
public Map<String, ExpectedAttributeValue> getDynamoNonexistantExpectation();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the attribute value map asserting that a lease does exist.
|
||||||
|
*/
|
||||||
|
default Map<String, ExpectedAttributeValue> getDynamoExistantExpectation(final String leaseKey) {
|
||||||
|
throw new UnsupportedOperationException("DynamoExistantExpectation is not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param lease
|
* @param lease
|
||||||
* @return the attribute value map that increments a lease counter
|
* @return the attribute value map that increments a lease counter
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue