private UpdateItemOutcome doUpdateItem(UpdateItemSpec spec) { final UpdateItemRequest request = spec.getRequest(); request.setKey(InternalUtils.toAttributeValueMap(spec.getKeyComponents())); request.setTableName(table.getTableName()); final Collection<Expected> expected = spec.getExpected(); final Map<String, ExpectedAttributeValue> expectedMap = InternalUtils.toExpectedAttributeValueMap(expected); request.setExpected(expectedMap); request.setAttributeUpdates( InternalUtils.toAttributeValueUpdate(spec.getAttributeUpdate())); request.setExpressionAttributeNames(spec.getNameMap()); request.setExpressionAttributeValues( InternalUtils.fromSimpleMap(spec.getValueMap())); return new UpdateItemOutcome(client.updateItem(request)); }
/** * Save the item using a UpdateItem request. The handler will call this * method if * <ul> * <li>CLOBBER configuration is not being used; * <li>AND the item does not contain auto-generated key value; * </ul> * <p> * The ReturnedValues parameter for the UpdateItem request is set as * ALL_NEW, which means the service should return all of the attributes * of the new version of the item after the update. The handler will use * the returned attributes to detect silent failure on the server-side. */ protected UpdateItemResult doUpdateItem() { UpdateItemRequest req = new UpdateItemRequest() .withTableName(getTableName()) .withKey(getPrimaryKeyAttributeValues()) .withAttributeUpdates( transformAttributeUpdates( this.clazz, getTableName(), getPrimaryKeyAttributeValues(), getAttributeValueUpdates(), saveConfig)) .withExpected(mergeExpectedAttributeValueConditions()) .withConditionalOperator(userProvidedConditionOperator) .withReturnValues(ReturnValue.ALL_NEW) .withRequestMetricCollector(saveConfig.getRequestMetricCollector()); return db.updateItem(applyUserAgent(req)); }
private Document updateItem(Document doc, Key key, UpdateItemOperationConfig config) { final boolean updateChangedAttributes = !this.haveKeysChanged(doc); final Map<String, AttributeValueUpdate> attributeUpdateValues = this.toAttributeUpdateMap( doc, updateChangedAttributes); for (final String keyName : this.keys.keySet()) { attributeUpdateValues.remove(keyName); } final UpdateItemRequest updateRequest = new UpdateItemRequest(); updateRequest.setTableName(this.tableName); updateRequest.setKey(key); updateRequest.setAttributeUpdates( attributeUpdateValues.size() == 0 ? null : attributeUpdateValues); updateRequest.setReturnValues(config.getReturnValue()); Table.appendDynamoDBDocumentUserAgentString(updateRequest); final UpdateItemResult result = this.client.updateItem(updateRequest); doc.commit(); if (config.getReturnValue() != ReturnValue.NONE) { return this.fromAttributeMap(result.getAttributes()); } return null; }
@Override public UpdateItemResult updateItem(String tableName, Map<String, AttributeValue> key, Map<String, AttributeValueUpdate> attributeUpdates) throws AmazonServiceException, AmazonClientException { return getBackend().updateItem(tableName, key, attributeUpdates); }
@Override public UpdateItemResult updateItem(UpdateItemRequest request) throws AmazonServiceException, AmazonClientException { return getBackend().updateItem(request); }
@Override public UpdateItemResult updateItem(String tableName, Map<String, AttributeValue> key, Map<String, AttributeValueUpdate> attributeUpdates, String returnValues) throws AmazonServiceException, AmazonClientException { return getBackend().updateItem(tableName, key, attributeUpdates, returnValues); }
/** * Save the item using a UpdateItem request. The handler will call this * method if * <ul> * <li>CLOBBER configuration is not being used; * <li>AND the item does not contain auto-generated key value; * </ul> * <p> * The ReturnedValues parameter for the UpdateItem request is set as * ALL_NEW, which means the service should return all of the attributes * of the new version of the item after the update. The handler will use * the returned attributes to detect silent failure on the server-side. */ protected UpdateItemResult doUpdateItem() { final UpdateItemRequest req = new UpdateItemRequest() .withTableName(getTableName()) .withKey(getKeyAttributeValues()) .withAttributeUpdates( transformAttributeUpdates( this.clazz, getTableName(), getKeyAttributeValues(), getAttributeValueUpdates(), saveConfig)) .withExpected(mergeExpectedAttributeValueConditions()) .withConditionalOperator(userProvidedConditionOperator) .withReturnValues(ReturnValue.ALL_NEW) .withRequestMetricCollector(saveConfig.getRequestMetricCollector()); return db.updateItem(applyUserAgent(req)); }
final UpdateItemResult result = ddbClient.updateItem(updateItemRequest); log.info("Item updated : {}", result.getAttributes()); } catch (final Exception e) {
dynamoDBClient.updateItem(request); } catch (ConditionalCheckFailedException e) { if (LOG.isDebugEnabled()) {
txManager.getClient().updateItem(update); } catch (ConditionalCheckFailedException e) {
dynamoDBClient.updateItem(request); } catch (ConditionalCheckFailedException e) { if (LOG.isDebugEnabled()) {
.withReturnValues(ReturnValue.UPDATED_NEW); final long start = System.currentTimeMillis(); final UpdateItemResult result = aws.updateItem(request); Logger.info( this, "#put('%s'): updated item to DynamoDB, %s, in %[ms]s",
dynamoDBClient.updateItem(request); } catch (ConditionalCheckFailedException e) { if (LOG.isDebugEnabled()) {
.withReturnValues(ReturnValue.UPDATED_NEW); final long start = System.currentTimeMillis(); final UpdateItemResult result = aws.updateItem(request); Logger.info( this, "#put('%s'): updated item to DynamoDB, %s, in %[ms]s",
UpdateItemResult updateItem(final UpdateItemRequest request) throws BackendException { setUserAgent(request); UpdateItemResult result; final int bytes; if (request.getUpdateExpression() != null) { bytes = calculateExpressionBasedUpdateSize(request); } else { bytes = calculateItemUpdateSizeInBytes(request.getAttributeUpdates()); } getBytesHistogram(UPDATE_ITEM, request.getTableName()).update(bytes); final int wcu = computeWcu(bytes); timedWriteThrottle(UPDATE_ITEM, request.getTableName(), wcu); final Timer.Context apiTimerContext = getTimerContext(UPDATE_ITEM, request.getTableName()); try { result = client.updateItem(request); } catch (Exception e) { throw processDynamoDbApiException(e, UPDATE_ITEM, request.getTableName()); } finally { apiTimerContext.stop(); } meterConsumedCapacity(UPDATE_ITEM, result.getConsumedCapacity()); return result; }
.withKey(key) .withExpected(expected); txManager.getClient().updateItem(update); } catch (ConditionalCheckFailedException e) { try {
.withExpected(expected); txItem = txManager.getClient().updateItem(completeRequest).getAttributes();
.withExpected(expected); UpdateItemResult finishResult = txManager.getClient().updateItem(finishRequest); txItem = finishResult.getAttributes(); if(txItem == null) {
private UpdateItemOutcome doUpdateItem(UpdateItemSpec spec) { final UpdateItemRequest request = spec.getRequest(); request.setKey(InternalUtils.toAttributeValueMap(spec.getKeyComponents())); request.setTableName(table.getTableName()); final Collection<Expected> expected = spec.getExpected(); final Map<String, ExpectedAttributeValue> expectedMap = InternalUtils.toExpectedAttributeValueMap(expected); request.setExpected(expectedMap); request.setAttributeUpdates( InternalUtils.toAttributeValueUpdate(spec.getAttributeUpdate())); request.setExpressionAttributeNames(spec.getNameMap()); request.setExpressionAttributeValues( InternalUtils.fromSimpleMap(spec.getValueMap())); return new UpdateItemOutcome(client.updateItem(request)); }
/** * Save the item using a UpdateItem request. The handler will call this * method if * <ul> * <li>CLOBBER configuration is not being used; * <li>AND the item does not contain auto-generated key value; * </ul> * <p> * The ReturnedValues parameter for the UpdateItem request is set as * ALL_NEW, which means the service should return all of the attributes * of the new version of the item after the update. The handler will use * the returned attributes to detect silent failure on the server-side. */ protected UpdateItemResult doUpdateItem() { UpdateItemRequest req = new UpdateItemRequest() .withTableName(getTableName()) .withKey(getPrimaryKeyAttributeValues()) .withAttributeUpdates( transformAttributeUpdates( this.clazz, getTableName(), getPrimaryKeyAttributeValues(), getAttributeValueUpdates(), saveConfig)) .withExpected(mergeExpectedAttributeValueConditions()) .withConditionalOperator(userProvidedConditionOperator) .withReturnValues(ReturnValue.ALL_NEW) .withRequestMetricCollector(saveConfig.getRequestMetricCollector()); return db.updateItem(applyUserAgent(req)); }