software.amazon.awssdk.services.dynamodb.model.AttributeValueUpdate Java Examples

The following examples show how to use software.amazon.awssdk.services.dynamodb.model.AttributeValueUpdate. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DynamoDBLeaseSerializer.java    From amazon-kinesis-client with Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, AttributeValueUpdate> getDynamoUpdateLeaseUpdate(final Lease lease) {
    Map<String, AttributeValueUpdate> result = new HashMap<>();
    result.put(CHECKPOINT_SEQUENCE_NUMBER_KEY, putUpdate(DynamoUtils.createAttributeValue(lease.checkpoint().sequenceNumber())));
    result.put(CHECKPOINT_SUBSEQUENCE_NUMBER_KEY, putUpdate(DynamoUtils.createAttributeValue(lease.checkpoint().subSequenceNumber())));
    result.put(OWNER_SWITCHES_KEY, putUpdate(DynamoUtils.createAttributeValue(lease.ownerSwitchesSinceCheckpoint())));

    if (lease.pendingCheckpoint() != null && !lease.pendingCheckpoint().sequenceNumber().isEmpty()) {
        result.put(PENDING_CHECKPOINT_SEQUENCE_KEY, putUpdate(DynamoUtils.createAttributeValue(lease.pendingCheckpoint().sequenceNumber())));
        result.put(PENDING_CHECKPOINT_SUBSEQUENCE_KEY, putUpdate(DynamoUtils.createAttributeValue(lease.pendingCheckpoint().subSequenceNumber())));
    } else {
        result.put(PENDING_CHECKPOINT_SEQUENCE_KEY, AttributeValueUpdate.builder().action(AttributeAction.DELETE).build());
        result.put(PENDING_CHECKPOINT_SUBSEQUENCE_KEY, AttributeValueUpdate.builder().action(AttributeAction.DELETE).build());
    }
    return result;
}
 
Example #2
Source File: DynamoDBLeaseSerializer.java    From amazon-kinesis-client with Apache License 2.0 5 votes vote down vote up
public Map<String, AttributeValueUpdate> getDynamoLeaseCounterUpdate(Long leaseCounter) {
    Map<String, AttributeValueUpdate> result = new HashMap<>();

    AttributeValueUpdate avu =
            AttributeValueUpdate.builder().value(DynamoUtils.createAttributeValue(leaseCounter + 1)).action(AttributeAction.PUT).build();
    result.put(LEASE_COUNTER_KEY, avu);

    return result;
}
 
Example #3
Source File: DynamoDBLeaseSerializer.java    From amazon-kinesis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, AttributeValueUpdate> getDynamoTakeLeaseUpdate(final Lease lease, String owner) {
    Map<String, AttributeValueUpdate> result = new HashMap<>();

    result.put(LEASE_OWNER_KEY, AttributeValueUpdate.builder().value(DynamoUtils.createAttributeValue(owner)).action(AttributeAction.PUT).build());

    String oldOwner = lease.leaseOwner();
    if (oldOwner != null && !oldOwner.equals(owner)) {
        result.put(OWNER_SWITCHES_KEY, AttributeValueUpdate.builder().value(DynamoUtils.createAttributeValue(1L)).action(AttributeAction.ADD).build());
    }

    return result;
}
 
Example #4
Source File: DynamoDBLeaseSerializer.java    From amazon-kinesis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, AttributeValueUpdate> getDynamoEvictLeaseUpdate(final Lease lease) {
    Map<String, AttributeValueUpdate> result = new HashMap<>();
    AttributeValue value = null;

    result.put(LEASE_OWNER_KEY, AttributeValueUpdate.builder().value(value).action(AttributeAction.DELETE).build());

    return result;
}
 
Example #5
Source File: DynamoDBLeaseSerializer.java    From amazon-kinesis-client with Apache License 2.0 4 votes vote down vote up
@Override
public Map<String, AttributeValueUpdate> getDynamoLeaseCounterUpdate(final Lease lease) {
    return getDynamoLeaseCounterUpdate(lease.leaseCounter());
}
 
Example #6
Source File: DynamoDBLeaseSerializer.java    From amazon-kinesis-client with Apache License 2.0 4 votes vote down vote up
private AttributeValueUpdate putUpdate(AttributeValue attributeValue) {
    return AttributeValueUpdate.builder().value(attributeValue).action(AttributeAction.PUT).build();
}
 
Example #7
Source File: LeaseSerializer.java    From amazon-kinesis-client with Apache License 2.0 2 votes vote down vote up
/**
 * @param lease
 * @return the attribute value map that increments a lease counter
 */
Map<String, AttributeValueUpdate> getDynamoLeaseCounterUpdate(Lease lease);
 
Example #8
Source File: LeaseSerializer.java    From amazon-kinesis-client with Apache License 2.0 2 votes vote down vote up
/**
 * @param lease
 * @param newOwner
 * @return the attribute value map that takes a lease for a new owner
 */
Map<String, AttributeValueUpdate> getDynamoTakeLeaseUpdate(Lease lease, String newOwner);
 
Example #9
Source File: LeaseSerializer.java    From amazon-kinesis-client with Apache License 2.0 2 votes vote down vote up
/**
 * @param lease
 * @return the attribute value map that voids a lease
 */
Map<String, AttributeValueUpdate> getDynamoEvictLeaseUpdate(Lease lease);
 
Example #10
Source File: LeaseSerializer.java    From amazon-kinesis-client with Apache License 2.0 2 votes vote down vote up
/**
 * @param lease
 * @return the attribute value map that updates application-specific data for a lease and increments the lease
 *         counter
 */
Map<String, AttributeValueUpdate> getDynamoUpdateLeaseUpdate(Lease lease);