Examples of UpdateItemRequest


Examples of com.amazonaws.services.dynamodbv2.model.UpdateItemRequest

        if (LOG.isDebugEnabled()) {
            LOG.debug(String.format("Updating lease %s", lease));
        }

        UpdateItemRequest request = new UpdateItemRequest();
        request.setTableName(table);
        request.setKey(serializer.getDynamoHashKey(lease));
        request.setExpected(serializer.getDynamoLeaseCounterExpectation(lease));

        Map<String, AttributeValueUpdate> updates = serializer.getDynamoLeaseCounterUpdate(lease);
        updates.putAll(serializer.getDynamoUpdateLeaseUpdate(lease));
        request.setAttributeUpdates(updates);

        try {
            dynamoDBClient.updateItem(request);
        } catch (ConditionalCheckFailedException e) {
            if (LOG.isDebugEnabled()) {
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.UpdateItemRequest

    public UpdateItemOutcome updateItem(UpdateItemSpec spec) {
        return doUpdateItem(spec);
    }

    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.setConditionExpression(spec.getConditionExpression());
        request.setUpdateExpression(spec.getUpdateExpression());
        request.setExpressionAttributeNames(spec.getNameMap());
        request.setExpressionAttributeValues(
            InternalUtils.fromSimpleMap(spec.getValueMap()));
        return new UpdateItemOutcome(client.updateItem(request));
    }
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.UpdateItemRequest

    Map<String, AttributeValueUpdate> rou = new HashMap<String, AttributeValueUpdate>();
    try {
      for (Entry<String, AttributeValue> attr : row.entrySet()) {
        rou.put(attr.getKey(), new AttributeValueUpdate(attr.getValue(), AttributeAction.PUT));
      }
      UpdateItemRequest updateItemRequest = new UpdateItemRequest(appid,
          Collections.singletonMap(Config._KEY, new AttributeValue(key)), rou);
      client().updateItem(updateItemRequest);
    } catch (Exception e) {
      logger.error(null, e);
    }
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.UpdateItemRequest

         * 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(getKeyAttributeValues())
                    .withAttributeUpdates(
                            transformAttributeUpdates(
                                    this.clazz,
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.UpdateItemRequest

  public UpdatePointResult updatePoint(UpdatePointRequest updatePointRequest) {
    long geohash = S2Manager.generateGeohash(updatePointRequest.getGeoPoint());
    long hashKey = S2Manager.generateHashKey(geohash, config.getHashKeyLength());

    UpdateItemRequest updateItemRequest = updatePointRequest.getUpdateItemRequest();
    updateItemRequest.setTableName(config.getTableName());

    AttributeValue hashKeyValue = new AttributeValue().withN(String.valueOf(hashKey));
    updateItemRequest.getKey().put(config.getHashKeyAttributeName(), hashKeyValue);
    updateItemRequest.getKey().put(config.getRangeKeyAttributeName(), updatePointRequest.getRangeKeyValue());

    // Geohash and geoJson cannot be updated.
    updateItemRequest.getAttributeUpdates().remove(config.getGeohashAttributeName());
    updateItemRequest.getAttributeUpdates().remove(config.getGeoJsonAttributeName());

    UpdateItemResult updateItemResult = config.getDynamoDBClient().updateItem(updateItemRequest);
    UpdatePointResult updatePointResult = new UpdatePointResult(updateItemResult);

    return updatePointResult;
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.UpdateItemRequest

    Map<String, AttributeValueUpdate> rou = new HashMap<String, AttributeValueUpdate>();
    try {
      for (Entry<String, AttributeValue> attr : row.entrySet()) {
        rou.put(attr.getKey(), new AttributeValueUpdate(attr.getValue(), AttributeAction.PUT));
      }
      UpdateItemRequest updateItemRequest = new UpdateItemRequest(appid,
          Collections.singletonMap(Config._KEY, new AttributeValue(key)), rou);
      client().updateItem(updateItemRequest);
    } catch (Exception e) {
      logger.error(null, e);
    }
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.UpdateItemRequest

         * 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(getKeyAttributeValues())
                    .withAttributeUpdates(
                            transformAttributeUpdates(
                                    this.clazz,
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.UpdateItemRequest

                            }
                        }
                    }
                    if ( doUpdateItem ) {
                        /* Send an updateItem request. */
                        db.updateItem(applyUserAgent(new UpdateItemRequest()
                                .withTableName(getTableName())
                                .withKey(getKeyAttributeValues())
                                .withAttributeUpdates(
                                        transformAttributeUpdates(this.clazz,
                                                getKeyAttributeValues(), getAttributeValueUpdates()))
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.UpdateItemRequest

  private UpdateItemRequest updateItemRequest;
  private GeoPoint geoPoint;
  private AttributeValue rangeKeyValue;

  public UpdatePointRequest(GeoPoint geoPoint, AttributeValue rangeKeyValue) {
    updateItemRequest = new UpdateItemRequest();
    updateItemRequest.setKey(new HashMap<String, AttributeValue>());
    updateItemRequest.setAttributeUpdates(new HashMap<String, AttributeValueUpdate>());

    this.geoPoint = geoPoint;
    this.rangeKeyValue = rangeKeyValue;
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.UpdateItemRequest

        if ( config.getSaveBehavior() == SaveBehavior.CLOBBER || forcePut ) {
            db.putItem(applyUserAgent(new PutItemRequest().withTableName(tableName)
                    .withItem(transformAttributes(clazz, convertToItem(updateValues)))
                    .withExpected(expectedValues)));
        } else {
            db.updateItem(applyUserAgent(new UpdateItemRequest().withTableName(tableName).withKey(key)
                    .withAttributeUpdates(transformAttributeUpdates(clazz, updateValues)).withExpected(expectedValues)));
        }

        /*
         * Finally, after the service call has succeeded, update the in-memory
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.